summaryrefslogtreecommitdiff
path: root/mysql-test/main/func_json.result
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2022-01-10 18:05:55 +0400
committerAlexander Barkov <bar@mariadb.com>2022-01-21 19:28:48 +0400
commite4b302e436c0a1e0d477a8e8e8e513112fd3ec7f (patch)
treeb8c180b94094978413fb3d6b7cdec3b803812b72 /mysql-test/main/func_json.result
parent28e166d6435741c46e0ea789657b739f78eb0425 (diff)
downloadmariadb-git-e4b302e436c0a1e0d477a8e8e8e513112fd3ec7f.tar.gz
MDEV-27018 IF and COALESCE lose "json" propertybb-10.5-bar-MDEV-27018
Hybrid functions (IF, COALESCE, etc) did not preserve the JSON property from their arguments. The same problem was repeatable for single row subselects. The problem happened because the method Item::is_json_type() was inconsistently implemented across the Item hierarchy. For example, Item_hybrid_func and Item_singlerow_subselect did not override is_json_type(). Solution: - Removing Item::is_json_type() - Implementing specific JSON type handlers: Type_handler_string_json Type_handler_varchar_json Type_handler_tiny_blob_json Type_handler_blob_json Type_handler_medium_blob_json Type_handler_long_blob_json - Reusing the existing data type infrastructure to pass JSON type handlers across all item types, including classes Item_hybrid_func and Item_singlerow_subselect. Note, these two classes themselves do not need any changes! - Extending the data type infrastructure so data types can inherit their properties (e.g. aggregation rules) from their base data types. E.g. VARCHAR/JSON acts as VARCHAR, LONGTEXT/JSON acts as LONGTEXT when mixed to a non-JSON data type. This is done by: - adding virtual method Type_handler::type_handler_base() - adding a helper class Type_handler_pair - refactoring Type_handler_hybrid_field_type methods aggregate_for_result(), aggregate_for_min_max(), aggregate_for_num_op() to use Type_handler_pair. This change also fixes: MDEV-27361 Hybrid functions with JSON arguments do not send format metadata Also, adding mtr tests for JSON replication. It was not covered yet. And the current patch changes the replication code slightly.
Diffstat (limited to 'mysql-test/main/func_json.result')
-rw-r--r--mysql-test/main/func_json.result9
1 files changed, 9 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result
index 74d301abf7a..c93ab405193 100644
--- a/mysql-test/main/func_json.result
+++ b/mysql-test/main/func_json.result
@@ -1388,5 +1388,14 @@ id materials
DROP TABLE t1;
DROP TABLE t2;
#
+# MDEV-27018 IF and COALESCE lose "json" property
+#
+SELECT json_object('a', if(1, json_object('b', 'c'), json_object('e', 'f')));
+json_object('a', if(1, json_object('b', 'c'), json_object('e', 'f')))
+{"a": {"b": "c"}}
+SELECT json_object('a', coalesce(json_object('b', 'c')));
+json_object('a', coalesce(json_object('b', 'c')))
+{"a": {"b": "c"}}
+#
# End of 10.5 tests
#