You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When recording is enabled for the query such as,
explain select * from seq_1_to_10;
it recorded the table context having a DDL definition as: -
CREATE TABLE `seq_1_to_10` (
-> `seq` bigint(20) unsigned NOT NULL,
-> PRIMARY KEY (`seq`)
-> ) ENGINE=SEQUENCE DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
Now, when that context is replayed, the DDL statement is executed.
But, we cannot create such a table, and instead it errors out saying
ERROR 1050 (42S01): Table 'seq_1_to_10' already exists.
Solution is to not record a DDL statement or any stats for sequence
tables such as seq_1_to_10.
Also, there is a different way to use sequences as: -
Create sequence s1;
Explain select * from s1;
Here, we should be recording the DDL statement, but no need to store the
stats for it. However, we didn't record the DDL statement earlier.
Moreover, sequence's next value should be the same in the replay environment.
Solution here is to record the DDL for such a sequence, and
set its start value as the recorded environment's previous value.
Copy file name to clipboardExpand all lines: mysql-test/main/opt_context_store_ddls.result
+37Lines changed: 37 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -542,4 +542,41 @@ CREATE TABLE `t1` (
542
542
543
543
544
544
drop table t1, t2;
545
+
#
546
+
# MDEV-40388: sequence.simple fails on replay
547
+
#
548
+
create sequence s1;
549
+
# context result should have the ddl
550
+
explain select * from s1;
551
+
id select_type table type possible_keys key key_len ref rows Extra
552
+
1 SIMPLE s1 system NULL NULL NULL NULL 1
553
+
# == Optimizer Context Tables
554
+
name
555
+
# === Optimizer Context DDLs
556
+
@ddls
557
+
CREATE TABLE `s1` (
558
+
`next_not_cached_value` bigint(21) NOT NULL,
559
+
`minimum_value` bigint(21) NOT NULL,
560
+
`maximum_value` bigint(21) NOT NULL,
561
+
`start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used',
562
+
`increment` bigint(21) NOT NULL COMMENT 'increment value',
563
+
`cache_size` bigint(21) unsigned NOT NULL,
564
+
`cycle_option` tinyint(1) unsigned NOT NULL COMMENT '0 if no cycles are allowed, 1 if the sequence should begin a new cycle when maximum_value is passed',
565
+
`cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done'
566
+
) ENGINE=MyISAM SEQUENCE=1;
567
+
568
+
SELECT SETVAL(db1.s1, 1);
569
+
570
+
571
+
drop table s1;
572
+
# no ddl should be captured here
573
+
explain select * from seq_1_to_10;
574
+
id select_type table type possible_keys key key_len ref rows Extra
575
+
1 SIMPLE seq_1_to_10 index NULL PRIMARY 8 NULL 10 Using index
0 commit comments