mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-22837 JSON_ARRAYAGG and JSON_OBJECTAGG treat JSON arguments as text.
Item_field::is_json_value() implemented.
This commit is contained in:
parent
6c573a9146
commit
e290e5a75d
6 changed files with 27 additions and 1 deletions
|
@ -1320,6 +1320,13 @@ Warnings:
|
|||
Warning 1260 Row 1 was cut by JSON_ARRAYAGG()
|
||||
drop table t1;
|
||||
SET group_concat_max_len= default;
|
||||
create table t1 (col1 json);
|
||||
insert into t1 values('{"color":"red", "size":1}' );
|
||||
insert into t1 values('{"color":"blue", "size":2}' );
|
||||
select JSON_ARRAYAGG(col1) from t1;
|
||||
JSON_ARRAYAGG(col1)
|
||||
[{"color":"red", "size":1},{"color":"blue", "size":2}]
|
||||
drop table t1;
|
||||
#
|
||||
# End of 10.5 tests
|
||||
#
|
||||
|
|
|
@ -820,6 +820,12 @@ select json_arrayagg(a) from t1;
|
|||
drop table t1;
|
||||
SET group_concat_max_len= default;
|
||||
|
||||
create table t1 (col1 json);
|
||||
insert into t1 values('{"color":"red", "size":1}' );
|
||||
insert into t1 values('{"color":"blue", "size":2}' );
|
||||
select JSON_ARRAYAGG(col1) from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.5 tests
|
||||
--echo #
|
||||
|
|
11
sql/item.cc
11
sql/item.cc
|
@ -3052,6 +3052,17 @@ Item_field::Item_field(THD *thd, Item_field *item)
|
|||
}
|
||||
|
||||
|
||||
bool Item_field::is_json_type()
|
||||
{
|
||||
if (!field->check_constraint ||
|
||||
field->check_constraint->expr->type() != FUNC_ITEM)
|
||||
return FALSE;
|
||||
|
||||
Item_func *f= (Item_func *) field->check_constraint->expr;
|
||||
return f->functype() == Item_func::JSON_VALID_FUNC;
|
||||
}
|
||||
|
||||
|
||||
void Item_field::set_field(Field *field_par)
|
||||
{
|
||||
field=result_field=field_par; // for easy coding with fields
|
||||
|
|
|
@ -3389,6 +3389,7 @@ public:
|
|||
my_decimal *val_decimal_result(my_decimal *);
|
||||
bool val_bool_result();
|
||||
bool is_null_result();
|
||||
bool is_json_type();
|
||||
bool send(Protocol *protocol, st_value *buffer);
|
||||
Load_data_outvar *get_load_data_outvar()
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
|
||||
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC,
|
||||
NEG_FUNC, GSYSVAR_FUNC, IN_OPTIMIZER_FUNC, DYNCOL_FUNC,
|
||||
JSON_EXTRACT_FUNC,
|
||||
JSON_EXTRACT_FUNC, JSON_VALID_FUNC,
|
||||
CASE_SEARCHED_FUNC, // Used by ColumnStore/Spider
|
||||
CASE_SIMPLE_FUNC // Used by ColumnStore/spider
|
||||
};
|
||||
|
|
|
@ -91,6 +91,7 @@ public:
|
|||
}
|
||||
Item *get_copy(THD *thd)
|
||||
{ return get_item_copy<Item_func_json_valid>(thd, this); }
|
||||
enum Functype functype() const { return JSON_VALID_FUNC; }
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue