Commit 83516a33 authored by Alexander Barkov's avatar Alexander Barkov

An additional patch for MDEV-27690 Crash on `CHARACTER SET csname COLLATE...

An additional patch for MDEV-27690 Crash on `CHARACTER SET csname COLLATE DEFAULT` in column definition

Applying the fix to sql_yacc_ora.yy. Adding a test for sql_mode=ORACLE.
parent 9d734cdd
SET sql_mode=ORACLE;
#
# Start of 10.2 tests
#
#
# MDEV-27690 Crash on `CHARACTER SET csname COLLATE DEFAULT` in column definition
#
CREATE TABLE t1 (a CHAR(10) CHARACTER SET latin1 COLLATE DEFAULT);
DROP TABLE t1;
SELECT CAST('a' AS CHAR(10) CHARACTER SET latin1 COLLATE DEFAULT);
CAST('a' AS CHAR(10) CHARACTER SET latin1 COLLATE DEFAULT)
a
SELECT COLUMN_GET(COLUMN_CREATE(0, 'string'),0 AS CHAR CHARACTER SET latin1 COLLATE DEFAULT) AS c1;
c1
string
#
# End of 10.2 tests
#
#
# Start of 10.3 tests
#
#
# MDEV-12086 sql_mode=ORACLE: allow SELECT UNIQUE as a synonym for SELECT DISTINCT
#
CREATE TABLE t1 (a INT);
......@@ -10,3 +30,6 @@ a
20
30
DROP TABLE t1;
#
# End of 10.3 tests
#
SET sql_mode=ORACLE;
--echo #
--echo # Start of 10.2 tests
--echo #
--echo #
--echo # MDEV-27690 Crash on `CHARACTER SET csname COLLATE DEFAULT` in column definition
--echo #
CREATE TABLE t1 (a CHAR(10) CHARACTER SET latin1 COLLATE DEFAULT);
DROP TABLE t1;
SELECT CAST('a' AS CHAR(10) CHARACTER SET latin1 COLLATE DEFAULT);
SELECT COLUMN_GET(COLUMN_CREATE(0, 'string'),0 AS CHAR CHARACTER SET latin1 COLLATE DEFAULT) AS c1;
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
--echo # Start of 10.3 tests
--echo #
--echo #
--echo # MDEV-12086 sql_mode=ORACLE: allow SELECT UNIQUE as a synonym for SELECT DISTINCT
--echo #
......@@ -8,3 +31,8 @@ CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(20),(30),(30),(30);
SELECT UNIQUE a FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #
......@@ -1438,6 +1438,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%type <charset>
opt_collate
collate
charset_name
charset_or_alias
charset_name_or_default
......@@ -7466,10 +7467,7 @@ charset_or_alias:
}
;
collate: COLLATE_SYM collation_name_or_default
{
Lex->charset= $2;
}
collate: COLLATE_SYM collation_name_or_default { $$= $2; }
;
opt_binary:
......@@ -7484,11 +7482,17 @@ binary:
| BINARY charset_or_alias { bincmp_collation($2, true); }
| charset_or_alias collate
{
if (!my_charset_same(Lex->charset, $1))
my_yyabort_error((ER_COLLATION_CHARSET_MISMATCH, MYF(0),
Lex->charset->name, $1->csname));
if (!$2)
Lex->charset= $1; // CHARACTER SET cs COLLATE DEFAULT
else
{
if (!my_charset_same($2, $1))
my_yyabort_error((ER_COLLATION_CHARSET_MISMATCH, MYF(0),
$2->name, $1->csname));
Lex->charset= $2;
}
}
| collate { }
| collate { Lex->charset= $1; }
;
opt_bin_mod:
......
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