Commit 02eb1b1a authored by Sergei Golubchik's avatar Sergei Golubchik

reject invalid spatial key declarations in the parser

parent 956a8a53
...@@ -833,8 +833,6 @@ ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used le ...@@ -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 d INT;
ALTER TABLE t1 ADD KEY (d(20)); 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 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; DROP TABLE t1;
CREATE TABLE t1 (s CHAR(8) BINARY); CREATE TABLE t1 (s CHAR(8) BINARY);
INSERT INTO t1 VALUES ('test'); INSERT INTO t1 VALUES ('test');
......
...@@ -705,10 +705,6 @@ ALTER TABLE t1 ADD d INT; ...@@ -705,10 +705,6 @@ ALTER TABLE t1 ADD d INT;
--error ER_WRONG_SUB_KEY --error ER_WRONG_SUB_KEY
ALTER TABLE t1 ADD KEY (d(20)); 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; DROP TABLE t1;
# #
......
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 ( CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
g GEOMETRY NOT NULL, g GEOMETRY NOT NULL,
......
-- source include/have_geometry.inc -- 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) # test of rtree (using with spatial data)
# #
......
...@@ -1098,15 +1098,6 @@ col0 INTEGER NOT NULL, ...@@ -1098,15 +1098,6 @@ col0 INTEGER NOT NULL,
col1 POINT, col1 POINT,
col2 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; DROP TABLE t0, t1, t2;
# #
# BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS # BUG#12414917 - ISCLOSED() CRASHES ON 64-BIT BUILDS
......
...@@ -826,17 +826,6 @@ CREATE TABLE t2 ( ...@@ -826,17 +826,6 @@ CREATE TABLE t2 (
col2 POINT 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 # cleanup
DROP TABLE t0, t1, t2; DROP TABLE t0, t1, t2;
......
...@@ -1074,8 +1074,6 @@ col0 INTEGER NOT NULL, ...@@ -1074,8 +1074,6 @@ col0 INTEGER NOT NULL,
col1 POINT, col1 POINT,
col2 POINT col2 POINT
); );
CREATE SPATIAL INDEX idx0 ON t2 (col1, col2);
ERROR HY000: Incorrect arguments to SPATIAL INDEX
CREATE TABLE t4 ( CREATE TABLE t4 (
col0 INTEGER NOT NULL, col0 INTEGER NOT NULL,
col1 POINT, col1 POINT,
......
...@@ -46,16 +46,16 @@ INSERT INTO tab(c1,c2,c3,c4,c5) ...@@ -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)'), 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))'),
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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE; ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
...@@ -110,9 +110,9 @@ ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON; ...@@ -110,9 +110,9 @@ ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON;
ERROR 42000: All parts of a SPATIAL index must be NOT NULL ERROR 42000: All parts of a SPATIAL index must be NOT NULL
ALTER TABLE tab add SPATIAL INDEX idx1(c1); ALTER TABLE tab add SPATIAL INDEX idx1(c1);
ERROR HY000: Incorrect arguments to SPATIAL INDEX 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 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 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; SHOW CREATE TABLE tab;
Table Create Table Table Create Table
...@@ -340,7 +340,7 @@ DELETE FROM tab; ...@@ -340,7 +340,7 @@ DELETE FROM tab;
ALTER TABLE tab ADD PRIMARY KEY(c2); ALTER TABLE tab ADD PRIMARY KEY(c2);
affected rows: 0 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2); ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2);
...@@ -449,16 +449,16 @@ ANALYZE TABLE tab; ...@@ -449,16 +449,16 @@ ANALYZE TABLE tab;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.tab analyze status Engine-independent statistics collected test.tab analyze status Engine-independent statistics collected
test.tab analyze status OK 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE; ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
...@@ -678,10 +678,10 @@ c1 ST_AsText(c2) ST_AsText(c3) ST_Astext(c4) ...@@ -678,10 +678,10 @@ c1 ST_AsText(c2) ST_AsText(c3) ST_Astext(c4)
DROP TABLE tab; DROP TABLE tab;
CREATE TABLE parent (id POINT, PRIMARY KEY(id)) ENGINE=InnoDB; CREATE TABLE parent (id POINT, PRIMARY KEY(id)) ENGINE=InnoDB;
CREATE TABLE child (id GEOMETRY NOT NULL, parent_id POINT NOT NULL) 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
SHOW CREATE TABLE parent; SHOW CREATE TABLE parent;
...@@ -710,10 +710,10 @@ ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ON DELETE CAS ...@@ -710,10 +710,10 @@ ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ON DELETE CAS
DROP table child,parent; DROP table child,parent;
CREATE TABLE parent (id GEOMETRY, PRIMARY KEY(id(10))) ENGINE=InnoDB; 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; 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 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 affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0 info: Records: 0 Duplicates: 0 Warnings: 0
SHOW CREATE TABLE parent; SHOW CREATE TABLE parent;
......
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, 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) c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8; ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
CREATE SPATIAL INDEX idx1 on tab(c2 ASC); CREATE SPATIAL INDEX idx1 on tab(c2);
CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968';
CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=8 ; CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=8 ;
CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=4 CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=4
COMMENT 'Spatial index on Geometry type column'; COMMENT 'Spatial index on Geometry type column';
SHOW INDEXES FROM tab; 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 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; ...@@ -449,10 +449,10 @@ DROP PROCEDURE proc_wl6968;
CREATE TABLE tab(c1 int ,c2 POINT NOT NULL, CREATE TABLE tab(c1 int ,c2 POINT NOT NULL,
c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
CREATE SPATIAL INDEX idx1 on tab(c2 ASC); CREATE SPATIAL INDEX idx1 on tab(c2);
CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968';
CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=2 ; CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=2 ;
CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=8 CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=8
COMMENT 'Spatial index on Geometry type column'; COMMENT 'Spatial index on Geometry type column';
SHOW INDEXES FROM tab; 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 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; ...@@ -882,10 +882,10 @@ DROP PROCEDURE proc_wl6968;
CREATE TABLE tab(c1 int AUTO_INCREMENT PRIMARY KEY,c2 POINT NOT NULL, 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) c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16; ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
CREATE SPATIAL INDEX idx1 on tab(c2 ASC); CREATE SPATIAL INDEX idx1 on tab(c2);
CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968';
CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=16 ; CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=16 ;
CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=16 CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=16
COMMENT 'Spatial index on Geometry type column'; COMMENT 'Spatial index on Geometry type column';
SHOW INDEXES FROM tab; 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 Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored
......
...@@ -1075,15 +1075,6 @@ col0 INTEGER NOT NULL, ...@@ -1075,15 +1075,6 @@ col0 INTEGER NOT NULL,
col1 POINT, col1 POINT,
col2 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; DROP TABLE t0, t1, t2;
# #
# BUG#12414917 - ST_ISCLOSED() CRASHES ON 64-BIT BUILDS # BUG#12414917 - ST_ISCLOSED() CRASHES ON 64-BIT BUILDS
......
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 ( CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
g GEOMETRY NOT NULL, g GEOMETRY NOT NULL,
......
...@@ -1543,8 +1543,8 @@ DROP TABLE t1; ...@@ -1543,8 +1543,8 @@ DROP TABLE t1;
# #
CREATE TABLE parent(p POINT, PRIMARY KEY(p)) ENGINE=InnoDB; CREATE TABLE parent(p POINT, PRIMARY KEY(p)) ENGINE=InnoDB;
CREATE TABLE child(p POINT NOT NULL) ENGINE=InnoDB; CREATE TABLE child(p POINT NOT NULL) ENGINE=InnoDB;
ALTER TABLE parent ADD SPATIAL INDEX idx1(p ASC); ALTER TABLE parent ADD SPATIAL INDEX idx1(p);
ALTER TABLE child ADD SPATIAL INDEX idx2(p ASC); ALTER TABLE child ADD SPATIAL INDEX idx2(p);
SHOW CREATE TABLE parent; SHOW CREATE TABLE parent;
Table Create Table Table Create Table
parent CREATE TABLE `parent` ( parent CREATE TABLE `parent` (
......
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, 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) c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB; 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) INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'), 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))'), ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'),
...@@ -88,10 +88,10 @@ DROP TABLE tab; ...@@ -88,10 +88,10 @@ DROP TABLE tab;
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, 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) c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB; 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) INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'), 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))'), ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'),
......
...@@ -830,11 +830,6 @@ CREATE TABLE t3 ( ...@@ -830,11 +830,6 @@ CREATE TABLE t3 (
col2 POINT col2 POINT
); );
# --error ER_TOO_MANY_KEY_PARTS
--error ER_WRONG_ARGUMENTS
CREATE SPATIAL INDEX idx0 ON t2 (col1, col2);
CREATE TABLE t4 ( CREATE TABLE t4 (
col0 INTEGER NOT NULL, col0 INTEGER NOT NULL,
col1 POINT, col1 POINT,
......
# ****************************************************************** # ******************************************************************
# 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 No not null option
# Test error Alter table modify column with null option # Test error Alter table modify column with null option
# Test table column having both indexes spatial and Btree # 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 ...@@ -87,13 +87,13 @@ ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010
--enable_info --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; ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
--disable_info --disable_info
...@@ -166,10 +166,10 @@ ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON; ...@@ -166,10 +166,10 @@ ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON;
ALTER TABLE tab add SPATIAL INDEX idx1(c1); ALTER TABLE tab add SPATIAL INDEX idx1(c1);
--error ER_PARSE_ERROR --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 --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 # --error ER_INVALID_USE_OF_NULL
# ALTER TABLE tab CHANGE c2 c2 MULTIPOINT NOT NULL FIRST, ALGORITHM=COPY; # ALTER TABLE tab CHANGE c2 c2 MULTIPOINT NOT NULL FIRST, ALGORITHM=COPY;
...@@ -366,7 +366,7 @@ DELETE FROM tab; ...@@ -366,7 +366,7 @@ DELETE FROM tab;
--enable_info --enable_info
ALTER TABLE tab ADD PRIMARY KEY(c2); 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); ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2);
--disable_info --disable_info
...@@ -471,13 +471,13 @@ ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 ...@@ -471,13 +471,13 @@ ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010
ANALYZE TABLE tab; ANALYZE TABLE tab;
--enable_info --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; ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
...@@ -656,9 +656,9 @@ CREATE TABLE parent (id POINT, PRIMARY KEY(id)) ENGINE=InnoDB; ...@@ -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; CREATE TABLE child (id GEOMETRY NOT NULL, parent_id POINT NOT NULL) ENGINE=InnoDB;
--enable_info --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 --disable_info
SHOW CREATE TABLE parent; SHOW CREATE TABLE parent;
...@@ -689,9 +689,9 @@ CREATE TABLE parent (id GEOMETRY, PRIMARY KEY(id(10))) ENGINE=InnoDB; ...@@ -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; CREATE TABLE child (id GEOMETRY NOT NULL, parent_id GEOMETRY NOT NULL) ENGINE=InnoDB;
--enable_info --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 --disable_info
SHOW CREATE TABLE parent; SHOW CREATE TABLE parent;
......
...@@ -26,10 +26,10 @@ c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ...@@ -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; ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
# Check spatial index functionality with Create Index clause options # Check spatial index functionality with Create Index clause options
CREATE SPATIAL INDEX idx1 on tab(c2 ASC); CREATE SPATIAL INDEX idx1 on tab(c2);
CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968';
CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=8 ; CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=8 ;
CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=4 CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=4
COMMENT 'Spatial index on Geometry type column'; COMMENT 'Spatial index on Geometry type column';
# Check index type # Check index type
...@@ -411,10 +411,10 @@ c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ...@@ -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; ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
# Check spatial index functionality with Create Index clause options # Check spatial index functionality with Create Index clause options
CREATE SPATIAL INDEX idx1 on tab(c2 ASC); CREATE SPATIAL INDEX idx1 on tab(c2);
CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968';
CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=2 ; CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=2 ;
CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=8 CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=8
COMMENT 'Spatial index on Geometry type column'; COMMENT 'Spatial index on Geometry type column';
# Check index type # Check index type
...@@ -783,10 +783,10 @@ c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL) ...@@ -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; ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=16;
# Check spatial index functionality with Create Index clause options # Check spatial index functionality with Create Index clause options
CREATE SPATIAL INDEX idx1 on tab(c2 ASC); CREATE SPATIAL INDEX idx1 on tab(c2);
CREATE SPATIAL INDEX idx2 on tab(c3 DESC) COMMENT 'wl6968'; CREATE SPATIAL INDEX idx2 on tab(c3) COMMENT 'wl6968';
CREATE SPATIAL INDEX idx3 on tab(c4 ASC) KEY_BLOCK_SIZE=16 ; CREATE SPATIAL INDEX idx3 on tab(c4) KEY_BLOCK_SIZE=16 ;
CREATE SPATIAL INDEX idx4 on tab(c5 DESC) KEY_BLOCK_SIZE=16 CREATE SPATIAL INDEX idx4 on tab(c5) KEY_BLOCK_SIZE=16
COMMENT 'Spatial index on Geometry type column'; COMMENT 'Spatial index on Geometry type column';
# Check index type # Check index type
......
...@@ -830,19 +830,6 @@ CREATE TABLE t2 ( ...@@ -830,19 +830,6 @@ CREATE TABLE t2 (
col2 POINT 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 # cleanup
DROP TABLE t0, t1, t2; DROP TABLE t0, t1, t2;
......
...@@ -822,8 +822,8 @@ DROP TABLE t1; ...@@ -822,8 +822,8 @@ DROP TABLE t1;
--echo # --echo #
CREATE TABLE parent(p POINT, PRIMARY KEY(p)) ENGINE=InnoDB; CREATE TABLE parent(p POINT, PRIMARY KEY(p)) ENGINE=InnoDB;
CREATE TABLE child(p POINT NOT NULL) ENGINE=InnoDB; CREATE TABLE child(p POINT NOT NULL) ENGINE=InnoDB;
ALTER TABLE parent ADD SPATIAL INDEX idx1(p ASC); ALTER TABLE parent ADD SPATIAL INDEX idx1(p);
ALTER TABLE child ADD SPATIAL INDEX idx2(p ASC); ALTER TABLE child ADD SPATIAL INDEX idx2(p);
SHOW CREATE TABLE parent; SHOW CREATE TABLE parent;
SHOW CREATE TABLE child; SHOW CREATE TABLE child;
......
...@@ -15,13 +15,13 @@ CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL, ...@@ -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) c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB; 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) INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'), 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, ...@@ -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) c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB; 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) INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'), VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'),
......
...@@ -1664,7 +1664,7 @@ rule: ...@@ -1664,7 +1664,7 @@ rule:
using_list opt_use_partition use_partition using_list opt_use_partition use_partition
%type <key_part> %type <key_part>
key_part key_part key_part_simple
%type <table_list> %type <table_list>
join_table_list join_table join_table_list join_table
...@@ -2643,9 +2643,10 @@ create: ...@@ -2643,9 +2643,10 @@ create:
if (Lex->add_create_index($2, &$6, HA_KEY_ALG_UNDEF, $1 | $5)) if (Lex->add_create_index($2, &$6, HA_KEY_ALG_UNDEF, $1 | $5))
MYSQL_YYABORT; 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 opt_index_lock_algorithm
{ {
Lex->last_key->columns.push_back($11, thd->mem_root);
Lex->pop_select(); //main select Lex->pop_select(); //main select
} }
| create_or_replace DATABASE opt_if_not_exists ident | create_or_replace DATABASE opt_if_not_exists ident
...@@ -5917,7 +5918,10 @@ key_def: ...@@ -5917,7 +5918,10 @@ key_def:
if (unlikely(Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3))) if (unlikely(Lex->add_key($1, &$4, HA_KEY_ALG_UNDEF, $3)))
MYSQL_YYABORT; 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_constraint constraint_key_type
opt_if_not_exists opt_ident opt_if_not_exists opt_ident
opt_USING_key_algorithm opt_USING_key_algorithm
...@@ -7128,12 +7132,7 @@ opt_without_overlaps: ...@@ -7128,12 +7132,7 @@ opt_without_overlaps:
; ;
key_part: key_part:
ident key_part_simple
{
$$= new (thd->mem_root) Key_part_spec(&$1, 0);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
| ident '(' NUM ')' | ident '(' NUM ')'
{ {
int key_part_len= atoi($3.str); int key_part_len= atoi($3.str);
...@@ -7145,6 +7144,15 @@ key_part: ...@@ -7145,6 +7144,15 @@ key_part:
} }
; ;
key_part_simple:
ident
{
$$= new (thd->mem_root) Key_part_spec(&$1, 0);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
;
opt_ident: opt_ident:
/* empty */ { $$= null_clex_str; } /* empty */ { $$= null_clex_str; }
| field_ident { $$= $1; } | field_ident { $$= $1; }
......
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