summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2020-10-24 00:16:56 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2020-10-24 00:16:56 +0400
commit9df99151dae05574cf21e7787ffd4fe988a66d77 (patch)
treeaee1c30b2fff4dda774f349a8bb416a89b96ea53
parentbff82f51ba01d31b4307a94b22a438e3ea1c471c (diff)
downloadmariadb-git-9df99151dae05574cf21e7787ffd4fe988a66d77.tar.gz
MDEV-23437 Item_func_json_objectagg::print is not implemented.
Fix the Item_func_json_objectagg::fix_fields to save the orig_args.
-rw-r--r--mysql-test/main/func_json.result5
-rw-r--r--mysql-test/main/func_json.test4
-rw-r--r--sql/item_jsonfunc.cc6
-rw-r--r--sql/item_jsonfunc.h3
4 files changed, 12 insertions, 6 deletions
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result
index 523048ccb7a..1af786c8d3f 100644
--- a/mysql-test/main/func_json.result
+++ b/mysql-test/main/func_json.result
@@ -1354,6 +1354,11 @@ e JSON_OBJECTAGG(B.a, B.v)
0 {"a1":"1", "a1":"1", "a1":"1"}
0 {"a2":"2", "a2":"2", "a2":"2"}
1 {"b1":"3", "b1":"3", "b1":"3"}
+CREATE VIEW v AS SELECT JSON_OBJECTAGG(a, e) FROM t1;
+SELECT * FROM v;
+JSON_OBJECTAGG(a, e)
+{"a1":0, "a2":0, "b1":1}
+DROP VIEW v;
DROP TABLE t1;
#
# End of 10.5 tests
diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test
index 68d381f5c07..04e16c02e6d 100644
--- a/mysql-test/main/func_json.test
+++ b/mysql-test/main/func_json.test
@@ -849,6 +849,10 @@ INSERT INTO t1 VALUES (0, 'a1', '1') , (0, 'a2', '2') , (1, 'b1', '3');
EXPLAIN SELECT B.e, JSON_OBJECTAGG(B.a, B.v) FROM t1 A, t1 B GROUP BY B.e, B.a;
SELECT B.e, JSON_OBJECTAGG(B.a, B.v) FROM t1 A, t1 B GROUP BY B.e, B.a;
+CREATE VIEW v AS SELECT JSON_OBJECTAGG(a, e) FROM t1;
+SELECT * FROM v;
+
+DROP VIEW v;
DROP TABLE t1;
--echo #
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index aec3e1edcd3..0299adf42bc 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -3772,6 +3772,8 @@ Item_func_json_objectagg::fix_fields(THD *thd, Item **ref)
uint i; /* for loop variable */
DBUG_ASSERT(fixed == 0);
+ memcpy(orig_args, args, sizeof(Item*) * arg_count);
+
if (init_sum_func_check(thd))
return TRUE;
@@ -3867,7 +3869,3 @@ String* Item_func_json_objectagg::val_str(String* str)
}
-void Item_func_json_objectagg::print(String *str, enum_query_type query_type)
-{
-}
-
diff --git a/sql/item_jsonfunc.h b/sql/item_jsonfunc.h
index 6bd2a81afc6..ec6c6696001 100644
--- a/sql/item_jsonfunc.h
+++ b/sql/item_jsonfunc.h
@@ -589,7 +589,7 @@ public:
void cleanup();
enum Sumfunctype sum_func () const {return JSON_OBJECTAGG_FUNC;}
- const char *func_name() const { return "json_objectagg("; }
+ const char *func_name() const { return "json_objectagg"; }
const Type_handler *type_handler() const
{
if (too_big_for_varchar())
@@ -618,7 +618,6 @@ public:
String* val_str(String* str);
Item *copy_or_same(THD* thd);
void no_rows_in_result() {}
- void print(String *str, enum_query_type query_type);
Item *get_copy(THD *thd)
{ return get_item_copy<Item_func_json_objectagg>(thd, this); }
};