File: ddl.result

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (411 lines) | stat: -rw-r--r-- 22,760 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# Create a table with three columns:
# 1) Normal POINT column without SRID specification
# 2) Normal POINT column with SRID 0
# 3) Normal POINT column with SRID 4326
CREATE TABLE t1 (no_srid POINT DEFAULT NULL,
srid_0 POINT SRID 0 DEFAULT NULL,
srid_4326 POINT SRID 4326 DEFAULT NULL);
SELECT * FROM INFORMATION_SCHEMA.ST_GEOMETRY_COLUMNS;
TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	COLUMN_NAME	SRS_NAME	SRS_ID	GEOMETRY_TYPE_NAME
def	test	t1	no_srid	NULL	NULL	point
def	test	t1	srid_0		0	point
def	test	t1	srid_4326	WGS 84	4326	point
# Insert some data with correct SRID into these columns
INSERT INTO t1 (no_srid, srid_0, srid_4326)
VALUES (ST_GeomFromText('POINT(0 0)', 0),
ST_GeomFromText('POINT(0 0)', 0),
ST_GeomFromText('POINT(0 0)', 4326));
INSERT INTO t1 (no_srid, srid_0, srid_4326)
VALUES (ST_GeomFromText('POINT(1 1)', 4326),
ST_GeomFromText('POINT(1 1)', 0),
ST_GeomFromText('POINT(1 1)', 4326));
# Insert data with wrong SRID, which should fail.
INSERT INTO t1 (srid_0) VALUES (ST_GeomFromText('POINT(1 1)', 4326));
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'srid_0'. The SRID of the geometry is 4326, but the SRID of the column is 0. Consider changing the SRID of the geometry or the SRID property of the column.
INSERT INTO t1 (srid_4326) VALUES (ST_GeomFromText('POINT(1 1)', 0));
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'srid_4326'. The SRID of the geometry is 0, but the SRID of the column is 4326. Consider changing the SRID of the geometry or the SRID property of the column.
INSERT INTO t1 (srid_4326) VALUES (POINT(0, 0));
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'srid_4326'. The SRID of the geometry is 0, but the SRID of the column is 4326. Consider changing the SRID of the geometry or the SRID property of the column.
# Try to alter the SRID of the columns, which should fail for all columns
# now since they already contain data.
ALTER TABLE t1 CHANGE COLUMN no_srid no_srid POINT SRID 0 DEFAULT NULL;
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'no_srid'. The SRID of the geometry is 4326, but the SRID of the column is 0. Consider changing the SRID of the geometry or the SRID property of the column.
ALTER TABLE t1 CHANGE COLUMN srid_0 srid_0 POINT SRID 4326 DEFAULT NULL;
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'srid_0'. The SRID of the geometry is 0, but the SRID of the column is 4326. Consider changing the SRID of the geometry or the SRID property of the column.
ALTER TABLE t1 CHANGE COLUMN srid_4326 srid_4326 POINT SRID 0 DEFAULT NULL;
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'srid_4326'. The SRID of the geometry is 4326, but the SRID of the column is 0. Consider changing the SRID of the geometry or the SRID property of the column.
# Removing the SRID specification from a column should work just fine.
ALTER TABLE t1 CHANGE COLUMN srid_0 no_srid_2 POINT DEFAULT NULL;
SELECT * FROM INFORMATION_SCHEMA.ST_GEOMETRY_COLUMNS;
TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	COLUMN_NAME	SRS_NAME	SRS_ID	GEOMETRY_TYPE_NAME
def	test	t1	no_srid	NULL	NULL	point
def	test	t1	no_srid_2	NULL	NULL	point
def	test	t1	srid_4326	WGS 84	4326	point
# Setting the SRID to a non-existing SRID should not work.
ALTER TABLE t1 CHANGE COLUMN srid_4326 srid_1 POINT SRID 1 DEFAULT NULL;
ERROR SR001: There's no spatial reference system with SRID 1.
DROP TABLE t1;
# Creating a geometry column with a non-existing SRID should not work
CREATE TABLE t1 (col1 POINT SRID 1);
ERROR SR001: There's no spatial reference system with SRID 1.
# Try to create a table without the SRID property, insert data with
# different SRIDs and then add the SRID property (which should not work).
CREATE TABLE t1 (col1 POINT);
INSERT INTO t1 VALUES (ST_GeomFromText('POINT(1 1)', 4326)),
(ST_GeomFromText('POINT(2 2)', 0)),
(ST_GeomFromText('POINT(3 3)', 4326)),
(ST_GeomFromText('POINT(4 4)', 0)),
(ST_GeomFromText('POINT(5 5)', 4326)),
(ST_GeomFromText('POINT(6 6)', 0));
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT SRID 4326;
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'col1'. The SRID of the geometry is 0, but the SRID of the column is 4326. Consider changing the SRID of the geometry or the SRID property of the column.
DELETE FROM t1 WHERE ST_SRID(col1) = 0;
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT SRID 4326;
DROP TABLE t1;
# The SRID property on a generated column should work
CREATE TABLE t1 (col1 POINT SRID 4326,
col2 POINT AS (ST_SRID(col1, 0)) SRID 0);
SELECT * FROM INFORMATION_SCHEMA.ST_GEOMETRY_COLUMNS;
TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	COLUMN_NAME	SRS_NAME	SRS_ID	GEOMETRY_TYPE_NAME
def	test	t1	col1	WGS 84	4326	point
def	test	t1	col2		0	point
INSERT INTO t1 (col1) VALUES (ST_GeomFromText('POINT(1 1)', 4326));
DROP TABLE t1;
# However, if the SRID property on the generated column doesn't match
# the SRID of the data, it should fail.
CREATE TABLE t1 (col1 POINT SRID 4326,
col2 POINT AS (ST_SRID(col1, 0)) SRID 2000);
INSERT INTO t1 (col1) VALUES (ST_GeomFromText('POINT(1 1)', 4326));
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'col2'. The SRID of the geometry is 0, but the SRID of the column is 2000. Consider changing the SRID of the geometry or the SRID property of the column.
DROP TABLE t1;
# Creating a column with SRID property on a MyISAM table should only
# be supported if the SRID represents a cartesian coordinate system.
CREATE TABLE t1 (col1 POINT SRID 0) ENGINE = MyISAM;
CREATE TABLE t2 (col1 POINT SRID 2000) ENGINE = MyISAM;
CREATE TABLE t3 (col1 POINT SRID 4326) ENGINE = MyISAM;
ERROR 42000: The storage engine for the table doesn't support geographic spatial reference systems
DROP TABLE t1, t2;
# It should not be possible to use the SRID property with any other types
# than geometric types.
CREATE TABLE t1 (col1 DOUBLE SRID 0);
ERROR HY000: Incorrect usage of SRID and non-geometry column
CREATE TABLE t1 (col1 BLOB SRID 0);
ERROR HY000: Incorrect usage of SRID and non-geometry column
CREATE TABLE t1 (col1 VARCHAR(255) SRID 0);
ERROR HY000: Incorrect usage of SRID and non-geometry column
# Check that any indexes on SRID-less columns are ignored by the
# optimizer
CREATE TABLE t1 (col1 POINT NOT NULL, SPATIAL INDEX (col1));
Warnings:
Warning	3674	The spatial index on column 'col1' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
INSERT INTO t1 VALUES (POINT(0, 0)), (POINT(0.5, 0.5)), (POINT(1, 1));
# Update table statistics to make the EXPLAIN stable
ANALYZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
# The following query plan should NOT use the index on "col1", since
# the column does not have the SRID property defined.
EXPLAIN SELECT ST_AsText(col1) FROM t1
WHERE MBRContains(col1, ST_GeomFromText("POLYGON((0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0))"));
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t1	NULL	ALL	NULL	NULL	NULL	NULL	3	100.00	Using where
Warnings:
Note	1003	/* select#1 */ select st_astext(`test`.`t1`.`col1`) AS `ST_AsText(col1)` from `test`.`t1` where mbrcontains(`test`.`t1`.`col1`,<cache>(st_geomfromtext('POLYGON((0 0, 0 0.5, 0.5 0.5, 0.5 0, 0 0))')))
DROP TABLE t1;
# Check that we print error message for misuse of SRID with non-geometric
# data type instead of "SRID not found"
CREATE TABLE t1 (a INTEGER SRID 1);
ERROR HY000: Incorrect usage of SRID and non-geometry column
CREATE TABLE t1 (a INTEGER);
ALTER TABLE t1 MODIFY COLUMN a INTEGER SRID 1;
ERROR HY000: Incorrect usage of SRID and non-geometry column
DROP TABLE t1;
#
# Bug#26594499 WL#8592:ALTER TABLE ADD SPATIAL INDEX RETURNS CANNOT GET
#              GEOMETRY OBJECT ERROR
#
CREATE TABLE t1 (
g1 geometry NOT NULL,
g3 geometry SRID 2000 NOT NULL,
g4 geometry SRID 4326 NOT NULL
);
INSERT INTO t1 VALUES (ST_GeomFromText('POINT(0 0)'),
ST_GeomFromText('POINT(0 0)', 2000), ST_GeomFromText('POINT(0 0)', 4326));
ALTER TABLE t1 add spatial index idx1(g4);
ALTER TABLE t1 add spatial index idx3(g3);
DROP TABLE t1;
CREATE TABLE t1 (col1 POINT SRID 4294967296);
ERROR 22003: SRID value is out of range in 'SRID'
#
# Check that adding, modifying and removing spatial indexes works well
# with SRID columns
#
CREATE TABLE t1 (col_no_srid POINT NOT NULL,
col_srid_0 POINT SRID 0 NOT NULL,
col_srid_4326 POINT SRID 4326 NOT NULL);
INSERT INTO t1 VALUES (
ST_GeomFromText("POINT(0 0)", 0),
ST_GeomFromText("POINT(0 0)", 0),
ST_GeomFromText("POINT(0 0)", 4326));
INSERT INTO t1 VALUES (
ST_GeomFromText("POINT(1 1)", 4326),
ST_GeomFromText("POINT(1 1)", 0),
ST_GeomFromText("POINT(1 1)", 4326));
ALTER TABLE t1 ADD SPATIAL INDEX idx1 (col_no_srid);
Warnings:
Warning	3674	The spatial index on column 'col_no_srid' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
ALTER TABLE t1 ADD SPATIAL INDEX idx2 (col_srid_0);
ALTER TABLE t1 ADD SPATIAL INDEX idx3 (col_srid_4326);
ALTER TABLE t1 DROP INDEX idx2;
ALTER TABLE t1 DROP INDEX idx3;
ALTER TABLE t1 DROP INDEX idx1;
CREATE SPATIAL INDEX idx1 ON t1 (col_srid_4326);
CREATE SPATIAL INDEX idx2 ON t1 (col_no_srid);
Warnings:
Warning	3674	The spatial index on column 'col_no_srid' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
CREATE SPATIAL INDEX idx3 ON t1 (col_srid_0);
DROP INDEX idx1 ON t1;
DROP INDEX idx2 ON t1;
DROP INDEX idx3 ON t1;
DROP TABLE t1;
CREATE TABLE t1 (col_no_srid POINT NOT NULL,
col_srid_0 POINT SRID 0 NOT NULL,
col_srid_4326 POINT SRID 4326 NOT NULL,
SPATIAL INDEX idx1 (col_no_srid),
SPATIAL INDEX idx2 (col_srid_0),
SPATIAL INDEX idx3 (col_srid_4326));
Warnings:
Warning	3674	The spatial index on column 'col_no_srid' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
INSERT INTO t1 VALUES (
ST_GeomFromText("POINT(0 0)", 0),
ST_GeomFromText("POINT(0 0)", 0),
ST_GeomFromText("POINT(0 0)", 4326));
INSERT INTO t1 VALUES (
ST_GeomFromText("POINT(1 1)", 4326),
ST_GeomFromText("POINT(1 1)", 0),
ST_GeomFromText("POINT(1 1)", 4326));
DROP INDEX idx3 ON t1;
DROP INDEX idx2 ON t1;
DROP INDEX idx1 ON t1;
DROP TABLE t1;
#
# Altering the SRID specification should not be allowed if there is a
# spatial index on the column.
#
CREATE TABLE t1 (col1 POINT NOT NULL SRID 4326,
SPATIAL INDEX idx1 (col1));
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT NOT NULL SRID 0;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT NOT NULL;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT NOT NULL SRID 0, ALGORITHM=INPLACE;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT NOT NULL, ALGORITHM=INPLACE;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT NOT NULL SRID 0, ALGORITHM=COPY;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT NOT NULL, ALGORITHM=COPY;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT NOT NULL SRID 0, ALGORITHM=DEFAULT;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col1 POINT NOT NULL, ALGORITHM=DEFAULT;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col2 POINT NOT NULL SRID 0;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
ALTER TABLE t1 CHANGE COLUMN col1 col2 POINT NOT NULL;
ERROR HY000: The SRID specification on the column 'col1' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
DROP TABLE t1;
# Test SRID specification in combination with generated columns and
# spatial indexes.
CREATE TABLE t1 (
col_no_srid POINT NOT NULL,
col_srid_0 POINT NOT NULL SRID 0,
col_srid_4326 POINT NOT NULL SRID 4326);
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_4326) VALUES (
ST_GeomFromText('POINT(0 0)'),
ST_GeomFromText('POINT(0 0)', 0),
ST_GeomFromText('POINT(0 0)', 4326));
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_4326) VALUES (
ST_GeomFromText('POINT(0 0)', 4326),
ST_GeomFromText('POINT(0 0)', 0),
ST_GeomFromText('POINT(0 0)', 4326));
# This should not be allowed since the column contains data with a
# different SRID
ALTER TABLE t1 CHANGE COLUMN col_srid_4326 col_srid_2000 POINT NOT NULL SRID 2000;
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'col_srid_2000'. The SRID of the geometry is 4326, but the SRID of the column is 2000. Consider changing the SRID of the geometry or the SRID property of the column.
DELETE FROM t1;
# Now it should be allowed since there is no data in the table,
ALTER TABLE t1 CHANGE COLUMN col_srid_4326 col_srid_2000 POINT NOT NULL SRID 2000;
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_2000) VALUES (
ST_GeomFromText('POINT(0 0)'),
ST_GeomFromText('POINT(0 0)', 0),
ST_GeomFromText('POINT(0 0)', 2000));
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_2000) VALUES (
ST_GeomFromText('POINT(0 0)', 4326),
ST_GeomFromText('POINT(0 0)', 0),
ST_GeomFromText('POINT(0 0)', 2000));
# Add an index on "col_srid_2000"
CREATE SPATIAL INDEX idx_2000 ON t1 (col_srid_2000);
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_2000) VALUES (
ST_GeomFromText('POINT(0 0)', 4326),
ST_GeomFromText('POINT(0 0)', 0),
ST_GeomFromText('POINT(0 0)', 2000));
# Add an generated column that is based on the indexed column
# (col_srid_2000).
ALTER TABLE t1 ADD COLUMN (col_srid_4326_generated POINT AS
(ST_SRID(col_srid_2000, 4326)) SRID 4326);
SELECT
ST_AsText(col_no_srid),
ST_AsText(col_srid_0),
ST_AsText(col_srid_2000),
ST_AsText(col_srid_4326_generated),
ST_SRID(col_no_srid),
ST_SRID(col_srid_0),
ST_SRID(col_srid_2000),
ST_SRID(col_srid_4326_generated)
FROM t1;
ST_AsText(col_no_srid)	ST_AsText(col_srid_0)	ST_AsText(col_srid_2000)	ST_AsText(col_srid_4326_generated)	ST_SRID(col_no_srid)	ST_SRID(col_srid_0)	ST_SRID(col_srid_2000)	ST_SRID(col_srid_4326_generated)
POINT(0 0)	POINT(0 0)	POINT(0 0)	POINT(0 0)	0	0	2000	4326
POINT(0 0)	POINT(0 0)	POINT(0 0)	POINT(0 0)	4326	0	2000	4326
POINT(0 0)	POINT(0 0)	POINT(0 0)	POINT(0 0)	4326	0	2000	4326
# Add a spatial index on the generated column
CREATE INDEX idx_4326_generated ON t1 (col_srid_4326_generated);
ERROR HY000: 'Spatial index on virtual generated column' is not supported for generated columns.
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_2000) VALUES (
ST_GeomFromText('POINT(1 1)', 4326),
ST_GeomFromText('POINT(1 1)', 0),
ST_GeomFromText('POINT(1 1)', 2000));
# This should give an error since there is an index on the column.
ALTER TABLE t1 CHANGE COLUMN col_srid_2000 col_srid_2000 POINT NOT NULL SRID 4326;
ERROR HY000: The SRID specification on the column 'col_srid_2000' cannot be changed because there is a spatial index on the column. Please remove the spatial index before altering the SRID specification.
# Remove the index from col_srid_2000
DROP INDEX idx_2000 ON t1;
# This should not be allowed since the column contains data with a
# different SRID
ALTER TABLE t1 CHANGE COLUMN col_srid_2000 col_srid_2000 POINT NOT NULL SRID 4326;
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'col_srid_2000'. The SRID of the geometry is 2000, but the SRID of the column is 4326. Consider changing the SRID of the geometry or the SRID property of the column.
DELETE FROM t1;
# Now it should be allowed since there is no data in the table,
ALTER TABLE t1 CHANGE COLUMN col_srid_2000 col_srid_2000 POINT NOT NULL SRID 4326;
# Wrong SRID for col_srid_2000, so should not work
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_2000) VALUES (
ST_GeomFromText('POINT(1 1)'),
ST_GeomFromText('POINT(1 1)', 0),
ST_GeomFromText('POINT(1 1)', 2000));
ERROR HY000: The SRID of the geometry does not match the SRID of the column 'col_srid_2000'. The SRID of the geometry is 2000, but the SRID of the column is 4326. Consider changing the SRID of the geometry or the SRID property of the column.
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_2000) VALUES (
ST_GeomFromText('POINT(1 1)'),
ST_GeomFromText('POINT(1 1)', 0),
ST_GeomFromText('POINT(1 1)', 4326));
ALTER TABLE t1 CHANGE COLUMN col_srid_2000 col_srid_2000 POINT NOT NULL;
# This should work just fine, since we have removed the SRID specification
# for col_srid_2000
INSERT INTO t1 (col_no_srid, col_srid_0, col_srid_2000) VALUES (
ST_GeomFromText('POINT(1 1)'),
ST_GeomFromText('POINT(1 1)', 0),
ST_GeomFromText('POINT(1 1)', 2000));
SELECT
ST_AsText(col_no_srid),
ST_AsText(col_srid_0),
ST_AsText(col_srid_2000),
ST_AsText(col_srid_4326_generated),
ST_SRID(col_no_srid),
ST_SRID(col_srid_0),
ST_SRID(col_srid_2000),
ST_SRID(col_srid_4326_generated)
FROM t1;
ST_AsText(col_no_srid)	ST_AsText(col_srid_0)	ST_AsText(col_srid_2000)	ST_AsText(col_srid_4326_generated)	ST_SRID(col_no_srid)	ST_SRID(col_srid_0)	ST_SRID(col_srid_2000)	ST_SRID(col_srid_4326_generated)
POINT(1 1)	POINT(1 1)	POINT(1 1)	POINT(1 1)	0	0	4326	4326
POINT(1 1)	POINT(1 1)	POINT(1 1)	POINT(1 1)	0	0	2000	4326
CREATE SPATIAL INDEX idx_0 ON t1 (col_srid_0);
# Check that all columns have the correct SRID specification.
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `col_no_srid` point NOT NULL,
  `col_srid_0` point NOT NULL /*!80003 SRID 0 */,
  `col_srid_2000` point NOT NULL,
  `col_srid_4326_generated` point GENERATED ALWAYS AS (st_srid(`col_srid_2000`,4326)) VIRTUAL /*!80003 SRID 4326 */,
  SPATIAL KEY `idx_0` (`col_srid_0`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
ALTER TABLE t1 DROP COLUMN col_srid_4326_generated;
DROP TABLE t1;
#
# Bug#26594499  WL#8592: CANNOT GET GEOMETRY OBJECT ERROR
#
CREATE TABLE t1 (
g1 geometry NOT NULL,
g3 geometry SRID 2000 NOT NULL,
g4 geometry SRID 4326 NOT NULL
);
INSERT INTO t1 VALUES (ST_GeomFromText('POINT(0 0)'),
ST_GeomFromText('POINT(0 0)', 2000), ST_GeomFromText('POINT(0 0)', 4326));
ALTER TABLE t1 add spatial index idx1(g4);
ALTER TABLE t1 add spatial index idx3(g3);
DROP TABLE t1;
#
# Bug#27015964 USELESS SPATIAL INDEX CAN BE CREATED WITHOUT WARNING
#
# Creating a table with a spatial index on a SRID-less column should
# raise a warning.
CREATE TABLE t1 (
g1 POINT NOT NULL
, g2 POINT NOT NULL
, g3 POINT NOT NULL SRID 0
, SPATIAL INDEX idx1 (g1)
, SPATIAL INDEX idx2 (g2)
, SPATIAL INDEX idx3 (g3));
Warnings:
Warning	3674	The spatial index on column 'g1' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
Warning	3674	The spatial index on column 'g2' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
DROP INDEX idx1 ON t1;
DROP INDEX idx2 ON t1;
DROP INDEX idx3 ON t1;
# Verify that we get the same warning when using CREATE INDEX syntax.
CREATE SPATIAL INDEX idx1 ON t1 (g1);
Warnings:
Warning	3674	The spatial index on column 'g1' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
CREATE SPATIAL INDEX idx2 ON t1 (g2);
Warnings:
Warning	3674	The spatial index on column 'g2' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
CREATE SPATIAL INDEX idx3 ON t1 (g3);
DROP INDEX idx1 ON t1;
DROP INDEX idx2 ON t1;
DROP INDEX idx3 ON t1;
# Verify that we get the same warning when using ALTER TABLE syntax.
ALTER TABLE t1 ADD SPATIAL INDEX idx1 (g1);
Warnings:
Warning	3674	The spatial index on column 'g1' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
ALTER TABLE t1 ADD SPATIAL INDEX idx2 (g2);
Warnings:
Warning	3674	The spatial index on column 'g2' will not be used by the query optimizer since the column does not have an SRID attribute. Consider adding an SRID attribute to the column.
ALTER TABLE t1 ADD SPATIAL INDEX idx3 (g3);
DROP TABLE t1;
#
# Bug#27220467 SERVER HANGS WHILE CREATING A NEW SRS WHICH IS USED IN
#              ANOTHER CLIENT
#
# Try to create a point column using a SRID that doesn't exist
CREATE TABLE t1 (col1 POINT SRID 4326, col2 POINT SRID 1000000000);
ERROR SR001: There's no spatial reference system with SRID 1000000000.
# Verify that any lock that was taken for SRIDs is released
SELECT COUNT(*) AS should_be_zero FROM performance_schema.metadata_locks
WHERE OBJECT_TYPE = 'SRID';
should_be_zero
0
# Force the error to happen after all the columns are contextualized.
CREATE TABLE t1 (col1 POINT SRID 4326) ENGINE = "foo";
ERROR 42000: Unknown storage engine 'foo'
SELECT COUNT(*) AS should_be_zero FROM performance_schema.metadata_locks
WHERE OBJECT_TYPE = 'SRID';
should_be_zero
0
# Verify the same behavior for ALTER TABLE as well.
CREATE TABLE t1 (col1 INT);
ALTER TABLE t1 ADD COLUMN col2 POINT SRID 1000000000;
ERROR SR001: There's no spatial reference system with SRID 1000000000.
SELECT COUNT(*) AS should_be_zero FROM performance_schema.metadata_locks
WHERE OBJECT_TYPE = 'SRID';
should_be_zero
0
DROP TABLE t1;