mirror of
https://github.com/MariaDB/server.git
synced 2025-11-12 10:22:39 +03:00
Allow ADD COLUMN anywhere in a table, not only adding as the last column. Allow instant DROP COLUMN and instant changing the order of columns. The added columns will always be added last in clustered index records. In new records, instantly dropped columns will be stored as NULL or empty when possible. Information about dropped and reordered columns will be written in a metadata BLOB (mblob), which is stored before the first 'user' field in the hidden metadata record at the start of the clustered index. The presence of mblob is indicated by setting the delete-mark flag in the metadata record. The metadata BLOB stores the number of clustered index fields, followed by an array of column information for each field. For dropped columns, we store the NOT NULL flag, the fixed length, and for variable-length columns, whether the maximum length exceeded 255 bytes. For non-dropped columns, we store the column position. Unlike with MDEV-11369, when a table becomes empty, it cannot be converted back to the canonical format. The reason for this is that other threads may hold cached objects such as row_prebuilt_t::ins_node that could refer to dropped or reordered index fields. For instant DROP COLUMN and ROW_FORMAT=COMPACT or ROW_FORMAT=DYNAMIC, we must store the n_core_null_bytes in the root page, so that the chain of node pointer records can be followed in order to reach the leftmost leaf page where the metadata record is located. If the mblob is present, we will zero-initialize the strings "infimum" and "supremum" in the root page, and use the last byte of "supremum" for storing the number of null bytes (which are allocated but useless on node pointer pages). This is necessary for btr_cur_instant_init_metadata() to be able to navigate to the mblob. If the PRIMARY KEY contains any variable-length column and some nullable columns were instantly dropped, the dict_index_t::n_nullable in the data dictionary could be smaller than it actually is in the non-leaf pages. Because of this, the non-leaf pages could use more bytes for the null flags than the data dictionary expects, and we could be reading the lengths of the variable-length columns from the wrong offset, and thus reading the child page number from wrong place. This is the result of two design mistakes that involve unnecessary storage of data: First, it is nonsense to store any data fields for the leftmost node pointer records, because the comparisons would be resolved by the MIN_REC_FLAG alone. Second, there cannot be any null fields in the clustered index node pointer fields, but we nevertheless reserve space for all the null flags. Limitations (future work): MDEV-17459 Allow instant ALTER TABLE even if FULLTEXT INDEX exists MDEV-17468 Avoid table rebuild on operations on generated columns MDEV-17494 Refuse ALGORITHM=INSTANT when the row size is too large btr_page_reorganize_low(): Preserve any metadata in the root page. Call lock_move_reorganize_page() only after restoring the "infimum" and "supremum" records, to avoid a memcmp() assertion failure. dict_col_t::DROPPED: Magic value for dict_col_t::ind. dict_col_t::clear_instant(): Renamed from dict_col_t::remove_instant(). Do not assert that the column was instantly added, because we sometimes call this unconditionally for all columns. Convert an instantly added column to a "core column". The old name remove_instant() could be mistaken to refer to "instant DROP COLUMN". dict_col_t::is_added(): Rename from dict_col_t::is_instant(). dtype_t::metadata_blob_init(): Initialize the mblob data type. dtuple_t::is_metadata(), dtuple_t::is_alter_metadata(), upd_t::is_metadata(), upd_t::is_alter_metadata(): Check if info_bits refer to a metadata record. dict_table_t::instant: Metadata about dropped or reordered columns. dict_table_t::prepare_instant(): Prepare ha_innobase_inplace_ctx::instant_table for instant ALTER TABLE. innobase_instant_try() will pass this to dict_table_t::instant_column(). On rollback, dict_table_t::rollback_instant() will be called. dict_table_t::instant_column(): Renamed from instant_add_column(). Add the parameter col_map so that columns can be reordered. Copy and adjust v_cols[] as well. dict_table_t::find(): Find an old column based on a new column number. dict_table_t::serialise_columns(), dict_table_t::deserialise_columns(): Convert the mblob. dict_index_t::instant_metadata(): Create the metadata record for instant ALTER TABLE. Invoke dict_table_t::serialise_columns(). dict_index_t::reconstruct_fields(): Invoked by dict_table_t::deserialise_columns(). dict_index_t::clear_instant_alter(): Move the fields for the dropped columns to the end, and sort the surviving index fields in ascending order of column position. ha_innobase::check_if_supported_inplace_alter(): Do not allow adding a FTS_DOC_ID column if a hidden FTS_DOC_ID column exists due to FULLTEXT INDEX. (This always required ALGORITHM=COPY.) instant_alter_column_possible(): Add a parameter for InnoDB table, to check for additional conditions, such as the maximum number of index fields. ha_innobase_inplace_ctx::first_alter_pos: The first column whose position is affected by instant ADD, DROP, or changing the order of columns. innobase_build_col_map(): Skip added virtual columns. prepare_inplace_add_virtual(): Correctly compute num_to_add_vcol. Remove some unnecessary code. Note that the call to innodb_base_col_setup() should be executed later. commit_try_norebuild(): If ctx->is_instant(), let the virtual columns be added or dropped by innobase_instant_try(). innobase_instant_try(): Fill in a zero default value for the hidden column FTS_DOC_ID (to reduce the work needed in MDEV-17459). If any columns were dropped or reordered (or added not last), delete any SYS_COLUMNS records for the following columns, and insert SYS_COLUMNS records for all subsequent stored columns as well as for all virtual columns. If any virtual column is dropped, rewrite all virtual column metadata. Use a shortcut only for adding virtual columns. This is because innobase_drop_virtual_try() assumes that the dropped virtual columns still exist in ctx->old_table. innodb_update_cols(): Renamed from innodb_update_n_cols(). innobase_add_one_virtual(), innobase_insert_sys_virtual(): Change the return type to bool, and invoke my_error() when detecting an error. innodb_insert_sys_columns(): Insert a record into SYS_COLUMNS. Refactored from innobase_add_one_virtual() and innobase_instant_add_col(). innobase_instant_add_col(): Replace the parameter dfield with type. innobase_instant_drop_cols(): Drop matching columns from SYS_COLUMNS and all columns from SYS_VIRTUAL. innobase_add_virtual_try(), innobase_drop_virtual_try(): Let the caller invoke innodb_update_cols(). innobase_rename_column_try(): Skip dropped columns. commit_cache_norebuild(): Update table->fts->doc_col. dict_mem_table_col_rename_low(): Skip dropped columns. trx_undo_rec_get_partial_row(): Skip dropped columns. trx_undo_update_rec_get_update(): Handle the metadata BLOB correctly. trx_undo_page_report_modify(): Avoid out-of-bounds access to record fields. Log metadata records consistently. Apparently, the first fields of a clustered index may be updated in an update_undo vector when the index is ID_IND of SYS_FOREIGN, as part of renaming the table during ALTER TABLE. Normally, updates of the PRIMARY KEY should be logged as delete-mark and an insert. row_undo_mod_parse_undo_rec(), row_purge_parse_undo_rec(): Use trx_undo_metadata. row_undo_mod_clust_low(): On metadata rollback, roll back the root page too. row_undo_mod_clust(): Relax an assertion. The delete-mark flag was repurposed for ALTER TABLE metadata records. row_rec_to_index_entry_impl(): Add the template parameter mblob and the optional parameter info_bits for specifying the desired new info bits. For the metadata tuple, allow conversion between the original format (ADD COLUMN only) and the generic format (with hidden BLOB). Add the optional parameter "pad" to determine whether the tuple should be padded to the index fields (on ALTER TABLE it should), or whether it should remain at its original size (on rollback). row_build_index_entry_low(): Clean up the code, removing redundant variables and conditions. For instantly dropped columns, generate a dummy value that is NULL, the empty string, or a fixed length of NUL bytes, depending on the type of the dropped column. row_upd_clust_rec_by_insert_inherit_func(): On the update of PRIMARY KEY of a record that contained a dropped column whose value was stored externally, we will be inserting a dummy NULL or empty string value to the field of the dropped column. The externally stored column would eventually be dropped when purge removes the delete-marked record for the old PRIMARY KEY value. btr_index_rec_validate(): Recognize the metadata record. btr_discard_only_page_on_level(): Preserve the generic instant ALTER TABLE metadata. btr_set_instant(): Replaces page_set_instant(). This sets a clustered index root page to the appropriate format, or upgrades from the MDEV-11369 instant ADD COLUMN to generic ALTER TABLE format. btr_cur_instant_init_low(): Read and validate the metadata BLOB page before reconstructing the dictionary information based on it. btr_cur_instant_init_metadata(): Do not read any lengths from the metadata record header before reading the BLOB. At this point, we would not actually know how many nullable fields the metadata record contains. btr_cur_instant_root_init(): Initialize n_core_null_bytes in one of two possible ways. btr_cur_trim(): Handle the mblob record. row_metadata_to_tuple(): Convert a metadata record to a data tuple, based on the new info_bits of the metadata record. btr_cur_pessimistic_update(): Invoke row_metadata_to_tuple() if needed. Invoke dtuple_convert_big_rec() for metadata records if the record is too large, or if the mblob is not yet marked as externally stored. btr_cur_optimistic_delete_func(), btr_cur_pessimistic_delete(): When the last user record is deleted, do not delete the generic instant ALTER TABLE metadata record. Only delete MDEV-11369 instant ADD COLUMN metadata records. btr_cur_optimistic_insert(): Avoid unnecessary computation of rec_size. btr_pcur_store_position(): Allow a logically empty page to contain a metadata record for generic ALTER TABLE. REC_INFO_DEFAULT_ROW_ADD: Renamed from REC_INFO_DEFAULT_ROW. This is for the old instant ADD COLUMN (MDEV-11369) only. REC_INFO_DEFAULT_ROW_ALTER: The more generic metadata record, with additional information for dropped or reordered columns. rec_info_bits_valid(): Remove. The only case when this would fail is when the record is the generic ALTER TABLE metadata record. rec_is_alter_metadata(): Check if a record is the metadata record for instant ALTER TABLE (other than ADD COLUMN). NOTE: This function must not be invoked on node pointer records, because the delete-mark flag in those records may be set (it is garbage), and then a debug assertion could fail because index->is_instant() does not necessarily hold. rec_is_add_metadata(): Check if a record is MDEV-11369 ADD COLUMN metadata record (not more generic instant ALTER TABLE). rec_get_converted_size_comp_prefix_low(): Assume that the metadata field will be stored externally. In dtuple_convert_big_rec() during the rec_get_converted_size() call, it would not be there yet. rec_get_converted_size_comp(): Replace status,fields,n_fields with tuple. rec_init_offsets_comp_ordinary(), rec_get_converted_size_comp_prefix_low(), rec_convert_dtuple_to_rec_comp(): Add template<bool mblob = false>. With mblob=true, process a record with a metadata BLOB. rec_copy_prefix_to_buf(): Assert that no fields beyond the key and system columns are being copied. Exclude the metadata BLOB field. rec_convert_dtuple_to_metadata_comp(): Convert an alter metadata tuple into a record. row_upd_index_replace_metadata(): Apply an update vector to an alter_metadata tuple. row_log_allocate(): Replace dict_index_t::is_instant() with a more appropriate condition that ignores dict_table_t::instant. Only a table on which the MDEV-11369 ADD COLUMN was performed can "lose its instantness" when it becomes empty. After instant DROP COLUMN or reordering columns, we cannot simply convert the table to the canonical format, because the data dictionary cache and all possibly existing references to it from other client connection threads would have to be adjusted. row_quiesce_write_index_fields(): Do not crash when the table contains an instantly dropped column. Thanks to Thirunarayanan Balathandayuthapani for discussing the design and implementing an initial prototype of this. Thanks to Matthias Leich for testing.
805 lines
38 KiB
Plaintext
805 lines
38 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 MODIFY COLUMN c3 POLYGON NOT NULL;
|
|
affected rows: 10
|
|
info: Records: 10 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
ALTER TABLE tab add COLUMN c8 POINT NOT NULL, ALGORITHM = INPLACE, LOCK=NONE;
|
|
SELECT HEX(c8) FROM tab;
|
|
HEX(c8)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN;
|
|
INSERT INTO tab SELECT 0,c2,c3,c4,c5,
|
|
ST_GeomFromText('POINT(67 89)'),ST_GeomFromText('POINT(67 89)')
|
|
FROM tab LIMIT 1;
|
|
SELECT HEX(c8) FROM tab;
|
|
HEX(c8)
|
|
0000000001010000000000000000C050400000000000405640
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ROLLBACK;
|
|
ALTER TABLE tab add COLUMN c9 POINT NOT NULL AFTER c5, ALGORITHM = INPLACE, LOCK=NONE;
|
|
ALTER TABLE tab DROP COLUMN c9, ALGORITHM=INSTANT;
|
|
SHOW CREATE TABLE tab;
|
|
Table Create Table
|
|
tab CREATE TABLE `tab` (
|
|
`c1` int(11) NOT NULL,
|
|
`c2` geometry NOT NULL,
|
|
`c3` polygon NOT NULL,
|
|
`c4` polygon NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
`c7` point NOT NULL,
|
|
`c8` point 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` polygon NOT NULL,
|
|
`c4` geometry NOT NULL,
|
|
`c5` geometry NOT NULL,
|
|
`c7` point NOT NULL,
|
|
`c8` point 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: 8
|
|
info: Records: 8 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,
|
|
`c7` point NOT NULL,
|
|
`c8` point 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;
|
|
create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),LineString(Point(0,0),Point(1,1)))) ENGINE=innodb;
|
|
set timestamp=10;
|
|
insert into t1 values(default);
|
|
ERROR 22007: Incorrect POINT value: 'GEOMETRYCOLLECTION' for column 'p' at row 1
|
|
drop table t1;
|
|
SET timestamp=default;
|
|
create table t1 (p point not null default if(unix_timestamp()>10,POINT(1,1),LineString(Point(0,0),Point(1,1)))) ENGINE=innodb;
|
|
set timestamp=10;
|
|
alter table t1 add column i int;
|
|
ERROR 22007: Incorrect POINT value: 'GEOMETRYCOLLECTION' for column 'p' at row 1
|
|
drop table t1;
|
|
SET timestamp=default;
|
|
CREATE OR REPLACE TABLE t1 (a INT) ENGINE=InnoDB;
|
|
ALTER TABLE t1 ADD COLUMN b POINT DEFAULT '0';
|
|
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
|
DROP TABLE t1;
|