Skip to content

Commit 99fc076

Browse files
spetruniaAlexey Botchkov
authored andcommitted
MDEV-25145: JSON_TABLE: Assertion fixed == 1 failed .. on 2nd execution
1 parent 98556ef commit 99fc076

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

mysql-test/suite/json/r/json_table.result

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,5 +491,22 @@ id select_type table type possible_keys key key_len ref rows Extra
491491
1 SIMPLE jt1 ALL NULL NULL NULL NULL 40 Table function: json_table
492492
drop table t20,t21,t31,t32;
493493
#
494+
# MDEV-25142: JSON_TABLE: CREATE VIEW involving EXISTS PATH ends up with invalid frm
495+
#
496+
drop view if exists v1;
497+
CREATE VIEW v1 AS SELECT * FROM JSON_TABLE('[]', '$' COLUMNS (f INT EXISTS PATH '$')) a ;
498+
show create view v1;
499+
View Create View character_set_client collation_connection
500+
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `a`.`f` AS `f` from JSON_TABLE('[]', '$' COLUMNS (`f` int(11) EXISTS PATH '$')) `a` latin1 latin1_swedish_ci
501+
drop view v1;
502+
#
503+
# MDEV-25145: JSON_TABLE: Assertion `fixed == 1' failed in Item_load_file::val_str on 2nd execution of PS
504+
#
505+
PREPARE stmt FROM "SELECT * FROM (SELECT * FROM JSON_TABLE(LOAD_FILE('x'), '$' COLUMNS (a FOR ORDINALITY)) AS t) AS sq";
506+
EXECUTE stmt;
507+
a
508+
EXECUTE stmt;
509+
a
510+
#
494511
# End of 10.6 tests
495512
#

mysql-test/suite/json/t/json_table.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,13 @@ CREATE VIEW v1 AS SELECT * FROM JSON_TABLE('[]', '$' COLUMNS (f INT EXISTS PATH
388388
show create view v1;
389389
drop view v1;
390390

391+
--echo #
392+
--echo # MDEV-25145: JSON_TABLE: Assertion `fixed == 1' failed in Item_load_file::val_str on 2nd execution of PS
393+
--echo #
394+
PREPARE stmt FROM "SELECT * FROM (SELECT * FROM JSON_TABLE(LOAD_FILE('x'), '$' COLUMNS (a FOR ORDINALITY)) AS t) AS sq";
395+
EXECUTE stmt;
396+
EXECUTE stmt;
397+
391398
--echo #
392399
--echo # End of 10.6 tests
393400
--echo #

sql/sql_select.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,11 +1243,14 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num,
12431243
thd->lex->current_select->context_analysis_place;
12441244
thd->lex->current_select->context_analysis_place= SELECT_LIST;
12451245

1246-
for (TABLE_LIST *tbl= tables_list; tbl; tbl= tbl->next_local)
12471246
{
1248-
if (tbl->table_function &&
1249-
tbl->table_function->setup(thd, tbl, select_lex_arg))
1250-
DBUG_RETURN(-1);
1247+
List_iterator_fast<TABLE_LIST> it(select_lex->leaf_tables);
1248+
while ((tbl= it++))
1249+
{
1250+
if (tbl->table_function &&
1251+
tbl->table_function->setup(thd, tbl, select_lex_arg))
1252+
DBUG_RETURN(-1);
1253+
}
12511254
}
12521255

12531256
if (setup_fields(thd, ref_ptrs, fields_list, MARK_COLUMNS_READ,

0 commit comments

Comments
 (0)