Skip to content

Commit c4456b9

Browse files
committed
MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup...
[Attempt #] Make the code that handles "Prepare" phase for multi-table UPDATE statements handle non-merged semijoins. It can encounter them when a prepared statement is executed for the second time.
1 parent 517ef2b commit c4456b9

File tree

5 files changed

+83
-1
lines changed

5 files changed

+83
-1
lines changed

mysql-test/r/subselect_mat.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,24 @@ Handler_read_rnd_next 6003
21972197
Handler_tmp_write 2000
21982198
Handler_write 1000
21992199
drop table t0,t1,t2,t3;
2200+
#
2201+
# MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup
2202+
# on 2nd execution os PS with multi-table update
2203+
#
2204+
CREATE TABLE t1 (f1 INT);
2205+
INSERT INTO t1 VALUES (1),(2);
2206+
CREATE TABLE t2 (f2 INT);
2207+
INSERT INTO t2 VALUES (3),(4);
2208+
CREATE TABLE t3 (f3 INT);
2209+
INSERT INTO t3 VALUES (5),(6);
2210+
PREPARE stmt FROM '
2211+
UPDATE t1, t2
2212+
SET f1 = 5
2213+
WHERE 8 IN ( SELECT MIN(f3) FROM t3 )
2214+
';
2215+
EXECUTE stmt;
2216+
EXECUTE stmt;
2217+
DROP TABLE t1,t2,t3;
22002218
set @subselect_mat_test_optimizer_switch_value=null;
22012219
set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off';
22022220
set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';

mysql-test/r/subselect_sj_mat.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,3 +2237,21 @@ Handler_read_rnd_next 6003
22372237
Handler_tmp_write 2000
22382238
Handler_write 1000
22392239
drop table t0,t1,t2,t3;
2240+
#
2241+
# MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup
2242+
# on 2nd execution os PS with multi-table update
2243+
#
2244+
CREATE TABLE t1 (f1 INT);
2245+
INSERT INTO t1 VALUES (1),(2);
2246+
CREATE TABLE t2 (f2 INT);
2247+
INSERT INTO t2 VALUES (3),(4);
2248+
CREATE TABLE t3 (f3 INT);
2249+
INSERT INTO t3 VALUES (5),(6);
2250+
PREPARE stmt FROM '
2251+
UPDATE t1, t2
2252+
SET f1 = 5
2253+
WHERE 8 IN ( SELECT MIN(f3) FROM t3 )
2254+
';
2255+
EXECUTE stmt;
2256+
EXECUTE stmt;
2257+
DROP TABLE t1,t2,t3;

mysql-test/t/subselect_sj_mat.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,3 +1885,28 @@ select * from t1 where (a,b) in (select max(a),b from t2 group by b);
18851885
show status where Variable_name like 'Handler_read%' or Variable_name like 'Handler_%write%';
18861886

18871887
drop table t0,t1,t2,t3;
1888+
1889+
--echo #
1890+
--echo # MDEV-7971: Assertion `name != __null' failed in ACL_internal_schema_registry::lookup
1891+
--echo # on 2nd execution os PS with multi-table update
1892+
--echo #
1893+
CREATE TABLE t1 (f1 INT);
1894+
INSERT INTO t1 VALUES (1),(2);
1895+
1896+
CREATE TABLE t2 (f2 INT);
1897+
INSERT INTO t2 VALUES (3),(4);
1898+
1899+
CREATE TABLE t3 (f3 INT);
1900+
INSERT INTO t3 VALUES (5),(6);
1901+
1902+
PREPARE stmt FROM '
1903+
UPDATE t1, t2
1904+
SET f1 = 5
1905+
WHERE 8 IN ( SELECT MIN(f3) FROM t3 )
1906+
';
1907+
1908+
EXECUTE stmt;
1909+
EXECUTE stmt;
1910+
1911+
DROP TABLE t1,t2,t3;
1912+

sql/sql_parse.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7749,6 +7749,8 @@ bool multi_update_precheck(THD *thd, TABLE_LIST *tables)
77497749
*/
77507750
for (table= tables; table; table= table->next_local)
77517751
{
7752+
if (table->is_jtbm())
7753+
continue;
77527754
if (table->derived)
77537755
table->grant.privilege= SELECT_ACL;
77547756
else if ((check_access(thd, UPDATE_ACL, table->db,

sql/sql_update.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ bool unsafe_key_update(List<TABLE_LIST> leaves, table_map tables_for_update)
11611161

11621162
while ((tl= it++))
11631163
{
1164-
if (tl->table->map & tables_for_update)
1164+
if (!tl->is_jtbm() && (tl->table->map & tables_for_update))
11651165
{
11661166
TABLE *table1= tl->table;
11671167
bool primkey_clustered= (table1->file->primary_key_is_clustered() &&
@@ -1178,6 +1178,8 @@ bool unsafe_key_update(List<TABLE_LIST> leaves, table_map tables_for_update)
11781178
it2.rewind();
11791179
while ((tl2= it2++))
11801180
{
1181+
if (tl2->is_jtbm())
1182+
continue;
11811183
/*
11821184
Look at "next" tables only since all previous tables have
11831185
already been checked
@@ -1409,6 +1411,9 @@ int mysql_multi_update_prepare(THD *thd)
14091411
{
14101412
TABLE *table= tl->table;
14111413

1414+
if (tl->is_jtbm())
1415+
continue;
1416+
14121417
/* if table will be updated then check that it is unique */
14131418
if (table->map & tables_for_update)
14141419
{
@@ -1457,13 +1462,17 @@ int mysql_multi_update_prepare(THD *thd)
14571462
for (tl= table_list; tl; tl= tl->next_local)
14581463
{
14591464
bool not_used= false;
1465+
if (tl->is_jtbm())
1466+
continue;
14601467
if (multi_update_check_table_access(thd, tl, tables_for_update, &not_used))
14611468
DBUG_RETURN(TRUE);
14621469
}
14631470

14641471
/* check single table update for view compound from several tables */
14651472
for (tl= table_list; tl; tl= tl->next_local)
14661473
{
1474+
if (tl->is_jtbm())
1475+
continue;
14671476
if (tl->is_merged_derived())
14681477
{
14691478
TABLE_LIST *for_update= 0;
@@ -1493,6 +1502,8 @@ int mysql_multi_update_prepare(THD *thd)
14931502
ti.rewind();
14941503
while ((tl= ti++))
14951504
{
1505+
if (tl->is_jtbm())
1506+
continue;
14961507
TABLE *table= tl->table;
14971508
TABLE_LIST *tlist;
14981509
if (!(tlist= tl->top_table())->derived)
@@ -1635,6 +1646,9 @@ int multi_update::prepare(List<Item> &not_used_values,
16351646
*/
16361647
while ((table_ref= ti++))
16371648
{
1649+
if (table_ref->is_jtbm())
1650+
continue;
1651+
16381652
TABLE *table= table_ref->table;
16391653
if (tables_to_update & table->map)
16401654
{
@@ -1654,6 +1668,9 @@ int multi_update::prepare(List<Item> &not_used_values,
16541668
ti.rewind();
16551669
while ((table_ref= ti++))
16561670
{
1671+
if (table_ref->is_jtbm())
1672+
continue;
1673+
16571674
TABLE *table= table_ref->table;
16581675
if (tables_to_update & table->map)
16591676
{
@@ -1684,6 +1701,8 @@ int multi_update::prepare(List<Item> &not_used_values,
16841701
while ((table_ref= ti++))
16851702
{
16861703
/* TODO: add support of view of join support */
1704+
if (table_ref->is_jtbm())
1705+
continue;
16871706
TABLE *table=table_ref->table;
16881707
leaf_table_count++;
16891708
if (tables_to_update & table->map)

0 commit comments

Comments
 (0)