Details
Description
The sequence used as the default value in the table ('t1' in my example) produces incorrect values when the data is inserted from INSERT SELECT.
Example:
SELECT VERSION(); |
|
DROP TABLE IF EXISTS `t1`; |
DROP SEQUENCE IF EXISTS `s1`; |
|
CREATE SEQUENCE IF NOT EXISTS `s1`; |
|
CREATE TABLE IF NOT EXISTS `t1` ( |
`a` BIGINT UNSIGNED NOT NULL PRIMARY KEY |
DEFAULT (NEXT VALUE FOR `s1`), |
`b` CHAR(1) NOT NULL |
) ENGINE=InnoDB;
|
|
SHOW CREATE TABLE `s1`; |
|
INSERT INTO `t1` (`b`) VALUES ('a'); |
INSERT INTO `t1` (`b`) VALUES ('b'), ('c'); |
INSERT INTO `t1` (`b`) VALUES ('d'); |
INSERT INTO `t1` (`b`) |
SELECT `c` |
FROM ( |
SELECT 'e' `c` |
UNION |
SELECT 'f' `c` |
UNION |
SELECT 'g' `c` |
) `der`;
|
|
SELECT
|
`a`, `b`
|
FROM
|
`t1`;
|
Result:
VERSION() |
---|
10.6.9-MariaDB-1:10.6.9+maria~deb11 |
Table | Create Table |
---|---|
s1 | CREATE TABLE `s1` ( `next_not_cached_value` bigint(21) NOT NULL, `minimum_value` bigint(21) NOT NULL, `maximum_value` bigint(21) NOT NULL, `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used', `increment` bigint(21) NOT NULL COMMENT 'increment value', `cache_size` bigint(21) unsigned NOT NULL, `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', `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done' ) ENGINE=InnoDB SEQUENCE=1 |
a | b | |
---|---|---|
1 | a | ![]() |
2 | b | ![]() |
3 | c | ![]() |
4 | d | ![]() |
6 | e | ![]() |
8 | f | ![]() |
10 | g | ![]() |
See dbfiddle.
Related bug: MDEV-17037.
Attachments
Issue Links
- causes
-
MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error in recent releases
-
- Closed
-
- links to
Activity
Field | Original Value | New Value |
---|---|---|
Remote Link | This issue links to "SO user with same problem (Web Link)" [ 34468 ] |
Fix Version/s | 10.3 [ 22126 ] |
Status | Open [ 1 ] | Confirmed [ 10101 ] |
Assignee | Daniel Black [ danblack ] |
Status | Confirmed [ 10101 ] | In Progress [ 3 ] |
Assignee | Daniel Black [ danblack ] | Michael Widenius [ monty ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Link |
This issue relates to |
Description |
The sequence used as the default value in the table ('t1' in my example) produces incorrect values when the data is inserted from INSERT SELECT.
*Example*: {code:sql} SELECT VERSION(); DROP TABLE IF EXISTS `t1`; DROP SEQUENCE IF EXISTS `s1`; CREATE SEQUENCE IF NOT EXISTS `s1`; CREATE TABLE IF NOT EXISTS `t1` ( `a` BIGINT UNSIGNED NOT NULL PRIMARY KEY DEFAULT (NEXT VALUE FOR `s1`), `b` CHAR(1) NOT NULL ) ENGINE=InnoDB; SHOW CREATE TABLE `s1`; INSERT INTO `t1` (`b`) VALUES ('a'); INSERT INTO `t1` (`b`) VALUES ('b'), ('c'); INSERT INTO `t1` (`b`) VALUES ('d'); INSERT INTO `t1` (`b`) SELECT `c` FROM ( SELECT 'e' `c` UNION SELECT 'f' `c` UNION SELECT 'g' `c` ) `der`; SELECT `a`, `b` FROM `t1`; {code} *Result*: ||VERSION()|| |10.6.9-MariaDB-1:10.6.9+maria~deb11| ||Table||Create Table|| |s1|CREATE TABLE `s1` ( `next_not_cached_value` bigint(21) NOT NULL, `minimum_value` bigint(21) NOT NULL, `maximum_value` bigint(21) NOT NULL, `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used', `increment` bigint(21) NOT NULL COMMENT 'increment value', `cache_size` bigint(21) unsigned NOT NULL, `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', `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done' ) ENGINE=InnoDB SEQUENCE=1| ||a||||b|| |1|a|(/) |2|b|(/) |3|c|(/) |4|d|(/) |6|e|(x) |8|f|(x) |10|g|(x) See [dbfiddle|https://dbfiddle.uk/sLlUhNLQ]. Related bug: [ |
The sequence used as the default value in the table ('t1' in my example) produces incorrect values when the data is inserted from INSERT SELECT.
*Example*: {code:sql} SELECT VERSION(); DROP TABLE IF EXISTS `t1`; DROP SEQUENCE IF EXISTS `s1`; CREATE SEQUENCE IF NOT EXISTS `s1`; CREATE TABLE IF NOT EXISTS `t1` ( `a` BIGINT UNSIGNED NOT NULL PRIMARY KEY DEFAULT (NEXT VALUE FOR `s1`), `b` CHAR(1) NOT NULL ) ENGINE=InnoDB; SHOW CREATE TABLE `s1`; INSERT INTO `t1` (`b`) VALUES ('a'); INSERT INTO `t1` (`b`) VALUES ('b'), ('c'); INSERT INTO `t1` (`b`) VALUES ('d'); INSERT INTO `t1` (`b`) SELECT `c` FROM ( SELECT 'e' `c` UNION SELECT 'f' `c` UNION SELECT 'g' `c` ) `der`; SELECT `a`, `b` FROM `t1`; {code} *Result*: ||VERSION()|| |10.6.9-MariaDB-1:10.6.9+maria~deb11| ||Table||Create Table|| |s1|CREATE TABLE `s1` ( `next_not_cached_value` bigint(21) NOT NULL, `minimum_value` bigint(21) NOT NULL, `maximum_value` bigint(21) NOT NULL, `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used', `increment` bigint(21) NOT NULL COMMENT 'increment value', `cache_size` bigint(21) unsigned NOT NULL, `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', `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done' ) ENGINE=InnoDB SEQUENCE=1| ||a||||b|| |1|a|(/) |2|b|(/) |3|c|(/) |4|d|(/) |6|e|(x) |8|f|(x) |10|g|(x) See [dbfiddle|https://dbfiddle.uk/sLlUhNLQ]. |
Link |
This issue relates to |
Description |
The sequence used as the default value in the table ('t1' in my example) produces incorrect values when the data is inserted from INSERT SELECT.
*Example*: {code:sql} SELECT VERSION(); DROP TABLE IF EXISTS `t1`; DROP SEQUENCE IF EXISTS `s1`; CREATE SEQUENCE IF NOT EXISTS `s1`; CREATE TABLE IF NOT EXISTS `t1` ( `a` BIGINT UNSIGNED NOT NULL PRIMARY KEY DEFAULT (NEXT VALUE FOR `s1`), `b` CHAR(1) NOT NULL ) ENGINE=InnoDB; SHOW CREATE TABLE `s1`; INSERT INTO `t1` (`b`) VALUES ('a'); INSERT INTO `t1` (`b`) VALUES ('b'), ('c'); INSERT INTO `t1` (`b`) VALUES ('d'); INSERT INTO `t1` (`b`) SELECT `c` FROM ( SELECT 'e' `c` UNION SELECT 'f' `c` UNION SELECT 'g' `c` ) `der`; SELECT `a`, `b` FROM `t1`; {code} *Result*: ||VERSION()|| |10.6.9-MariaDB-1:10.6.9+maria~deb11| ||Table||Create Table|| |s1|CREATE TABLE `s1` ( `next_not_cached_value` bigint(21) NOT NULL, `minimum_value` bigint(21) NOT NULL, `maximum_value` bigint(21) NOT NULL, `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used', `increment` bigint(21) NOT NULL COMMENT 'increment value', `cache_size` bigint(21) unsigned NOT NULL, `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', `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done' ) ENGINE=InnoDB SEQUENCE=1| ||a||||b|| |1|a|(/) |2|b|(/) |3|c|(/) |4|d|(/) |6|e|(x) |8|f|(x) |10|g|(x) See [dbfiddle|https://dbfiddle.uk/sLlUhNLQ]. |
The sequence used as the default value in the table ('t1' in my example) produces incorrect values when the data is inserted from INSERT SELECT.
*Example*: {code:sql} SELECT VERSION(); DROP TABLE IF EXISTS `t1`; DROP SEQUENCE IF EXISTS `s1`; CREATE SEQUENCE IF NOT EXISTS `s1`; CREATE TABLE IF NOT EXISTS `t1` ( `a` BIGINT UNSIGNED NOT NULL PRIMARY KEY DEFAULT (NEXT VALUE FOR `s1`), `b` CHAR(1) NOT NULL ) ENGINE=InnoDB; SHOW CREATE TABLE `s1`; INSERT INTO `t1` (`b`) VALUES ('a'); INSERT INTO `t1` (`b`) VALUES ('b'), ('c'); INSERT INTO `t1` (`b`) VALUES ('d'); INSERT INTO `t1` (`b`) SELECT `c` FROM ( SELECT 'e' `c` UNION SELECT 'f' `c` UNION SELECT 'g' `c` ) `der`; SELECT `a`, `b` FROM `t1`; {code} *Result*: ||VERSION()|| |10.6.9-MariaDB-1:10.6.9+maria~deb11| ||Table||Create Table|| |s1|CREATE TABLE `s1` ( `next_not_cached_value` bigint(21) NOT NULL, `minimum_value` bigint(21) NOT NULL, `maximum_value` bigint(21) NOT NULL, `start_value` bigint(21) NOT NULL COMMENT 'start value when sequences is created or value if RESTART is used', `increment` bigint(21) NOT NULL COMMENT 'increment value', `cache_size` bigint(21) unsigned NOT NULL, `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', `cycle_count` bigint(21) NOT NULL COMMENT 'How many cycles have been done' ) ENGINE=InnoDB SEQUENCE=1| ||a||||b|| |1|a|(/) |2|b|(/) |3|c|(/) |4|d|(/) |6|e|(x) |8|f|(x) |10|g|(x) See [dbfiddle|https://dbfiddle.uk/sLlUhNLQ]. Related bug: [ |
Assignee | Michael Widenius [ monty ] | Vicențiu Ciorbaru [ cvicentiu ] |
Assignee | Vicențiu Ciorbaru [ cvicentiu ] | Daniel Black [ danblack ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Fix Version/s | 10.3.37 [ 28404 ] | |
Fix Version/s | 10.4.27 [ 28405 ] | |
Fix Version/s | 10.5.18 [ 28421 ] | |
Fix Version/s | 10.6.11 [ 28441 ] | |
Fix Version/s | 10.7.7 [ 28442 ] | |
Fix Version/s | 10.8.6 [ 28443 ] | |
Fix Version/s | 10.9.4 [ 28444 ] | |
Fix Version/s | 10.10.2 [ 28410 ] | |
Fix Version/s | 10.11.1 [ 28454 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Link |
This issue causes |