MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:ahristov Date:August 26 2005 9:33am
Subject:bk commit into 5.0 tree (andrey:1.1915) BUG#12808
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1915 05/08/26 11:33:34 andrey@lmy004. +3 -0
  fix for bug #12808 (SHOW OPEN TABLES doesn't sort the output)

  sql/table.h
    1.110 05/08/26 11:33:28 andrey@lmy004. +1 -0
    add two new fields to st_schema_table to allow ordering of the result set of a SHOW command/ select on
    information_schema table

  sql/sql_show.cc
    1.275 05/08/26 11:33:28 andrey@lmy004. +44 -22
    allow ordering of the result set by up to 2 fields. (changed struct st_schema_table).
    - backup the query arena or we get a crash in SP & PS
    - if the orderby_field1 is -1 then orderby_field2 does not work
    - if there is already existing order_by columns don't sort by the predefined ones.

  mysql-test/r/show_check.result
    1.74 05/08/26 11:33:28 andrey@lmy004. +7 -7
    fix the test result after the patch

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	andrey
# Host:	lmy004.
# Root:	/work/mysql-5.0-ready2

--- 1.274/sql/sql_show.cc	2005-08-25 09:38:55 +02:00
+++ 1.275/sql/sql_show.cc	2005-08-26 11:33:28 +02:00
@@ -3313,6 +3313,8 @@
   ST_SCHEMA_TABLE *schema_table= table_list->schema_table;
   ST_FIELD_INFO *fields_info= schema_table->fields_info;
   CHARSET_INFO *cs= system_charset_info;
+  Query_arena *arena, backup;
+  char we_order=0;
   DBUG_ENTER("create_schema_table");
 
   for (; fields_info->field_name; fields_info++)
@@ -3345,8 +3347,28 @@
     }
     field_list.push_back(item);
     item->maybe_null= fields_info->maybe_null;
+    if ((field_count == schema_table->orderby_field1
+          && !thd->lex->current_select->order_list.elements)
+        || (field_count == schema_table->orderby_field2 && 
+            we_order))
+    {
+      int res;
+      we_order= 1;
+      arena= thd->change_arena_if_needed(&backup);
+      res= add_order_to_list(thd, new Item_string(fields_info->field_name,
+                                         strlen(fields_info->field_name), cs),
+                            1);
+      if (arena)
+      {
+        thd->restore_backup_item_arena(arena, &backup);
+        arena= NULL;
+      }
+      if (res)
+        DBUG_RETURN(0);
+    }
     field_count++;
   }
+
   TMP_TABLE_PARAM *tmp_table_param =
     (TMP_TABLE_PARAM*) (thd->calloc(sizeof(TMP_TABLE_PARAM)));
   tmp_table_param->init();
