Skip to content

Commit 2d36e5a

Browse files
committed
Fixed bug mdev-10736 that caused crashes.
The bug manifested itself for recursive definitions that used anchors over tables with blobs.
1 parent 2254400 commit 2d36e5a

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

mysql-test/r/cte_recursive.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,3 +1623,12 @@ n
16231623
3
16241624
4
16251625
5
1626+
#
1627+
# MDEV-10736: recursive definition with anchor over a table with blob
1628+
#
1629+
CREATE TABLE t1 (f VARCHAR(1024));
1630+
WITH RECURSIVE cte(f) AS
1631+
(SELECT t1.f FROM t1 UNION ALL SELECT cte.f FROM cte)
1632+
SELECT * FROM cte;
1633+
f
1634+
DROP TABLE t1;

mysql-test/t/cte_recursive.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,3 +1184,13 @@ drop table t1;
11841184
WITH RECURSIVE cte(n) AS
11851185
( SELECT n+1 FROM cte WHERE n < 5 UNION SELECT 1 UNION SELECT 1 )
11861186
SELECT * FROM cte;
1187+
1188+
--echo #
1189+
--echo # MDEV-10736: recursive definition with anchor over a table with blob
1190+
--echo #
1191+
1192+
CREATE TABLE t1 (f VARCHAR(1024));
1193+
WITH RECURSIVE cte(f) AS
1194+
(SELECT t1.f FROM t1 UNION ALL SELECT cte.f FROM cte)
1195+
SELECT * FROM cte;
1196+
DROP TABLE t1;

sql/sql_cte.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,9 @@ bool With_element::instantiate_tmp_tables()
13011301
&rec_result->tmp_table_param.recinfo,
13021302
0))
13031303
return true;
1304+
1305+
rec_table->file->extra(HA_EXTRA_WRITE_CACHE);
1306+
rec_table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
13041307
}
13051308
return false;
13061309
}

sql/sql_union.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,6 @@ select_union_recursive::create_result_table(THD *thd_arg,
237237
for (uint i=0; i < table->s->fields; i++)
238238
rec_table->field[i]->flags &= ~PART_KEY_FLAG;
239239

240-
if (create_table)
241-
{
242-
rec_table->file->extra(HA_EXTRA_WRITE_CACHE);
243-
rec_table->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
244-
}
245-
246240
if (rec_tables.push_back(rec_table))
247241
return true;
248242

0 commit comments

Comments
 (0)