Merge lp:~akopytov/percona-server/bug745241-5.1 into lp:percona-server/5.1

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 250
Proposed branch: lp:~akopytov/percona-server/bug745241-5.1
Merge into: lp:percona-server/5.1
Diff against target: 238 lines (+125/-16)
1 file modified
show_temp_51.patch (+125/-16)
To merge this branch: bzr merge lp:~akopytov/percona-server/bug745241-5.1
Reviewer Review Type Date Requested Status
Stewart Smith Pending
Review via email: mp+67004@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'show_temp_51.patch'
2--- show_temp_51.patch 2011-05-10 07:31:20 +0000
3+++ show_temp_51.patch 2011-07-06 08:46:30 +0000
4@@ -6,8 +6,8 @@
5 # Any small change to this file in the main branch
6 # should be done or reviewed by the maintainer!
7 diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
8---- a/sql/mysqld.cc 2010-08-27 15:24:41.663411604 +0900
9-+++ b/sql/mysqld.cc 2010-08-27 15:30:36.942106886 +0900
10+--- a/sql/mysqld.cc 2011-07-05 17:55:25.000000000 +0400
11++++ b/sql/mysqld.cc 2011-07-05 21:38:54.000000000 +0400
12 @@ -3244,6 +3244,7 @@
13 {"show_table_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
14 {"show_tables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLES]), SHOW_LONG_STATUS},
15@@ -17,8 +17,8 @@
16 {"show_user_statistics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_USER_STATS]), SHOW_LONG_STATUS},
17 {"show_variables", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_VARIABLES]), SHOW_LONG_STATUS},
18 diff -ruN a/sql/sql_lex.h b/sql/sql_lex.h
19---- a/sql/sql_lex.h 2010-08-27 15:19:09.940989847 +0900
20-+++ b/sql/sql_lex.h 2010-08-27 15:30:36.942106886 +0900
21+--- a/sql/sql_lex.h 2011-07-05 17:55:25.000000000 +0400
22++++ b/sql/sql_lex.h 2011-07-05 21:38:42.000000000 +0400
23 @@ -116,7 +116,7 @@
24 SQLCOM_CREATE_EVENT, SQLCOM_ALTER_EVENT, SQLCOM_DROP_EVENT,
25 SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS,
26@@ -29,8 +29,8 @@
27 SQLCOM_SHOW_PATCHES,
28
29 diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
30---- a/sql/sql_parse.cc 2010-08-27 15:19:09.944990047 +0900
31-+++ b/sql/sql_parse.cc 2010-08-27 15:30:36.949020748 +0900
32+--- a/sql/sql_parse.cc 2011-07-05 17:55:25.000000000 +0400
33++++ b/sql/sql_parse.cc 2011-07-05 21:38:45.000000000 +0400
34 @@ -339,6 +339,9 @@
35 sql_command_flags[SQLCOM_SHOW_TABLES]= (CF_STATUS_COMMAND |
36 CF_SHOW_TABLE_COMMAND |
37@@ -68,8 +68,8 @@
38 case SCH_TRIGGERS:
39 case SCH_EVENTS:
40 diff -ruN a/sql/sql_show.cc b/sql/sql_show.cc
41---- a/sql/sql_show.cc 2010-08-27 15:19:09.955989654 +0900
42-+++ b/sql/sql_show.cc 2010-08-27 15:30:36.959020753 +0900
43+--- a/sql/sql_show.cc 2011-07-05 17:55:25.000000000 +0400
44++++ b/sql/sql_show.cc 2011-07-05 21:38:43.000000000 +0400
45 @@ -3032,6 +3032,7 @@
46 break;
47 case SQLCOM_SHOW_TABLES:
48@@ -78,7 +78,7 @@
49 case SQLCOM_SHOW_TRIGGERS:
50 case SQLCOM_SHOW_EVENTS:
51 thd->make_lex_string(&lookup_field_values->db_value,
52-@@ -3508,6 +3509,228 @@
53+@@ -3508,6 +3509,231 @@
54 return (uint) OPEN_FULL_TABLE;
55 }
56
57@@ -244,6 +244,7 @@
58 +#endif
59 +
60 + while ((thd_item=it++)) {
61++ pthread_mutex_lock(&thd_item->LOCK_temporary_tables);
62 + for (tmp=thd_item->temporary_tables; tmp; tmp=tmp->next) {
63 +
64 +#ifndef NO_EMBEDDED_ACCESS_CHECKS
65@@ -263,12 +264,14 @@
66 +
67 + if (store_temporary_table_record(thd_item, tables->table, tmp, thd->lex->select_lex.db, table_names_only)) {
68 + tmp->in_use= t;
69++ pthread_mutex_unlock(&thd_item->LOCK_temporary_tables);
70 + pthread_mutex_unlock(&LOCK_thread_count);
71 + DBUG_RETURN(1);
72 + }
73 +
74 + tmp->in_use= t;
75 + }
76++ pthread_mutex_unlock(&thd_item->LOCK_temporary_tables);
77 + }
78 +
79 + pthread_mutex_unlock(&LOCK_thread_count);
80@@ -307,7 +310,7 @@
81
82 /**
83 @brief Fill I_S table with data from FRM file only
84-@@ -6618,6 +6841,25 @@
85+@@ -6618,6 +6844,25 @@
86 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
87 };
88
89@@ -333,7 +336,7 @@
90
91 ST_FIELD_INFO columns_fields_info[]=
92 {
93-@@ -7278,6 +7520,9 @@
94+@@ -7278,6 +7523,9 @@
95 fill_schema_files, 0, 0, -1, -1, 0, 0},
96 {"GLOBAL_STATUS", variables_fields_info, create_schema_table,
97 fill_status, make_old_format, 0, 0, -1, 0, 0},
98@@ -343,7 +346,7 @@
99 {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table,
100 fill_variables, make_old_format, 0, 0, -1, 0, 0},
101 {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table,
102-@@ -7321,6 +7566,9 @@
103+@@ -7321,6 +7569,9 @@
104 get_all_tables, make_table_names_old_format, 0, 1, 2, 1, 0},
105 {"TABLE_PRIVILEGES", table_privileges_fields_info, create_schema_table,
106 fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
107@@ -354,8 +357,8 @@
108 fill_schema_table_stats, make_old_format, 0, -1, -1, 0, 0},
109 {"THREAD_STATISTICS", thread_stats_fields_info, create_schema_table,
110 diff -ruN a/sql/sql_yacc.yy b/sql/sql_yacc.yy
111---- a/sql/sql_yacc.yy 2010-08-27 15:19:09.976059692 +0900
112-+++ b/sql/sql_yacc.yy 2010-08-27 15:30:36.971993050 +0900
113+--- a/sql/sql_yacc.yy 2011-07-05 17:55:25.000000000 +0400
114++++ b/sql/sql_yacc.yy 2011-07-05 21:38:43.000000000 +0400
115 @@ -10096,6 +10096,15 @@
116 if (prepare_schema_table(YYTHD, lex, 0, SCH_TABLE_NAMES))
117 MYSQL_YYABORT;
118@@ -373,8 +376,8 @@
119 {
120 LEX *lex= Lex;
121 diff -ruN a/sql/table.h b/sql/table.h
122---- a/sql/table.h 2010-08-27 15:19:09.988989663 +0900
123-+++ b/sql/table.h 2010-08-27 15:30:36.987021191 +0900
124+--- a/sql/table.h 2011-07-05 17:55:25.000000000 +0400
125++++ b/sql/table.h 2011-07-05 21:38:43.000000000 +0400
126 @@ -954,6 +954,7 @@
127 SCH_EVENTS,
128 SCH_FILES,
129@@ -391,3 +394,109 @@
130 SCH_TABLE_STATS,
131 SCH_THREAD_STATS,
132 SCH_TRIGGERS,
133+diff -ruN a/sql/sql_base.cc b/sql/sql_base.cc
134+--- a/sql/sql_base.cc 2011-07-05 17:56:23.000000000 +0400
135++++ b/sql/sql_base.cc 2011-07-05 21:38:45.000000000 +0400
136+@@ -1459,12 +1459,16 @@
137+ (thd->current_stmt_binlog_row_based && thd->variables.binlog_format == BINLOG_FORMAT_ROW))
138+ {
139+ TABLE *tmp_next;
140++
141++ pthread_mutex_lock(&thd->LOCK_temporary_tables);
142+ for (table= thd->temporary_tables; table; table= tmp_next)
143+ {
144+ tmp_next= table->next;
145+ close_temporary(table, 1, 1);
146+ }
147+ thd->temporary_tables= 0;
148++ pthread_mutex_unlock(&thd->LOCK_temporary_tables);
149++
150+ return;
151+ }
152+
153+@@ -1477,6 +1481,8 @@
154+
155+ memcpy(buf, stub, stub_len);
156+
157++ pthread_mutex_lock(&thd->LOCK_temporary_tables);
158++
159+ /*
160+ Insertion sort of temp tables by pseudo_thread_id to build ordered list
161+ of sublists of equal pseudo_thread_id
162+@@ -1581,6 +1587,7 @@
163+ if (!was_quote_show)
164+ thd->options&= ~OPTION_QUOTE_SHOW_CREATE; /* restore option */
165+ thd->temporary_tables=0;
166++ pthread_mutex_unlock(&thd->LOCK_temporary_tables);
167+ }
168+
169+ /*
170+@@ -1883,6 +1890,8 @@
171+ if (table->child_l || table->parent)
172+ detach_merge_children(table, TRUE);
173+
174++ pthread_mutex_lock(&thd->LOCK_temporary_tables);
175++
176+ if (table->prev)
177+ {
178+ table->prev->next= table->next;
179+@@ -1909,6 +1918,9 @@
180+ slave_open_temp_tables--;
181+ }
182+ close_temporary(table, free_share, delete_table);
183++
184++ pthread_mutex_unlock(&thd->LOCK_temporary_tables);
185++
186+ DBUG_VOID_RETURN;
187+ }
188+
189+@@ -5626,6 +5638,7 @@
190+ if (link_in_list)
191+ {
192+ /* growing temp list at the head */
193++ pthread_mutex_lock(&thd->LOCK_temporary_tables);
194+ tmp_table->next= thd->temporary_tables;
195+ if (tmp_table->next)
196+ tmp_table->next->prev= tmp_table;
197+@@ -5633,6 +5646,7 @@
198+ thd->temporary_tables->prev= 0;
199+ if (thd->slave_thread)
200+ slave_open_temp_tables++;
201++ pthread_mutex_unlock(&thd->LOCK_temporary_tables);
202+ }
203+ tmp_table->pos_in_table_list= 0;
204+ DBUG_PRINT("tmptable", ("opened table: '%s'.'%s' 0x%lx", tmp_table->s->db.str,
205+diff -ruN a/sql/sql_class.cc b/sql/sql_class.cc
206+--- a/sql/sql_class.cc 2011-07-05 17:56:29.000000000 +0400
207++++ b/sql/sql_class.cc 2011-07-05 21:38:54.000000000 +0400
208+@@ -733,6 +733,7 @@
209+ active_vio = 0;
210+ #endif
211+ pthread_mutex_init(&LOCK_thd_data, MY_MUTEX_INIT_FAST);
212++ pthread_mutex_init(&LOCK_temporary_tables, MY_MUTEX_INIT_FAST);
213+
214+ /* Variables with default values */
215+ proc_info="login";
216+@@ -1145,6 +1146,7 @@
217+ #endif
218+ mysys_var=0; // Safety (shouldn't be needed)
219+ pthread_mutex_destroy(&LOCK_thd_data);
220++ pthread_mutex_destroy(&LOCK_temporary_tables);
221+ #ifndef DBUG_OFF
222+ dbug_sentry= THD_SENTRY_GONE;
223+ #endif
224+diff -ruN a/sql/sql_class.h b/sql/sql_class.h
225+--- a/sql/sql_class.h 2011-07-05 17:56:23.000000000 +0400
226++++ b/sql/sql_class.h 2011-07-05 21:38:44.000000000 +0400
227+@@ -894,6 +894,11 @@
228+ */
229+ TABLE *temporary_tables;
230+ /**
231++ Protects temporary_tables.
232++ */
233++ pthread_mutex_t LOCK_temporary_tables;
234++
235++ /**
236+ List of tables that were opened with HANDLER OPEN and are
237+ still in use by this thread.
238+ */

Subscribers

People subscribed via source and target branches