summaryrefslogtreecommitdiff
blob: 154d22f75bb3ed72b1ec6cbbf669c5baf8235106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
From: <gshchepaDate: August 20 2007 10:39pm
Subject: bk commit into 5.0 tree (gshchepa:1.2496) BUG#30287

Below is the list of changes that have just been committed into a local
5.0 repository of uchum. When uchum 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@stripped, 2007-08-21 01:39:39+05:00, gshchepa@stripped +3 -0
  Fixed bug #30287.
  The server created temporary tables for filesort in the working directory
  instead of the specified tmpdir directory.

  sql/item.cc@stripped, 2007-08-21 01:09:20+05:00, gshchepa@stripped +2 -0
    Fixed bug #30287.
    The Item_field::set_field method has been modified to reset the any_privileges
    flag to false in case of system temporary table. This modification prevents the
    server from unnecessary checking of user privileges to access system temporary
    tables.

  sql/sql_select.cc@stripped, 2007-08-21 01:09:43+05:00, gshchepa@stripped +8 -11
    Fixed bug #30287.
    Bugfix for #29015 has been removed: TABLE_SHARE::table_name of system
    temporary tables contains full path to table file basename again.

  sql/sql_view.cc@stripped, 2007-08-21 01:09:50+05:00, gshchepa@stripped +6 -0
    Fixed bug #30287.
    Commentary has been added.

diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc	2007-08-08 12:34:31 +05:00
+++ b/sql/item.cc	2007-08-21 01:09:20 +05:00
@@ -1765,6 +1765,8 @@ void Item_field::set_field(Field *field_
   unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
   collation.set(field_par->charset(), field_par->derivation());
   fixed= 1;
+  if (field->table->s->tmp_table == SYSTEM_TMP_TABLE)
+    any_privileges= 0;
 }
 
 
diff -Nrup a/sql/sql_select.cc b/sql/sql_select.cc
--- a/sql/sql_select.cc	2007-07-31 16:24:13 +05:00
+++ b/sql/sql_select.cc	2007-08-21 01:09:43 +05:00
@@ -9169,7 +9169,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
   bool  using_unique_constraint= 0;
   bool  use_packed_rows= 0;
   bool  not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS);
-  char	*tmpname, *tmppath, path[FN_REFLEN], table_name[NAME_LEN+1];
+  char  *tmpname,path[FN_REFLEN];
   byte	*pos,*group_buff;
   uchar *null_flags;
   Field **reg_field, **from_field, **default_field;
@@ -9192,12 +9192,12 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
     temp_pool_slot = bitmap_set_next(&temp_pool);
 
   if (temp_pool_slot != MY_BIT_NONE) // we got a slot
-    sprintf(table_name, "%s_%lx_%i", tmp_file_prefix,
+    sprintf(path, "%s_%lx_%i", tmp_file_prefix,
             current_pid, temp_pool_slot);
   else
   {
     /* if we run out of slots or we are not using tempool */
-    sprintf(table_name, "%s%lx_%lx_%x", tmp_file_prefix,current_pid,
+    sprintf(path,"%s%lx_%lx_%x", tmp_file_prefix,current_pid,
             thd->thread_id, thd->tmp_table++);
   }
 
@@ -9205,8 +9205,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
     No need to change table name to lower case as we are only creating
     MyISAM or HEAP tables here
   */
-  fn_format(path, table_name, mysql_tmpdir, "",
-            MY_REPLACE_EXT|MY_UNPACK_FILENAME);
+  fn_format(path, path, mysql_tmpdir, "", MY_REPLACE_EXT|MY_UNPACK_FILENAME);
+
 
   if (group)
   {
@@ -9251,8 +9251,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
                         sizeof(*key_part_info)*(param->group_parts+1),
                         &param->start_recinfo,
                         sizeof(*param->recinfo)*(field_count*2+4),
-                        &tmppath, (uint) strlen(path)+1,
-                        &tmpname, (uint) strlen(table_name)+1,
+                        &tmpname, (uint) strlen(path)+1,
                         &group_buff, group && ! using_unique_constraint ?
                         param->group_length : 0,
                         NullS))
@@ -9270,8 +9269,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
     DBUG_RETURN(NULL);				/* purecov: inspected */
   }
   param->items_to_copy= copy_func;
-  strmov(tmppath, path);
-  strmov(tmpname, table_name);
+  strmov(tmpname,path);
   /* make table according to fields */
 
   bzero((char*) table,sizeof(*table));
@@ -9297,8 +9295,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
 
   table->s= &table->share_not_to_be_used;
   table->s->blob_field= blob_field;
-  table->s->table_name= tmpname;
-  table->s->path= tmppath;
+  table->s->table_name= table->s->path= tmpname;
   table->s->db= "";
   table->s->blob_ptr_size= mi_portable_sizeof_char_ptr;
   table->s->tmp_table= NON_TRANSACTIONAL_TMP_TABLE;
diff -Nrup a/sql/sql_view.cc b/sql/sql_view.cc
--- a/sql/sql_view.cc	2007-07-12 23:26:39 +05:00
+++ b/sql/sql_view.cc	2007-08-21 01:09:50 +05:00
@@ -397,7 +397,13 @@ bool mysql_create_view(THD *thd, TABLE_L
     {
       Item_field *field;
       if ((field= item->filed_for_view_update()))
+      {
+        /*
+         any_privileges may be reset later by the Item_field::set_field
+         method in case of a system temporary table.
+        */
         field->any_privileges= 1;
+      }
     }
   }
 #endif