Commit graph

32 commits

Author SHA1 Message Date
Sergei Petrunia
b0817ff8de MDEV-25202: JSON_TABLE: Early table reference leads to unexpected result set
Address review input: switch Name_resolution_context::ignored_tables from
table_map to a list of TABLE_LIST objects. The rationale is that table
bits may be changed due to query rewrites, etc, which may potentially
require updating ignored_tables.
2021-04-21 10:21:48 +04:00
Alexey Botchkov
91cd3c8f5b MDEV-25353 JSON_TABLE: Illegal mix of collations upon executing PS once, or SP/function twice.
Do not adapt to the argument charset anymore. Just use the utf8mb4 as
the default cherset.
2021-04-21 10:21:47 +04:00
Alexey Botchkov
59f3399e29 MDEV-25420 JSON_TABLE: ASAN heap-buffer-overflow in Protocol::net_store_data or consequent failures.
Create_tmp_table::add_field didn't consider BIT type field for
null_counter.
2021-04-21 10:21:47 +04:00
Alexey Botchkov
277aa532f3 MDEV-25408 JSON_TABLE: AddressSanitizer CHECK failed in Binary_string::realloc_raw
We need to update default values if we change the column's charsets.
2021-04-21 10:21:47 +04:00
Alexey Botchkov
991bfebe8f MDEV-25379 JSON_TABLE: ERROR ON clauses are ignored if a column is not on select list.
If a field is not in the read set - read it in the local buffer anyway to check for errors.
2021-04-21 10:21:47 +04:00
Sergei Petrunia
a96408092c MDEV-25397: JSON_TABLE: Unexpected ER_MIX_OF_GROUP_FUNC_AND_FIELDS
When doing name resolution, do the same what WHERE/ON clauses do:
they don't count in select_lex->non_agg_field_used().
2021-04-21 10:21:47 +04:00
Alexey Botchkov
a2ce788f02 MDEV-25259 JSON_TABLE: Illegal mix of collations upon executing query with combination of charsets via view.
The ::print method didn't print the explicitly specified charset.
2021-04-21 10:21:47 +04:00
Sergei Petrunia
6bac48d0cf MDEV-25381: JSON_TABLE: ER_WRONG_OUTER_JOIN upon query with LEFT and RIGHT joins and view
Table_function_json_table::m_dep_tables attempts to cache the value of
m_json->used_tables(), poorly. Remove the cache and use the value
directly.
2021-04-21 10:21:46 +04:00
Sergei Petrunia
4a10dd0253 MDEV-25380: JSON_TABLE: Assertion `join->best_read < double(1.797...) fails
The query used a subquery of this form:

SELECT ...
WHERE
   EXISTS( SELECT ...
           FROM JSON_TABLE(outer_ref, ..) as JT
           WHERE trivial_correlation_cond)

EXISTS-to-IN conversion code was unable to see that the subquery will
still be correlated after the trivial_correlation is removed, which
eventually caused a crash due to inability to construct a query plan.

Fixed by making Item_subselect::walk() also walk arguments of Table
Functions.
2021-04-21 10:21:46 +04:00
Sergei Petrunia
90629aa83c MDEV-25346: JSON_TABLE: Server crashes in Item_field::fix_outer_field ...
mysql_derived_prepare() sets Name_resolution_context::outer_context=NULL
for the WHERE clause's context.
Do the same for all ON expressions, too.
2021-04-21 10:21:46 +04:00
Sergei Petrunia
bd1d6ee4b1 MDEV-25352: JSON_TABLE: Inconsistent name resolution and ER_VIEW_INVALID
Add testcase
2021-04-21 10:21:46 +04:00
Sergei Petrunia
74895090b3 MDEV-25202: JSON_TABLE: Early table reference leads to unexpected result set
Followup: also handle NATURAL JOIN, extend the new approach with
Name_resolution_context::ignored_tables
2021-04-21 10:21:45 +04:00
Alexey Botchkov
5a8abbb77d MDEV-17399 JSON_TABLE.
tests updated.
2021-04-21 10:21:45 +04:00
Sergei Petrunia
84cf9c2e11 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").
2021-04-21 10:21:45 +04:00
Alexey Botchkov
13390a70e2 MDEV-25255 JSON_TABLE: CREATE TABLE ignores NULL ON ERROR (implicit or explicit) and fails.
should not abort on field::set().
2021-04-21 10:21:45 +04:00
Alexey Botchkov
d2e2219e46 MDEV-25146 JSON_TABLE: Non-descriptive + wrong error messages upon trying to store array or object.
More informative messages added.
Do not issue additional messages if already handled.
2021-04-21 10:21:45 +04:00
Alexey Botchkov
11c8ce4348 MDEV-25138 JSON_TABLE: A space between JSON_TABLE and opening bracket causes syntax error.
syntax fixed.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
3edc4a0998 MDEV-25229 SON_TABLE: Server crashes in hton_name upon MATCH .. AGAINST.
No plugin for the JSON_TABLE so get the storage type name directly.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
6a5f86bf59 MDEV-25230 JSON_TABLE: CREATE VIEW with 2nd level NESTED PATH ends up with invalid frm, Assertion `m_status == DA_ERROR || m_status == DA_OK || m_status == DA_OK_BULK' failed.
Handle multiple NESTED paths.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
7075955f4e MDEV-25189 SON_TABLE: Assertion `l_offset >= 0 && table->s->rec_buff_length - l_offset > 0' failed upon CREATE .. SELECT.
fixed already, so just the testcase.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
46d592a047 MDEV-25188 JSON_TABLE: ASAN use-after-poison in Field_long::reset / Table_function_json_table::setup or malloc(): invalid size.
MDEV-25192 JSON_TABLE: ASAN use-after-poison in field_conv_memcpy / Create_tmp_table::finalize upon query with derived table.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
90c4dff5ab MDEV-25178 JSON_TABLE: ASAN use-after-poison in my_fill_8bit Json_table_column::On_response::respond.
table record buffer size was smaller than required when the charset
changes.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
6f56458a76 MDEV-25183 JSON_TABLE: CREATE VIEW involving NESTED PATH ends up with invalid frm.
Wrong comma was added after the single column.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
51ac57fbbe MDEV-25151 JSON_TABLE: Unexpectedly padded values in a PATH column.
Field length can increase after the change_charset(), so need to
set field->ptr properly.

also sensitive parts of the test moved to json_not_embedded.test.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
047eb2258d MDEV-25141 JSON_TABLE: SELECT into outfile bypasses file privilege check.
access rights checking fixed.
2021-04-21 10:21:44 +04:00
Alexey Botchkov
abdc39b0a7 MDEV-25143 JSON_TABLE: Server crashes in handler::print_error / hton_name upon ERROR ON EMPTY.
should return some error code from ha_json_table::rnd_pos() not just 1.
2021-04-21 10:21:44 +04:00
Sergei Petrunia
99fc076fea MDEV-25145: JSON_TABLE: Assertion fixed == 1 failed .. on 2nd execution 2021-04-21 10:21:43 +04:00
Sergei Petrunia
98556ef84a MDEV-25142: JSON_TABLE: CREATE VIEW involving EXISTS PATH ends up with invalid frm 2021-04-21 10:21:43 +04:00
Sergei Petrunia
2f650fb955 MDEV-17399: JSON_TABLE: Fix the problem with cross-nested-join dependency
Fix for for the problem with
- Cross-outer-join dependency
- dead-end join prefix
- join order pruning

See the comments in the patch for detailed description
2021-04-21 10:21:43 +04:00
Alexey Botchkov
e9fd327ee3 MDEV-17399 Add support for JSON_TABLE.
The specific table handler for the table functions was introduced,
and used to implement JSON_TABLE.
2021-04-21 10:21:43 +04:00
Sergei Golubchik
6f6d0531dc MDEV-11439 No data type JSON, but CAST(something AS JSON) pretends to work
Use JSON_COMPACT(X) instead of CAST(X AS JSON).
Bonus - X is validated to be a valid JSON.
Fix a typo in the error message.
2017-02-14 20:43:41 +01:00
Alexey Botchkov
50831b0f19 MDEV-11557 port MySQL-5.7 JSON tests to MariaDB.
json_no_table.test ported.
2017-01-24 17:34:44 +04:00