mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
MDEV-29562 Spider table charset error should happen correctly.
When trying to create a spider table with banned charsets including utf32, utf16, ucs2 and utf16le[1], spider should emit an error immediately, rather than wait until a separate statement that establishes a connection (e.g. SELECT). This also applies to ALTER TABLE statement that changes charsets. [1] https://mariadb.com/kb/en/server-system-variables/#character_set_client Signed-off-by: Yuchen Pei <yuchen.pei@mariadb.com> Reviewed-by: Nayuta Yanagisawa <nayuta.yanagisawa@mariadb.com>
This commit is contained in:
parent
76c2402812
commit
5eb545e5c2
4 changed files with 116 additions and 0 deletions
|
@ -11464,6 +11464,17 @@ int ha_spider::create(
|
|||
sql_command == SQLCOM_DROP_INDEX
|
||||
)
|
||||
DBUG_RETURN(0);
|
||||
if (!is_supported_parser_charset(info->default_table_charset))
|
||||
{
|
||||
String charset_option;
|
||||
charset_option.append(STRING_WITH_LEN("CHARSET "));
|
||||
charset_option.append(
|
||||
STRING_WITH_LEN(info->default_table_charset->cs_name.str));
|
||||
my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), "SPIDER",
|
||||
charset_option.c_ptr());
|
||||
error_num= ER_ILLEGAL_HA_CREATE_OPTION;
|
||||
goto error_charset;
|
||||
}
|
||||
if (!(trx = spider_get_trx(thd, TRUE, &error_num)))
|
||||
goto error_get_trx;
|
||||
if (
|
||||
|
@ -11638,6 +11649,7 @@ error:
|
|||
spider_free_share_alloc(&tmp_share);
|
||||
error_alter_before_unlock:
|
||||
error_get_trx:
|
||||
error_charset:
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
47
storage/spider/mysql-test/spider/bugfix/r/mdev_29562.result
Normal file
47
storage/spider/mysql-test/spider/bugfix/r/mdev_29562.result
Normal file
|
@ -0,0 +1,47 @@
|
|||
#
|
||||
# MDEV-29562 Spider table with charset utf32/utf16/ucs2 tries to set client charset to unsupported value
|
||||
#
|
||||
for master_1
|
||||
for child2
|
||||
child2_1
|
||||
child2_2
|
||||
child2_3
|
||||
for child3
|
||||
connection child2_1;
|
||||
CREATE DATABASE auto_test_remote;
|
||||
USE auto_test_remote;
|
||||
CREATE TABLE tbl_a (
|
||||
a INT
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
connection master_1;
|
||||
CREATE DATABASE auto_test_local;
|
||||
USE auto_test_local;
|
||||
CREATE TABLE tbl_a (
|
||||
a INT
|
||||
) ENGINE=Spider CHARSET utf32 COMMENT='table "tbl_a", srv "s_2_1"';
|
||||
ERROR HY000: Table storage engine 'SPIDER' does not support the create option 'CHARSET utf32'
|
||||
ALTER DATABASE auto_test_local CHARSET="ucs2";
|
||||
CREATE TABLE tbl_a (
|
||||
a INT
|
||||
) ENGINE=Spider COMMENT='table "tbl_a", srv "s_2_1"';
|
||||
ERROR HY000: Table storage engine 'SPIDER' does not support the create option 'CHARSET ucs2'
|
||||
CREATE TABLE tbl_a (
|
||||
a INT
|
||||
) ENGINE=Spider CHARSET utf8 COMMENT='table "tbl_a", srv "s_2_1"';
|
||||
SELECT * FROM tbl_a;
|
||||
a
|
||||
ALTER TABLE tbl_a CONVERT TO CHARACTER SET utf16;
|
||||
ERROR HY000: Table storage engine 'SPIDER' does not support the create option 'CHARSET utf16'
|
||||
ALTER TABLE tbl_a CONVERT TO CHARACTER SET utf16le;
|
||||
ERROR HY000: Table storage engine 'SPIDER' does not support the create option 'CHARSET utf16le'
|
||||
ALTER TABLE tbl_a CONVERT TO CHARACTER SET latin1;
|
||||
connection master_1;
|
||||
DROP DATABASE IF EXISTS auto_test_local;
|
||||
connection child2_1;
|
||||
DROP DATABASE IF EXISTS auto_test_remote;
|
||||
for master_1
|
||||
for child2
|
||||
child2_1
|
||||
child2_2
|
||||
child2_3
|
||||
for child3
|
3
storage/spider/mysql-test/spider/bugfix/t/mdev_29562.cnf
Normal file
3
storage/spider/mysql-test/spider/bugfix/t/mdev_29562.cnf
Normal file
|
@ -0,0 +1,3 @@
|
|||
!include include/default_mysqld.cnf
|
||||
!include ../my_1_1.cnf
|
||||
!include ../my_2_1.cnf
|
54
storage/spider/mysql-test/spider/bugfix/t/mdev_29562.test
Normal file
54
storage/spider/mysql-test/spider/bugfix/t/mdev_29562.test
Normal file
|
@ -0,0 +1,54 @@
|
|||
--echo #
|
||||
--echo # MDEV-29562 Spider table with charset utf32/utf16/ucs2 tries to set client charset to unsupported value
|
||||
--echo #
|
||||
|
||||
--disable_query_log
|
||||
--disable_result_log
|
||||
--source ../../t/test_init.inc
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
--connection child2_1
|
||||
CREATE DATABASE auto_test_remote;
|
||||
USE auto_test_remote;
|
||||
eval CREATE TABLE tbl_a (
|
||||
a INT
|
||||
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET;
|
||||
|
||||
--connection master_1
|
||||
CREATE DATABASE auto_test_local;
|
||||
USE auto_test_local;
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
eval CREATE TABLE tbl_a (
|
||||
a INT
|
||||
) $MASTER_1_ENGINE CHARSET utf32 COMMENT='table "tbl_a", srv "s_2_1"';
|
||||
|
||||
ALTER DATABASE auto_test_local CHARSET="ucs2";
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
eval CREATE TABLE tbl_a (
|
||||
a INT
|
||||
) $MASTER_1_ENGINE COMMENT='table "tbl_a", srv "s_2_1"';
|
||||
|
||||
eval CREATE TABLE tbl_a (
|
||||
a INT
|
||||
) $MASTER_1_ENGINE CHARSET utf8 COMMENT='table "tbl_a", srv "s_2_1"';
|
||||
SELECT * FROM tbl_a;
|
||||
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
ALTER TABLE tbl_a CONVERT TO CHARACTER SET utf16;
|
||||
--error ER_ILLEGAL_HA_CREATE_OPTION
|
||||
ALTER TABLE tbl_a CONVERT TO CHARACTER SET utf16le;
|
||||
|
||||
ALTER TABLE tbl_a CONVERT TO CHARACTER SET latin1;
|
||||
|
||||
--connection master_1
|
||||
DROP DATABASE IF EXISTS auto_test_local;
|
||||
|
||||
--connection child2_1
|
||||
DROP DATABASE IF EXISTS auto_test_remote;
|
||||
|
||||
--disable_query_log
|
||||
--disable_result_log
|
||||
--source ../t/test_deinit.inc
|
||||
--enable_query_log
|
||||
--enable_result_log
|
Loading…
Reference in a new issue