Skip to content

Commit 70b82f6

Browse files
committed
SQL: duplicate of historical row fix [#365 bug 7]
Tests affected (forced mode): main.type_timestamp
1 parent a3802ec commit 70b82f6

File tree

3 files changed

+32
-71
lines changed

3 files changed

+32
-71
lines changed

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

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -193,19 +193,12 @@ set @str= concat('
193193
prepare stmt from @str; execute stmt; drop prepare stmt;
194194
insert into t1(x, y) values
195195
(1, 1000),
196-
(2, 2000),
197196
(3, 3000),
198197
(4, 4000),
199-
(5, 5000),
200-
(6, 6000),
201-
(7, 7000),
202-
(8, 8000),
203-
(9, 9000);
198+
(5, 5000);
204199
insert into t1(x, y) values(3, 3000) on duplicate key update y = y+1;
205-
insert into t1(x, y) values(4, 4000) on duplicate key update y = y+1;
206-
insert into t1(x, y) values(4, 4001) on duplicate key update y = y+1;
207200
insert into t1(x, y) values(4, 4444) on duplicate key update y = y+1;
208-
select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
201+
select x, y from t1 for system_time all;
209202
select x, y from t1;
210203
drop table t1;
211204
end~~
@@ -408,62 +401,36 @@ No A B C D
408401
call test_05('timestamp(6)', 'myisam', 'sys_end');
409402
x y
410403
1 1000
411-
2 2000
412-
3 3001
413-
4 4002
414-
5 5000
415-
6 6000
416-
7 7000
417-
8 8000
418-
9 9000
419404
3 3000
405+
3 3001
420406
4 4000
421-
4 4001
422407
4 4444
408+
5 5000
423409
x y
424410
1 1000
425-
2 2000
426411
3 3001
427-
4 4002
412+
4 4000
428413
4 4444
429414
5 5000
430-
6 6000
431-
7 7000
432-
8 8000
433-
9 9000
434415
call test_05('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
435416
x y
436417
1 1000
437-
2 2000
438418
3 3000
439419
3 3001
440420
4 4000
441-
4 4001
442-
4 4002
443421
4 4444
444422
5 5000
445-
6 6000
446-
7 7000
447-
8 8000
448-
9 9000
449423
x y
450424
1 1000
451-
2 2000
452425
3 3001
453-
4 4002
426+
4 4000
454427
4 4444
455428
5 5000
456-
6 6000
457-
7 7000
458-
8 8000
459-
9 9000
460429
call verify_vtq;
461430
No A B C D
462431
1 1 1 1 1
463432
2 1 1 1 1
464433
3 1 1 1 1
465-
4 1 1 1 1
466-
5 1 1 1 1
467434
call test_06('timestamp(6)', 'myisam', 'sys_end');
468435
x y
469436
1 1000
@@ -590,17 +557,13 @@ No A B C D
590557
1 1 1 1 1
591558
2 1 1 1 1
592559
3 1 1 1 1
593-
drop procedure test_01;
594-
drop procedure test_02;
595-
drop procedure test_03;
596-
drop procedure test_04;
597-
drop procedure test_05;
598-
drop procedure test_06;
599-
drop procedure test_07;
600-
drop procedure verify_vtq;
601-
drop procedure innodb_verify_vtq;
602-
drop function default_engine;
603-
drop function sys_commit_ts;
604-
drop function sys_datatype;
605-
drop procedure concat_exec2;
606-
drop procedure concat_exec3;
560+
### Issue #365, bug 7 (duplicate of historical row)
561+
set timestamp= 1000000019;
562+
create or replace table t1 (a int primary key, b int)
563+
with system versioning engine myisam;
564+
insert into t1 (a) values (1);
565+
update t1 set b= 2;
566+
insert into t1 (a) values (1) on duplicate key update a= 2;
567+
ERROR 23000: Duplicate entry '1-2001-09-09 01:46:59.000000' for key 'PRIMARY'
568+
drop database test;
569+
create database test;

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

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,12 @@ begin
134134
prepare stmt from @str; execute stmt; drop prepare stmt;
135135
insert into t1(x, y) values
136136
(1, 1000),
137-
(2, 2000),
138137
(3, 3000),
139138
(4, 4000),
140-
(5, 5000),
141-
(6, 6000),
142-
(7, 7000),
143-
(8, 8000),
144-
(9, 9000);
139+
(5, 5000);
145140
insert into t1(x, y) values(3, 3000) on duplicate key update y = y+1;
146-
insert into t1(x, y) values(4, 4000) on duplicate key update y = y+1;
147-
insert into t1(x, y) values(4, 4001) on duplicate key update y = y+1;
148141
insert into t1(x, y) values(4, 4444) on duplicate key update y = y+1;
149-
select x, y from t1 for system_time between timestamp '0-0-0 0:0:0' and timestamp '9999-1-1 0:0:0';
142+
select x, y from t1 for system_time all;
150143
select x, y from t1;
151144
drop table t1;
152145
end~~
@@ -262,12 +255,14 @@ call test_07('bigint unsigned', 'innodb', 'vtq_commit_ts(sys_end)');
262255

263256
call verify_vtq;
264257

265-
drop procedure test_01;
266-
drop procedure test_02;
267-
drop procedure test_03;
268-
drop procedure test_04;
269-
drop procedure test_05;
270-
drop procedure test_06;
271-
drop procedure test_07;
258+
--echo ### Issue #365, bug 7 (duplicate of historical row)
259+
set timestamp= 1000000019;
260+
create or replace table t1 (a int primary key, b int)
261+
with system versioning engine myisam;
262+
insert into t1 (a) values (1);
263+
update t1 set b= 2;
264+
--error ER_DUP_ENTRY
265+
insert into t1 (a) values (1) on duplicate key update a= 2;
272266

273-
-- source suite/versioning/common_finish.inc
267+
drop database test;
268+
create database test;

sql/sql_insert.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,8 +1870,11 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
18701870
store_record(table, record[2]);
18711871
if ((error= vers_insert_history_row(table)))
18721872
{
1873+
info->last_errno= error;
1874+
table->file->print_error(error, MYF(0));
1875+
trg_error= 1;
18731876
restore_record(table, record[2]);
1874-
goto err;
1877+
goto ok_or_after_trg_err;
18751878
}
18761879
restore_record(table, record[2]);
18771880
}

0 commit comments

Comments
 (0)