diff options
author | Alexander Barkov <bar@mariadb.com> | 2022-04-11 18:26:17 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2022-04-11 19:45:31 +0400 |
commit | 833f4486cf7c9858e1f6d2e2deeded6d43fd4e21 (patch) | |
tree | b71d2f6b508f62267d25eb82ec6f1ff8adfa7774 | |
parent | 4d1955d3485971f20c14757d0b83d3ad13543f6a (diff) | |
download | mariadb-git-833f4486cf7c9858e1f6d2e2deeded6d43fd4e21.tar.gz |
MDEV-27690 Crash on `CHARACTER SET csname COLLATE DEFAULT` in column definition
This is a temporary fix for 10.2.
This problem was permanently fixed in 10.9 under terms of MDEV-27743.
This patch should propagate up to 10.8 then null-merged to 10.9.
-rw-r--r-- | mysql-test/r/ctype_collate.result | 17 | ||||
-rw-r--r-- | mysql-test/t/ctype_collate.test | 17 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 20 |
3 files changed, 46 insertions, 8 deletions
diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index 5e8c5adac8f..9a177bee4dd 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -754,3 +754,20 @@ hex(b) 61 drop table t1; +# +# 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 +# diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index 6704395a0a1..ce8559732ee 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -339,3 +339,20 @@ select hex(b) from t1 where b<'zzz' order by b; drop table t1; +--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 # diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 34f37efafdb..528d4ee4bdc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1916,6 +1916,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 @@ -6776,10 +6777,7 @@ charset_or_alias: } ; -collate: COLLATE_SYM collation_name_or_default - { - Lex->charset= Lex->last_field->charset= $2; - } +collate: COLLATE_SYM collation_name_or_default { $$= $2; } ; opt_binary: @@ -6790,11 +6788,17 @@ opt_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: |