Skip to content

Commit 0515577

Browse files
committed
cleanup: prepare "update_handler" for WITHOUT OVERLAPS
* rename to a generic name * move remaning initializations from query exec to prepare time * simplify/unify key handling in open_table_from_share and delayed * remove dead code * move tests where they belong
1 parent 045510c commit 0515577

17 files changed

+200
-274
lines changed

mysql-test/main/long_unique.result

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,13 +1492,4 @@ DROP TABLE t1, t2;
14921492
#
14931493
CREATE TABLE t1 (pk INT, a TEXT NOT NULL DEFAULT '', PRIMARY KEY (pk), b INT AUTO_INCREMENT, UNIQUE(b), UNIQUE (a,b)) ENGINE=myisam;
14941494
ERROR HY000: AUTO_INCREMENT column `b` cannot be used in the UNIQUE index `a`
1495-
#
1496-
# MDEV-21819 Assertion `inited == NONE || update_handler != this'
1497-
# failed in handler::ha_write_row
1498-
#
1499-
CREATE OR REPLACE TABLE t1 (a INT, b BLOB, s DATE, e DATE, PERIOD FOR app(s,e), UNIQUE(b)) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
1500-
INSERT INTO t1 VALUES (1,'foo','2022-01-01', '2025-01-01');
1501-
DELETE FROM t1 FOR PORTION OF app FROM '2023-01-01' TO '2024-01-01';
1502-
ERROR 23000: Duplicate entry 'foo' for key 'b'
1503-
DROP TABLE t1;
15041495
set @@GLOBAL.max_allowed_packet= @allowed_packet;

mysql-test/main/long_unique.test

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -573,16 +573,5 @@ DROP TABLE t1, t2;
573573
--error ER_NO_AUTOINCREMENT_WITH_UNIQUE
574574
CREATE TABLE t1 (pk INT, a TEXT NOT NULL DEFAULT '', PRIMARY KEY (pk), b INT AUTO_INCREMENT, UNIQUE(b), UNIQUE (a,b)) ENGINE=myisam;
575575

576-
--echo #
577-
--echo # MDEV-21819 Assertion `inited == NONE || update_handler != this'
578-
--echo # failed in handler::ha_write_row
579-
--echo #
580-
581-
CREATE OR REPLACE TABLE t1 (a INT, b BLOB, s DATE, e DATE, PERIOD FOR app(s,e), UNIQUE(b)) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
582-
INSERT INTO t1 VALUES (1,'foo','2022-01-01', '2025-01-01');
583-
--error ER_DUP_ENTRY
584-
DELETE FROM t1 FOR PORTION OF app FROM '2023-01-01' TO '2024-01-01';
585-
DROP TABLE t1;
586-
587576
# Cleanup
588577
set @@GLOBAL.max_allowed_packet= @allowed_packet;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Assertion `inited == NONE || update_handler != this' failed in
3+
# handler::ha_write_row
4+
#
5+
CREATE TABLE t1 (f VARCHAR(4096), s DATE, e DATE, PERIOD FOR app(s,e), UNIQUE(f)) ENGINE=MyISAM;
6+
INSERT INTO t1 VALUES ('foo', '2023-08-30', '2025-07-09'),('bar', '2021-01-01', '2021-12-31');
7+
DELETE FROM t1 FOR PORTION OF app FROM '2023-08-29' TO '2025-07-01';
8+
DROP TABLE t1;
9+
#
10+
# MDEV-21819 Assertion `inited == NONE || update_handler != this'
11+
# failed in handler::ha_write_row
12+
#
13+
CREATE OR REPLACE TABLE t1 (a INT, b BLOB, s DATE, e DATE, PERIOD FOR app(s,e), UNIQUE(b)) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
14+
INSERT INTO t1 VALUES (1,'foo','2022-01-01', '2025-01-01');
15+
DELETE FROM t1 FOR PORTION OF app FROM '2023-01-01' TO '2024-01-01';
16+
ERROR 23000: Duplicate entry 'foo' for key 'b'
17+
DROP TABLE t1;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--source include/have_partition.inc
2+
3+
--echo #
4+
--echo # Assertion `inited == NONE || update_handler != this' failed in
5+
--echo # handler::ha_write_row
6+
--echo #
7+
8+
CREATE TABLE t1 (f VARCHAR(4096), s DATE, e DATE, PERIOD FOR app(s,e), UNIQUE(f)) ENGINE=MyISAM;
9+
INSERT INTO t1 VALUES ('foo', '2023-08-30', '2025-07-09'),('bar', '2021-01-01', '2021-12-31');
10+
DELETE FROM t1 FOR PORTION OF app FROM '2023-08-29' TO '2025-07-01';
11+
DROP TABLE t1;
12+
13+
--echo #
14+
--echo # MDEV-21819 Assertion `inited == NONE || update_handler != this'
15+
--echo # failed in handler::ha_write_row
16+
--echo #
17+
18+
CREATE OR REPLACE TABLE t1 (a INT, b BLOB, s DATE, e DATE, PERIOD FOR app(s,e), UNIQUE(b)) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
19+
INSERT INTO t1 VALUES (1,'foo','2022-01-01', '2025-01-01');
20+
--error ER_DUP_ENTRY
21+
DELETE FROM t1 FOR PORTION OF app FROM '2023-01-01' TO '2024-01-01';
22+
DROP TABLE t1;
23+

mysql-test/suite/versioning/r/long_unique.result

Lines changed: 0 additions & 8 deletions
This file was deleted.

mysql-test/suite/versioning/t/long_unique.test

Lines changed: 0 additions & 9 deletions
This file was deleted.

sql/ha_partition.cc

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4352,16 +4352,6 @@ int ha_partition::write_row(const uchar * buf)
43524352
}
43534353
m_last_part= part_id;
43544354
DBUG_PRINT("info", ("Insert in partition %u", part_id));
4355-
/*
4356-
We have to call prepare_for_insert() if we have an update handler
4357-
in the underlying table (to clone the handler). This is because for
4358-
INSERT's prepare_for_insert() is only called for the main table,
4359-
not for all partitions. This is to reduce the huge overhead of cloning
4360-
a possible not needed handler if there are many partitions.
4361-
*/
4362-
if (table->s->long_unique_table &&
4363-
m_file[part_id]->update_handler == m_file[part_id] && inited == RND)
4364-
m_file[part_id]->prepare_for_insert(0);
43654355

43664356
start_part_bulk_insert(thd, part_id);
43674357

@@ -9940,8 +9930,13 @@ void ha_partition::print_error(int error, myf errflag)
99409930
/* fall through to generic error handling. */
99419931
}
99429932

9943-
/* In case m_file has not been initialized, like in bug#42438 */
9944-
if (m_file)
9933+
/*
9934+
We choose a main handler's print_error if:
9935+
* m_file has not been initialized, like in bug#42438
9936+
* lookup_errkey is set, which means that an error has occured in the
9937+
main handler, not in individual partitions
9938+
*/
9939+
if (m_file && lookup_errkey == (uint)-1)
99459940
{
99469941
if (m_last_part >= m_tot_parts)
99479942
{

0 commit comments

Comments
 (0)