1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-25202: JSON_TABLE: Early table reference leads to unexpected result set

(Also fixes MDEV-25254).
Re-work Name Resolution for the argument of JSON_TABLE(json_doc, ....)
function. The json_doc argument can refer to other tables, but it can
only refer to the tables that precede[*] the JSON_TABLE(...) call.

[*] - For queries with RIGHT JOINs, the "preceding" is determined after
the query is normalized by converting RIGHT JOIN into left one.

The implementation is as follows:
- Table function arguments use their own Name_resolution_context.

- The Name_resolution_context now has a bitmap of tables that should be
  ignored when searching for a field.

- get_disallowed_table_deps() walks the TABLE_LIST::nested_join tree
  and computes a bitmap of tables that do not "precede" the given
  JSON_TABLE(...) invocation  (according the above definition of
  "preceding").
This commit is contained in:
Sergei Petrunia
2021-04-05 14:15:05 +03:00
committed by Alexey Botchkov
parent 13390a70e2
commit 84cf9c2e11
16 changed files with 398 additions and 39 deletions

View File

@ -99,6 +99,7 @@ static bool init_fields(THD *thd, TABLE_LIST *tables,
Lex_cstring_strlen(find_fields->table_name),
Lex_cstring_strlen(find_fields->field_name)));
if (!(find_fields->field= find_field_in_tables(thd, field, tables, NULL,
table_map(0),
0, REPORT_ALL_ERRORS, 1,
TRUE)))
DBUG_RETURN(1);