Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
None
-
None
Description
Create and populate table t1 with commands:
create table t1 (o_id int, attribute varchar(16), value varchar(16)); |
insert into t1 values (2,'color','red'),(2,'fabric','silk'),(3,'color','green'),(3,'shape','square'); |
Define view v1:
create view v1 as SELECT o_id, JSON_ARRAYAGG(attribute) AS attributes FROM t1 GROUP BY o_id order by attribute; |
The query
select * from v1; |
returns
MariaDB [test]> select * from v1;
|
+------+--------------+
|
| o_id | attributes |
|
+------+--------------+
|
| 2 | color,fabric |
|
| 3 | color,shape |
|
+------+--------------+
|
while the query used in the definition of v1 returns
MariaDB [test]> SELECT o_id, JSON_ARRAYAGG(attribute) AS attributes FROM t1 GROUP BY o_id order by attribute;
|
+------+--------------------+
|
| o_id | attributes |
|
+------+--------------------+
|
| 2 | ["color","fabric"] |
|
| 3 | ["color","shape"] |
|
+------+--------------------+
|
We also have:
MariaDB [test]> show create view v1;
|
+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
|
| View | Create View | character_set_client | collation_connection |
|
+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
|
| v1 | CREATE ALGORITHM=UNDEFINED DEFINER=`` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`o_id` AS `o_id`,group_concat(`t1`.`attribute` separator ',') AS `attributes` from `t1` group by `t1`.`o_id` order by `t1`.`attribute` | utf8 | utf8_general_ci |
|
+------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
|
The bug happens because the class Item_func_json_arrayagg lacks an implementation of the print method.