MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:August 27 2010 11:38am
Subject:bzr commit into mysql-5.5-runtime branch (alik:3128) Bug#27480
View as plain text  
#At file:///mnt/raid/alik/MySQL/bzr/00/bug27480/mysql-5.5-runtime-bug27480.3/ based on revid:alik@stripped

 3128 Alexander Nozdrin	2010-08-27
      Bug#27480 (Extend CREATE TEMPORARY TABLES privilege
      to allow temp table operations) -- prerequisite patch #3.
      
      Rename open_temporary_table() to open_table_uncached().
      open_temporary_table() will be introduced in following patches
      to open temporary tables for a statement.

    modified:
      sql/sql_base.cc
      sql/sql_base.h
      sql/sql_table.cc
      sql/sql_truncate.cc
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2010-08-27 09:21:38 +0000
+++ b/sql/sql_base.cc	2010-08-27 11:38:09 +0000
@@ -5696,35 +5696,37 @@ void close_tables_for_reopen(THD *thd, T
 }
 
 
-/*
-  Open a single table without table caching and don't set it in open_list
-
-  SYNPOSIS
-    open_temporary_table()
-    thd		  Thread object
-    path	  Path (without .frm)
-    db		  database
-    table_name	  Table name
-    link_in_list  1 if table should be linked into thd->temporary_tables
-
- NOTES:
-    Used by alter_table to open a temporary table and when creating
-    a temporary table with CREATE TEMPORARY ...
-
- RETURN
-   0  Error
-   #  TABLE object
-*/
-
-TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
-			    const char *table_name, bool link_in_list)
+/**
+  Open a single table without table caching and don't add it to
+  THD::open_tables. Depending on the 'add_to_temporary_tables_list' value,
+  the opened TABLE instance will be addded to THD::temporary_tables list.
+
+  @param thd                          Thread context.
+  @param path                         Path (without .frm)
+  @param db                           Database name.
+  @param table_name                   Table name.
+  @param add_to_temporary_tables_list Specifies if the opened TABLE
+                                      instance should be linked into
+                                      THD::temporary_tables list.
+
+  @note This function is used:
+    - by alter_table() to open a temporary table;
+    - when creating a temporary table with CREATE TEMPORARY TABLE.
+
+  @return TABLE instance for opened table.
+  @retval NULL on error.
+*/
+
+TABLE *open_table_uncached(THD *thd, const char *path, const char *db,
+                           const char *table_name,
+                           bool add_to_temporary_tables_list)
 {
   TABLE *tmp_table;
   TABLE_SHARE *share;
   char cache_key[MAX_DBKEY_LENGTH], *saved_cache_key, *tmp_path;
   uint key_length;
   TABLE_LIST table_list;
-  DBUG_ENTER("open_temporary_table");
+  DBUG_ENTER("open_table_uncached");
   DBUG_PRINT("enter",
              ("table: '%s'.'%s'  path: '%s'  server_id: %u  "
               "pseudo_thread_id: %lu",
@@ -5767,7 +5769,7 @@ TABLE *open_temporary_table(THD *thd, co
   share->tmp_table= (tmp_table->file->has_transactions() ? 
                      TRANSACTIONAL_TMP_TABLE : NON_TRANSACTIONAL_TMP_TABLE);
 
-  if (link_in_list)
+  if (add_to_temporary_tables_list)
   {
     /* growing temp list at the head */
     tmp_table->next= thd->temporary_tables;

=== modified file 'sql/sql_base.h'
--- a/sql/sql_base.h	2010-08-27 09:31:12 +0000
+++ b/sql/sql_base.h	2010-08-27 11:38:09 +0000
@@ -141,8 +141,9 @@ bool open_new_frm(THD *thd, TABLE_SHARE 
 
 bool get_key_map_from_key_list(key_map *map, TABLE *table,
                                List<String> *index_list);
-TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
-			    const char *table_name, bool link_in_list);
+TABLE *open_table_uncached(THD *thd, const char *path, const char *db,
+			   const char *table_name,
+                           bool add_to_temporary_tables_list);
 TABLE *find_locked_table(TABLE *list, const char *db, const char *table_name);
 TABLE *find_write_locked_table(TABLE *list, const char *db,
                                const char *table_name);

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2010-08-27 09:21:38 +0000
+++ b/sql/sql_table.cc	2010-08-27 11:38:09 +0000
@@ -22,7 +22,7 @@
 #include "sql_rename.h" // do_rename
 #include "sql_parse.h"                        // test_if_data_home_dir
 #include "sql_cache.h"                          // query_cache_*
-#include "sql_base.h"   // open_temporary_table, lock_table_names
+#include "sql_base.h"   // open_table_uncached, lock_table_names
 #include "lock.h"       // wait_if_global_read_lock
                         // start_waiting_global_read_lock,
                         // mysql_unlock_tables
@@ -4224,9 +4224,14 @@ bool mysql_create_table_no_lock(THD *thd
 
   if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
   {
-    TABLE *table= NULL;
-    /* Open table and put in temporary table list */
-    if (!(table= open_temporary_table(thd, path, db, table_name, 1)))
+    /*
+      Open a table (skipping table cache) and add it into
+      THD::temporary_tables list.
+    */
+
+    TABLE *table= open_table_uncached(thd, path, db, table_name, TRUE);
+
+    if (!table)
     {
       (void) rm_temporary_table(create_info->db_type, path);
       goto err;
@@ -6301,8 +6306,8 @@ bool mysql_alter_table(THD *thd,char *ne
       /* table is a normal table: Create temporary table in same directory */
       build_table_filename(path, sizeof(path) - 1, new_db, tmp_name, "",
                            FN_IS_TMP);
-      /* Open our intermediate table */
-      new_table= open_temporary_table(thd, path, new_db, tmp_name, 1);
+      /* Open our intermediate table. */
+      new_table= open_table_uncached(thd, path, new_db, tmp_name, TRUE);
     }
     if (!new_table)
       goto err_new_table_cleanup;
@@ -6642,7 +6647,7 @@ bool mysql_alter_table(THD *thd,char *ne
     char path[FN_REFLEN];
     TABLE *t_table;
     build_table_filename(path + 1, sizeof(path) - 1, new_db, table_name, "", 0);
-    t_table= open_temporary_table(thd, path, new_db, tmp_name, 0);
+    t_table= open_table_uncached(thd, path, new_db, tmp_name, FALSE);
     if (t_table)
     {
       intern_close_table(t_table);

=== modified file 'sql/sql_truncate.cc'
--- a/sql/sql_truncate.cc	2010-08-18 11:29:04 +0000
+++ b/sql/sql_truncate.cc	2010-08-27 11:38:09 +0000
@@ -208,8 +208,8 @@ static bool recreate_temporary_table(THD
   ha_create_table(thd, share->normalized_path.str, share->db.str,
                   share->table_name.str, &create_info, 1);
 
-  if (open_temporary_table(thd, share->path.str, share->db.str,
-                           share->table_name.str, 1))
+  if (open_table_uncached(thd, share->path.str, share->db.str,
+                          share->table_name.str, TRUE))
   {
     error= FALSE;
     thd->thread_specific_used= TRUE;


Attachment: [text/bzr-bundle] bzr/alik@sun.com-20100827113809-7ncef9cs933umunm.bundle
Thread
bzr commit into mysql-5.5-runtime branch (alik:3128) Bug#27480Alexander Nozdrin27 Aug
  • Re: bzr commit into mysql-5.5-runtime branch (alik:3128) Bug#27480Dmitry Lenev27 Aug