1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

A cleanup for MDEV-13916 Enforce check constraint on JSON type

1. Renaming Type_handler_json to Type_handler_json_longtext
   There will be other JSON handlers soon, e.g. Type_handler_json_varchar.

2. Making the code more symmetric for data types:

- Adding a new virtual method
  Type_handler::Column_definition_validate_check_constraint()
- Moving JSON-specific code from sql_yacc.yy to
  Type_handler_json_longtext::Column_definition_validate_check_constraint()

3. Adding new files sql_type_json.cc and sql_type_json.h
   and moving Type_handler+JSON related code into these files.
This commit is contained in:
Alexander Barkov
2019-02-14 14:29:55 +04:00
parent 568dd5293c
commit 62c0ac2da6
12 changed files with 126 additions and 45 deletions

View File

@ -78,6 +78,7 @@ struct Schema_specification_st;
struct TABLE;
struct SORT_FIELD_ATTR;
class Vers_history_point;
class Virtual_column_info;
#define my_charset_numeric my_charset_latin1
@ -3280,7 +3281,6 @@ 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; }
@ -3338,6 +3338,10 @@ public:
// Automatic upgrade, e.g. for ALTER TABLE t1 FORCE
virtual void Column_definition_implicit_upgrade(Column_definition *c) const
{ }
// Validate CHECK constraint after the parser
virtual bool Column_definition_validate_check_constraint(THD *thd,
Column_definition *c)
const;
// Fix attributes after the parser
virtual bool Column_definition_fix_attributes(Column_definition *c) const= 0;
/*
@ -5895,14 +5899,6 @@ 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;
@ -6231,7 +6227,6 @@ 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;