Skip to content

Commit 20ae481

Browse files
committed
MDEV-28478: INSERT into SPATIAL INDEX in TEMPORARY table writes log
row_ins_sec_index_entry_low(): If a separate mini-transaction is needed to adjust the minimum bounding rectangle (MBR) in the parent page, we must disable redo logging if the table is a temporary table. For temporary tables, no log is supposed to be written, because the temporary tablespace will be reinitialized on server restart. rtr_update_mbr_field(): Plug a memory leak.
1 parent 84e32ef commit 20ae481

File tree

6 files changed

+41
-19
lines changed

6 files changed

+41
-19
lines changed

mysql-test/suite/innodb_gis/r/rtree_split.result

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,3 @@ select count(*) from t1 where MBRWithin(t1.c2, @g1);
6161
count(*)
6262
57344
6363
drop table t1;
64-
#
65-
# MDEV-27417 Spatial index tries to update
66-
# change buffer bookkeeping page
67-
#
68-
CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB;
69-
INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366;
70-
DROP TABLE t1;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# MDEV-27417 Spatial index tries to update
3+
# change buffer bookkeeping page
4+
#
5+
CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB;
6+
INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366;
7+
DROP TABLE t1;
8+
#
9+
# MDEV-28478 Assertion mtr->get_log_mode() == MTR_LOG_NO_REDO
10+
#
11+
CREATE TEMPORARY TABLE t1 (c POINT NOT NULL,SPATIAL (c)) ENGINE=InnoDB;
12+
INSERT INTO t1 SELECT POINT(0,0) FROM seq_1_to_366;
13+
INSERT INTO t1 VALUES (POINT(1e-270,1e-130));
14+
DROP TABLE t1;

mysql-test/suite/innodb_gis/t/rtree_split.test

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,3 @@ select count(*) from t1 where MBRWithin(t1.c2, @g1);
7272

7373
# Clean up.
7474
drop table t1;
75-
76-
--echo #
77-
--echo # MDEV-27417 Spatial index tries to update
78-
--echo # change buffer bookkeeping page
79-
--echo #
80-
CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB;
81-
INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366;
82-
DROP TABLE t1;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--source include/have_innodb.inc
2+
--source include/have_sequence.inc
3+
4+
--echo #
5+
--echo # MDEV-27417 Spatial index tries to update
6+
--echo # change buffer bookkeeping page
7+
--echo #
8+
CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB;
9+
INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366;
10+
DROP TABLE t1;
11+
12+
--echo #
13+
--echo # MDEV-28478 Assertion mtr->get_log_mode() == MTR_LOG_NO_REDO
14+
--echo #
15+
CREATE TEMPORARY TABLE t1 (c POINT NOT NULL,SPATIAL (c)) ENGINE=InnoDB;
16+
INSERT INTO t1 SELECT POINT(0,0) FROM seq_1_to_366;
17+
INSERT INTO t1 VALUES (POINT(1e-270,1e-130));
18+
DROP TABLE t1;

storage/innobase/gis/gis0rtree.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2019, 2020, MariaDB Corporation.
4+
Copyright (c) 2019, 2022, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -376,6 +376,7 @@ rtr_update_mbr_field(
376376

377377
if (!rtr_update_mbr_field_in_place(index, rec,
378378
offsets, mbr, mtr)) {
379+
mem_heap_free(heap);
379380
return(false);
380381
}
381382

storage/innobase/row/row0ins.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2016, 2021, MariaDB Corporation.
4+
Copyright (c) 2016, 2022, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -2900,8 +2900,12 @@ row_ins_sec_index_entry_low(
29002900
rtr_init_rtr_info(&rtr_info, false, &cursor,
29012901
index, false);
29022902
rtr_info_update_btr(&cursor, &rtr_info);
2903-
mtr_start(&mtr);
2904-
mtr.set_named_space(index->space);
2903+
mtr.start();
2904+
if (index->table->is_temporary()) {
2905+
mtr.set_log_mode(MTR_LOG_NO_REDO);
2906+
} else {
2907+
mtr.set_named_space(index->space);
2908+
}
29052909
search_mode &= ulint(~BTR_MODIFY_LEAF);
29062910
search_mode |= BTR_MODIFY_TREE;
29072911
err = btr_cur_search_to_nth_level(

0 commit comments

Comments
 (0)