Commit graph

48 commits

Author SHA1 Message Date
Rucha Deodhar
2fdb556e04 MDEV-8334: Rename utf8 to utf8mb3
This patch changes the main name of 3 byte character set from utf8 to
utf8mb3. New old_mode UTF8_IS_UTF8MB3 is added and set TRUE by default,
so that utf8 would mean utf8mb3. If not set, utf8 would mean utf8mb4.
2021-05-19 06:48:36 +02:00
Sergei Petrunia
4547c6f283 MDEV-25154: JSON_TABLE: Queries involving ordinality columns are unsafe ...
Mark the JSON_TABLE function as SBR-unsafe.
It is not unsafe for the current implementation. But we still mark it as such
in order to be future-proof and keep it possible to change JSON data
representation in the future.
2021-05-13 15:34:25 +03:00
Alexey Botchkov
502b769561 MDEV-17399 JSON_TABLE.
Aftermerge fixes.
2021-04-21 10:21:48 +04:00
Alexey Botchkov
41e368f22d MDEV-25149 JSON_TABLE: Inconsistency in implicit data type conversion.
Only return the error if field->store produced errors, not warnings.
2021-04-21 10:21:48 +04:00
Sergei Petrunia
0a09525625 MDEV-25202: JSON_TABLE: Early table reference leads to unexpected result set
Followup part#2: allocate the List object on the right mem-root, too.
2021-04-21 10:21:48 +04:00
Alexey Botchkov
a4353c25ca MDEV-25420 JSON_TABLE: ASAN heap-buffer-overflow in Protocol::net_store_data or consequent failur es.
fixed changed.
2021-04-21 10:21:48 +04:00
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
Alexey Botchkov
6ac2a35553 MDEV-19628 JSON with starting double quotes key is not valid.
First character of the key name is just skipped, so the escapement
wasn't handled properly.
2019-09-30 14:43:32 +04:00
Alexey Botchkov
cd16d6d518 MDEV-13992 Implement JSON_MERGE_PATCH.
JSON_MERGE_PATCH implemented. Added JSON_MERGE_PRESERVE as a synonim for
the JSON_MERGE.
2019-05-17 11:53:58 +04:00
Alexey Botchkov
d702e46390 MDEV-15561 json_extract returns NULL with numbers in scientific notation.
Scientific notation handling fixed.
2018-03-25 00:15:11 +04:00
Alexey Botchkov
467acc2119 MDEV-13324 JSON_SET returns NULL instead of object.
Superfluous ',' was added to the JSON_SET result so it became
        invalid.
2017-09-12 14:40:18 +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
Nirbhay Choubey
8b2e642aa2 MDEV-7635: Update tests to adapt to the new default sql_mode 2017-02-10 06:30:42 -05:00
Alexey Botchkov
25aaecb240 MDEV-11858 json_merge() concatenates instead of merging.
Fix json_merge implementation.
2017-02-10 01:05:27 +04:00
Alexey Botchkov
abf7582112 MDEV-11557 port MySQL-5.7 JSON tests to MariaDB.
Fixes for issues found.
2017-02-06 06:47:48 +04:00
Alexey Botchkov
d123ed852a MDEV-11938 json.json_no_table crashes or fails with valgrind warnings in json_find_path / Item_func_json_length::val_int.
Paths with quoted keynames handled improperly.
2017-02-02 18:56:15 +04:00
Alexey Botchkov
d96ee168a1 MDEV-11557 port MySQL-5.7 JSON tests to MariaDB.
paths ending on [0]..[0] should be handled in conforming manner.
2017-01-26 16:35:05 +04:00
Alexey Botchkov
35760c0000 MDEV-11557 Port MySQL-5.7 JSON tests to MariaDB.
more fixes.
2017-01-25 00:13:15 +04: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