You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: mysql-test/suite/innodb_gis/r/alter_spatial_index.result
+25-19
Original file line number
Diff line number
Diff line change
@@ -105,15 +105,18 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
105
105
ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING HASH;
106
106
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
107
107
ALTER TABLE tab CHANGE c2 c2 MULTIPOINT NOT NULL FIRST, ALGORITHM=COPY;
108
+
ERROR 22004: Invalid use of NULL value
108
109
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
109
111
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON NOT NULL;
112
+
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
110
113
SHOW CREATE TABLE tab;
111
114
Table Create Table
112
115
tab CREATE TABLE `tab` (
113
-
`c2` multipoint NOT NULL,
114
116
`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,
117
120
`c5` geometry NOT NULL,
118
121
PRIMARY KEY (`c1`),
119
122
SPATIAL KEY `idx2` (`c2`),
@@ -144,8 +147,8 @@ ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON NOT NULL;
144
147
SHOW CREATE TABLE tab;
145
148
Table Create Table
146
149
tab CREATE TABLE `tab` (
147
-
`c22` point NOT NULL,
148
150
`c1` int(11) NOT NULL,
151
+
`c22` point NOT NULL,
149
152
`c33` linestring NOT NULL,
150
153
`c44` polygon NOT NULL,
151
154
`c5` geometry NOT NULL,
@@ -170,8 +173,8 @@ ALTER TABLE tab CHANGE COLUMN c44 c4 POLYGON NOT NULL;
170
173
SHOW CREATE TABLE tab;
171
174
Table Create Table
172
175
tab CREATE TABLE `tab` (
173
-
`c2` point NOT NULL,
174
176
`c1` int(11) NOT NULL,
177
+
`c2` point NOT NULL,
175
178
`c3` linestring NOT NULL,
176
179
`c4` polygon NOT NULL,
177
180
`c5` geometry NOT NULL,
@@ -269,8 +272,8 @@ CREATE SPATIAL INDEX idx5 ON temp_tab(c5);
0 commit comments