MDEV-27316 Assertion `!(index)->is_spatial()' failed

  This issue is caused by MDEV-24621
(commit 045757af).
InnoDB tries to insert the number of rows into an empty spatial
index table, but it fails to apply the buffered insert.
InnoDB should insert into the spatial index directly instead of
buffering the insert operation.
parent 1b8f0d4b
......@@ -222,3 +222,12 @@ ALTER TABLE t1 ADD COLUMN row_start BIGINT UNSIGNED AS ROW START,
ADD COLUMN row_end BIGINT UNSIGNED AS ROW END,
ADD PERIOD FOR SYSTEM_TIME(row_start,row_end), WITH SYSTEM VERSIONING;
DROP TABLE t1;
#
# MDEV-27316 Assertion `!(index)->is_spatial()' failed.
#
CREATE TABLE t (c POINT NOT NULL, SPATIAL INDEX(c)) ENGINE=InnoDB;
INSERT INTO t VALUES (POINT(1, 1));
SELECT COUNT(*) FROM t WHERE MBRWithin(t.c, POINT(1,1));
COUNT(*)
1
DROP TABLE t;
--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/maybe_debug.inc
--source include/have_partition.inc
......@@ -233,3 +234,11 @@ ALTER TABLE t1 ADD COLUMN row_start BIGINT UNSIGNED AS ROW START,
ADD COLUMN row_end BIGINT UNSIGNED AS ROW END,
ADD PERIOD FOR SYSTEM_TIME(row_start,row_end), WITH SYSTEM VERSIONING;
DROP TABLE t1;
--echo #
--echo # MDEV-27316 Assertion `!(index)->is_spatial()' failed.
--echo #
CREATE TABLE t (c POINT NOT NULL, SPATIAL INDEX(c)) ENGINE=InnoDB;
INSERT INTO t VALUES (POINT(1, 1));
SELECT COUNT(*) FROM t WHERE MBRWithin(t.c, POINT(1,1));
DROP TABLE t;
......@@ -1184,6 +1184,13 @@ struct dict_index_t {
/** @return whether this is the change buffer */
bool is_ibuf() const { return UNIV_UNLIKELY(type & DICT_IBUF); }
/** @return whether this is a normal B-tree index
(not the change buffer, not SPATIAL or FULLTEXT) */
bool is_btree() const {
return UNIV_LIKELY(!(type & (DICT_IBUF | DICT_SPATIAL
| DICT_FTS | DICT_CORRUPT)));
}
/** @return whether the index includes virtual columns */
bool has_virtual() const { return type & DICT_VIRTUAL; }
......
......@@ -3370,10 +3370,13 @@ row_ins_index_entry(
DBUG_SET("-d,row_ins_index_entry_timeout");
return(DB_LOCK_WAIT);});
if (auto t= trx->check_bulk_buffer(index->table)) {
/* MDEV-25036 FIXME: check also foreign key constraints */
ut_ad(!trx->check_foreigns);
return t->bulk_insert_buffered(*entry, *index, trx);
if (index->is_btree()) {
if (auto t= trx->check_bulk_buffer(index->table)) {
/* MDEV-25036 FIXME: check also foreign key
constraints */
ut_ad(!trx->check_foreigns);
return t->bulk_insert_buffered(*entry, *index, trx);
}
}
if (index->is_primary()) {
......
......@@ -4986,7 +4986,7 @@ row_merge_bulk_t::row_merge_bulk_t(dict_table_t *table)
for (dict_index_t *index= UT_LIST_GET_FIRST(table->indexes);
index; index= UT_LIST_GET_NEXT(indexes, index))
{
if (index->type & DICT_FTS)
if (!index->is_btree())
continue;
n_index++;
}
......@@ -4998,7 +4998,7 @@ row_merge_bulk_t::row_merge_bulk_t(dict_table_t *table)
for (dict_index_t *index= UT_LIST_GET_FIRST(table->indexes);
index; index= UT_LIST_GET_NEXT(indexes, index))
{
if (index->type & DICT_FTS)
if (!index->is_btree())
continue;
mem_heap_t *heap= mem_heap_create(100);
......@@ -5019,7 +5019,7 @@ row_merge_bulk_t::~row_merge_bulk_t()
for (dict_index_t *index= UT_LIST_GET_FIRST(table->indexes);
index; index= UT_LIST_GET_NEXT(indexes, index))
{
if (index->type & DICT_FTS)
if (!index->is_btree())
continue;
row_merge_buf_free(&m_merge_buf[i]);
if (m_merge_files)
......@@ -5049,7 +5049,7 @@ void row_merge_bulk_t::init_tmp_file()
for (dict_index_t *index= UT_LIST_GET_FIRST(table->indexes);
index; index= UT_LIST_GET_NEXT(indexes, index))
{
if (index->type & DICT_FTS)
if (!index->is_btree())
continue;
n_index++;
}
......@@ -5112,7 +5112,7 @@ dberr_t row_merge_bulk_t::bulk_insert_buffered(const dtuple_t &row,
for (dict_index_t *index= UT_LIST_GET_FIRST(ind.table->indexes);
index; index= UT_LIST_GET_NEXT(indexes, index))
{
if (index->type & DICT_FTS)
if (!index->is_btree())
continue;
if (index != &ind)
......@@ -5210,7 +5210,7 @@ dberr_t row_merge_bulk_t::write_to_table(dict_table_t *table, trx_t *trx)
for (dict_index_t *index= UT_LIST_GET_FIRST(table->indexes);
index; index= UT_LIST_GET_NEXT(indexes, index))
{
if (index->type & DICT_FTS)
if (!index->is_btree())
continue;
dberr_t err= write_to_index(i, trx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment