MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:August 19 2010 5:51pm
Subject:bzr commit into mysql-5.5-bugfixing branch (alik:3115) Bug#27480
View as plain text  
#At file:///mnt/raid/alik/MySQL/bzr/00/bug27480/mysql-5.5-runtime-bug27480.2/ based on revid:alik@stripped

 3115 Alexander Nozdrin	2010-08-19
      Bug#27480 (Extend CREATE TEMPORARY TABLES privilege
      to allow temp table operations) -- prerequisite patch #2:
        
      split find_temporary_table() into three forms.

    modified:
      sql/sql_base.cc
      sql/sql_base.h
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2010-08-19 17:38:24 +0000
+++ b/sql/sql_base.cc	2010-08-19 17:51:24 +0000
@@ -247,7 +247,8 @@ static void check_unused(void)
     Length of key
 */
 
-uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
+uint create_table_def_key(THD *thd, char *key,
+                          const TABLE_LIST *table_list,
                           bool tmp_table)
 {
   uint key_length= (uint) (strmov(strmov(key, table_list->db)+1,
@@ -1987,39 +1988,71 @@ void update_non_unique_table_error(TABLE
 }
 
 
+/**
+  Find temporary table specified by database and table names in the
+  temporary table cache.
+
+  @return TABLE instance if a temporary table has been found; NULL otherwise.
+*/
+
 TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name)
 {
   TABLE_LIST table_list;
 
   table_list.db= (char*) db;
   table_list.table_name= (char*) table_name;
+
   return find_temporary_table(thd, &table_list);
 }
 
 
-TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list)
+/**
+  Find a temporary table specified by TABLE_LIST instance in the temporary
+  table cache.
+
+  @return TABLE instance if a temporary table has been found; NULL otherwise.
+*/
+
+TABLE *find_temporary_table(THD *thd, const TABLE_LIST *table_list)
 {
   char	key[MAX_DBKEY_LENGTH];
-  uint	key_length;
-  TABLE *table;
-  DBUG_ENTER("find_temporary_table");
+
+  DBUG_ENTER("find_temporary_table(TABLE_LIST)");
   DBUG_PRINT("enter", ("table: '%s'.'%s'",
                        table_list->db, table_list->table_name));
 
-  key_length= create_table_def_key(thd, key, table_list, 1);
-  for (table=thd->temporary_tables ; table ; table= table->next)
+  DBUG_RETURN(find_temporary_table(thd, key,
+                                   create_table_def_key(thd, key,
+                                                        table_list, 1)));
+}
+
+
+/**
+  Find a temporary table specified by a key in the temporary table cache.
+
+  @return TABLE instance if a temporary table has been found; NULL otherwise.
+*/
+
+TABLE *find_temporary_table(THD *thd,
+                            const char *table_key,
+                            uint table_key_length)
+{
+  DBUG_ENTER("find_temporary_table(table_key)");
+
+  for (TABLE *table= thd->temporary_tables; table; table= table->next)
   {
-    if (table->s->table_cache_key.length == key_length &&
-	!memcmp(table->s->table_cache_key.str, key, key_length))
+    if (table->s->table_cache_key.length == table_key_length &&
+	!memcmp(table->s->table_cache_key.str, table_key, table_key_length))
     {
       DBUG_PRINT("info",
-                 ("Found table. server_id: %u  pseudo_thread_id: %lu",
+                 ("Found table. server_id: %u; pseudo_thread_id: %lu",
                   (uint) thd->server_id,
                   (ulong) thd->variables.pseudo_thread_id));
       DBUG_RETURN(table);
     }
   }
-  DBUG_RETURN(0);                               // Not a temporary table
+
+  DBUG_RETURN(NULL);                                // Not a temporary table
 }
 
 

=== modified file 'sql/sql_base.h'
--- a/sql/sql_base.h	2010-08-19 09:33:37 +0000
+++ b/sql/sql_base.h	2010-08-19 17:51:24 +0000
@@ -79,7 +79,8 @@ void table_def_start_shutdown(void);
 void assign_new_table_id(TABLE_SHARE *share);
 uint cached_open_tables(void);
 uint cached_table_definitions(void);
-uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
+uint create_table_def_key(THD *thd, char *key,
+                          const TABLE_LIST *table_list,
                           bool tmp_table);
 TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
                              uint key_length, uint db_flags, int *error,
@@ -159,7 +160,9 @@ TABLE_LIST *find_table_in_list(TABLE_LIS
                                const char *db_name,
                                const char *table_name);
 TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name);
-TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list);
+TABLE *find_temporary_table(THD *thd, const TABLE_LIST *table_list);
+TABLE *find_temporary_table(THD *thd, const char *table_key,
+                            uint table_key_length);
 void close_thread_tables(THD *thd);
 bool fill_record_n_invoke_before_triggers(THD *thd, List<Item> &fields,
                                           List<Item> &values,


Attachment: [text/bzr-bundle] bzr/alik@sun.com-20100819175124-vxdb35a0qsaal0x6.bundle
Thread
bzr commit into mysql-5.5-bugfixing branch (alik:3115) Bug#27480Alexander Nozdrin19 Aug