Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mysql-test/suite/parts/t/mdev_41989.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE TABLE t1 (id INT PRIMARY KEY, a INT) ENGINE=MyISAM PARTITION BY HASH (id) PARTITIONS 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this test into the relevant partitioning suite and pick a file to put it in that's testing similar things.
Or keep it in a separate file, but prefix it with

--echo # 
--echo # MDEV-41989: Fix duplicate key error code on cross-partition update - #6049
--echo #

And suffix it with

--echo End of 11.4 tests

Also, make sure to use the following at the top (as the rest of the part suite files do):

# The server must support partitioning.
--source include/have_partition.inc

INSERT INTO t1 VALUES (1, 1), (2, 2);
--error ER_DUP_ENTRY
UPDATE t1 SET id = 2 WHERE id = 1;
DROP TABLE t1;
10 changes: 7 additions & 3 deletions sql/ha_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ void ha_partition::init_handler_variables()
m_top_entry= NO_CURRENT_PART_ID;
m_rec_length= 0;
m_last_part= 0;
m_err_part= NO_CURRENT_PART_ID;
m_err_rec= NULL;
m_curr_key_info[0]= NULL;
m_curr_key_info[1]= NULL;
Expand Down Expand Up @@ -4715,15 +4716,18 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data)
goto exit;
}


uint32 saved_last_part= m_last_part;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to the top of the function to fix the following compile error:

/home/buildbot/aarch64-debian-12/build/sql/ha_partition.cc: In member function ‘virtual int ha_partition::update_row(const uchar*, const uchar*)’:
/home/buildbot/aarch64-debian-12/build/sql/ha_partition.cc:4759:1: error: jump to label ‘exit’
 4759 | exit:
      | ^~~~
/home/buildbot/aarch64-debian-12/build/sql/ha_partition.cc:4716:10: note:   from here
 4716 |     goto exit;
      |          ^~~~
/home/buildbot/aarch64-debian-12/build/sql/ha_partition.cc:4719:10: note:   crosses initialization of ‘uint32 saved_last_part’
 4719 |   uint32 saved_last_part= m_last_part;
      |          ^~~~~~~~~~~~~~~
/home/buildbot/aarch64-debian-12/build/sql/ha_partition.cc:4759:1: error: jump to label ‘exit’
 4759 | exit:
      | ^~~~
/home/buildbot/aarch64-debian-12/build/sql/ha_partition.cc:4712:10: note:   from here
 4712 |     goto exit;
      |          ^~~~
/home/buildbot/aarch64-debian-12/build/sql/ha_partition.cc:4719:10: note:   crosses initialization of ‘uint32 saved_last_part’
 4719 |   uint32 saved_last_part= m_last_part;
      |          ^~~~~~~~~~~~~~~
make[2]: *** [sql/CMakeFiles/partition.dir/build.make:76: sql/CMakeFiles/partition.dir/ha_partition.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:11024: sql/CMakeFiles/partition.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

start_part_bulk_insert(thd, new_part_id);
DBUG_ASSERT(!m_file[new_part_id]->row_logging);
if (new_part_id == old_part_id)
DBUG_ASSERT(m_file[new_part_id]->row_logging);
if (new_part_id != old_part_id)
{
DBUG_PRINT("info", ("Update in partition %u", (uint) new_part_id));
error= m_file[new_part_id]->ha_update_row(old_data, new_data);
if (error)
m_last_part= saved_last_part;
goto exit;
}

else
{
Field *saved_next_number_field= table->next_number_field;
Expand Down
1 change: 1 addition & 0 deletions sql/ha_partition.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ class ha_partition final :public handler
uint m_tot_parts; // Total number of partitions;
uint m_num_locks; // For engines like ha_blackhole, which needs no locks
uint m_last_part; // Last file that we update,write,read
uint m_err_part; // Partition where last error occurred
part_id_range m_part_spec; // Which parts to scan
uint m_scan_value; // Value passed in rnd_init
// call
Expand Down