diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 676869ae4ea..f3dfab5a848 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -833,8 +833,6 @@ ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used le ALTER TABLE t1 ADD d INT; ALTER TABLE t1 ADD KEY (d(20)); ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys -ALTER TABLE t1 ADD e GEOMETRY NOT NULL, ADD SPATIAL KEY (e(30)); -ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys DROP TABLE t1; CREATE TABLE t1 (s CHAR(8) BINARY); INSERT INTO t1 VALUES ('test'); diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index edd3dbecf88..fbd2c465e0d 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -705,10 +705,6 @@ ALTER TABLE t1 ADD d INT; --error ER_WRONG_SUB_KEY ALTER TABLE t1 ADD KEY (d(20)); -# the 5.1 part of the test ---error ER_WRONG_SUB_KEY -ALTER TABLE t1 ADD e GEOMETRY NOT NULL, ADD SPATIAL KEY (e(30)); - DROP TABLE t1; # diff --git a/mysql-test/main/gis-rtree.result b/mysql-test/main/gis-rtree.result index a219cf19118..2263c484041 100644 --- a/mysql-test/main/gis-rtree.result +++ b/mysql-test/main/gis-rtree.result @@ -1,3 +1,29 @@ +create table t1 (g geometry not null, spatial key(g(10))); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(10)))' at line 1 +create table t1 (g geometry not null, spatial key(g asc)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'asc))' at line 1 +create table t1 (g geometry not null, spatial key(g desc)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc))' at line 1 +create table t1 (g geometry not null, f geometry not null, spatial key(g,f)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'f))' at line 1 +create table t1 (g geometry not null, f geometry not null); +create spatial index bad on t1 (g(10)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(10))' at line 1 +create spatial index bad on t1 (g asc); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'asc)' at line 1 +create spatial index bad on t1 (g desc); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc)' at line 1 +create spatial index bad on t1 (f,g); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'g)' at line 1 +alter table t1 add spatial index bad (g(10)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(10))' at line 1 +alter table t1 add spatial index bad (g asc); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'asc)' at line 1 +alter table t1 add spatial index bad (g desc); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc)' at line 1 +alter table t1 add spatial index bad (f,g); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'g)' at line 1 +drop table t1; CREATE TABLE t1 ( fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, g GEOMETRY NOT NULL, diff --git a/mysql-test/main/gis-rtree.test b/mysql-test/main/gis-rtree.test index c4ff77991e8..2a87814e09a 100644 --- a/mysql-test/main/gis-rtree.test +++ b/mysql-test/main/gis-rtree.test @@ -1,5 +1,38 @@ -- source include/have_geometry.inc +# +# invalid index specifications +# +--error ER_PARSE_ERROR +create table t1 (g geometry not null, spatial key(g(10))); +--error ER_PARSE_ERROR +create table t1 (g geometry not null, spatial key(g asc)); +--error ER_PARSE_ERROR +create table t1 (g geometry not null, spatial key(g desc)); +--error ER_PARSE_ERROR +create table t1 (g geometry not null, f geometry not null, spatial key(g,f)); + +create table t1 (g geometry not null, f geometry not null); +--error ER_PARSE_ERROR +create spatial index bad on t1 (g(10)); +--error ER_PARSE_ERROR +create spatial index bad on t1 (g asc); +--error ER_PARSE_ERROR +create spatial index bad on t1 (g desc); +--error ER_PARSE_ERROR +create spatial index bad on t1 (f,g); + +--error ER_PARSE_ERROR +alter table t1 add spatial index bad (g(10)); +--error ER_PARSE_ERROR +alter table t1 add spatial index bad (g asc); +--error ER_PARSE_ERROR +alter table t1 add spatial index bad (g desc); +--error ER_PARSE_ERROR +alter table t1 add spatial index bad (f,g); + +drop table t1; + # # test of rtree (using with spatial data) # diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result index 05f7386872c..f31f7fb7320 100644 --- a/mysql-test/main/gis.result +++ b/mysql-test/main/gis.result @@ -1098,15 +1098,6 @@ col0 INTEGER NOT NULL, col1 POINT, col2 POINT ); -CREATE SPATIAL INDEX idx0 ON t2 (col1, col2); -ERROR HY000: Incorrect arguments to SPATIAL INDEX -CREATE TABLE t3 ( -col0 INTEGER NOT NULL, -col1 POINT, -col2 LINESTRING, -SPATIAL INDEX i1 (col1, col2) -); -ERROR HY000: Incorrect arguments to SPATIAL INDEX DROP TABLE t0, t1, t2; # # BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index aef729161a9..a3a0b8961fd 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -829,17 +829,6 @@ CREATE TABLE t2 ( col2 POINT ); ---error ER_WRONG_ARGUMENTS -CREATE SPATIAL INDEX idx0 ON t2 (col1, col2); - ---error ER_WRONG_ARGUMENTS -CREATE TABLE t3 ( - col0 INTEGER NOT NULL, - col1 POINT, - col2 LINESTRING, - SPATIAL INDEX i1 (col1, col2) -); - # cleanup DROP TABLE t0, t1, t2; diff --git a/mysql-test/suite/innodb_gis/r/1.result b/mysql-test/suite/innodb_gis/r/1.result index 2719006bea1..b693541b1ad 100644 --- a/mysql-test/suite/innodb_gis/r/1.result +++ b/mysql-test/suite/innodb_gis/r/1.result @@ -1074,8 +1074,6 @@ col0 INTEGER NOT NULL, col1 POINT, col2 POINT ); -CREATE SPATIAL INDEX idx0 ON t2 (col1, col2); -ERROR HY000: Incorrect arguments to SPATIAL INDEX CREATE TABLE t4 ( col0 INTEGER NOT NULL, col1 POINT, diff --git a/mysql-test/suite/innodb_gis/r/alter_spatial_index.result b/mysql-test/suite/innodb_gis/r/alter_spatial_index.result index 344f1ff5a99..aa1aae1ee0f 100644 --- a/mysql-test/suite/innodb_gis/r/alter_spatial_index.result +++ b/mysql-test/suite/innodb_gis/r/alter_spatial_index.result @@ -46,16 +46,16 @@ INSERT INTO tab(c1,c2,c3,c4,c5) VALUES(10,ST_GeomFromText('POINT(160 160)'),ST_GeomFromText('LINESTRING(140 140,150 150,160 160)'), ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'), ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))')); -ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC); +ALTER TABLE tab ADD SPATIAL INDEX idx2(c2); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC); +ALTER TABLE tab ADD SPATIAL KEY idx3(c3); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon'; +ALTER TABLE tab ADD SPATIAL INDEX idx4(c4) COMMENT 'testing spatial index on Polygon'; affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry'; +ALTER TABLE tab ADD SPATIAL KEY idx5(c5) COMMENT 'testing spatial index on Geometry'; affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE; @@ -110,9 +110,9 @@ ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON; ERROR 42000: All parts of a SPATIAL index must be NOT NULL ALTER TABLE tab add SPATIAL INDEX idx1(c1); ERROR HY000: Incorrect arguments to SPATIAL INDEX -ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING BTREE; +ALTER TABLE tab ADD SPATIAL INDEX idx6(c2) USING BTREE; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING BTREE' at line 1 -ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING HASH; +ALTER TABLE tab ADD SPATIAL INDEX idx6(c2) USING HASH; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING HASH' at line 1 SHOW CREATE TABLE tab; Table Create Table @@ -340,7 +340,7 @@ DELETE FROM tab; ALTER TABLE tab ADD PRIMARY KEY(c2); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -CREATE SPATIAL INDEX idx2 ON tab(c2 ASC); +CREATE SPATIAL INDEX idx2 ON tab(c2); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2); @@ -449,16 +449,16 @@ ANALYZE TABLE tab; Table Op Msg_type Msg_text test.tab analyze status Engine-independent statistics collected test.tab analyze status OK -ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC); +ALTER TABLE tab ADD SPATIAL INDEX idx2(c2); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC); +ALTER TABLE tab ADD SPATIAL KEY idx3(c3); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon'; +ALTER TABLE tab ADD SPATIAL INDEX idx4(c4) COMMENT 'testing spatial index on Polygon'; affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry'; +ALTER TABLE tab ADD SPATIAL KEY idx5(c5) COMMENT 'testing spatial index on Geometry'; affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE; @@ -678,10 +678,10 @@ c1 ST_AsText(c2) ST_AsText(c3) ST_Astext(c4) DROP TABLE tab; CREATE TABLE parent (id POINT, PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE child (id GEOMETRY NOT NULL, parent_id POINT NOT NULL) ENGINE=InnoDB; -ALTER TABLE parent ADD SPATIAL INDEX idx1(id ASC); +ALTER TABLE parent ADD SPATIAL INDEX idx1(id); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC); +ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 SHOW CREATE TABLE parent; @@ -710,10 +710,10 @@ ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ON DELETE CAS DROP table child,parent; CREATE TABLE parent (id GEOMETRY, PRIMARY KEY(id(10))) ENGINE=InnoDB; CREATE TABLE child (id GEOMETRY NOT NULL, parent_id GEOMETRY NOT NULL) ENGINE=InnoDB; -ALTER TABLE parent ADD SPATIAL INDEX idx1(id ASC) ; +ALTER TABLE parent ADD SPATIAL INDEX idx1(id) ; affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 -ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC); +ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id); affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 SHOW CREATE TABLE parent; diff --git a/mysql-test/suite/innodb_gis/r/create_spatial_index.result b/mysql-test/suite/innodb_gis/r/create_spatial_index.result index dddd0033689..388e361bf8b 100644 --- a/mysql-test/suite/innodb_gis/r/create_spatial_index.result +++ b/mysql-test/suite/innodb_gis/r/create_spatial_index.result @@ -1,10 +1,10 @@ CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; -CREATE SPATIAL INDEX idx1 on tab(c2 ASC); -CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; -CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=8 ; -CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=4 +CREATE SPATIAL INDEX idx1 on tab(c2); +CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968'; +CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=8 ; +CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=4 COMMENT 'Spatial index on Geometry type column'; SHOW INDEXES FROM tab; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored @@ -449,10 +449,10 @@ DROP PROCEDURE proc_wl6968; CREATE TABLE tab(c1 int ,c2 POINT NOT NULL, c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; -CREATE SPATIAL INDEX idx1 on tab(c2 ASC); -CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; -CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=2 ; -CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=8 +CREATE SPATIAL INDEX idx1 on tab(c2); +CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968'; +CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=2 ; +CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=8 COMMENT 'Spatial index on Geometry type column'; SHOW INDEXES FROM tab; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored @@ -882,10 +882,10 @@ DROP PROCEDURE proc_wl6968; CREATE TABLE tab(c1 int AUTO_INCREMENT PRIMARY KEY,c2 POINT NOT NULL, c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; -CREATE SPATIAL INDEX idx1 on tab(c2 ASC); -CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; -CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=16 ; -CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=16 +CREATE SPATIAL INDEX idx1 on tab(c2); +CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968'; +CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=16 ; +CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=16 COMMENT 'Spatial index on Geometry type column'; SHOW INDEXES FROM tab; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored diff --git a/mysql-test/suite/innodb_gis/r/gis.result b/mysql-test/suite/innodb_gis/r/gis.result index 64aba34867e..9aca6af1dbc 100644 --- a/mysql-test/suite/innodb_gis/r/gis.result +++ b/mysql-test/suite/innodb_gis/r/gis.result @@ -1075,15 +1075,6 @@ col0 INTEGER NOT NULL, col1 POINT, col2 POINT ); -CREATE SPATIAL INDEX idx0 ON t2 (col1, col2); -ERROR HY000: Incorrect arguments to SPATIAL INDEX -CREATE TABLE t3 ( -col0 INTEGER NOT NULL, -col1 POINT, -col2 LINESTRING, -SPATIAL INDEX i1 (col1, col2) -); -ERROR HY000: Incorrect arguments to SPATIAL INDEX DROP TABLE t0, t1, t2; # # BUG#12414917 - ST_ISCLOSED() CRASHES ON 64-BIT BUILDS diff --git a/mysql-test/suite/innodb_gis/r/innodb_gis_rtree.result b/mysql-test/suite/innodb_gis/r/innodb_gis_rtree.result index a219cf19118..2263c484041 100644 --- a/mysql-test/suite/innodb_gis/r/innodb_gis_rtree.result +++ b/mysql-test/suite/innodb_gis/r/innodb_gis_rtree.result @@ -1,3 +1,29 @@ +create table t1 (g geometry not null, spatial key(g(10))); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(10)))' at line 1 +create table t1 (g geometry not null, spatial key(g asc)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'asc))' at line 1 +create table t1 (g geometry not null, spatial key(g desc)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc))' at line 1 +create table t1 (g geometry not null, f geometry not null, spatial key(g,f)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'f))' at line 1 +create table t1 (g geometry not null, f geometry not null); +create spatial index bad on t1 (g(10)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(10))' at line 1 +create spatial index bad on t1 (g asc); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'asc)' at line 1 +create spatial index bad on t1 (g desc); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc)' at line 1 +create spatial index bad on t1 (f,g); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'g)' at line 1 +alter table t1 add spatial index bad (g(10)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(10))' at line 1 +alter table t1 add spatial index bad (g asc); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'asc)' at line 1 +alter table t1 add spatial index bad (g desc); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc)' at line 1 +alter table t1 add spatial index bad (f,g); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'g)' at line 1 +drop table t1; CREATE TABLE t1 ( fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, g GEOMETRY NOT NULL, diff --git a/mysql-test/suite/innodb_gis/r/point_basic.result b/mysql-test/suite/innodb_gis/r/point_basic.result index 4744a87bfbb..f71e5b4b91c 100644 --- a/mysql-test/suite/innodb_gis/r/point_basic.result +++ b/mysql-test/suite/innodb_gis/r/point_basic.result @@ -1543,8 +1543,8 @@ DROP TABLE t1; # CREATE TABLE parent(p POINT, PRIMARY KEY(p)) ENGINE=InnoDB; CREATE TABLE child(p POINT NOT NULL) ENGINE=InnoDB; -ALTER TABLE parent ADD SPATIAL INDEX idx1(p ASC); -ALTER TABLE child ADD SPATIAL INDEX idx2(p ASC); +ALTER TABLE parent ADD SPATIAL INDEX idx1(p); +ALTER TABLE child ADD SPATIAL INDEX idx2(p); SHOW CREATE TABLE parent; Table Create Table parent CREATE TABLE `parent` ( diff --git a/mysql-test/suite/innodb_gis/r/repeatable_spatial.result b/mysql-test/suite/innodb_gis/r/repeatable_spatial.result index 561b1f77ae7..ef907af8247 100644 --- a/mysql-test/suite/innodb_gis/r/repeatable_spatial.result +++ b/mysql-test/suite/innodb_gis/r/repeatable_spatial.result @@ -1,10 +1,10 @@ CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB; -ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC); -ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC); -ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon'; -ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry'; +ALTER TABLE tab ADD SPATIAL INDEX idx2(c2); +ALTER TABLE tab ADD SPATIAL KEY idx3(c3); +ALTER TABLE tab ADD SPATIAL INDEX idx4(c4) COMMENT 'testing spatial index on Polygon'; +ALTER TABLE tab ADD SPATIAL KEY idx5(c5) COMMENT 'testing spatial index on Geometry'; INSERT INTO tab(c1,c2,c3,c4,c5) VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'), ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'), @@ -88,10 +88,10 @@ DROP TABLE tab; CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB; -ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC); -ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC); -ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon'; -ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry'; +ALTER TABLE tab ADD SPATIAL INDEX idx2(c2); +ALTER TABLE tab ADD SPATIAL KEY idx3(c3); +ALTER TABLE tab ADD SPATIAL INDEX idx4(c4) COMMENT 'testing spatial index on Polygon'; +ALTER TABLE tab ADD SPATIAL KEY idx5(c5) COMMENT 'testing spatial index on Geometry'; INSERT INTO tab(c1,c2,c3,c4,c5) VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'), ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'), diff --git a/mysql-test/suite/innodb_gis/t/1.test b/mysql-test/suite/innodb_gis/t/1.test index c3a270c9ec2..2755243574a 100644 --- a/mysql-test/suite/innodb_gis/t/1.test +++ b/mysql-test/suite/innodb_gis/t/1.test @@ -838,11 +838,6 @@ CREATE TABLE t3 ( col2 POINT ); -# --error ER_TOO_MANY_KEY_PARTS ---error ER_WRONG_ARGUMENTS -CREATE SPATIAL INDEX idx0 ON t2 (col1, col2); - - CREATE TABLE t4 ( col0 INTEGER NOT NULL, col1 POINT, diff --git a/mysql-test/suite/innodb_gis/t/alter_spatial_index.test b/mysql-test/suite/innodb_gis/t/alter_spatial_index.test index 50364b97a8a..de76e5ead04 100644 --- a/mysql-test/suite/innodb_gis/t/alter_spatial_index.test +++ b/mysql-test/suite/innodb_gis/t/alter_spatial_index.test @@ -1,5 +1,5 @@ # ****************************************************************** -# Test Alter table add spatial idex asc/desc comments +# Test Alter table add spatial index comments # Test error Alter table modify column with No not null option # Test error Alter table modify column with null option # Test table column having both indexes spatial and Btree @@ -87,13 +87,13 @@ ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 --enable_info -ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC); +ALTER TABLE tab ADD SPATIAL INDEX idx2(c2); -ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC); +ALTER TABLE tab ADD SPATIAL KEY idx3(c3); -ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon'; +ALTER TABLE tab ADD SPATIAL INDEX idx4(c4) COMMENT 'testing spatial index on Polygon'; -ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry'; +ALTER TABLE tab ADD SPATIAL KEY idx5(c5) COMMENT 'testing spatial index on Geometry'; ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE; --disable_info @@ -166,10 +166,10 @@ ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON; ALTER TABLE tab add SPATIAL INDEX idx1(c1); --error ER_PARSE_ERROR -ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING BTREE; +ALTER TABLE tab ADD SPATIAL INDEX idx6(c2) USING BTREE; --error ER_PARSE_ERROR -ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING HASH; +ALTER TABLE tab ADD SPATIAL INDEX idx6(c2) USING HASH; # --error ER_INVALID_USE_OF_NULL # ALTER TABLE tab CHANGE c2 c2 MULTIPOINT NOT NULL FIRST, ALGORITHM=COPY; @@ -366,7 +366,7 @@ DELETE FROM tab; --enable_info ALTER TABLE tab ADD PRIMARY KEY(c2); -CREATE SPATIAL INDEX idx2 ON tab(c2 ASC); +CREATE SPATIAL INDEX idx2 ON tab(c2); ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2); --disable_info @@ -471,13 +471,13 @@ ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 ANALYZE TABLE tab; --enable_info -ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC); +ALTER TABLE tab ADD SPATIAL INDEX idx2(c2); -ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC); +ALTER TABLE tab ADD SPATIAL KEY idx3(c3); -ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon'; +ALTER TABLE tab ADD SPATIAL INDEX idx4(c4) COMMENT 'testing spatial index on Polygon'; -ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry'; +ALTER TABLE tab ADD SPATIAL KEY idx5(c5) COMMENT 'testing spatial index on Geometry'; ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE; @@ -656,9 +656,9 @@ CREATE TABLE parent (id POINT, PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE child (id GEOMETRY NOT NULL, parent_id POINT NOT NULL) ENGINE=InnoDB; --enable_info -ALTER TABLE parent ADD SPATIAL INDEX idx1(id ASC); +ALTER TABLE parent ADD SPATIAL INDEX idx1(id); -ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC); +ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id); --disable_info SHOW CREATE TABLE parent; @@ -689,9 +689,9 @@ CREATE TABLE parent (id GEOMETRY, PRIMARY KEY(id(10))) ENGINE=InnoDB; CREATE TABLE child (id GEOMETRY NOT NULL, parent_id GEOMETRY NOT NULL) ENGINE=InnoDB; --enable_info -ALTER TABLE parent ADD SPATIAL INDEX idx1(id ASC) ; +ALTER TABLE parent ADD SPATIAL INDEX idx1(id) ; -ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC); +ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id); --disable_info SHOW CREATE TABLE parent; diff --git a/mysql-test/suite/innodb_gis/t/create_spatial_index.test b/mysql-test/suite/innodb_gis/t/create_spatial_index.test index 178041d0414..f1454020cec 100644 --- a/mysql-test/suite/innodb_gis/t/create_spatial_index.test +++ b/mysql-test/suite/innodb_gis/t/create_spatial_index.test @@ -26,10 +26,10 @@ c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; # Check spatial index functionality with Create Index clause options -CREATE SPATIAL INDEX idx1 on tab(c2 ASC); -CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; -CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=8 ; -CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=4 +CREATE SPATIAL INDEX idx1 on tab(c2); +CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968'; +CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=8 ; +CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=4 COMMENT 'Spatial index on Geometry type column'; # Check index type @@ -411,10 +411,10 @@ c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; # Check spatial index functionality with Create Index clause options -CREATE SPATIAL INDEX idx1 on tab(c2 ASC); -CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; -CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=2 ; -CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=8 +CREATE SPATIAL INDEX idx1 on tab(c2); +CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968'; +CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=2 ; +CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=8 COMMENT 'Spatial index on Geometry type column'; # Check index type @@ -783,10 +783,10 @@ c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; # Check spatial index functionality with Create Index clause options -CREATE SPATIAL INDEX idx1 on tab(c2 ASC); -CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; -CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=16 ; -CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=16 +CREATE SPATIAL INDEX idx1 on tab(c2); +CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968'; +CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=16 ; +CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=16 COMMENT 'Spatial index on Geometry type column'; # Check index type diff --git a/mysql-test/suite/innodb_gis/t/gis.test b/mysql-test/suite/innodb_gis/t/gis.test index 731dfe86c65..d3f915cb434 100644 --- a/mysql-test/suite/innodb_gis/t/gis.test +++ b/mysql-test/suite/innodb_gis/t/gis.test @@ -838,19 +838,6 @@ CREATE TABLE t2 ( col2 POINT ); -# --error ER_TOO_MANY_KEY_PARTS ---error ER_WRONG_ARGUMENTS -CREATE SPATIAL INDEX idx0 ON t2 (col1, col2); - -# --error ER_TOO_MANY_KEY_PARTS ---error ER_WRONG_ARGUMENTS -CREATE TABLE t3 ( - col0 INTEGER NOT NULL, - col1 POINT, - col2 LINESTRING, - SPATIAL INDEX i1 (col1, col2) -); - # cleanup DROP TABLE t0, t1, t2; diff --git a/mysql-test/suite/innodb_gis/t/point_basic.test b/mysql-test/suite/innodb_gis/t/point_basic.test index f6bc6d234a7..55a341742ef 100644 --- a/mysql-test/suite/innodb_gis/t/point_basic.test +++ b/mysql-test/suite/innodb_gis/t/point_basic.test @@ -822,8 +822,8 @@ DROP TABLE t1; --echo # CREATE TABLE parent(p POINT, PRIMARY KEY(p)) ENGINE=InnoDB; CREATE TABLE child(p POINT NOT NULL) ENGINE=InnoDB; -ALTER TABLE parent ADD SPATIAL INDEX idx1(p ASC); -ALTER TABLE child ADD SPATIAL INDEX idx2(p ASC); +ALTER TABLE parent ADD SPATIAL INDEX idx1(p); +ALTER TABLE child ADD SPATIAL INDEX idx2(p); SHOW CREATE TABLE parent; SHOW CREATE TABLE child; diff --git a/mysql-test/suite/innodb_gis/t/repeatable_spatial.test b/mysql-test/suite/innodb_gis/t/repeatable_spatial.test index 16372dc14dc..a178688fa33 100644 --- a/mysql-test/suite/innodb_gis/t/repeatable_spatial.test +++ b/mysql-test/suite/innodb_gis/t/repeatable_spatial.test @@ -15,13 +15,13 @@ CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB; -ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC); +ALTER TABLE tab ADD SPATIAL INDEX idx2(c2); -ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC); +ALTER TABLE tab ADD SPATIAL KEY idx3(c3); -ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon'; +ALTER TABLE tab ADD SPATIAL INDEX idx4(c4) COMMENT 'testing spatial index on Polygon'; -ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry'; +ALTER TABLE tab ADD SPATIAL KEY idx5(c5) COMMENT 'testing spatial index on Geometry'; INSERT INTO tab(c1,c2,c3,c4,c5) VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'), @@ -130,13 +130,13 @@ CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ENGINE=InnoDB; -ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC); +ALTER TABLE tab ADD SPATIAL INDEX idx2(c2); -ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC); +ALTER TABLE tab ADD SPATIAL KEY idx3(c3); -ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon'; +ALTER TABLE tab ADD SPATIAL INDEX idx4(c4) COMMENT 'testing spatial index on Polygon'; -ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry'; +ALTER TABLE tab ADD SPATIAL KEY idx5(c5) COMMENT 'testing spatial index on Geometry'; INSERT INTO tab(c1,c2,c3,c4,c5) VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'), diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c1c624b16fc..1e1b9041f83 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1672,7 +1672,7 @@ rule: using_list opt_use_partition use_partition %type - key_part + key_part key_part_simple %type join_table_list join_table @@ -2653,9 +2653,10 @@ create: if (Lex->add_create_index($2, &$6, HA_KEY_ALG_UNDEF, $1 | $5)) MYSQL_YYABORT; } - '(' key_list ')' opt_lock_wait_timeout spatial_key_options + '(' key_part_simple ')' opt_lock_wait_timeout spatial_key_options opt_index_lock_algorithm { + Lex->last_key->columns.push_back($11, thd->mem_root); Lex->pop_select(); //main select } | create_or_replace DATABASE opt_if_not_exists ident @@ -6015,7 +6016,10 @@ key_def: if (unlikely(Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3))) MYSQL_YYABORT; } - '(' key_list ')' spatial_key_options { } + '(' key_part_simple ')' spatial_key_options + { + Lex->last_key->columns.push_back($7, thd->mem_root); + } | opt_constraint constraint_key_type opt_if_not_exists opt_ident opt_USING_key_algorithm @@ -7226,12 +7230,7 @@ opt_without_overlaps: ; key_part: - ident - { - $$= new (thd->mem_root) Key_part_spec(&$1, 0); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } + key_part_simple | ident '(' NUM ')' { int key_part_len= atoi($3.str); @@ -7243,6 +7242,15 @@ key_part: } ; +key_part_simple: + ident + { + $$= new (thd->mem_root) Key_part_spec(&$1, 0); + if (unlikely($$ == NULL)) + MYSQL_YYABORT; + } + ; + opt_ident: /* empty */ { $$= null_clex_str; } | field_ident { $$= $1; }