Skip to content

Commit

Permalink
MDEV-33731 Only iterate over m_locked_partitions in update_next_auto_…
Browse files Browse the repository at this point in the history
…inc_val()

Only locked will participate in the query in this case. Chances are
that not-locked partitions were not opened, which is the cause of the
crash in the added test case spider/bugfix.mdev_33731 without this
patch.
  • Loading branch information
mariadb-YuchenPei committed Apr 8, 2024
1 parent 7e3090a commit b7b58a2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sql/ha_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10753,18 +10753,19 @@ int ha_partition::update_next_auto_inc_val()

bool ha_partition::need_info_for_auto_inc()
{
handler **file= m_file;
DBUG_ENTER("ha_partition::need_info_for_auto_inc");

do
for (uint i= bitmap_get_first_set(&m_locked_partitions);
i < m_tot_parts;
i= bitmap_get_next_set(&m_locked_partitions, i))
{
if ((*file)->need_info_for_auto_inc())
if ((m_file[i])->need_info_for_auto_inc())
{
/* We have to get new auto_increment values from handler */
part_share->auto_inc_initialized= FALSE;
DBUG_RETURN(TRUE);
}
} while (*(++file));
}
DBUG_RETURN(FALSE);
}

Expand Down
10 changes: 10 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/r/mdev_33731.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
for master_1
for child2
for child3
CREATE TABLE t (a INT) ENGINE=Spider PARTITION BY LIST (a) PARTITIONS 2 (PARTITION p1 VALUES IN (0,1),PARTITION p2 VALUES IN (2,3));
DELETE FROM t PARTITION (p2);
ERROR HY000: Unable to connect to foreign data source: localhost
drop table t;
for master_1
for child2
for child3
16 changes: 16 additions & 0 deletions storage/spider/mysql-test/spider/bugfix/t/mdev_33731.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log

CREATE TABLE t (a INT) ENGINE=Spider PARTITION BY LIST (a) PARTITIONS 2 (PARTITION p1 VALUES IN (0,1),PARTITION p2 VALUES IN (2,3));
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
DELETE FROM t PARTITION (p2);
drop table t;

--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log

0 comments on commit b7b58a2

Please sign in to comment.