Skip to content

Commit 8504744

Browse files
committed
Bug#19880316 ALTER TABLE INSERTS INVALID VALUES IN GEOMETRY COLUMNS
Problem: ALTER TABLE ADD/MODIFY COLUMN may create geometry columns with invalid data. Geometry value validation was implemented in the fix for bug #19593342 and checks all values inserted into a geometry field with Field::store(). However, in some cases, ALTER TABLE bypasses Field::store(), and thereby also the validation. Fix: Return an error when trying to add NOT NULL geometry type columns, or trying to convert nullable columns of other types to NOT NULL geometry types, if the table is not empty. Use do_conv_blob() to copy geometry fields if the types aren't guaranteed to match. Since there is no default value, ALTER TABLE ADD COLUMN can only add a geometry column if the table is empty or the column is nullable. ALTER TABLE MODIFY COLUMN can only change a column to a geometry type if all values in the column can be interpreted as a valid value of that type.
1 parent ac50202 commit 8504744

10 files changed

+959
-62
lines changed

mysql-test/r/gis.result

+470
Large diffs are not rendered by default.

mysql-test/suite/innodb_gis/r/alter_spatial_index.result

+25-19
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,18 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
105105
ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING HASH;
106106
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING HASH' at line 1
107107
ALTER TABLE tab CHANGE c2 c2 MULTIPOINT NOT NULL FIRST, ALGORITHM=COPY;
108+
ERROR 22004: Invalid use of NULL value
108109
ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING NOT NULL,ALGORITHM=COPY;
110+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
109111
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON NOT NULL;
112+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
110113
SHOW CREATE TABLE tab;
111114
Table Create Table
112115
tab CREATE TABLE `tab` (
113-
`c2` multipoint NOT NULL,
114116
`c1` int(11) NOT NULL,
115-
`c3` multilinestring NOT NULL,
116-
`c4` multipolygon NOT NULL,
117+
`c2` point NOT NULL,
118+
`c3` linestring NOT NULL,
119+
`c4` polygon NOT NULL,
117120
`c5` geometry NOT NULL,
118121
PRIMARY KEY (`c1`),
119122
SPATIAL KEY `idx2` (`c2`),
@@ -144,8 +147,8 @@ ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON NOT NULL;
144147
SHOW CREATE TABLE tab;
145148
Table Create Table
146149
tab CREATE TABLE `tab` (
147-
`c22` point NOT NULL,
148150
`c1` int(11) NOT NULL,
151+
`c22` point NOT NULL,
149152
`c33` linestring NOT NULL,
150153
`c44` polygon NOT NULL,
151154
`c5` geometry NOT NULL,
@@ -170,8 +173,8 @@ ALTER TABLE tab CHANGE COLUMN c44 c4 POLYGON NOT NULL;
170173
SHOW CREATE TABLE tab;
171174
Table Create Table
172175
tab CREATE TABLE `tab` (
173-
`c2` point NOT NULL,
174176
`c1` int(11) NOT NULL,
177+
`c2` point NOT NULL,
175178
`c3` linestring NOT NULL,
176179
`c4` polygon NOT NULL,
177180
`c5` geometry NOT NULL,
@@ -269,8 +272,8 @@ CREATE SPATIAL INDEX idx5 ON temp_tab(c5);
269272
SHOW CREATE TABLE temp_tab;
270273
Table Create Table
271274
temp_tab CREATE TEMPORARY TABLE `temp_tab` (
272-
`c2` point NOT NULL,
273275
`c1` int(11) NOT NULL,
276+
`c2` point NOT NULL,
274277
`c3` linestring NOT NULL,
275278
`c4` polygon NOT NULL,
276279
`c5` geometry NOT NULL,
@@ -292,8 +295,8 @@ c1 ST_Astext(c2) ST_Astext(c4)
292295
SHOW CREATE TABLE tab;
293296
Table Create Table
294297
tab CREATE TABLE `tab` (
295-
`c2` point NOT NULL,
296298
`c1` int(11) NOT NULL,
299+
`c2` point NOT NULL,
297300
`c3` linestring NOT NULL,
298301
`c4` polygon NOT NULL,
299302
`c5` geometry NOT NULL,
@@ -315,8 +318,8 @@ ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2);
315318
SHOW CREATE TABLE tab;
316319
Table Create Table
317320
tab CREATE TABLE `tab` (
318-
`c2` point NOT NULL,
319321
`c1` int(11) NOT NULL,
322+
`c2` point NOT NULL,
320323
`c3` linestring NOT NULL,
321324
`c4` polygon NOT NULL,
322325
`c5` geometry NOT NULL,
@@ -349,8 +352,8 @@ ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c5(10));
349352
SHOW CREATE TABLE tab;
350353
Table Create Table
351354
tab CREATE TABLE `tab` (
352-
`c2` point NOT NULL,
353355
`c1` int(11) NOT NULL,
356+
`c2` point NOT NULL,
354357
`c3` linestring NOT NULL,
355358
`c4` polygon NOT NULL,
356359
`c5` geometry NOT NULL,
@@ -429,18 +432,19 @@ ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on G
429432
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
430433
ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
431434
ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL;
435+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
432436
ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
437+
ERROR 22004: Invalid use of NULL value
433438
ALTER TABLE tab add COLUMN c8 POINT NOT NULL, ALGORITHM = INPLACE, LOCK=NONE;
434439
ERROR 0A000: LOCK=NONE is not supported. Reason: Do not support online operation on table with GIS index. Try LOCK=SHARED.
435440
SHOW CREATE TABLE tab;
436441
Table Create Table
437442
tab CREATE TABLE `tab` (
438443
`c1` int(11) NOT NULL,
439444
`c2` geometry NOT NULL,
440-
`c3` polygon NOT NULL,
445+
`c3` linestring NOT NULL,
441446
`c4` polygon NOT NULL,
442447
`c5` geometry NOT NULL,
443-
`c7` point NOT NULL,
444448
PRIMARY KEY (`c1`),
445449
SPATIAL KEY `idx2` (`c2`),
446450
SPATIAL KEY `idx3` (`c3`),
@@ -466,16 +470,16 @@ DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
466470
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
467471
c1 ST_Astext(c2) ST_Astext(c4)
468472
ALTER TABLE tab MODIFY COLUMN c2 POLYGON NOT NULL;
473+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
469474
ALTER TABLE tab MODIFY COLUMN c4 GEOMETRY NOT NULL;
470475
SHOW CREATE TABLE tab;
471476
Table Create Table
472477
tab CREATE TABLE `tab` (
473478
`c1` int(11) NOT NULL,
474-
`c2` polygon NOT NULL,
475-
`c3` polygon NOT NULL,
479+
`c2` geometry NOT NULL,
480+
`c3` linestring NOT NULL,
476481
`c4` geometry NOT NULL,
477482
`c5` geometry NOT NULL,
478-
`c7` point NOT NULL,
479483
PRIMARY KEY (`c1`),
480484
SPATIAL KEY `idx2` (`c2`),
481485
SPATIAL KEY `idx3` (`c3`),
@@ -502,11 +506,10 @@ c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
502506
10 POINT(160 160) LINESTRING(140 140,150 150,160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
503507
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
504508
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
505-
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
506509
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
507510
AND MBREquals(tab.c3,@g2) ORDER BY c1;
508511
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
509-
10 POINT(160 160) LINESTRING(140 140,150 150,160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
512+
10 POINT(2000 2000) LINESTRING(140 140,150 150,160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
510513
DELETE FROM tab WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
511514
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
512515
AND MBREquals(tab.c3,@g2) ORDER BY c1;
@@ -527,7 +530,6 @@ tab CREATE TABLE `tab` (
527530
`c3` linestring NOT NULL,
528531
`c4` polygon NOT NULL,
529532
`c5` geometry NOT NULL,
530-
`c7` point NOT NULL,
531533
PRIMARY KEY (`c1`),
532534
SPATIAL KEY `idx2` (`c2`),
533535
SPATIAL KEY `idx3` (`c3`),
@@ -659,19 +661,23 @@ create table t1 (c1 int) engine=innodb;
659661
insert into t1 values(NULL);
660662
alter table t1 add b geometry, add spatial index(b), algorithm=inplace;
661663
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
662-
alter table t1 add b geometry not null, algorithm=inplace;
664+
alter table t1 add b geometry, algorithm=inplace;
663665
update t1 set b = st_geomfromtext('point(0 0)');
664666
alter table t1 add spatial index(b), algorithm=inplace;
667+
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
665668
delete from t1;
666669
DROP table t1;
667670
create table t1 (c1 int) engine=innodb;
668671
insert into t1 values(NULL);
669672
alter table t1 add b geometry, add spatial index(b), algorithm=copy;
670673
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
671674
alter table t1 add b geometry not null, add spatial index(b), algorithm=copy;
672-
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
675+
ERROR 22004: Invalid use of NULL value
673676
alter table t1 add b geometry not null, algorithm=copy;
677+
ERROR 22004: Invalid use of NULL value
674678
update t1 set b = st_geomfromtext('point(0 0)');
679+
ERROR 42S22: Unknown column 'b' in 'field list'
675680
alter table t1 add spatial index(b), algorithm=copy;
681+
ERROR 42000: Key column 'b' doesn't exist in table
676682
delete from t1;
677683
DROP table t1;

mysql-test/suite/innodb_gis/r/point_basic.result

+24-19
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,20 @@ SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE
6767
name mtype prtype len
6868
p 14 1535 12
6969
g 14 1535 12
70-
ALTER TABLE t1 ADD COLUMN p1 POINT NOT NULL, ADD COLUMN p2 POINT NOT NULL, ADD KEY(p), ADD KEY(p1), ADD KEY(p2);
70+
ALTER TABLE t1 ADD COLUMN p1 POINT, ADD COLUMN p2 POINT, ADD KEY(p);
7171
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1' OR name = 'p2';
7272
name mtype prtype len
7373
p 14 1535 12
7474
g 14 1535 12
75-
p1 14 1535 12
76-
p2 14 1535 12
75+
p1 14 1279 12
76+
p2 14 1279 12
7777
# NOT NULL POINT will use ''
7878
SELECT count(*) AS `Expect 4` FROM t1 WHERE p1 = '';
79-
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
79+
Expect 4
80+
0
8081
SELECT count(*) AS `Expect 4` FROM t1 WHERE p2 = '';
81-
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
82+
Expect 4
83+
0
8284
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p1;
8385
ST_AsText(p) ST_AsText(p1)
8486
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p2;
@@ -90,7 +92,7 @@ SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE
9092
name mtype prtype len
9193
p 14 1535 12
9294
g 14 1535 12
93-
p1 14 1535 12
95+
p1 14 1279 12
9496
p2 14 1279 12
9597
SELECT count(*) AS `Expect 4` FROM t1 WHERE p2 IS NULL;
9698
Expect 4
@@ -102,7 +104,7 @@ SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE
102104
name mtype prtype len
103105
p 14 1535 12
104106
g 14 1535 12
105-
p1 14 1535 12
107+
p1 14 1279 12
106108
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p1;
107109
ST_AsText(p) ST_AsText(p1)
108110
INSERT INTO t1 VALUES (ST_PointFromText('POINT(0.5 0.5)'), ST_PointFromText('POINT(0 1)'), ST_PointFromText('POINT(10 19)'));
@@ -122,11 +124,12 @@ POINT(10 20)
122124
POINT(10 20)
123125
# Add spatial keys on the table
124126
ALTER TABLE t1 ADD SPATIAL(p), ADD SPATIAL(p1);
127+
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
125128
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
126129
name mtype prtype len
127130
p 14 1535 12
128131
g 14 1535 12
129-
p1 14 1535 12
132+
p1 14 1279 12
130133
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
131134
ST_AsText(p) ST_AsText(p1)
132135
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
@@ -146,11 +149,12 @@ ST_AsText(p) ST_AsText(p1)
146149
POINT(0 0) POINT(10 20)
147150
# Drop spatial keys on the table
148151
ALTER TABLE t1 DROP KEY p, DROP KEY p1;
152+
ERROR 42000: Can't DROP 'p1'; check that column/key exists
149153
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
150154
name mtype prtype len
151155
p 14 1535 12
152156
g 14 1535 12
153-
p1 14 1535 12
157+
p1 14 1279 12
154158
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
155159
ST_AsText(p) ST_AsText(p1)
156160
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
@@ -173,18 +177,18 @@ ALTER TABLE t1 DROP COLUMN p, DROP COLUMN p1;
173177
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
174178
name mtype prtype len
175179
g 14 1535 12
176-
ALTER TABLE t1 ADD COLUMN p POINT NOT NULL, ADD COLUMN p1 POINT NOT NULL;
180+
ALTER TABLE t1 ADD COLUMN p POINT, ADD COLUMN p1 POINT;
177181
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
178182
name mtype prtype len
179183
g 14 1535 12
180-
p 14 1535 12
181-
p1 14 1535 12
184+
p 14 1279 12
185+
p1 14 1279 12
182186
SHOW CREATE TABLE t1;
183187
Table Create Table
184188
t1 CREATE TABLE `t1` (
185189
`g` geometry NOT NULL,
186-
`p` point NOT NULL,
187-
`p1` point NOT NULL
190+
`p` point DEFAULT NULL,
191+
`p1` point DEFAULT NULL
188192
) ENGINE=InnoDB DEFAULT CHARSET=latin1
189193
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.5 0.5)'), ST_PointFromText('POINT(0 1)'), ST_PointFromText('POINT(10 19)'));
190194
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.6 0.6)'), ST_PointFromText('POINT(1 1)'), ST_PointFromText('POINT(10 20)'));
@@ -202,12 +206,12 @@ POINT(1 1) POINT(10 20)
202206
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))'));
203207
ST_AsText(p) ST_AsText(p1)
204208
POINT(0 0) POINT(10 22)
205-
ALTER TABLE t1 DROP COLUMN p1, ADD COLUMN p1 POINT NOT NULL, CHANGE COLUMN p pp POINT NOT NULL AFTER p1;
209+
ALTER TABLE t1 DROP COLUMN p1, ADD COLUMN p1 POINT, CHANGE COLUMN p pp POINT AFTER p1;
206210
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'pp' OR name = 'g' OR name = 'p1';
207211
name mtype prtype len
208212
g 14 1535 12
209-
p1 14 1535 12
210-
pp 14 1535 12
213+
p1 14 1279 12
214+
pp 14 1279 12
211215
UPDATE t1 SET p1 = ST_PointFromText('POINT(5 5)');
212216
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1;
213217
ST_AsText(pp) ST_AsText(p1)
@@ -216,11 +220,12 @@ POINT(1 1) POINT(5 5)
216220
POINT(1 0) POINT(5 5)
217221
POINT(0 0) POINT(5 5)
218222
ALTER TABLE t1 ADD SPATIAL(p1), ADD SPATIAL(pp), ALGORITHM = COPY;
223+
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
219224
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'pp' OR name = 'g' OR name = 'p1';
220225
name mtype prtype len
221226
g 14 1535 12
222-
p1 14 1535 12
223-
pp 14 1535 12
227+
p1 14 1279 12
228+
pp 14 1279 12
224229
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
225230
ST_AsText(pp) ST_AsText(p1)
226231
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');

mysql-test/suite/innodb_gis/t/alter_spatial_index.test

+12-4
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@ ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING BTREE;
169169
--error ER_PARSE_ERROR
170170
ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING HASH;
171171

172-
172+
--error ER_INVALID_USE_OF_NULL
173173
ALTER TABLE tab CHANGE c2 c2 MULTIPOINT NOT NULL FIRST, ALGORITHM=COPY;
174174

175+
--error ER_CANT_CREATE_GEOMETRY_OBJECT
175176
ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING NOT NULL,ALGORITHM=COPY;
176177

178+
--error ER_CANT_CREATE_GEOMETRY_OBJECT
177179
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON NOT NULL;
178180

179181
SHOW CREATE TABLE tab;
@@ -455,8 +457,10 @@ ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
455457

456458
ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
457459

460+
--error ER_CANT_CREATE_GEOMETRY_OBJECT
458461
ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL;
459462

463+
--error ER_INVALID_USE_OF_NULL
460464
ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
461465

462466
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
@@ -478,6 +482,7 @@ DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
478482

479483
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
480484

485+
--error ER_CANT_CREATE_GEOMETRY_OBJECT
481486
ALTER TABLE tab MODIFY COLUMN c2 POLYGON NOT NULL;
482487

483488
ALTER TABLE tab MODIFY COLUMN c4 GEOMETRY NOT NULL;
@@ -496,7 +501,6 @@ SET @g2 = ST_GeomFromText('LINESTRING(140 140,150 150,160 160)');
496501
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
497502
AND MBREquals(tab.c3,@g2) ORDER BY c1;
498503

499-
--error ER_CANT_CREATE_GEOMETRY_OBJECT
500504
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
501505
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
502506

@@ -668,7 +672,7 @@ alter table t1 add b geometry, add spatial index(b), algorithm=inplace;
668672
# alter table t1 add b geometry not null, add spatial index(b), algorithm=inplace;
669673

670674
# Add a geometry column.
671-
alter table t1 add b geometry not null, algorithm=inplace;
675+
alter table t1 add b geometry, algorithm=inplace;
672676

673677
# Add spatial index fail, since there's a NULL or invalid geo data.
674678
# The case has to be commented because it no longer fails and following cases
@@ -680,6 +684,7 @@ alter table t1 add b geometry not null, algorithm=inplace;
680684
update t1 set b = st_geomfromtext('point(0 0)');
681685

682686
# Add spatial index success.
687+
--error ER_SPATIAL_CANT_HAVE_NULL
683688
alter table t1 add spatial index(b), algorithm=inplace;
684689

685690
# Delete rows.
@@ -697,10 +702,11 @@ insert into t1 values(NULL);
697702
alter table t1 add b geometry, add spatial index(b), algorithm=copy;
698703

699704
# Add spatial index fail, since there's a NULL or invalid geo data.
700-
--error ER_CANT_CREATE_GEOMETRY_OBJECT
705+
--error ER_INVALID_USE_OF_NULL
701706
alter table t1 add b geometry not null, add spatial index(b), algorithm=copy;
702707

703708
# Add a geometry column.
709+
--error ER_INVALID_USE_OF_NULL
704710
alter table t1 add b geometry not null, algorithm=copy;
705711

706712
# Add spatial index.
@@ -710,9 +716,11 @@ alter table t1 add b geometry not null, algorithm=copy;
710716
#alter table t1 add spatial index(b), algorithm=copy;
711717

712718
# Update invalide geo data to point(0 0).
719+
--error ER_BAD_FIELD_ERROR
713720
update t1 set b = st_geomfromtext('point(0 0)');
714721

715722
# Add spatial index success.
723+
--error ER_KEY_COLUMN_DOES_NOT_EXITS
716724
alter table t1 add spatial index(b), algorithm=copy;
717725

718726
# Delete rows.

0 commit comments

Comments
 (0)