Skip to content

Commit b9b03fa

Browse files
author
Haixiang Li
committed
Bug#21139522 PREPARED STATEMENT EXPLAIN DELETE .. WITH STRICT MODE VIOLATION
FLATLINES Description: ------------ When MySQL calls 'EXECUTE s' at the first time to run a prepare statement with 'EXPLAIN', it did not release 'column_buffer' object, if running the same statement at the second time, a dead loop appeared, it seems MySQL was hanged. Fix: ---- Release 'column_buffer' object by a helper class. Test case added.
1 parent 0d0cb97 commit b9b03fa

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

mysql-test/r/explain.result

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,4 +733,16 @@ id select_type table partitions type possible_keys key key_len ref rows filtered
733733
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
734734
DROP TABLE t1, t2;
735735
# End WL#4897
736+
#
737+
# Bug#21139522 PREPARED STATEMENT EXPLAIN DELETE .. WITH STRICT
738+
# MODE VIOLATION FLATLINES
739+
#
740+
CREATE TABLE t1(a INT);
741+
PREPARE s FROM "EXPLAIN DELETE FROM t1 WHERE a || 'a' LIMIT 1";
742+
EXECUTE s;
743+
ERROR 22007: Truncated incorrect INTEGER value: 'a'
744+
EXECUTE s;
745+
ERROR 22007: Truncated incorrect INTEGER value: 'a'
746+
DROP TABLE t1;
747+
# End of test Bug#21139522
736748
End of 6.0 tests.

mysql-test/t/explain.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,4 +412,17 @@ DROP TABLE t1, t2;
412412

413413
--echo # End WL#4897
414414

415+
--echo #
416+
--echo # Bug#21139522 PREPARED STATEMENT EXPLAIN DELETE .. WITH STRICT
417+
--echo # MODE VIOLATION FLATLINES
418+
--echo #
419+
CREATE TABLE t1(a INT);
420+
PREPARE s FROM "EXPLAIN DELETE FROM t1 WHERE a || 'a' LIMIT 1";
421+
--error ER_TRUNCATED_WRONG_VALUE
422+
EXECUTE s;
423+
--error ER_TRUNCATED_WRONG_VALUE
424+
EXECUTE s;
425+
DROP TABLE t1;
426+
427+
--echo # End of test Bug#21139522
415428
--echo End of 6.0 tests.

sql/opt_explain_traditional.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,23 @@ bool Explain_format_traditional::push_select_type(List<Item> *items)
164164
return item == NULL || items->push_back(item);
165165
}
166166

167+
class Buffer_cleanup
168+
{
169+
public:
170+
explicit Buffer_cleanup(qep_row *row)
171+
: m_row(row)
172+
{}
173+
~Buffer_cleanup()
174+
{
175+
m_row->cleanup();
176+
}
177+
private:
178+
qep_row *m_row;
179+
};
167180

168181
bool Explain_format_traditional::flush_entry()
169182
{
183+
Buffer_cleanup bc(&column_buffer); // release column_buffer
170184
List<Item> items;
171185
if (push(&items, column_buffer.col_id, nil) ||
172186
push_select_type(&items) ||
@@ -240,7 +254,5 @@ bool Explain_format_traditional::flush_entry()
240254

241255
if (output->send_data(items))
242256
return true;
243-
244-
column_buffer.cleanup();
245257
return false;
246258
}

0 commit comments

Comments
 (0)