summaryrefslogtreecommitdiff
path: root/sql/sql_type.h
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2019-02-13 19:39:41 +0200
committerMonty <monty@mariadb.org>2019-02-13 19:40:26 +0200
commit0f489494395a8cd6aeaf5943fea63a9e4465cabb (patch)
tree9562c59945740f74a8d15be8bcbaf213b7dc7796 /sql/sql_type.h
parent22feb179ae166500ec91feec6246c8154e33f9a2 (diff)
downloadmariadb-git-0f489494395a8cd6aeaf5943fea63a9e4465cabb.tar.gz
MDEV-13916 Enforce check constraint on JSON type
When creating a field of type JSON, it will be automatically converted to TEXT with CHECK (json_valid(`a`)), if there wasn't any previous check for the column. Additional things: - Added two bug fixes that was found while testing JSON. These bug fixes has also been pushed to 10.3 (with a test case), but as they where minimal and needed to get this task done and tested, the fixes are repeated here. - CREATE TABLE ... SELECT drops constraints for columns that are both in the create and select part. - If one has both a default expression and check constraint for a column, one can get the error "Expression for field `a` is refering to uninitialized field `a`. - Removed some duplicate MYSQL_PLUGIN_IMPORT symbols
Diffstat (limited to 'sql/sql_type.h')
-rw-r--r--sql/sql_type.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/sql/sql_type.h b/sql/sql_type.h
index 3eb7d39742c..d507241075e 100644
--- a/sql/sql_type.h
+++ b/sql/sql_type.h
@@ -3280,6 +3280,7 @@ public:
return true;
}
virtual bool is_scalar_type() const { return true; }
+ virtual bool is_json_type() const { return false; }
virtual bool can_return_int() const { return true; }
virtual bool can_return_decimal() const { return true; }
virtual bool can_return_real() const { return true; }
@@ -5890,6 +5891,14 @@ public:
};
+class Type_handler_json: public Type_handler_long_blob
+{
+public:
+ virtual ~Type_handler_json() {}
+ virtual bool is_json_type() const { return true; }
+};
+
+
class Type_handler_blob: public Type_handler_blob_common
{
static const Name m_name_blob;
@@ -6218,6 +6227,7 @@ extern MYSQL_PLUGIN_IMPORT Type_handler_hex_hybrid type_handler_hex_hybrid;
extern MYSQL_PLUGIN_IMPORT Type_handler_tiny_blob type_handler_tiny_blob;
extern MYSQL_PLUGIN_IMPORT Type_handler_medium_blob type_handler_medium_blob;
extern MYSQL_PLUGIN_IMPORT Type_handler_long_blob type_handler_long_blob;
+extern MYSQL_PLUGIN_IMPORT Type_handler_json type_handler_json;
extern MYSQL_PLUGIN_IMPORT Type_handler_blob type_handler_blob;
extern MYSQL_PLUGIN_IMPORT Type_handler_bool type_handler_bool;
@@ -6243,11 +6253,6 @@ extern MYSQL_PLUGIN_IMPORT Type_handler_datetime2 type_handler_datetime2;
extern MYSQL_PLUGIN_IMPORT Type_handler_timestamp type_handler_timestamp;
extern MYSQL_PLUGIN_IMPORT Type_handler_timestamp2 type_handler_timestamp2;
-extern MYSQL_PLUGIN_IMPORT Type_handler_tiny_blob type_handler_tiny_blob;
-extern MYSQL_PLUGIN_IMPORT Type_handler_blob type_handler_blob;
-extern MYSQL_PLUGIN_IMPORT Type_handler_medium_blob type_handler_medium_blob;
-extern MYSQL_PLUGIN_IMPORT Type_handler_long_blob type_handler_long_blob;
-
extern MYSQL_PLUGIN_IMPORT Type_handler_interval_DDhhmmssff
type_handler_interval_DDhhmmssff;