@@ -4008,46 +4030,46 @@
 ST_SCHEMA_TABLE schema_tables[]=
 {
   {"CHARACTER_SETS", charsets_fields_info, create_schema_table, 
-   fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0},
+   fill_schema_charsets, make_character_sets_old_format, 0, -1, -1, 0, -1, -1},
   {"COLLATIONS", collation_fields_info, create_schema_table, 
-   fill_schema_collation, make_old_format, 0, -1, -1, 0},
+   fill_schema_collation, make_old_format, 0, -1, -1, 0, -1, -1},
   {"COLLATION_CHARACTER_SET_APPLICABILITY", coll_charset_app_fields_info,
-   create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0},
+   create_schema_table, fill_schema_coll_charset_app, 0, 0, -1, -1, 0, -1, -1},
   {"COLUMNS", columns_fields_info, create_schema_table, 
-   get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0},
+   get_all_tables, make_columns_old_format, get_schema_column_record, 1, 2, 0, -1, -1},
   {"COLUMN_PRIVILEGES", column_privileges_fields_info, create_schema_table,
-    fill_schema_column_privileges, 0, 0, -1, -1, 0},
+    fill_schema_column_privileges, 0, 0, -1, -1, 0, -1, -1},
   {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
-    get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0},
+    get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0, -1, -1},
   {"OPEN_TABLES", open_tables_fields_info, create_schema_table,
-   fill_open_tables, make_old_format, 0, -1, -1, 1},
+   fill_open_tables, make_old_format, 0, -1, -1, 1, 0, 1},
   {"ROUTINES", proc_fields_info, create_schema_table, 
-    fill_schema_proc, make_proc_old_format, 0, -1, -1, 0},
+    fill_schema_proc, make_proc_old_format, 0, -1, -1, 0, -1, -1},
   {"SCHEMATA", schema_fields_info, create_schema_table,
-   fill_schema_shemata, make_schemata_old_format, 0, 1, -1, 0},
+   fill_schema_shemata, make_schemata_old_format, 0, 1, -1, 0, -1, -1},
   {"SCHEMA_PRIVILEGES", schema_privileges_fields_info, create_schema_table,
-    fill_schema_schema_privileges, 0, 0, -1, -1, 0},
+    fill_schema_schema_privileges, 0, 0, -1, -1, 0, -1, -1},
   {"STATISTICS", stat_fields_info, create_schema_table, 
-    get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0},
+    get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0, -1, -1},
   {"STATUS", variables_fields_info, create_schema_table, fill_status, 
-   make_old_format, 0, -1, -1, 1},
+   make_old_format, 0, -1, -1, 1, -1, -1},
   {"TABLES", tables_fields_info, create_schema_table, 
-   get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0},
+   get_all_tables, make_old_format, get_schema_tables_record, 1, 2, 0, -1, -1},
   {"TABLE_CONSTRAINTS", table_constraints_fields_info, create_schema_table,
-    get_all_tables, 0, get_schema_constraints_record, 3, 4, 0},
+    get_all_tables, 0, get_schema_constraints_record, 3, 4, 0, -1, -1},
   {"TABLE_NAMES", table_names_fields_info, create_schema_table,
-   get_all_tables, make_table_names_old_format, 0, 1, 2, 1},
+   get_all_tables, make_table_names_old_format, 0, 1, 2, 1, -1, -1},
   {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
-    fill_schema_table_privileges, 0, 0, -1, -1, 0},
+    fill_schema_table_privileges, 0, 0, -1, -1, 0, -1, -1},
   {"TRIGGERS", triggers_fields_info, create_schema_table,
-   get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0},
+   get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0, -1, -1},
   {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
-   make_old_format, 0, -1, -1, 1},
-  {"VIEWS", view_fields_info, create_schema_table, 
-    get_all_tables, 0, get_schema_views_record, 1, 2, 0},
+   make_old_format, 0, -1, -1, 1, -1, -1},
+  {"VIEWS", view_fields_info, create_schema_table,
+    get_all_tables, 0, get_schema_views_record, 1, 2, 0, -1, -1},
   {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, 
-    fill_schema_user_privileges, 0, 0, -1, -1, 0},
-  {0, 0, 0, 0, 0, 0, 0, 0, 0}
+    fill_schema_user_privileges, 0, 0, -1, -1, 0, -1, -1},
+  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
 };
 
 

--- 1.109/sql/table.h	2005-08-23 17:15:46 +02:00
+++ 1.110/sql/table.h	2005-08-26 11:33:28 +02:00
@@ -334,6 +334,7 @@
                         const char *file_name);
   int idx_field1, idx_field2; 
   bool hidden;
+  int orderby_field1, orderby_field2;
 } ST_SCHEMA_TABLE;
 
 

--- 1.73/mysql-test/r/show_check.result	2005-08-17 17:51:04 +02:00
+++ 1.74/mysql-test/r/show_check.result	2005-08-26 11:33:28 +02:00
@@ -521,33 +521,33 @@
 SHOW OPEN TABLES;
 Database	Table	In_use	Name_locked
 mysql	db	0	0
-test	urkunde	0	0
+mysql	proc	0	0
 mysql	time_zone	0	0
+mysql	time_zone_name	0	0
 mysql	user	0	0
 test	txt1	0	0
-mysql	proc	0	0
 test	tyt2	0	0
-mysql	time_zone_name	0	0
+test	urkunde	0	0
 SHOW OPEN TABLES FROM mysql;
 Database	Table	In_use	Name_locked
 mysql	db	0	0
-mysql	time_zone	0	0
-mysql	user	0	0
 mysql	proc	0	0
+mysql	time_zone	0	0
 mysql	time_zone_name	0	0
+mysql	user	0	0
 SHOW OPEN TABLES FROM mysql LIKE 'u%';
 Database	Table	In_use	Name_locked
 mysql	user	0	0
 SHOW OPEN TABLES LIKE 't%';
 Database	Table	In_use	Name_locked
 mysql	time_zone	0	0
+mysql	time_zone_name	0	0
 test	txt1	0	0
 test	tyt2	0	0
-mysql	time_zone_name	0	0
 SHOW OPEN TABLES LIKE '%o%';
 Database	Table	In_use	Name_locked
-mysql	time_zone	0	0
 mysql	proc	0	0
+mysql	time_zone	0	0
 mysql	time_zone_name	0	0
 FLUSH TABLES;
 SHOW OPEN TABLES;
Thread
bk commit into 5.0 tree (andrey:1.1915) BUG#12808ahristov26 Aug