mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-28480: Assertion `0' failed in Item_row::illegal_method_call on
SELECT FROM JSON_TABLE Analysis: When fix_fields_if_needed() is called, it doesnt check if operands are valid because check_cols() is not called. So it doesn't error out and eventually crashes. Fix: Use fix_fields_if_needed_for_scalar() instead of fix_fields_if_needed(). It filters the scalar and returns the error if it occurs.
This commit is contained in:
parent
1feccb505f
commit
5a9a80a213
4 changed files with 20 additions and 1 deletions
|
@ -1005,5 +1005,11 @@ name VARCHAR(10) CHARACTER SET latin1 COLLATE DEFAULT PATH '$.name'
|
|||
name
|
||||
Jeans
|
||||
#
|
||||
# MDEV-28480: Assertion `0' failed in Item_row::illegal_method_call
|
||||
# on SELECT FROM JSON_TABLE
|
||||
#
|
||||
SELECT 1 FROM JSON_TABLE (row(1,2), '$' COLUMNS (o FOR ORDINALITY)) AS j;
|
||||
ERROR 21000: Operand should contain 1 column(s)
|
||||
#
|
||||
# End of 10.6 tests
|
||||
#
|
||||
|
|
|
@ -863,6 +863,14 @@ SELECT * FROM json_table('[{"name":"Jeans"}]', '$[*]'
|
|||
) AS jt;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-28480: Assertion `0' failed in Item_row::illegal_method_call
|
||||
--echo # on SELECT FROM JSON_TABLE
|
||||
--echo #
|
||||
|
||||
--error ER_OPERAND_COLUMNS
|
||||
SELECT 1 FROM JSON_TABLE (row(1,2), '$' COLUMNS (o FOR ORDINALITY)) AS j;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.6 tests
|
||||
--echo #
|
||||
|
|
|
@ -1143,6 +1143,11 @@ public:
|
|||
{
|
||||
return fixed() ? false : fix_fields(thd, ref);
|
||||
}
|
||||
|
||||
/*
|
||||
fix_fields_if_needed_for_scalar() is used where we need to filter items
|
||||
that can't be scalars and want to return error for it.
|
||||
*/
|
||||
bool fix_fields_if_needed_for_scalar(THD *thd, Item **ref)
|
||||
{
|
||||
return fix_fields_if_needed(thd, ref) || check_cols(1);
|
||||
|
|
|
@ -1171,7 +1171,7 @@ bool Table_function_json_table::setup(THD *thd, TABLE_LIST *sql_table,
|
|||
// fields in non_agg_field_used:
|
||||
const bool saved_non_agg_field_used= s_lex->non_agg_field_used();
|
||||
|
||||
bool res= m_json->fix_fields_if_needed(thd, &m_json);
|
||||
bool res= m_json->fix_fields_if_needed_for_scalar(thd, &m_json);
|
||||
|
||||
s_lex->is_item_list_lookup= save_is_item_list_lookup;
|
||||
s_lex->set_non_agg_field_used(saved_non_agg_field_used);
|
||||
|
|
Loading…
Reference in a new issue