Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
533506b4
Commit
533506b4
authored
7 years ago
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-12777 Change Lex_field_type_st::m_type from enum_field_types to Type_handler pointer
parent
19163841
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
159 additions
and
127 deletions
+159
-127
sql/field.cc
sql/field.cc
+1
-1
sql/sql_class.cc
sql/sql_class.cc
+11
-0
sql/sql_class.h
sql/sql_class.h
+1
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+61
-51
sql/sql_yacc_ora.yy
sql/sql_yacc_ora.yy
+74
-65
sql/structs.h
sql/structs.h
+11
-10
No files found.
sql/field.cc
View file @
533506b4
...
@@ -9787,7 +9787,7 @@ void Column_definition::set_attributes(const Lex_field_type_st &type,
...
@@ -9787,7 +9787,7 @@ void Column_definition::set_attributes(const Lex_field_type_st &type,
DBUG_ASSERT
(
length
==
0
);
DBUG_ASSERT
(
length
==
0
);
DBUG_ASSERT
(
decimals
==
0
);
DBUG_ASSERT
(
decimals
==
0
);
set_handler
_by_real_type
(
type
.
field_type
());
set_handler
(
type
.
type_handler
());
charset
=
cs
;
charset
=
cs
;
if
(
type
.
length
())
if
(
type
.
length
())
...
...
This diff is collapsed.
Click to expand it.
sql/sql_class.cc
View file @
533506b4
...
@@ -1246,6 +1246,17 @@ extern "C" my_thread_id next_thread_id_noinline()
...
@@ -1246,6 +1246,17 @@ extern "C" my_thread_id next_thread_id_noinline()
}
}
#endif
#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
Init common variables that has to be reset on start and on change_user
*/
*/
...
...
This diff is collapsed.
Click to expand it.
sql/sql_class.h
View file @
533506b4
...
@@ -3192,6 +3192,7 @@ class THD :public Statement,
...
@@ -3192,6 +3192,7 @@ class THD :public Statement,
{
{
return
!
MY_TEST
(
variables
.
sql_mode
&
MODE_NO_BACKSLASH_ESCAPES
);
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
my_time_t
query_start
()
{
query_start_used
=
1
;
return
start_time
;
}
inline
ulong
query_start_sec_part
()
inline
ulong
query_start_sec_part
()
{
query_start_sec_part_used
=
1
;
return
start_time_sec_part
;
}
{
query_start_sec_part_used
=
1
;
return
start_time_sec_part
;
}
...
...
This diff is collapsed.
Click to expand it.
sql/sql_yacc.yy
View file @
533506b4
...
@@ -782,6 +782,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
...
@@ -782,6 +782,7 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
Create_field *create_field;
Create_field *create_field;
Spvar_definition *spvar_definition;
Spvar_definition *spvar_definition;
Row_definition_list *spvar_definition_list;
Row_definition_list *spvar_definition_list;
const Type_handler *type_handler;
CHARSET_INFO *charset;
CHARSET_INFO *charset;
Condition_information_item *cond_info_item;
Condition_information_item *cond_info_item;
DYNCALL_CREATE_DEF *dyncol_def;
DYNCALL_CREATE_DEF *dyncol_def;
...
@@ -836,7 +837,6 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
...
@@ -836,7 +837,6 @@ Virtual_column_info *add_virtual_expression(THD *thd, Item *expr)
enum Item_udftype udf_type;
enum Item_udftype udf_type;
enum Key::Keytype key_type;
enum Key::Keytype key_type;
enum Statement_information_item::Name stmt_info_item_name;
enum Statement_information_item::Name stmt_info_item_name;
enum enum_field_types field_type;
enum enum_filetype filetype;
enum enum_filetype filetype;
enum enum_tx_isolation tx_isolation;
enum enum_tx_isolation tx_isolation;
enum enum_var_type var_type;
enum enum_var_type var_type;
...
@@ -1645,7 +1645,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
...
@@ -1645,7 +1645,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <string>
%type <string>
text_string hex_or_bin_String opt_gconcat_separator
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
%type <Lex_field_type> type_with_opt_collate field_type
field_type_numeric
field_type_numeric
...
@@ -6296,7 +6296,7 @@ field_type_numeric:
...
@@ -6296,7 +6296,7 @@ field_type_numeric:
| real_type opt_precision field_options { $$.set($1, $2); }
| real_type opt_precision field_options { $$.set($1, $2); }
| FLOAT_SYM float_options field_options
| FLOAT_SYM float_options field_options
{
{
$$.set(
MYSQL_TYPE_FLOAT
, $2);
$$.set(
&type_handler_float
, $2);
if ($2.length() && !$2.dec())
if ($2.length() && !$2.dec())
{
{
int err;
int err;
...
@@ -6305,60 +6305,60 @@ field_type_numeric:
...
@@ -6305,60 +6305,60 @@ field_type_numeric:
my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0),
my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0),
Lex->last_field->field_name.str));
Lex->last_field->field_name.str));
if (tmp_length > PRECISION_FOR_FLOAT)
if (tmp_length > PRECISION_FOR_FLOAT)
$$.set(
MYSQL_TYPE_DOUBLE
);
$$.set(
&type_handler_double
);
else
else
$$.set(
MYSQL_TYPE_FLOAT
);
$$.set(
&type_handler_float
);
}
}
}
}
| BIT_SYM opt_field_length_default_1
| BIT_SYM opt_field_length_default_1
{
{
$$.set(
MYSQL_TYPE_BIT
, $2);
$$.set(
&type_handler_bit
, $2);
}
}
| BOOL_SYM
| BOOL_SYM
{
{
$$.set(
MYSQL_TYPE_TINY
, "1");
$$.set(
&type_handler_tiny
, "1");
}
}
| BOOLEAN_SYM
| BOOLEAN_SYM
{
{
$$.set(
MYSQL_TYPE_TINY
, "1");
$$.set(
&type_handler_tiny
, "1");
}
}
| DECIMAL_SYM float_options field_options
| DECIMAL_SYM float_options field_options
{ $$.set(
MYSQL_TYPE_NEWDECIMAL
, $2);}
{ $$.set(
&type_handler_newdecimal
, $2);}
| NUMERIC_SYM float_options field_options
| NUMERIC_SYM float_options field_options
{ $$.set(
MYSQL_TYPE_NEWDECIMAL
, $2);}
{ $$.set(
&type_handler_newdecimal
, $2);}
| FIXED_SYM float_options field_options
| FIXED_SYM float_options field_options
{ $$.set(
MYSQL_TYPE_NEWDECIMAL
, $2);}
{ $$.set(
&type_handler_newdecimal
, $2);}
;
;
field_type_string:
field_type_string:
char opt_field_length_default_1 opt_binary
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
| 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);
bincmp_collation(national_charset_info, $3);
}
}
| BINARY opt_field_length_default_1
| BINARY opt_field_length_default_1
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_STRING
, $2);
$$.set(
&type_handler_string
, $2);
}
}
| varchar field_length opt_binary
| varchar field_length opt_binary
{
{
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
}
}
| nvarchar field_length opt_bin_mod
| nvarchar field_length opt_bin_mod
{
{
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
bincmp_collation(national_charset_info, $3);
bincmp_collation(national_charset_info, $3);
}
}
| VARBINARY field_length
| VARBINARY field_length
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
}
}
;
;
...
@@ -6379,18 +6379,23 @@ field_type_temporal:
...
@@ -6379,18 +6379,23 @@ field_type_temporal:
buff, "YEAR(4)");
buff, "YEAR(4)");
}
}
}
}
$$.set(
MYSQL_TYPE_YEAR
, $2);
$$.set(
&type_handler_year
, $2);
}
}
| DATE_SYM
| DATE_SYM { $$.set(thd->type_handler_for_date()); }
{ $$.set(MYSQL_TYPE_DATE); }
| TIME_SYM opt_field_length
| 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
| TIMESTAMP opt_field_length
{
{
if (thd->variables.sql_mode & MODE_MAXDB)
if (thd->variables.sql_mode & MODE_MAXDB)
$$.set(opt_mysql56_temporal_format ?
$$.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
else
{
{
/*
/*
...
@@ -6399,13 +6404,19 @@ field_type_temporal:
...
@@ -6399,13 +6404,19 @@ field_type_temporal:
*/
*/
if (!opt_explicit_defaults_for_timestamp)
if (!opt_explicit_defaults_for_timestamp)
Lex->last_field->flags|= NOT_NULL_FLAG;
Lex->last_field->flags|= NOT_NULL_FLAG;
$$.set(opt_mysql56_temporal_format ? MYSQL_TYPE_TIMESTAMP2
$$.set(opt_mysql56_temporal_format ?
: MYSQL_TYPE_TIMESTAMP, $2);
static_cast<const Type_handler*>(&type_handler_timestamp2):
static_cast<const Type_handler*>(&type_handler_timestamp),
$2);
}
}
}
}
| DATETIME opt_field_length
| 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:
...
@@ -6413,19 +6424,19 @@ field_type_lob:
TINYBLOB
TINYBLOB
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_TINY_BLOB
);
$$.set(
&type_handler_tiny_blob
);
}
}
| BLOB_SYM opt_field_length
| BLOB_SYM opt_field_length
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_BLOB
, $2);
$$.set(
&type_handler_blob
, $2);
}
}
| spatial_type float_options srid_option
| spatial_type float_options srid_option
{
{
#ifdef HAVE_SPATIAL
#ifdef HAVE_SPATIAL
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
Lex->last_field->geom_type= $1;
Lex->last_field->geom_type= $1;
$$.set(
MYSQL_TYPE_GEOMETRY
, $2);
$$.set(
&type_handler_geometry
, $2);
#else
#else
my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name,
my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name,
sym_group_geom.needed_define));
sym_group_geom.needed_define));
...
@@ -6434,38 +6445,38 @@ field_type_lob:
...
@@ -6434,38 +6445,38 @@ field_type_lob:
| MEDIUMBLOB
| MEDIUMBLOB
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_MEDIUM_BLOB
);
$$.set(
&type_handler_medium_blob
);
}
}
| LONGBLOB
| LONGBLOB
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_LONG_BLOB
);
$$.set(
&type_handler_long_blob
);
}
}
| LONG_SYM VARBINARY
| LONG_SYM VARBINARY
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_MEDIUM_BLOB
);
$$.set(
&type_handler_medium_blob
);
}
}
| LONG_SYM varchar opt_binary
| LONG_SYM varchar opt_binary
{ $$.set(
MYSQL_TYPE_MEDIUM_BLOB
); }
{ $$.set(
&type_handler_medium_blob
); }
| TINYTEXT opt_binary
| TINYTEXT opt_binary
{ $$.set(
MYSQL_TYPE_TINY_BLOB
); }
{ $$.set(
&type_handler_tiny_blob
); }
| TEXT_SYM opt_field_length opt_binary
| TEXT_SYM opt_field_length opt_binary
{ $$.set(
MYSQL_TYPE_BLOB
, $2); }
{ $$.set(
&type_handler_blob
, $2); }
| MEDIUMTEXT opt_binary
| MEDIUMTEXT opt_binary
{ $$.set(
MYSQL_TYPE_MEDIUM_BLOB
); }
{ $$.set(
&type_handler_medium_blob
); }
| LONGTEXT opt_binary
| LONGTEXT opt_binary
{ $$.set(
MYSQL_TYPE_LONG_BLOB
); }
{ $$.set(
&type_handler_long_blob
); }
| LONG_SYM opt_binary
| LONG_SYM opt_binary
{ $$.set(
MYSQL_TYPE_MEDIUM_BLOB
); }
{ $$.set(
&type_handler_medium_blob
); }
;
;
field_type_misc:
field_type_misc:
ENUM '(' string_list ')' opt_binary
ENUM '(' string_list ')' opt_binary
{ $$.set(
MYSQL_TYPE_ENUM
); }
{ $$.set(
&type_handler_enum
); }
| SET '(' string_list ')' opt_binary
| SET '(' string_list ')' opt_binary
{ $$.set(
MYSQL_TYPE_SET
); }
{ $$.set(
&type_handler_set
); }
;
;
spatial_type:
spatial_type:
...
@@ -6502,23 +6513,22 @@ nvarchar:
...
@@ -6502,23 +6513,22 @@ nvarchar:
;
;
int_type:
int_type:
INT_SYM { $$=
MYSQL_TYPE_LONG
; }
INT_SYM { $$=
&type_handler_long
; }
| TINYINT { $$=
MYSQL_TYPE_TINY
; }
| TINYINT { $$=
&type_handler_tiny
; }
| SMALLINT { $$=
MYSQL_TYPE_SHORT
; }
| SMALLINT { $$=
&type_handler_short
; }
| MEDIUMINT { $$=
MYSQL_TYPE_INT
24; }
| MEDIUMINT { $$=
&type_handler_int
24; }
| BIGINT { $$=
MYSQL_TYPE_LONGLONG
; }
| BIGINT { $$=
&type_handler_longlong
; }
;
;
real_type:
real_type:
REAL
REAL
{
{
$$= thd->variables.sql_mode & MODE_REAL_AS_FLOAT ?
$$= 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
| DOUBLE_SYM { $$= &type_handler_double; }
{ $$=MYSQL_TYPE_DOUBLE; }
| DOUBLE_SYM PRECISION { $$= &type_handler_double; }
| DOUBLE_SYM PRECISION
{ $$=MYSQL_TYPE_DOUBLE; }
;
;
srid_option:
srid_option:
...
...
This diff is collapsed.
Click to expand it.
sql/sql_yacc_ora.yy
View file @
533506b4
...
@@ -191,6 +191,7 @@ void ORAerror(THD *thd, const char *s)
...
@@ -191,6 +191,7 @@ void ORAerror(THD *thd, const char *s)
Create_field *create_field;
Create_field *create_field;
Spvar_definition *spvar_definition;
Spvar_definition *spvar_definition;
Row_definition_list *spvar_definition_list;
Row_definition_list *spvar_definition_list;
const Type_handler *type_handler;
CHARSET_INFO *charset;
CHARSET_INFO *charset;
Condition_information_item *cond_info_item;
Condition_information_item *cond_info_item;
DYNCALL_CREATE_DEF *dyncol_def;
DYNCALL_CREATE_DEF *dyncol_def;
...
@@ -245,7 +246,6 @@ void ORAerror(THD *thd, const char *s)
...
@@ -245,7 +246,6 @@ void ORAerror(THD *thd, const char *s)
enum Item_udftype udf_type;
enum Item_udftype udf_type;
enum Key::Keytype key_type;
enum Key::Keytype key_type;
enum Statement_information_item::Name stmt_info_item_name;
enum Statement_information_item::Name stmt_info_item_name;
enum enum_field_types field_type;
enum enum_filetype filetype;
enum enum_filetype filetype;
enum enum_tx_isolation tx_isolation;
enum enum_tx_isolation tx_isolation;
enum enum_var_type var_type;
enum enum_var_type var_type;
...
@@ -1059,7 +1059,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
...
@@ -1059,7 +1059,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <string>
%type <string>
text_string hex_or_bin_String opt_gconcat_separator
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
%type <Lex_field_type> type_with_opt_collate field_type
sp_param_type_with_opt_collate
sp_param_type_with_opt_collate
...
@@ -6178,7 +6178,7 @@ field_type_numeric:
...
@@ -6178,7 +6178,7 @@ field_type_numeric:
| real_type opt_precision field_options { $$.set($1, $2); }
| real_type opt_precision field_options { $$.set($1, $2); }
| FLOAT_SYM float_options field_options
| FLOAT_SYM float_options field_options
{
{
$$.set(
MYSQL_TYPE_FLOAT
, $2);
$$.set(
&type_handler_float
, $2);
if ($2.length() && !$2.dec())
if ($2.length() && !$2.dec())
{
{
int err;
int err;
...
@@ -6187,76 +6187,76 @@ field_type_numeric:
...
@@ -6187,76 +6187,76 @@ field_type_numeric:
my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0),
my_yyabort_error((ER_WRONG_FIELD_SPEC, MYF(0),
Lex->last_field->field_name.str));
Lex->last_field->field_name.str));
if (tmp_length > PRECISION_FOR_FLOAT)
if (tmp_length > PRECISION_FOR_FLOAT)
$$.set(
MYSQL_TYPE_DOUBLE
);
$$.set(
&type_handler_double
);
else
else
$$.set(
MYSQL_TYPE_FLOAT
);
$$.set(
&type_handler_float
);
}
}
}
}
| BIT_SYM opt_field_length_default_1
| BIT_SYM opt_field_length_default_1
{
{
$$.set(
MYSQL_TYPE_BIT
, $2);
$$.set(
&type_handler_bit
, $2);
}
}
| BOOL_SYM
| BOOL_SYM
{
{
$$.set(
MYSQL_TYPE_TINY
, "1");
$$.set(
&type_handler_tiny
, "1");
}
}
| BOOLEAN_SYM
| BOOLEAN_SYM
{
{
$$.set(
MYSQL_TYPE_TINY
, "1");
$$.set(
&type_handler_tiny
, "1");
}
}
| DECIMAL_SYM float_options field_options
| DECIMAL_SYM float_options field_options
{ $$.set(
MYSQL_TYPE_NEWDECIMAL
, $2);}
{ $$.set(
&type_handler_newdecimal
, $2);}
| NUMBER_SYM float_options field_options
| NUMBER_SYM float_options field_options
{
{
if ($2.length() != 0)
if ($2.length() != 0)
$$.set(
MYSQL_TYPE_NEWDECIMAL
, $2);
$$.set(
&type_handler_newdecimal
, $2);
else
else
$$.set(
MYSQL_TYPE_DOUBLE
);
$$.set(
&type_handler_double
);
}
}
| NUMERIC_SYM float_options field_options
| NUMERIC_SYM float_options field_options
{ $$.set(
MYSQL_TYPE_NEWDECIMAL
, $2);}
{ $$.set(
&type_handler_newdecimal
, $2);}
| FIXED_SYM float_options field_options
| FIXED_SYM float_options field_options
{ $$.set(
MYSQL_TYPE_NEWDECIMAL
, $2);}
{ $$.set(
&type_handler_newdecimal
, $2);}
;
;
field_type_string:
field_type_string:
char opt_field_length_default_1 opt_binary
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
| 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);
bincmp_collation(national_charset_info, $3);
}
}
| BINARY opt_field_length_default_1
| BINARY opt_field_length_default_1
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_STRING
, $2);
$$.set(
&type_handler_string
, $2);
}
}
| varchar field_length opt_binary
| varchar field_length opt_binary
{
{
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
}
}
| VARCHAR2 field_length opt_binary
| VARCHAR2 field_length opt_binary
{
{
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
}
}
| nvarchar field_length opt_bin_mod
| nvarchar field_length opt_bin_mod
{
{
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
bincmp_collation(national_charset_info, $3);
bincmp_collation(national_charset_info, $3);
}
}
| VARBINARY field_length
| VARBINARY field_length
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
}
}
| RAW field_length
| RAW field_length
{
{
Lex->charset= &my_charset_bin;
Lex->charset= &my_charset_bin;
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
}
}
;
;
...
@@ -6264,40 +6264,40 @@ field_type_string:
...
@@ -6264,40 +6264,40 @@ field_type_string:
sp_param_field_type_string:
sp_param_field_type_string:
char opt_field_length_default_sp_param_char opt_binary
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
| 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);
bincmp_collation(national_charset_info, $3);
}
}
| BINARY opt_field_length_default_sp_param_char
| BINARY opt_field_length_default_sp_param_char
{
{
Lex->charset=&my_charset_bin;
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
| 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
| 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
| 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);
bincmp_collation(national_charset_info, $3);
}
}
| VARBINARY opt_field_length_default_sp_param_varchar
| VARBINARY opt_field_length_default_sp_param_varchar
{
{
Lex->charset= &my_charset_bin;
Lex->charset= &my_charset_bin;
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
}
}
| RAW opt_field_length_default_sp_param_varchar
| RAW opt_field_length_default_sp_param_varchar
{
{
Lex->charset= &my_charset_bin;
Lex->charset= &my_charset_bin;
$$.set(
MYSQL_TYPE_VARCHAR
, $2);
$$.set(
&type_handler_varchar
, $2);
}
}
;
;
...
@@ -6319,19 +6319,23 @@ field_type_temporal:
...
@@ -6319,19 +6319,23 @@ field_type_temporal:
buff, "YEAR(4)");
buff, "YEAR(4)");
}
}
}
}
$$.set(
MYSQL_TYPE_YEAR
, $2);
$$.set(
&type_handler_year
, $2);
}
}
| DATE_SYM
| DATE_SYM { $$.set(thd->type_handler_for_date()); }
{ $$.set(opt_mysql56_temporal_format ?
MYSQL_TYPE_DATETIME2 : MYSQL_TYPE_DATETIME, 0); }
| TIME_SYM opt_field_length
| 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
| TIMESTAMP opt_field_length
{
{
if (thd->variables.sql_mode & MODE_MAXDB)
if (thd->variables.sql_mode & MODE_MAXDB)
$$.set(opt_mysql56_temporal_format ?
$$.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
else
{
{
/*
/*
...
@@ -6340,13 +6344,19 @@ field_type_temporal:
...
@@ -6340,13 +6344,19 @@ field_type_temporal:
*/
*/
if (!opt_explicit_defaults_for_timestamp)
if (!opt_explicit_defaults_for_timestamp)
Lex->last_field->flags|= NOT_NULL_FLAG;
Lex->last_field->flags|= NOT_NULL_FLAG;
$$.set(opt_mysql56_temporal_format ? MYSQL_TYPE_TIMESTAMP2
$$.set(opt_mysql56_temporal_format ?
: MYSQL_TYPE_TIMESTAMP, $2);
static_cast<const Type_handler*>(&type_handler_timestamp2):
static_cast<const Type_handler*>(&type_handler_timestamp),
$2);
}
}
}
}
| DATETIME opt_field_length
| 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:
...
@@ -6354,19 +6364,19 @@ field_type_lob:
TINYBLOB
TINYBLOB
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_TINY_BLOB
);
$$.set(
&type_handler_tiny_blob
);
}
}
| BLOB_SYM opt_field_length
| BLOB_SYM opt_field_length
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_LONG_BLOB
);
$$.set(
&type_handler_long_blob
);
}
}
| spatial_type float_options srid_option
| spatial_type float_options srid_option
{
{
#ifdef HAVE_SPATIAL
#ifdef HAVE_SPATIAL
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
Lex->last_field->geom_type= $1;
Lex->last_field->geom_type= $1;
$$.set(
MYSQL_TYPE_GEOMETRY
, $2);
$$.set(
&type_handler_geometry
, $2);
#else
#else
my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name,
my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name,
sym_group_geom.needed_define));
sym_group_geom.needed_define));
...
@@ -6375,40 +6385,40 @@ field_type_lob:
...
@@ -6375,40 +6385,40 @@ field_type_lob:
| MEDIUMBLOB
| MEDIUMBLOB
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_MEDIUM_BLOB
);
$$.set(
&type_handler_medium_blob
);
}
}
| LONGBLOB
| LONGBLOB
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_LONG_BLOB
);
$$.set(
&type_handler_long_blob
);
}
}
| LONG_SYM VARBINARY
| LONG_SYM VARBINARY
{
{
Lex->charset=&my_charset_bin;
Lex->charset=&my_charset_bin;
$$.set(
MYSQL_TYPE_MEDIUM_BLOB
);
$$.set(
&type_handler_medium_blob
);
}
}
| LONG_SYM varchar opt_binary
| LONG_SYM varchar opt_binary
{ $$.set(
MYSQL_TYPE_MEDIUM_BLOB
); }
{ $$.set(
&type_handler_medium_blob
); }
| TINYTEXT opt_binary
| TINYTEXT opt_binary
{ $$.set(
MYSQL_TYPE_TINY_BLOB
); }
{ $$.set(
&type_handler_tiny_blob
); }
| TEXT_SYM opt_field_length opt_binary
| TEXT_SYM opt_field_length opt_binary
{ $$.set(
MYSQL_TYPE_BLOB
, $2); }
{ $$.set(
&type_handler_blob
, $2); }
| MEDIUMTEXT opt_binary
| MEDIUMTEXT opt_binary
{ $$.set(
MYSQL_TYPE_MEDIUM_BLOB
); }
{ $$.set(
&type_handler_medium_blob
); }
| LONGTEXT opt_binary
| LONGTEXT opt_binary
{ $$.set(
MYSQL_TYPE_LONG_BLOB
); }
{ $$.set(
&type_handler_long_blob
); }
| CLOB opt_binary
| CLOB opt_binary
{ $$.set(
MYSQL_TYPE_LONG_BLOB
); }
{ $$.set(
&type_handler_long_blob
); }
| LONG_SYM opt_binary
| LONG_SYM opt_binary
{ $$.set(
MYSQL_TYPE_MEDIUM_BLOB
); }
{ $$.set(
&type_handler_medium_blob
); }
;
;
field_type_misc:
field_type_misc:
ENUM '(' string_list ')' opt_binary
ENUM '(' string_list ')' opt_binary
{ $$.set(
MYSQL_TYPE_ENUM
); }
{ $$.set(
&type_handler_enum
); }
| SET '(' string_list ')' opt_binary
| SET '(' string_list ')' opt_binary
{ $$.set(
MYSQL_TYPE_SET
); }
{ $$.set(
&type_handler_set
); }
;
;
spatial_type:
spatial_type:
...
@@ -6445,23 +6455,22 @@ nvarchar:
...
@@ -6445,23 +6455,22 @@ nvarchar:
;
;
int_type:
int_type:
INT_SYM { $$=
MYSQL_TYPE_LONG
; }
INT_SYM { $$=
&type_handler_long
; }
| TINYINT { $$=
MYSQL_TYPE_TINY
; }
| TINYINT { $$=
&type_handler_tiny
; }
| SMALLINT { $$=
MYSQL_TYPE_SHORT
; }
| SMALLINT { $$=
&type_handler_short
; }
| MEDIUMINT { $$=
MYSQL_TYPE_INT
24; }
| MEDIUMINT { $$=
&type_handler_int
24; }
| BIGINT { $$=
MYSQL_TYPE_LONGLONG
; }
| BIGINT { $$=
&type_handler_longlong
; }
;
;
real_type:
real_type:
REAL
REAL
{
{
$$= thd->variables.sql_mode & MODE_REAL_AS_FLOAT ?
$$= 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
| DOUBLE_SYM { $$= &type_handler_double; }
{ $$=MYSQL_TYPE_DOUBLE; }
| DOUBLE_SYM PRECISION { $$= &type_handler_double; }
| DOUBLE_SYM PRECISION
{ $$=MYSQL_TYPE_DOUBLE; }
;
;
srid_option:
srid_option:
...
...
This diff is collapsed.
Click to expand it.
sql/structs.h
View file @
533506b4
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include <mysql_com.h>
/* USERNAME_LENGTH */
#include <mysql_com.h>
/* USERNAME_LENGTH */
struct
TABLE
;
struct
TABLE
;
class
Type_handler
;
class
Field
;
class
Field
;
class
Index_statistics
;
class
Index_statistics
;
...
@@ -581,27 +582,27 @@ struct Lex_length_and_dec_st
...
@@ -581,27 +582,27 @@ struct Lex_length_and_dec_st
struct
Lex_field_type_st
:
public
Lex_length_and_dec_st
struct
Lex_field_type_st
:
public
Lex_length_and_dec_st
{
{
private:
private:
enum_field_types
m_type
;
const
Type_handler
*
m_handler
;
void
set
(
enum_field_types
type
,
const
char
*
length
,
const
char
*
dec
)
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
);
Lex_length_and_dec_st
::
set
(
length
,
dec
);
}
}
public:
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
);
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
;
}
};
};
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment