summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2021-12-23 12:50:00 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2021-12-24 14:40:52 +0530
commit9f2a6bbe6ba03ca5297cd37b75301d05eb44e044 (patch)
tree8cc0afb6b482cc0348d981c3f4fcdddbc80a15c2
parent1b8f0d4b674dd7f9414778054ef714f0fed71ccc (diff)
downloadmariadb-git-bb-10.7-MDEV-27316.tar.gz
MDEV-27316 Assertion `!(index)->is_spatial()' failedbb-10.7-MDEV-27316
This issue is caused by MDEV-24621 (commit 045757af4c301757ba449269351cc27b1691a7d6). 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.
-rw-r--r--mysql-test/suite/innodb/r/insert_into_empty.result9
-rw-r--r--mysql-test/suite/innodb/t/insert_into_empty.test9
-rw-r--r--storage/innobase/include/dict0mem.h7
-rw-r--r--storage/innobase/row/row0ins.cc11
-rw-r--r--storage/innobase/row/row0merge.cc12
5 files changed, 38 insertions, 10 deletions
diff --git a/mysql-test/suite/innodb/r/insert_into_empty.result b/mysql-test/suite/innodb/r/insert_into_empty.result
index f33bef890fd..31bf91595e7 100644
--- a/mysql-test/suite/innodb/r/insert_into_empty.result
+++ b/mysql-test/suite/innodb/r/insert_into_empty.result
@@ -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;
diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test
index 7719ae68d7b..bfcf96d854c 100644
--- a/mysql-test/suite/innodb/t/insert_into_empty.test
+++ b/mysql-test/suite/innodb/t/insert_into_empty.test
@@ -1,4 +1,5 @@
--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;
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index 919dd48a032..744ef5316ef 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -1184,6 +1184,13 @@ public:
/** @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; }
diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc
index c2c87cf3a78..711a2ff02d5 100644
--- a/storage/innobase/row/row0ins.cc
+++ b/storage/innobase/row/row0ins.cc
@@ -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()) {
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 4a5b8ffb271..f693a9ec96e 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -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);