mirror of
https://github.com/MariaDB/server.git
synced 2025-12-01 17:39:21 +03:00
For InnoDB tables, adding, dropping and reordering columns has
required a rebuild of the table and all its indexes. Since MySQL 5.6
(and MariaDB 10.0) this has been supported online (LOCK=NONE), allowing
concurrent modification of the tables.
This work revises the InnoDB ROW_FORMAT=REDUNDANT, ROW_FORMAT=COMPACT
and ROW_FORMAT=DYNAMIC so that columns can be appended instantaneously,
with only minor changes performed to the table structure. The counter
innodb_instant_alter_column in INFORMATION_SCHEMA.GLOBAL_STATUS
is incremented whenever a table rebuild operation is converted into
an instant ADD COLUMN operation.
ROW_FORMAT=COMPRESSED tables will not support instant ADD COLUMN.
Some usability limitations will be addressed in subsequent work:
MDEV-13134 Introduce ALTER TABLE attributes ALGORITHM=NOCOPY
and ALGORITHM=INSTANT
MDEV-14016 Allow instant ADD COLUMN, ADD INDEX, LOCK=NONE
The format of the clustered index (PRIMARY KEY) is changed as follows:
(1) The FIL_PAGE_TYPE of the root page will be FIL_PAGE_TYPE_INSTANT,
and a new field PAGE_INSTANT will contain the original number of fields
in the clustered index ('core' fields).
If instant ADD COLUMN has not been used or the table becomes empty,
or the very first instant ADD COLUMN operation is rolled back,
the fields PAGE_INSTANT and FIL_PAGE_TYPE will be reset
to 0 and FIL_PAGE_INDEX.
(2) A special 'default row' record is inserted into the leftmost leaf,
between the page infimum and the first user record. This record is
distinguished by the REC_INFO_MIN_REC_FLAG, and it is otherwise in the
same format as records that contain values for the instantly added
columns. This 'default row' always has the same number of fields as
the clustered index according to the table definition. The values of
'core' fields are to be ignored. For other fields, the 'default row'
will contain the default values as they were during the ALTER TABLE
statement. (If the column default values are changed later, those
values will only be stored in the .frm file. The 'default row' will
contain the original evaluated values, which must be the same for
every row.) The 'default row' must be completely hidden from
higher-level access routines. Assertions have been added to ensure
that no 'default row' is ever present in the adaptive hash index
or in locked records. The 'default row' is never delete-marked.
(3) In clustered index leaf page records, the number of fields must
reside between the number of 'core' fields (dict_index_t::n_core_fields
introduced in this work) and dict_index_t::n_fields. If the number
of fields is less than dict_index_t::n_fields, the missing fields
are replaced with the column value of the 'default row'.
Note: The number of fields in the record may shrink if some of the
last instantly added columns are updated to the value that is
in the 'default row'. The function btr_cur_trim() implements this
'compression' on update and rollback; dtuple::trim() implements it
on insert.
(4) In ROW_FORMAT=COMPACT and ROW_FORMAT=DYNAMIC records, the new
status value REC_STATUS_COLUMNS_ADDED will indicate the presence of
a new record header that will encode n_fields-n_core_fields-1 in
1 or 2 bytes. (In ROW_FORMAT=REDUNDANT records, the record header
always explicitly encodes the number of fields.)
We introduce the undo log record type TRX_UNDO_INSERT_DEFAULT for
covering the insert of the 'default row' record when instant ADD COLUMN
is used for the first time. Subsequent instant ADD COLUMN can use
TRX_UNDO_UPD_EXIST_REC.
This is joint work with Vin Chen (陈福荣) from Tencent. The design
that was discussed in April 2017 would not have allowed import or
export of data files, because instead of the 'default row' it would
have introduced a data dictionary table. The test
rpl.rpl_alter_instant is exactly as contributed in pull request #408.
The test innodb.instant_alter is based on a contributed test.
The redo log record format changes for ROW_FORMAT=DYNAMIC and
ROW_FORMAT=COMPACT are as contributed. (With this change present,
crash recovery from MariaDB 10.3.1 will fail in spectacular ways!)
Also the semantics of higher-level redo log records that modify the
PAGE_INSTANT field is changed. The redo log format version identifier
was already changed to LOG_HEADER_FORMAT_CURRENT=103 in MariaDB 10.3.1.
Everything else has been rewritten by me. Thanks to Elena Stepanova,
the code has been tested extensively.
When rolling back an instant ADD COLUMN operation, we must empty the
PAGE_FREE list after deleting or shortening the 'default row' record,
by calling either btr_page_empty() or btr_page_reorganize(). We must
know the size of each entry in the PAGE_FREE list. If rollback left a
freed copy of the 'default row' in the PAGE_FREE list, we would be
unable to determine its size (if it is in ROW_FORMAT=COMPACT or
ROW_FORMAT=DYNAMIC) because it would contain more fields than the
rolled-back definition of the clustered index.
UNIV_SQL_DEFAULT: A new special constant that designates an instantly
added column that is not present in the clustered index record.
len_is_stored(): Check if a length is an actual length. There are
two magic length values: UNIV_SQL_DEFAULT, UNIV_SQL_NULL.
dict_col_t::def_val: The 'default row' value of the column. If the
column is not added instantly, def_val.len will be UNIV_SQL_DEFAULT.
dict_col_t: Add the accessors is_virtual(), is_nullable(), is_instant(),
instant_value().
dict_col_t::remove_instant(): Remove the 'instant ADD' status of
a column.
dict_col_t::name(const dict_table_t& table): Replaces
dict_table_get_col_name().
dict_index_t::n_core_fields: The original number of fields.
For secondary indexes and if instant ADD COLUMN has not been used,
this will be equal to dict_index_t::n_fields.
dict_index_t::n_core_null_bytes: Number of bytes needed to
represent the null flags; usually equal to UT_BITS_IN_BYTES(n_nullable).
dict_index_t::NO_CORE_NULL_BYTES: Magic value signalling that
n_core_null_bytes was not initialized yet from the clustered index
root page.
dict_index_t: Add the accessors is_instant(), is_clust(),
get_n_nullable(), instant_field_value().
dict_index_t::instant_add_field(): Adjust clustered index metadata
for instant ADD COLUMN.
dict_index_t::remove_instant(): Remove the 'instant ADD' status
of a clustered index when the table becomes empty, or the very first
instant ADD COLUMN operation is rolled back.
dict_table_t: Add the accessors is_instant(), is_temporary(),
supports_instant().
dict_table_t::instant_add_column(): Adjust metadata for
instant ADD COLUMN.
dict_table_t::rollback_instant(): Adjust metadata on the rollback
of instant ADD COLUMN.
prepare_inplace_alter_table_dict(): First create the ctx->new_table,
and only then decide if the table really needs to be rebuilt.
We must split the creation of table or index metadata from the
creation of the dictionary table records and the creation of
the data. In this way, we can transform a table-rebuilding operation
into an instant ADD COLUMN operation. Dictionary objects will only
be added to cache when table rebuilding or index creation is needed.
The ctx->instant_table will never be added to cache.
dict_table_t::add_to_cache(): Modified and renamed from
dict_table_add_to_cache(). Do not modify the table metadata.
Let the callers invoke dict_table_add_system_columns() and if needed,
set can_be_evicted.
dict_create_sys_tables_tuple(), dict_create_table_step(): Omit the
system columns (which will now exist in the dict_table_t object
already at this point).
dict_create_table_step(): Expect the callers to invoke
dict_table_add_system_columns().
pars_create_table(): Before creating the table creation execution
graph, invoke dict_table_add_system_columns().
row_create_table_for_mysql(): Expect all callers to invoke
dict_table_add_system_columns().
create_index_dict(): Replaces row_merge_create_index_graph().
innodb_update_n_cols(): Renamed from innobase_update_n_virtual().
Call my_error() if an error occurs.
btr_cur_instant_init(), btr_cur_instant_init_low(),
btr_cur_instant_root_init():
Load additional metadata from the clustered index and set
dict_index_t::n_core_null_bytes. This is invoked
when table metadata is first loaded into the data dictionary.
dict_boot(): Initialize n_core_null_bytes for the four hard-coded
dictionary tables.
dict_create_index_step(): Initialize n_core_null_bytes. This is
executed as part of CREATE TABLE.
dict_index_build_internal_clust(): Initialize n_core_null_bytes to
NO_CORE_NULL_BYTES if table->supports_instant().
row_create_index_for_mysql(): Initialize n_core_null_bytes for
CREATE TEMPORARY TABLE.
commit_cache_norebuild(): Call the code to rename or enlarge columns
in the cache only if instant ADD COLUMN is not being used.
(Instant ADD COLUMN would copy all column metadata from
instant_table to old_table, including the names and lengths.)
PAGE_INSTANT: A new 13-bit field for storing dict_index_t::n_core_fields.
This is repurposing the 16-bit field PAGE_DIRECTION, of which only the
least significant 3 bits were used. The original byte containing
PAGE_DIRECTION will be accessible via the new constant PAGE_DIRECTION_B.
page_get_instant(), page_set_instant(): Accessors for the PAGE_INSTANT.
page_ptr_get_direction(), page_get_direction(),
page_ptr_set_direction(): Accessors for PAGE_DIRECTION.
page_direction_reset(): Reset PAGE_DIRECTION, PAGE_N_DIRECTION.
page_direction_increment(): Increment PAGE_N_DIRECTION
and set PAGE_DIRECTION.
rec_get_offsets(): Use the 'leaf' parameter for non-debug purposes,
and assume that heap_no is always set.
Initialize all dict_index_t::n_fields for ROW_FORMAT=REDUNDANT records,
even if the record contains fewer fields.
rec_offs_make_valid(): Add the parameter 'leaf'.
rec_copy_prefix_to_dtuple(): Assert that the tuple is only built
on the core fields. Instant ADD COLUMN only applies to the
clustered index, and we should never build a search key that has
more than the PRIMARY KEY and possibly DB_TRX_ID,DB_ROLL_PTR.
All these columns are always present.
dict_index_build_data_tuple(): Remove assertions that would be
duplicated in rec_copy_prefix_to_dtuple().
rec_init_offsets(): Support ROW_FORMAT=REDUNDANT records whose
number of fields is between n_core_fields and n_fields.
cmp_rec_rec_with_match(): Implement the comparison between two
MIN_REC_FLAG records.
trx_t::in_rollback: Make the field available in non-debug builds.
trx_start_for_ddl_low(): Remove dangerous error-tolerance.
A dictionary transaction must be flagged as such before it has generated
any undo log records. This is because trx_undo_assign_undo() will mark
the transaction as a dictionary transaction in the undo log header
right before the very first undo log record is being written.
btr_index_rec_validate(): Account for instant ADD COLUMN
row_undo_ins_remove_clust_rec(): On the rollback of an insert into
SYS_COLUMNS, revert instant ADD COLUMN in the cache by removing the
last column from the table and the clustered index.
row_search_on_row_ref(), row_undo_mod_parse_undo_rec(), row_undo_mod(),
trx_undo_update_rec_get_update(): Handle the 'default row'
as a special case.
dtuple_t::trim(index): Omit a redundant suffix of an index tuple right
before insert or update. After instant ADD COLUMN, if the last fields
of a clustered index tuple match the 'default row', there is no
need to store them. While trimming the entry, we must hold a page latch,
so that the table cannot be emptied and the 'default row' be deleted.
btr_cur_optimistic_update(), btr_cur_pessimistic_update(),
row_upd_clust_rec_by_insert(), row_ins_clust_index_entry_low():
Invoke dtuple_t::trim() if needed.
row_ins_clust_index_entry(): Restore dtuple_t::n_fields after calling
row_ins_clust_index_entry_low().
rec_get_converted_size(), rec_get_converted_size_comp(): Allow the number
of fields to be between n_core_fields and n_fields. Do not support
infimum,supremum. They are never supposed to be stored in dtuple_t,
because page creation nowadays uses a lower-level method for initializing
them.
rec_convert_dtuple_to_rec_comp(): Assign the status bits based on the
number of fields.
btr_cur_trim(): In an update, trim the index entry as needed. For the
'default row', handle rollback specially. For user records, omit
fields that match the 'default row'.
btr_cur_optimistic_delete_func(), btr_cur_pessimistic_delete():
Skip locking and adaptive hash index for the 'default row'.
row_log_table_apply_convert_mrec(): Replace 'default row' values if needed.
In the temporary file that is applied by row_log_table_apply(),
we must identify whether the records contain the extra header for
instantly added columns. For now, we will allocate an additional byte
for this for ROW_T_INSERT and ROW_T_UPDATE records when the source table
has been subject to instant ADD COLUMN. The ROW_T_DELETE records are
fine, as they will be converted and will only contain 'core' columns
(PRIMARY KEY and some system columns) that are converted from dtuple_t.
rec_get_converted_size_temp(), rec_init_offsets_temp(),
rec_convert_dtuple_to_temp(): Add the parameter 'status'.
REC_INFO_DEFAULT_ROW = REC_INFO_MIN_REC_FLAG | REC_STATUS_COLUMNS_ADDED:
An info_bits constant for distinguishing the 'default row' record.
rec_comp_status_t: An enum of the status bit values.
rec_leaf_format: An enum that replaces the bool parameter of
rec_init_offsets_comp_ordinary().
746 lines
36 KiB
Plaintext
746 lines
36 KiB
Plaintext
CALL mtr.add_suppression("but MySQL is asking statistics for 2 columns. Have you mixed");
|
|
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;
|
|
CREATE TABLE tab1(c1 int NOT NULL PRIMARY KEY,c2 MULTIPOINT NOT NULL,
|
|
c3 MULTILINESTRING NOT NULL,c4 MULTIPOLYGON NOT NULL,c5 GEOMETRY NOT NULL)
|
|
ENGINE=InnoDB;
|
|
INSERT INTO tab1 SELECT * FROM tab;
|
|
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))'),
|
|
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(2,ST_GeomFromText('POINT(20 20)'),ST_GeomFromText('LINESTRING(20 20,30 30,40 40)'),
|
|
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'),
|
|
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(3,ST_GeomFromText('POINT(4 4)'),ST_GeomFromText('LINESTRING(130 130,140 140,150 150)'),
|
|
ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'),
|
|
ST_GeomFromText('POLYGON((4 -2,5 -4,6 -5,7 -4,7 2,4 -2))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(4,ST_GeomFromText('POINT(50 50)'),ST_GeomFromText('LINESTRING(200 200,300 300,400 400)'),
|
|
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'),
|
|
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(5,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(400 400,500 500,600 700)'),
|
|
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'),
|
|
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(6,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
|
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'),
|
|
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(7,ST_GeomFromText('POINT(60 70)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
|
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
|
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(8,ST_GeomFromText('POINT(0 0)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
|
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
|
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(9,ST_GeomFromText('POINT(120 120)'),ST_GeomFromText('LINESTRING(100 100,110 110,120 120)'),
|
|
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'),
|
|
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'));
|
|
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);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC);
|
|
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';
|
|
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';
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
3 POINT(4 4) POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)')
|
|
WHERE MBRContains(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
3 POINT(0 0) POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))
|
|
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
SET @g1 = ST_GeomFromText('LINESTRING( 300 300,400 400)');
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
4 POINT(50 50) POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(100 100)')
|
|
WHERE MBRContains(tab.c4, @g1);
|
|
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
|
SET @g1 = ST_GeomFromText( 'POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))');
|
|
SELECT c1,ST_AsText(c2),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1);
|
|
c1 ST_AsText(c2) ST_Astext(c4)
|
|
5 POINT(3 3) POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(200 200)')
|
|
WHERE MBRWithin(tab.c4, @g1);
|
|
SELECT c1,ST_AsText(c2),ST_AsText(c4) FROM tab WHERE MBRWithin(tab.c4, @g1);
|
|
c1 ST_AsText(c2) ST_AsText(c4)
|
|
5 POINT(200 200) POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))
|
|
DELETE FROM tab WHERE MBRWithin(tab.c4, @g1);
|
|
ALTER TABLE tab MODIFY COLUMN c2 MULTIPOINT;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING NULL;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON NULL;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
ALTER TABLE tab MODIFY COLUMN c4 Geometry NULL;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
ALTER TABLE tab CHANGE COLUMN c2 c22 POINT;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
ALTER TABLE tab CHANGE COLUMN c3 c33 LINESTRING;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
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;
|
|
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;
|
|
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
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` point NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
PRIMARY KEY (`c1`),
|
|
SPATIAL KEY `idx2` (`c2`),
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c4`(10)) USING BTREE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
|
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
|
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
|
SET @g1 = ST_GeomFromText('POLYGON((20 20,30 30,40 40,50 50,40 50,30 40,30 30,20 20))');
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
2 POINT(20 20) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
|
|
1 POINT(10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
|
WHERE ST_Crosses(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
2 POINT(1000 1000) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
|
|
1 POINT(1000 1000) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
|
|
DELETE FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
|
ALTER TABLE tab CHANGE COLUMN c2 c22 POINT NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab CHANGE COLUMN c3 c33 LINESTRING NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c22` point NOT NULL,
|
|
`c33` linestring NOT NULL,
|
|
`c44` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
PRIMARY KEY (`c1`),
|
|
SPATIAL KEY `idx2` (`c22`),
|
|
SPATIAL KEY `idx3` (`c33`),
|
|
SPATIAL KEY `idx4` (`c44`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c44`(10)) USING BTREE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
|
tab 1 idx2 1 c22 A # 32 NULL SPATIAL
|
|
tab 1 idx3 1 c33 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c44 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c44 A # 10 NULL BTREE
|
|
ALTER TABLE tab CHANGE COLUMN c22 c2 POINT NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab CHANGE COLUMN c33 c3 LINESTRING NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab CHANGE COLUMN c44 c4 POLYGON NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` point NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
PRIMARY KEY (`c1`),
|
|
SPATIAL KEY `idx2` (`c2`),
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c4`(10)) USING BTREE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
|
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
|
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
|
ALTER TABLE tab DISABLE KEYS;
|
|
Warnings:
|
|
Note 1031 Storage engine InnoDB of the table `test`.`tab` doesn't have this option
|
|
SHOW WARNINGS;
|
|
Level Code Message
|
|
Note 1031 Storage engine InnoDB of the table `test`.`tab` doesn't have this option
|
|
SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))');
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
10 POINT(160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
|
WHERE MBREquals(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
10 POINT(2000 2000) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
|
|
DELETE FROM tab WHERE MBREquals(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
ALTER TABLE tab DROP PRIMARY KEY;
|
|
affected rows: 4
|
|
info: Records: 4 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab ADD PRIMARY KEY(c2) ;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))');
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(3000 3000)')
|
|
WHERE ST_Touches(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
FLUSH TABLE tab FOR EXPORT;
|
|
UNLOCK TABLES;
|
|
ALTER TABLE tab DISCARD TABLESPACE;
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab;
|
|
ERROR HY000: Tablespace has been discarded for table `tab`
|
|
CHECK TABLE tab;
|
|
Table Op Msg_type Msg_text
|
|
test.tab check status OK
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
6 POINT(3 3) POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))
|
|
7 POINT(60 70) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
|
8 POINT(0 0) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
|
9 POINT(120 120) POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))
|
|
SET @g1 = ST_GeomFromText('LINESTRING( 3010 3010,4010 4010,5010 5010)');
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) order by c1;
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
7 POINT(60 70) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
|
8 POINT(0 0) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
|
9 POINT(120 120) POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))
|
|
UPDATE tab SET c2 = ST_GeomFromText('POINT(4000 4000)')
|
|
WHERE MBRIntersects(tab.c4, @g1);
|
|
ERROR 23000: Duplicate entry '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00@\xAF@\x' for key 'PRIMARY'
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
7 POINT(60 70) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
|
8 POINT(0 0) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
|
9 POINT(120 120) POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))
|
|
DELETE FROM tab WHERE MBRIntersects(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
INSERT INTO tab SELECT * FROM tab1;
|
|
ALTER TABLE tab DROP PRIMARY KEY;
|
|
affected rows: 1
|
|
info: Records: 1 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab DROP INDEX idx2;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
|
|
CREATE TEMPORARY TABLE temp_tab AS SELECT * FROM tab where c1 = c2;
|
|
ERROR HY000: Illegal parameter data types int and geometry for operation '='
|
|
SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR
|
|
CREATE TEMPORARY TABLE temp_tab AS SELECT * FROM tab;
|
|
INSERT INTO temp_tab SELECT * FROM tab;
|
|
CREATE SPATIAL INDEX idx2 ON temp_tab(c2);
|
|
CREATE SPATIAL INDEX idx3 ON temp_tab(c3);
|
|
CREATE SPATIAL INDEX idx4 ON temp_tab(c4);
|
|
CREATE SPATIAL INDEX idx5 ON temp_tab(c5);
|
|
SHOW CREATE TABLE temp_tab;
|
|
Table Create Table
|
|
temp_tab CREATE TEMPORARY TABLE `temp_tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` point NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
SPATIAL KEY `idx2` (`c2`),
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`),
|
|
SPATIAL KEY `idx5` (`c5`)
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
|
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
UPDATE temp_tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
|
WHERE MBRContains(temp_tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1);
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
DELETE FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` point NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c4`(10)) USING BTREE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
|
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);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` point NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
PRIMARY KEY (`c2`(25)),
|
|
UNIQUE KEY `const_1` (`c2`(25)),
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c4`(10)) USING BTREE,
|
|
SPATIAL KEY `idx2` (`c2`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 0 PRIMARY 1 c2 A # 25 NULL BTREE
|
|
tab 0 const_1 1 c2 A # 25 NULL BTREE
|
|
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
|
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
|
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))'),
|
|
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
|
|
DELETE FROM tab;
|
|
ALTER TABLE tab DROP PRIMARY KEY ;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab DROP KEY const_1;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab ADD PRIMARY KEY(c5(10));
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c5(10));
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` point NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
PRIMARY KEY (`c5`(10)),
|
|
UNIQUE KEY `const_1` (`c5`(10)),
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c4`(10)) USING BTREE,
|
|
SPATIAL KEY `idx2` (`c2`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 0 PRIMARY 1 c5 A # 10 NULL BTREE
|
|
tab 0 const_1 1 c5 A # 10 NULL BTREE
|
|
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
|
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
|
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))'),
|
|
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
|
|
DROP TABLE tab,tab1,temp_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;
|
|
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))'),
|
|
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(2,ST_GeomFromText('POINT(20 20)'),ST_GeomFromText('LINESTRING(20 20,30 30,40 40)'),
|
|
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'),
|
|
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(3,ST_GeomFromText('POINT(4 4)'),ST_GeomFromText('LINESTRING(130 130,140 140,150 150)'),
|
|
ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'),
|
|
ST_GeomFromText('POLYGON((4 -2,5 -4,6 -5,7 -4,7 2,4 -2))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(4,ST_GeomFromText('POINT(50 50)'),ST_GeomFromText('LINESTRING(200 200,300 300,400 400)'),
|
|
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'),
|
|
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(5,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(400 400,500 500,600 700)'),
|
|
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'),
|
|
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(6,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
|
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'),
|
|
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(7,ST_GeomFromText('POINT(60 70)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
|
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
|
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(8,ST_GeomFromText('POINT(0 0)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
|
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
|
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
|
INSERT INTO tab(c1,c2,c3,c4,c5)
|
|
VALUES(9,ST_GeomFromText('POINT(120 120)'),ST_GeomFromText('LINESTRING(100 100,110 110,120 120)'),
|
|
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'),
|
|
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'));
|
|
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))'));
|
|
ANALYZE TABLE tab;
|
|
Table Op Msg_type Msg_text
|
|
test.tab analyze status OK
|
|
ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC);
|
|
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';
|
|
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';
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab add COLUMN c8 POINT NOT NULL AFTER c5, ALGORITHM = INPLACE, LOCK=NONE;
|
|
ERROR 0A000: LOCK=NONE is not supported. Reason: Do not support online operation on table with GIS index. Try LOCK=SHARED
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` geometry NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
PRIMARY KEY (`c1`),
|
|
SPATIAL KEY `idx2` (`c2`),
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c4`(10)) USING BTREE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
|
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
|
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
|
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
|
WHERE MBRContains(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
3 POINT(1000 1000) POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))
|
|
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
|
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_Astext(c4)
|
|
ALTER TABLE tab MODIFY COLUMN c4 GEOMETRY NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` geometry NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` geometry NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
PRIMARY KEY (`c1`),
|
|
SPATIAL KEY `idx2` (`c2`),
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c4`(10)) USING BTREE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
|
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
|
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
|
ANALYZE TABLE tab;
|
|
Table Op Msg_type Msg_text
|
|
test.tab analyze status OK
|
|
SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))');
|
|
SET @g2 = ST_GeomFromText('LINESTRING(140 140,150 150,160 160)');
|
|
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
|
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
|
10 POINT(160 160) LINESTRING(140 140,150 150,160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
|
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
|
|
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
|
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
|
10 POINT(2000 2000) LINESTRING(140 140,150 150,160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
|
|
DELETE FROM tab WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
|
|
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
|
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
|
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
|
ANALYZE TABLE tab;
|
|
Table Op Msg_type Msg_text
|
|
test.tab analyze status OK
|
|
SET @g1 = ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))');
|
|
SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
|
|
ALTER TABLE tab MODIFY COLUMN c2 POINT NOT NULL;
|
|
affected rows: 8
|
|
info: Records: 8 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab MODIFY COLUMN c3 LINESTRING NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab MODIFY COLUMN c4 POLYGON NOT NULL;
|
|
affected rows: 8
|
|
info: Records: 8 Duplicates: 0 Warnings: 0
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` point NOT NULL,
|
|
`c3` linestring NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
PRIMARY KEY (`c1`),
|
|
SPATIAL KEY `idx2` (`c2`),
|
|
SPATIAL KEY `idx3` (`c3`),
|
|
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
|
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
|
KEY `idx6` (`c4`(10)) USING BTREE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM tab;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
|
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
|
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
|
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
|
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
|
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
|
ANALYZE TABLE tab;
|
|
Table Op Msg_type Msg_text
|
|
test.tab analyze status OK
|
|
SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))');
|
|
SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
|
|
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
|
AND ST_Touches(tab.c3,@g2);
|
|
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
|
WHERE ST_Touches(tab.c4, @g1) AND ST_Touches(tab.c3,@g2);
|
|
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1) AND ST_Touches(tab.c3,@g2);
|
|
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
|
AND ST_Touches(tab.c3,@g2);
|
|
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
|
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
|
OR ST_Touches(tab.c3,@g2);
|
|
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
|
2 POINT(20 20) LINESTRING(20 20,30 30,40 40) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
|
|
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
|
WHERE ST_Touches(tab.c4, @g1) OR ST_Touches(tab.c3,@g2);
|
|
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
|
OR ST_Touches(tab.c3,@g2);
|
|
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
|
2 POINT(2000 2000) LINESTRING(20 20,30 30,40 40) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
|
|
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1) OR ST_Touches(tab.c3,@g2);
|
|
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
|
OR ST_Touches(tab.c3,@g2);
|
|
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
|
ALTER TABLE tab MODIFY COLUMN c4 INT NOT NULL;
|
|
ERROR HY000: Incorrect arguments to SPATIAL INDEX
|
|
ALTER TABLE tab MODIFY COLUMN c4 BLOB NOT NULL;
|
|
ERROR HY000: Incorrect arguments to SPATIAL INDEX
|
|
ALTER TABLE tab ENGINE Myisam;
|
|
ALTER TABLE tab ENGINE InnoDB;
|
|
ANALYZE TABLE tab;
|
|
Table Op Msg_type Msg_text
|
|
test.tab analyze status OK
|
|
SET @g1 = ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))');
|
|
SET @g2 = ST_GeomFromText('LINESTRING(400 400,500 500,600 700)');
|
|
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) AND MBRWithin(tab.c3, @g2);
|
|
c1 ST_AsText(c2) ST_AsText(c3) ST_Astext(c4)
|
|
5 POINT(3 3) LINESTRING(400 400,500 500,600 700) POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))
|
|
SET @g1 = ST_GeomFromText('POINT(2000 2000)');
|
|
SET @g2 = ST_GeomFromText('POINT(2000 2000)');
|
|
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
|
c1 ST_AsText(c2) ST_AsText(c3) ST_Astext(c4)
|
|
DELETE FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
|
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
|
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);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SHOW CREATE TABLE parent;
|
|
Table Create Table
|
|
parent CREATE TABLE `parent` (
|
|
`id` point NOT NULL,
|
|
PRIMARY KEY (`id`(25)),
|
|
SPATIAL KEY `idx1` (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE child;
|
|
Table Create Table
|
|
child CREATE TABLE `child` (
|
|
`id` geometry NOT NULL,
|
|
`parent_id` point NOT NULL,
|
|
SPATIAL KEY `idx2` (`parent_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM parent;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
parent 0 PRIMARY 1 id A 0 25 NULL BTREE
|
|
parent 1 idx1 1 id A NULL 32 NULL SPATIAL
|
|
SHOW INDEX FROM child;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
child 1 idx2 1 parent_id A # 32 NULL SPATIAL
|
|
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ;
|
|
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ON DELETE CASCADE ;
|
|
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) ;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SHOW CREATE TABLE parent;
|
|
Table Create Table
|
|
parent CREATE TABLE `parent` (
|
|
`id` geometry NOT NULL,
|
|
PRIMARY KEY (`id`(10)),
|
|
SPATIAL KEY `idx1` (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW CREATE TABLE child;
|
|
Table Create Table
|
|
child CREATE TABLE `child` (
|
|
`id` geometry NOT NULL,
|
|
`parent_id` geometry NOT NULL,
|
|
SPATIAL KEY `idx2` (`parent_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
SHOW INDEX FROM parent;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
parent 0 PRIMARY 1 id A 0 10 NULL BTREE
|
|
parent 1 idx1 1 id A NULL 32 NULL SPATIAL
|
|
SHOW INDEX FROM child;
|
|
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
|
child 1 idx2 1 parent_id A NULL 32 NULL SPATIAL
|
|
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ;
|
|
DROP table child,parent;
|
|
create table t1 (c1 int) engine=innodb;
|
|
insert into t1 values(NULL);
|
|
alter table t1 add b geometry, add spatial index(b), algorithm=inplace;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
alter table t1 add b geometry not null, add spatial index(b), algorithm=inplace;
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
alter table t1 add b geometry not null default st_geomfromtext('POINT(0 0)'),
|
|
add spatial index(b), algorithm=inplace;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
DROP table t1;
|
|
create table t1 (c1 int) engine=innodb;
|
|
insert into t1 values(NULL);
|
|
alter table t1 add b geometry, add spatial index(b), algorithm=copy;
|
|
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
|
alter table t1 add b geometry not null, add spatial index(b), algorithm=copy;
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
alter table t1 add b geometry not null default st_geomfromtext('POINT(0 0)'),
|
|
add spatial index(b), algorithm=copy;
|
|
DROP table t1;
|
|
#
|
|
# BUG#20111575 ALTER TABLE...ADD SPATIAL INDEX...LOCK NONE IS REFUSED
|
|
# WITHOUT STATING A REASON
|
|
#
|
|
CREATE TABLE t1(p point NOT NULL) ENGINE=innodb;
|
|
ALTER TABLE t1 ADD SPATIAL INDEX(p), LOCK=NONE;
|
|
ERROR 0A000: LOCK=NONE is not supported. Reason: Do not support online operation on table with GIS index. Try LOCK=SHARED
|
|
ALTER TABLE t1 ADD SPATIAL INDEX(p);
|
|
ALTER TABLE t1 FORCE, LOCK=NONE;
|
|
ERROR 0A000: LOCK=NONE is not supported. Reason: Do not support online operation on table with GIS index. Try LOCK=SHARED
|
|
DROP TABLE t1;
|