From d396fb92265fefb5d4de10c47ace2a8f7b582a9f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 30 Sep 2024 22:59:47 +0200 Subject: [PATCH] MDEV-35021 Behavior for RTREE indexes changed, assertion fails disallow USING RTREE for not SPATIAL index --- mysql-test/main/create_drop_index.result | 8 ++++++++ mysql-test/main/create_drop_index.test | 10 ++++++++++ sql/sql_table.cc | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/create_drop_index.result b/mysql-test/main/create_drop_index.result index 557b0083ad4..b9931704ef7 100644 --- a/mysql-test/main/create_drop_index.result +++ b/mysql-test/main/create_drop_index.result @@ -42,3 +42,11 @@ t1 CREATE TABLE `t1` ( DROP TABLE t1; CREATE OR REPLACE INDEX IF NOT EXISTS i1 ON t1(b,a); ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS +# +# MDEV-35021 Behavior for RTREE indexes changed, assertion fails +# +create table t (f int not null); +create index ind using rtree on t (f); +ERROR HY000: Incorrect arguments to RTREE INDEX +drop table t; +# End of 11.7 tests diff --git a/mysql-test/main/create_drop_index.test b/mysql-test/main/create_drop_index.test index 4c861266325..bb6c61568bd 100644 --- a/mysql-test/main/create_drop_index.test +++ b/mysql-test/main/create_drop_index.test @@ -14,3 +14,13 @@ DROP TABLE t1; --error ER_WRONG_USAGE CREATE OR REPLACE INDEX IF NOT EXISTS i1 ON t1(b,a); + +--echo # +--echo # MDEV-35021 Behavior for RTREE indexes changed, assertion fails +--echo # +create table t (f int not null); +--error ER_WRONG_ARGUMENTS +create index ind using rtree on t (f); +drop table t; + +--echo # End of 11.7 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4616064cbea..44e9a1f1d4f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3347,7 +3347,7 @@ mysql_prepare_create_table_finalize(THD *thd, HA_CREATE_INFO *create_info, my_error(ER_TABLE_CANT_HANDLE_SPKEYS, MYF(0), file->table_type()); DBUG_RETURN(TRUE); } - if (key_info->user_defined_key_parts != 1) + if (key->type != Key::SPATIAL || key_info->user_defined_key_parts != 1) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "RTREE INDEX"); DBUG_RETURN(TRUE);