mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
reject invalid spatial key declarations in the parser
This commit is contained in:
@@ -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');
|
||||
|
@@ -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;
|
||||
|
||||
#
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
#
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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,
|
||||
|
@@ -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` (
|
||||
|
@@ -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))'),
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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)'),
|
||||
|
@@ -1672,7 +1672,7 @@ rule:
|
||||
using_list opt_use_partition use_partition
|
||||
|
||||
%type <key_part>
|
||||
key_part
|
||||
key_part key_part_simple
|
||||
|
||||
%type <table_list>
|
||||
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; }
|
||||
|
Reference in New Issue
Block a user