Commit 4de26a8e authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10343 Providing compatibility for basic SQL data types

Based on the patch by Dmitry Tolpeko.
parent decc550f
......@@ -1319,3 +1319,12 @@ t1 CREATE TABLE `t1` (
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
#
# MDEV-10343 Providing compatibility for basic SQL data types
#
CREATE TABLE clob (clob int);
DROP TABLE clob;
CREATE TABLE raw (raw int);
DROP TABLE raw;
CREATE TABLE varchar2 (varchar2 int);
DROP TABLE varchar2;
SET sql_mode=ORACLE;
CREATE TABLE t1 (a BLOB);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" longblob DEFAULT NULL
)
DROP TABLE t1;
SET sql_mode=ORACLE;
CREATE TABLE clob (clob INT);
SHOW CREATE TABLE clob;
Table Create Table
clob CREATE TABLE "clob" (
"clob" int(11) DEFAULT NULL
)
DROP TABLE clob;
CREATE TABLE t1 (a CLOB);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" longtext DEFAULT NULL
)
DROP TABLE t1;
SET sql_mode=ORACLE;
CREATE TABLE t1 (a DATE);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" datetime DEFAULT NULL
)
DROP TABLE t1;
SET sql_mode=ORACLE;
CREATE TABLE t1 (a NUMBER);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" double DEFAULT NULL
)
DROP TABLE t1;
CREATE TABLE t1 (a NUMBER(10,2));
SHOW CREATE TABLE t1;
Table Create Table
......
SET sql_mode=ORACLE;
CREATE TABLE raw (raw INT);
SHOW CREATE TABLE raw;
Table Create Table
raw CREATE TABLE "raw" (
"raw" int(11) DEFAULT NULL
)
DROP TABLE raw;
CREATE TABLE t1 (a RAW(10));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" varbinary(10) DEFAULT NULL
)
DROP TABLE t1;
SET sql_mode=ORACLE;
CREATE TABLE varchar2 (varchar2 INT);
SHOW CREATE TABLE varchar2;
Table Create Table
varchar2 CREATE TABLE "varchar2" (
"varchar2" int(11) DEFAULT NULL
)
DROP TABLE varchar2;
CREATE TABLE t1 (a VARCHAR2(10));
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE "t1" (
"a" varchar(10) DEFAULT NULL
)
DROP TABLE t1;
SET sql_mode=ORACLE;
CREATE TABLE t1 (a BLOB);
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET sql_mode=ORACLE;
# CLOB is not a reserved word even in sql_mode=ORACLE
CREATE TABLE clob (clob INT);
SHOW CREATE TABLE clob;
DROP TABLE clob;
CREATE TABLE t1 (a CLOB);
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET sql_mode=ORACLE;
CREATE TABLE t1 (a DATE);
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET sql_mode=ORACLE;
CREATE TABLE t1 (a NUMBER);
SHOW CREATE TABLE t1;
DROP TABLE t1;
CREATE TABLE t1 (a NUMBER(10,2));
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET sql_mode=ORACLE;
# RAW is not a reserved word even in sql_mode=ORACLE
CREATE TABLE raw (raw INT);
SHOW CREATE TABLE raw;
DROP TABLE raw;
CREATE TABLE t1 (a RAW(10));
SHOW CREATE TABLE t1;
DROP TABLE t1;
SET sql_mode=ORACLE;
# VARCHAR2 is not a reserved word even in sql_mode=ORACLE
CREATE TABLE varchar2 (varchar2 INT);
SHOW CREATE TABLE varchar2;
DROP TABLE varchar2;
CREATE TABLE t1 (a VARCHAR2(10));
SHOW CREATE TABLE t1;
DROP TABLE t1;
......@@ -1337,3 +1337,15 @@ create function fs() returns serial return 1;
create table t1 ( id serial );
show create table t1;
drop table t1;
--echo #
--echo # MDEV-10343 Providing compatibility for basic SQL data types
--echo #
CREATE TABLE clob (clob int);
DROP TABLE clob;
CREATE TABLE raw (raw int);
DROP TABLE raw;
CREATE TABLE varchar2 (varchar2 int);
DROP TABLE varchar2;
......@@ -114,6 +114,7 @@ static SYMBOL symbols[] = {
{ "CIPHER", SYM(CIPHER_SYM)},
{ "CLASS_ORIGIN", SYM(CLASS_ORIGIN_SYM)},
{ "CLIENT", SYM(CLIENT_SYM)},
{ "CLOB", SYM(CLOB)},
{ "CLOSE", SYM(CLOSE_SYM)},
{ "COALESCE", SYM(COALESCE)},
{ "CODE", SYM(CODE_SYM)},
......@@ -472,6 +473,7 @@ static SYMBOL symbols[] = {
{ "QUERY", SYM(QUERY_SYM)},
{ "QUICK", SYM(QUICK)},
{ "RANGE", SYM(RANGE_SYM)},
{ "RAW", SYM(RAW)},
{ "READ", SYM(READ_SYM)},
{ "READ_ONLY", SYM(READ_ONLY_SYM)},
{ "READ_WRITE", SYM(READ_WRITE_SYM)},
......@@ -660,6 +662,7 @@ static SYMBOL symbols[] = {
{ "VARBINARY", SYM(VARBINARY)},
{ "VARCHAR", SYM(VARCHAR)},
{ "VARCHARACTER", SYM(VARCHAR)},
{ "VARCHAR2", SYM(VARCHAR2)},
{ "VARIABLES", SYM(VARIABLES)},
{ "VARYING", SYM(VARYING)},
{ "VIA", SYM(VIA_SYM)},
......
......@@ -1050,6 +1050,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token CLASS_ORIGIN_SYM /* SQL-2003-N */
%token CLIENT_SYM
%token CLOSE_SYM /* SQL-2003-R */
%token CLOB /* SQL-2003-R */
%token COALESCE /* SQL-2003-N */
%token CODE_SYM
%token COLLATE_SYM /* SQL-2003-R */
......@@ -1429,6 +1430,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token QUICK
%token RANGE_SYM /* SQL-2003-R */
%token RANK_SYM
%token RAW /* Oracle */
%token READS_SYM /* SQL-2003-R */
%token READ_ONLY_SYM
%token READ_SYM /* SQL-2003-N */
......@@ -1621,6 +1623,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token VALUE_SYM /* SQL-2003-R */
%token VARBINARY
%token VARCHAR /* SQL-2003-R */
%token VARCHAR2 /* Oracle */
%token VARIABLES
%token VARIANCE_SYM
%token VARYING /* SQL-2003-R */
......@@ -14591,6 +14594,7 @@ keyword_sp:
| CIPHER_SYM {}
| CLIENT_SYM {}
| CLASS_ORIGIN_SYM {}
| CLOB {}
| COALESCE {}
| CODE_SYM {}
| COLLATION_SYM {}
......@@ -14777,6 +14781,7 @@ keyword_sp:
| QUARTER_SYM {}
| QUERY_SYM {}
| QUICK {}
| RAW {}
| READ_ONLY_SYM {}
| REBUILD_SYM {}
| RECOVER_SYM {}
......@@ -14863,6 +14868,7 @@ keyword_sp:
| UNTIL_SYM {}
| USER_SYM {}
| USE_FRM {}
| VARCHAR2 {}
| VARIABLES {}
| VIEW_SYM {}
| VIRTUAL_SYM {}
......
......@@ -426,6 +426,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token CLASS_ORIGIN_SYM /* SQL-2003-N */
%token CLIENT_SYM
%token CLOSE_SYM /* SQL-2003-R */
%token CLOB /* SQL-2003-R */
%token COALESCE /* SQL-2003-N */
%token CODE_SYM
%token COLLATE_SYM /* SQL-2003-R */
......@@ -805,6 +806,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token QUICK
%token RANGE_SYM /* SQL-2003-R */
%token RANK_SYM
%token RAW /* Oracle */
%token READS_SYM /* SQL-2003-R */
%token READ_ONLY_SYM
%token READ_SYM /* SQL-2003-N */
......@@ -997,6 +999,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token VALUE_SYM /* SQL-2003-R */
%token VARBINARY
%token VARCHAR /* SQL-2003-R */
%token VARCHAR2 /* Oracle */
%token VARIABLES
%token VARIANCE_SYM
%token VARYING /* SQL-2003-R */
......@@ -5680,6 +5683,10 @@ field_type:
{
$$.set(MYSQL_TYPE_VARCHAR, $2);
}
| VARCHAR2 field_length opt_binary
{
$$.set(MYSQL_TYPE_VARCHAR, $2);
}
| nvarchar field_length opt_bin_mod
{
$$.set(MYSQL_TYPE_VARCHAR, $2);
......@@ -5690,6 +5697,11 @@ field_type:
Lex->charset=&my_charset_bin;
$$.set(MYSQL_TYPE_VARCHAR, $2);
}
| RAW field_length
{
Lex->charset= &my_charset_bin;
$$.set(MYSQL_TYPE_VARCHAR, $2);
}
| YEAR_SYM opt_field_length field_options
{
if ($2)
......@@ -5709,7 +5721,8 @@ field_type:
$$.set(MYSQL_TYPE_YEAR, $2);
}
| DATE_SYM
{ $$.set(MYSQL_TYPE_DATE); }
{ $$.set(opt_mysql56_temporal_format ?
MYSQL_TYPE_DATETIME2 : MYSQL_TYPE_DATETIME, 0); }
| TIME_SYM opt_field_length
{ $$.set(opt_mysql56_temporal_format ?
MYSQL_TYPE_TIME2 : MYSQL_TYPE_TIME, $2); }
......@@ -5741,7 +5754,7 @@ field_type:
| BLOB_SYM opt_field_length
{
Lex->charset=&my_charset_bin;
$$.set(MYSQL_TYPE_BLOB, $2);
$$.set(MYSQL_TYPE_LONG_BLOB);
}
| spatial_type float_options srid_option
{
......@@ -5779,10 +5792,17 @@ field_type:
{ $$.set(MYSQL_TYPE_MEDIUM_BLOB); }
| LONGTEXT opt_binary
{ $$.set(MYSQL_TYPE_LONG_BLOB); }
| CLOB opt_binary
{ $$.set(MYSQL_TYPE_LONG_BLOB); }
| DECIMAL_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
| NUMBER_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
{
if ($2.length() != 0)
$$.set(MYSQL_TYPE_NEWDECIMAL, $2);
else
$$.set(MYSQL_TYPE_DOUBLE);
}
| NUMERIC_SYM float_options field_options
{ $$.set(MYSQL_TYPE_NEWDECIMAL, $2);}
| FIXED_SYM float_options field_options
......@@ -13969,6 +13989,7 @@ keyword_sp:
| CIPHER_SYM {}
| CLIENT_SYM {}
| CLASS_ORIGIN_SYM {}
| CLOB {}
| COALESCE {}
| CODE_SYM {}
| COLLATION_SYM {}
......@@ -14155,6 +14176,7 @@ keyword_sp:
| QUARTER_SYM {}
| QUERY_SYM {}
| QUICK {}
| RAW {}
| READ_ONLY_SYM {}
| REBUILD_SYM {}
| RECOVER_SYM {}
......@@ -14241,6 +14263,7 @@ keyword_sp:
| UNTIL_SYM {}
| USER_SYM {}
| USE_FRM {}
| VARCHAR2 {}
| VARIABLES {}
| VIEW_SYM {}
| VIRTUAL_SYM {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment