summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-05-10 18:14:08 +0400
committerAlexander Barkov <bar@mariadb.org>2017-05-10 18:14:08 +0400
commit533506b4edb5873dc25ae335dbd018da37235f2b (patch)
tree9f9b3e36d6ac3df9428f55e72dffeca775974968
parent191638416b3dbc206b4955639533e87cd488550c (diff)
downloadmariadb-git-533506b4edb5873dc25ae335dbd018da37235f2b.tar.gz
MDEV-12777 Change Lex_field_type_st::m_type from enum_field_types to Type_handler pointer
-rw-r--r--sql/field.cc2
-rw-r--r--sql/sql_class.cc11
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_yacc.yy112
-rw-r--r--sql/sql_yacc_ora.yy139
-rw-r--r--sql/structs.h21
6 files changed, 159 insertions, 127 deletions
diff --git a/sql/field.cc b/sql/field.cc
index b0345788bf3..3bff4213f7c 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -9787,7 +9787,7 @@ void Column_definition::set_attributes(const Lex_field_type_st &type,
DBUG_ASSERT(length == 0);
DBUG_ASSERT(decimals == 0);
- set_handler_by_real_type(type.field_type());
+ set_handler(type.type_handler());
charset= cs;
if (type.length())
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index b586cd138de..5b8aa9ce2aa 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1246,6 +1246,17 @@ extern "C" my_thread_id next_thread_id_noinline()
}
#endif
+
+const Type_handler *THD::type_handler_for_date() const
+{
+ if (!(variables.sql_mode & MODE_ORACLE))
+ return &type_handler_newdate;
+ if (opt_mysql56_temporal_format)
+ return &type_handler_datetime2;
+ return &type_handler_datetime;
+}
+
+
/*
Init common variables that has to be reset on start and on change_user
*/
diff --git a/sql/sql_class.h b/sql/sql_class.h
index c1e80761235..58145703499 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3192,6 +3192,7 @@ public:
{
return !MY_TEST(variables.sql_mode & MODE_NO_BACKSLASH_ESCAPES);
}
+ const Type_handler *type_handler_for_date() const;
inline my_time_t query_start() { query_start_used=1; return start_time; }
inline ulong query_start_sec_part()
{ query_start_sec_part_used=1; return start_time_sec_part; }
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index c065cd7dcf7..c401a1d8b3a 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -782,6 +782,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
Create_field *create_field;
Spvar_definition *spvar_definition;
Row_definition_list *spvar_definition_list;
+ const Type_handler *type_handler;
CHARSET_INFO *charset;
Condition_information_item *cond_info_item;
DYNCALL_CREATE_DEF *dyncol_def;
@@ -836,7 +837,6 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
enum Item_udftype udf_type;
enum Key::Keytype key_type;
enum Statement_information_item::Name stmt_info_item_name;
- enum enum_field_types field_type;
enum enum_filetype filetype;
enum enum_tx_isolation tx_isolation;
enum enum_var_type var_type;
@@ -1645,7 +1645,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <string>
text_string hex_or_bin_String opt_gconcat_separator
-%type <field_type> int_type real_type
+%type <type_handler> int_type real_type
%type <Lex_field_type> type_with_opt_collate field_type
field_type_numeric
@@ -6296,7 +6296,7 @@ field_type_numeric:
| real_type opt_precision field_options { $$.set($1, $2); }
| FLOAT_SYM float_options field_options
{
- $$.set(MYSQL_TYPE_FLOAT, $2);
+ $$.set(&type_handler_float, $2);
if ($2.length() && !$2.dec())
{
int err;
@@ -6305,60 +6305,60 @@ field_type_numeric:
my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0),
Lex->last_field->field_name.str));
if (tmp_length > PRECISION_FOR_FLOAT)
- $$.set(MYSQL_TYPE_DOUBLE);
+ $$.set(&type_handler_double);
else
- $$.set(MYSQL_TYPE_FLOAT);
+ $$.set(&type_handler_float);
}
}
| BIT_SYM opt_field_length_default_1
{
- $$.set(MYSQL_TYPE_BIT, $2);
+ $$.set(&type_handler_bit, $2);
}
| BOOL_SYM
{
- $$.set(MYSQL_TYPE_TINY, "1");
+ $$.set(&type_handler_tiny, "1");
}
| BOOLEAN_SYM
{
- $$.set(MYSQL_TYPE_TINY, "1");
+ $$.set(&type_handler_tiny, "1");
}
| DECIMAL_SYM float_options field_options
- { $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
+ { $$.set(&type_handler_newdecimal, $2);}
| NUMERIC_SYM float_options field_options
- { $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
+ { $$.set(&type_handler_newdecimal, $2);}
| FIXED_SYM float_options field_options
- { $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
+ { $$.set(&type_handler_newdecimal, $2);}
;
field_type_string:
char opt_field_length_default_1 opt_binary
{
- $$.set(MYSQL_TYPE_STRING, $2);
+ $$.set(&type_handler_string, $2);
}
| nchar opt_field_length_default_1 opt_bin_mod
{
- $$.set(MYSQL_TYPE_STRING, $2);
+ $$.set(&type_handler_string, $2);
bincmp_collation(national_charset_info, $3);
}
| BINARY opt_field_length_default_1
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_STRING, $2);
+ $$.set(&type_handler_string, $2);
}
| varchar field_length opt_binary
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| nvarchar field_length opt_bin_mod
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
bincmp_collation(national_charset_info, $3);
}
| VARBINARY field_length
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
;
@@ -6379,18 +6379,23 @@ field_type_temporal:
buff, "YEAR(4)");
}
}
- $$.set(MYSQL_TYPE_YEAR, $2);
+ $$.set(&type_handler_year, $2);
}
- | DATE_SYM
- { $$.set(MYSQL_TYPE_DATE); }
+ | DATE_SYM { $$.set(thd->type_handler_for_date()); }
| TIME_SYM opt_field_length
- { $$.set(opt_mysql56_temporal_format ?
- MYSQL_TYPE_TIME2 : MYSQL_TYPE_TIME, $2); }
+ {
+ $$.set(opt_mysql56_temporal_format ?
+ static_cast<const Type_handler*>(&type_handler_time2) :
+ static_cast<const Type_handler*>(&type_handler_time),
+ $2);
+ }
| TIMESTAMP opt_field_length
{
if (thd->variables.sql_mode & MODE_MAXDB)
$$.set(opt_mysql56_temporal_format ?
- MYSQL_TYPE_DATETIME2 : MYSQL_TYPE_DATETIME, $2);
+ static_cast<const Type_handler*>(&type_handler_datetime2) :
+ static_cast<const Type_handler*>(&type_handler_datetime),
+ $2);
else
{
/*
@@ -6399,13 +6404,19 @@ field_type_temporal:
*/
if (!opt_explicit_defaults_for_timestamp)
Lex->last_field->flags|= NOT_NULL_FLAG;
- $$.set(opt_mysql56_temporal_format ? MYSQL_TYPE_TIMESTAMP2
- : MYSQL_TYPE_TIMESTAMP, $2);
+ $$.set(opt_mysql56_temporal_format ?
+ static_cast<const Type_handler*>(&type_handler_timestamp2):
+ static_cast<const Type_handler*>(&type_handler_timestamp),
+ $2);
}
}
| DATETIME opt_field_length
- { $$.set(opt_mysql56_temporal_format ?
- MYSQL_TYPE_DATETIME2 : MYSQL_TYPE_DATETIME, $2); }
+ {
+ $$.set(opt_mysql56_temporal_format ?
+ static_cast<const Type_handler*>(&type_handler_datetime2) :
+ static_cast<const Type_handler*>(&type_handler_datetime),
+ $2);
+ }
;
@@ -6413,19 +6424,19 @@ field_type_lob:
TINYBLOB
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_TINY_BLOB);
+ $$.set(&type_handler_tiny_blob);
}
| BLOB_SYM opt_field_length
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_BLOB, $2);
+ $$.set(&type_handler_blob, $2);
}
| spatial_type float_options srid_option
{
#ifdef HAVE_SPATIAL
Lex->charset=&my_charset_bin;
Lex->last_field->geom_type= $1;
- $$.set(MYSQL_TYPE_GEOMETRY, $2);
+ $$.set(&type_handler_geometry, $2);
#else
my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name,
sym_group_geom.needed_define));
@@ -6434,38 +6445,38 @@ field_type_lob:
| MEDIUMBLOB
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_MEDIUM_BLOB);
+ $$.set(&type_handler_medium_blob);
}
| LONGBLOB
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_LONG_BLOB);
+ $$.set(&type_handler_long_blob);
}
| LONG_SYM VARBINARY
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_MEDIUM_BLOB);
+ $$.set(&type_handler_medium_blob);
}
| LONG_SYM varchar opt_binary
- { $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
+ { $$.set(&type_handler_medium_blob); }
| TINYTEXT opt_binary
- { $$.set(MYSQL_TYPE_TINY_BLOB); }
+ { $$.set(&type_handler_tiny_blob); }
| TEXT_SYM opt_field_length opt_binary
- { $$.set(MYSQL_TYPE_BLOB, $2); }
+ { $$.set(&type_handler_blob, $2); }
| MEDIUMTEXT opt_binary
- { $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
+ { $$.set(&type_handler_medium_blob); }
| LONGTEXT opt_binary
- { $$.set(MYSQL_TYPE_LONG_BLOB); }
+ { $$.set(&type_handler_long_blob); }
| LONG_SYM opt_binary
- { $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
+ { $$.set(&type_handler_medium_blob); }
;
field_type_misc:
ENUM '(' string_list ')' opt_binary
- { $$.set(MYSQL_TYPE_ENUM); }
+ { $$.set(&type_handler_enum); }
| SET '(' string_list ')' opt_binary
- { $$.set(MYSQL_TYPE_SET); }
+ { $$.set(&type_handler_set); }
;
spatial_type:
@@ -6502,23 +6513,22 @@ nvarchar:
;
int_type:
- INT_SYM { $$=MYSQL_TYPE_LONG; }
- | TINYINT { $$=MYSQL_TYPE_TINY; }
- | SMALLINT { $$=MYSQL_TYPE_SHORT; }
- | MEDIUMINT { $$=MYSQL_TYPE_INT24; }
- | BIGINT { $$=MYSQL_TYPE_LONGLONG; }
+ INT_SYM { $$= &type_handler_long; }
+ | TINYINT { $$= &type_handler_tiny; }
+ | SMALLINT { $$= &type_handler_short; }
+ | MEDIUMINT { $$= &type_handler_int24; }
+ | BIGINT { $$= &type_handler_longlong; }
;
real_type:
REAL
{
$$= thd->variables.sql_mode & MODE_REAL_AS_FLOAT ?
- MYSQL_TYPE_FLOAT : MYSQL_TYPE_DOUBLE;
+ static_cast<const Type_handler *>(&type_handler_float) :
+ static_cast<const Type_handler *>(&type_handler_double);
}
- | DOUBLE_SYM
- { $$=MYSQL_TYPE_DOUBLE; }
- | DOUBLE_SYM PRECISION
- { $$=MYSQL_TYPE_DOUBLE; }
+ | DOUBLE_SYM { $$= &type_handler_double; }
+ | DOUBLE_SYM PRECISION { $$= &type_handler_double; }
;
srid_option:
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 61577b53006..e4cdd81ce80 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -191,6 +191,7 @@ void ORAerror(THD *thd, const char *s)
Create_field *create_field;
Spvar_definition *spvar_definition;
Row_definition_list *spvar_definition_list;
+ const Type_handler *type_handler;
CHARSET_INFO *charset;
Condition_information_item *cond_info_item;
DYNCALL_CREATE_DEF *dyncol_def;
@@ -245,7 +246,6 @@ void ORAerror(THD *thd, const char *s)
enum Item_udftype udf_type;
enum Key::Keytype key_type;
enum Statement_information_item::Name stmt_info_item_name;
- enum enum_field_types field_type;
enum enum_filetype filetype;
enum enum_tx_isolation tx_isolation;
enum enum_var_type var_type;
@@ -1059,7 +1059,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <string>
text_string hex_or_bin_String opt_gconcat_separator
-%type <field_type> int_type real_type
+%type <type_handler> int_type real_type
%type <Lex_field_type> type_with_opt_collate field_type
sp_param_type_with_opt_collate
@@ -6178,7 +6178,7 @@ field_type_numeric:
| real_type opt_precision field_options { $$.set($1, $2); }
| FLOAT_SYM float_options field_options
{
- $$.set(MYSQL_TYPE_FLOAT, $2);
+ $$.set(&type_handler_float, $2);
if ($2.length() && !$2.dec())
{
int err;
@@ -6187,76 +6187,76 @@ field_type_numeric:
my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0),
Lex->last_field->field_name.str));
if (tmp_length > PRECISION_FOR_FLOAT)
- $$.set(MYSQL_TYPE_DOUBLE);
+ $$.set(&type_handler_double);
else
- $$.set(MYSQL_TYPE_FLOAT);
+ $$.set(&type_handler_float);
}
}
| BIT_SYM opt_field_length_default_1
{
- $$.set(MYSQL_TYPE_BIT, $2);
+ $$.set(&type_handler_bit, $2);
}
| BOOL_SYM
{
- $$.set(MYSQL_TYPE_TINY, "1");
+ $$.set(&type_handler_tiny, "1");
}
| BOOLEAN_SYM
{
- $$.set(MYSQL_TYPE_TINY, "1");
+ $$.set(&type_handler_tiny, "1");
}
| DECIMAL_SYM float_options field_options
- { $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
+ { $$.set(&type_handler_newdecimal, $2);}
| NUMBER_SYM float_options field_options
{
if ($2.length() != 0)
- $$.set(MYSQL_TYPE_NEWDECIMAL, $2);
+ $$.set(&type_handler_newdecimal, $2);
else
- $$.set(MYSQL_TYPE_DOUBLE);
+ $$.set(&type_handler_double);
}
| NUMERIC_SYM float_options field_options
- { $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
+ { $$.set(&type_handler_newdecimal, $2);}
| FIXED_SYM float_options field_options
- { $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
+ { $$.set(&type_handler_newdecimal, $2);}
;
field_type_string:
char opt_field_length_default_1 opt_binary
{
- $$.set(MYSQL_TYPE_STRING, $2);
+ $$.set(&type_handler_string, $2);
}
| nchar opt_field_length_default_1 opt_bin_mod
{
- $$.set(MYSQL_TYPE_STRING, $2);
+ $$.set(&type_handler_string, $2);
bincmp_collation(national_charset_info, $3);
}
| BINARY opt_field_length_default_1
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_STRING, $2);
+ $$.set(&type_handler_string, $2);
}
| varchar field_length opt_binary
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| VARCHAR2 field_length opt_binary
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| nvarchar field_length opt_bin_mod
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
bincmp_collation(national_charset_info, $3);
}
| VARBINARY field_length
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| RAW field_length
{
Lex->charset= &my_charset_bin;
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
;
@@ -6264,40 +6264,40 @@ field_type_string:
sp_param_field_type_string:
char opt_field_length_default_sp_param_char opt_binary
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| nchar opt_field_length_default_sp_param_char opt_bin_mod
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
bincmp_collation(national_charset_info, $3);
}
| BINARY opt_field_length_default_sp_param_char
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| varchar opt_field_length_default_sp_param_varchar opt_binary
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| VARCHAR2 opt_field_length_default_sp_param_varchar opt_binary
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| nvarchar opt_field_length_default_sp_param_varchar opt_bin_mod
{
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
bincmp_collation(national_charset_info, $3);
}
| VARBINARY opt_field_length_default_sp_param_varchar
{
Lex->charset= &my_charset_bin;
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
| RAW opt_field_length_default_sp_param_varchar
{
Lex->charset= &my_charset_bin;
- $$.set(MYSQL_TYPE_VARCHAR, $2);
+ $$.set(&type_handler_varchar, $2);
}
;
@@ -6319,19 +6319,23 @@ field_type_temporal:
buff, "YEAR(4)");
}
}
- $$.set(MYSQL_TYPE_YEAR, $2);
+ $$.set(&type_handler_year, $2);
}
- | DATE_SYM
- { $$.set(opt_mysql56_temporal_format ?
- MYSQL_TYPE_DATETIME2 : MYSQL_TYPE_DATETIME, 0); }
+ | DATE_SYM { $$.set(thd->type_handler_for_date()); }
| TIME_SYM opt_field_length
- { $$.set(opt_mysql56_temporal_format ?
- MYSQL_TYPE_TIME2 : MYSQL_TYPE_TIME, $2); }
+ {
+ $$.set(opt_mysql56_temporal_format ?
+ static_cast<const Type_handler*>(&type_handler_time2) :
+ static_cast<const Type_handler*>(&type_handler_time),
+ $2);
+ }
| TIMESTAMP opt_field_length
{
if (thd->variables.sql_mode & MODE_MAXDB)
$$.set(opt_mysql56_temporal_format ?
- MYSQL_TYPE_DATETIME2 : MYSQL_TYPE_DATETIME, $2);
+ static_cast<const Type_handler*>(&type_handler_datetime2) :
+ static_cast<const Type_handler*>(&type_handler_datetime),
+ $2);
else
{
/*
@@ -6340,13 +6344,19 @@ field_type_temporal:
*/
if (!opt_explicit_defaults_for_timestamp)
Lex->last_field->flags|= NOT_NULL_FLAG;
- $$.set(opt_mysql56_temporal_format ? MYSQL_TYPE_TIMESTAMP2
- : MYSQL_TYPE_TIMESTAMP, $2);
+ $$.set(opt_mysql56_temporal_format ?
+ static_cast<const Type_handler*>(&type_handler_timestamp2):
+ static_cast<const Type_handler*>(&type_handler_timestamp),
+ $2);
}
}
| DATETIME opt_field_length
- { $$.set(opt_mysql56_temporal_format ?
- MYSQL_TYPE_DATETIME2 : MYSQL_TYPE_DATETIME, $2); }
+ {
+ $$.set(opt_mysql56_temporal_format ?
+ static_cast<const Type_handler*>(&type_handler_datetime2) :
+ static_cast<const Type_handler*>(&type_handler_datetime),
+ $2);
+ }
;
@@ -6354,19 +6364,19 @@ field_type_lob:
TINYBLOB
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_TINY_BLOB);
+ $$.set(&type_handler_tiny_blob);
}
| BLOB_SYM opt_field_length
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_LONG_BLOB);
+ $$.set(&type_handler_long_blob);
}
| spatial_type float_options srid_option
{
#ifdef HAVE_SPATIAL
Lex->charset=&my_charset_bin;
Lex->last_field->geom_type= $1;
- $$.set(MYSQL_TYPE_GEOMETRY, $2);
+ $$.set(&type_handler_geometry, $2);
#else
my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name,
sym_group_geom.needed_define));
@@ -6375,40 +6385,40 @@ field_type_lob:
| MEDIUMBLOB
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_MEDIUM_BLOB);
+ $$.set(&type_handler_medium_blob);
}
| LONGBLOB
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_LONG_BLOB);
+ $$.set(&type_handler_long_blob);
}
| LONG_SYM VARBINARY
{
Lex->charset=&my_charset_bin;
- $$.set(MYSQL_TYPE_MEDIUM_BLOB);
+ $$.set(&type_handler_medium_blob);
}
| LONG_SYM varchar opt_binary
- { $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
+ { $$.set(&type_handler_medium_blob); }
| TINYTEXT opt_binary
- { $$.set(MYSQL_TYPE_TINY_BLOB); }
+ { $$.set(&type_handler_tiny_blob); }
| TEXT_SYM opt_field_length opt_binary
- { $$.set(MYSQL_TYPE_BLOB, $2); }
+ { $$.set(&type_handler_blob, $2); }
| MEDIUMTEXT opt_binary
- { $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
+ { $$.set(&type_handler_medium_blob); }
| LONGTEXT opt_binary
- { $$.set(MYSQL_TYPE_LONG_BLOB); }
+ { $$.set(&type_handler_long_blob); }
| CLOB opt_binary
- { $$.set(MYSQL_TYPE_LONG_BLOB); }
+ { $$.set(&type_handler_long_blob); }
| LONG_SYM opt_binary
- { $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
+ { $$.set(&type_handler_medium_blob); }
;
field_type_misc:
ENUM '(' string_list ')' opt_binary
- { $$.set(MYSQL_TYPE_ENUM); }
+ { $$.set(&type_handler_enum); }
| SET '(' string_list ')' opt_binary
- { $$.set(MYSQL_TYPE_SET); }
+ { $$.set(&type_handler_set); }
;
spatial_type:
@@ -6445,23 +6455,22 @@ nvarchar:
;
int_type:
- INT_SYM { $$=MYSQL_TYPE_LONG; }
- | TINYINT { $$=MYSQL_TYPE_TINY; }
- | SMALLINT { $$=MYSQL_TYPE_SHORT; }
- | MEDIUMINT { $$=MYSQL_TYPE_INT24; }
- | BIGINT { $$=MYSQL_TYPE_LONGLONG; }
+ INT_SYM { $$= &type_handler_long; }
+ | TINYINT { $$= &type_handler_tiny; }
+ | SMALLINT { $$= &type_handler_short; }
+ | MEDIUMINT { $$= &type_handler_int24; }
+ | BIGINT { $$= &type_handler_longlong; }
;
real_type:
REAL
{
$$= thd->variables.sql_mode & MODE_REAL_AS_FLOAT ?
- MYSQL_TYPE_FLOAT : MYSQL_TYPE_DOUBLE;
+ static_cast<const Type_handler *>(&type_handler_float) :
+ static_cast<const Type_handler *>(&type_handler_double);
}
- | DOUBLE_SYM
- { $$=MYSQL_TYPE_DOUBLE; }
- | DOUBLE_SYM PRECISION
- { $$=MYSQL_TYPE_DOUBLE; }
+ | DOUBLE_SYM { $$= &type_handler_double; }
+ | DOUBLE_SYM PRECISION { $$= &type_handler_double; }
;
srid_option:
diff --git a/sql/structs.h b/sql/structs.h
index 1a143602eea..80371b1b8b6 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -29,6 +29,7 @@
#include <mysql_com.h> /* USERNAME_LENGTH */
struct TABLE;
+class Type_handler;
class Field;
class Index_statistics;
@@ -581,27 +582,27 @@ public:
struct Lex_field_type_st: public Lex_length_and_dec_st
{
private:
- enum_field_types m_type;
- void set(enum_field_types type, const char *length, const char *dec)
+ const Type_handler *m_handler;
+ void set(const Type_handler *handler, const char *length, const char *dec)
{
- m_type= type;
+ m_handler= handler;
Lex_length_and_dec_st::set(length, dec);
}
public:
- void set(enum_field_types type, Lex_length_and_dec_st length_and_dec)
+ void set(const Type_handler *handler, Lex_length_and_dec_st length_and_dec)
{
- m_type= type;
+ m_handler= handler;
Lex_length_and_dec_st::operator=(length_and_dec);
}
- void set(enum_field_types type, const char *length)
+ void set(const Type_handler *handler, const char *length)
{
- set(type, length, 0);
+ set(handler, length, 0);
}
- void set(enum_field_types type)
+ void set(const Type_handler *handler)
{
- set(type, 0, 0);
+ set(handler, 0, 0);
}
- enum_field_types field_type() const { return m_type; }
+ const Type_handler *type_handler() const { return m_handler; }
};