Merge lp:~laurynas-biveinis/percona-server/i-s-temp-tables-fixes-5.5 into lp:percona-server/5.5

Proposed by Laurynas Biveinis on 2013-09-13
Status: Work in progress
Proposed branch: lp:~laurynas-biveinis/percona-server/i-s-temp-tables-fixes-5.5
Merge into: lp:percona-server/5.5
Diff against target: 151 lines (+50/-23)
2 files modified
Percona-Server/sql/sql_show.cc (+46/-23)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+4/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/i-s-temp-tables-fixes-5.5
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Needs Fixing on 2013-09-24
Laurynas Biveinis (community) Needs Fixing on 2013-09-15
Review via email: mp+185498@code.launchpad.net

Description of the change

To post a comment you must log in.

Same comment as for 5.1.

review: Needs Fixing
Alexey Kopytov (akopytov) wrote :

Same comments as in 5.1.

review: Needs Fixing

Unmerged revisions

559. By Laurynas Biveinis on 2013-09-13

Merge bug 1222709, bug 1113388, and bug 1223335 fixes from 5.1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/sql/sql_show.cc'
2--- Percona-Server/sql/sql_show.cc 2013-06-27 15:11:49 +0000
3+++ Percona-Server/sql/sql_show.cc 2013-09-13 13:44:20 +0000
4@@ -3692,13 +3692,20 @@
5 @param[in] table I_S table
6 @param[in] tmp_table temporary table
7 @param[in] db database name
8+ @param[in] table_name_only whether to return only session_id,
9+ database, and table fields
10+ @param[in] thd_is_current_thd whether the temp table belongs to
11+ the current connection
12
13 @return Operation status
14 @retval 0 success
15 @retval 1 error
16 */
17
18-static int store_temporary_table_record(THD *thd, TABLE *table, TABLE *tmp_table, const char *db, bool table_name_only)
19+static int store_temporary_table_record(THD *thd, TABLE *table,
20+ TABLE *tmp_table, const char *db,
21+ bool table_name_only,
22+ bool thd_is_current_thd)
23 {
24 CHARSET_INFO *cs= system_charset_info;
25 DBUG_ENTER("store_temporary_table_record");
26@@ -3738,11 +3745,6 @@
27
28 MYSQL_TIME time;
29
30- /* We have only one handler object for a temp table globally and it might
31- be in use by other thread. Do not trash it by invoking handler methods on
32- it but rather clone it. */
33- file = file->clone(tmp_table->s->normalized_path.str, thd->mem_root);
34-
35 /**
36 TODO: InnoDB stat(file) checks file on short names within data dictionary
37 rather than using full path, because of that, temp files created in
38@@ -3750,14 +3752,33 @@
39
40 The fix is to patch InnoDB to use full path
41 */
42- file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
43-
44- table->field[5]->store((longlong) file->stats.records, TRUE);
45- table->field[5]->set_notnull();
46-
47- table->field[6]->store((longlong) file->stats.mean_rec_length, TRUE);
48- table->field[7]->store((longlong) file->stats.data_file_length, TRUE);
49- table->field[8]->store((longlong) file->stats.index_file_length, TRUE);
50+ if (thd_is_current_thd)
51+ file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
52+
53+ if (file->stats.records)
54+ {
55+ table->field[5]->store((longlong) file->stats.records, TRUE);
56+ table->field[5]->set_notnull();
57+ }
58+
59+ if (file->stats.mean_rec_length)
60+ {
61+ table->field[6]->store((longlong) file->stats.mean_rec_length, TRUE);
62+ table->field[6]->set_notnull();
63+ }
64+
65+ if (file->stats.data_file_length)
66+ {
67+ table->field[7]->store((longlong) file->stats.data_file_length, TRUE);
68+ table->field[7]->set_notnull();
69+ }
70+
71+ if (file->stats.index_file_length)
72+ {
73+ table->field[8]->store((longlong) file->stats.index_file_length, TRUE);
74+ table->field[8]->set_notnull();
75+ }
76+
77 if (file->stats.create_time)
78 {
79 thd->variables.time_zone->gmt_sec_to_TIME(&time,
80@@ -3765,6 +3786,7 @@
81 table->field[9]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
82 table->field[9]->set_notnull();
83 }
84+
85 if (file->stats.update_time)
86 {
87 thd->variables.time_zone->gmt_sec_to_TIME(&time,
88@@ -3772,8 +3794,6 @@
89 table->field[10]->store_time(&time, MYSQL_TIMESTAMP_DATETIME);
90 table->field[10]->set_notnull();
91 }
92-
93- file->close();
94 }
95
96 DBUG_RETURN(schema_table_store_record(thd, table));
97@@ -3823,17 +3843,14 @@
98 }
99 #endif
100
101- THD *t= tmp->in_use;
102- tmp->in_use= thd;
103-
104- if (store_temporary_table_record(thd_item, tables->table, tmp, thd->lex->select_lex.db, table_names_only)) {
105- tmp->in_use= t;
106+ if (store_temporary_table_record(thd_item, tables->table, tmp,
107+ thd->lex->select_lex.db,
108+ table_names_only, thd_item == thd)) {
109 mysql_mutex_unlock(&thd_item->LOCK_temporary_tables);
110 mysql_mutex_unlock(&LOCK_thread_count);
111 DBUG_RETURN(1);
112 }
113
114- tmp->in_use= t;
115 }
116 mysql_mutex_unlock(&thd_item->LOCK_temporary_tables);
117 }
118@@ -3864,11 +3881,17 @@
119 bool table_names_only= (thd->lex->sql_command == SQLCOM_SHOW_TEMPORARY_TABLES) ? 1 : 0;
120 TABLE *tmp;
121
122+ mysql_mutex_lock(&thd->LOCK_temporary_tables);
123+
124 for (tmp=thd->temporary_tables; tmp; tmp=tmp->next) {
125- if (store_temporary_table_record(thd, tables->table, tmp, thd->lex->select_lex.db, table_names_only)) {
126+ if (store_temporary_table_record(thd, tables->table, tmp,
127+ thd->lex->select_lex.db,
128+ table_names_only, true)) {
129+ mysql_mutex_unlock(&thd->LOCK_temporary_tables);
130 DBUG_RETURN(1);
131 }
132 }
133+ mysql_mutex_unlock(&thd->LOCK_temporary_tables);
134 DBUG_RETURN(0);
135 }
136
137
138=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
139--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-09-06 13:24:59 +0000
140+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-09-13 13:44:20 +0000
141@@ -5045,6 +5045,10 @@
142 new_handler = static_cast<ha_innobase*>(handler::clone(name,
143 mem_root));
144 if (new_handler) {
145+ DBUG_ASSERT(new_handler->prebuilt != NULL);
146+ DBUG_ASSERT(new_handler->user_thd == user_thd);
147+ DBUG_ASSERT(new_handler->prebuilt->trx == prebuilt->trx);
148+
149 new_handler->prebuilt->select_lock_type
150 = prebuilt->select_lock_type;
151 }

Subscribers

People subscribed via source and target branches