summaryrefslogtreecommitdiff
path: root/sql/field.h
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 /sql/field.h
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 'sql/field.h')
-rw-r--r--sql/field.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/sql/field.h b/sql/field.h
index 7ea0ce6e479..34446b2befe 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -4010,12 +4010,7 @@ public:
NONE, field_name_arg, collation),
can_alter_field_type(1) {};
- const Type_handler *type_handler() const override
- {
- if (is_var_string())
- return &type_handler_var_string;
- return &type_handler_string;
- }
+ const Type_handler *type_handler() const override;
enum ha_base_keytype key_type() const override
{ return binary() ? HA_KEYTYPE_BINARY : HA_KEYTYPE_TEXT; }
en_fieldtype tmp_engine_column_type(bool use_packed_rows) const override;
@@ -4134,8 +4129,7 @@ public:
share->varchar_fields++;
}
- const Type_handler *type_handler() const override
- { return &type_handler_varchar; }
+ const Type_handler *type_handler() const override;
en_fieldtype tmp_engine_column_type(bool use_packed_rows) const override
{
return FIELD_VARCHAR;