-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Query result set error,Involving primary key #988
Labels
A-bug
Something isn't working
Comments
shangyanwen
changed the title
bug:
bug: Query result set error,Results are inconsistent with innodb
Nov 23, 2022
shangyanwen
changed the title
bug: Query result set error,Results are inconsistent with innodb
bug: Query result set error,Involving primary key ,Results are inconsistent with innodb
Nov 29, 2022
shangyanwen
changed the title
bug: Query result set error,Involving primary key ,Results are inconsistent with innodb
bug: Query result set error,Involving primary key
Nov 29, 2022
ACK |
Compare INNODB query results:INNODB:mysql> SELECT id FROM t1 where id < 1000 limit 20;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 18 |
| 19 |
| 20 |
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
| 26 |
| 27 |
+----+
20 rows in set (0.00 sec)
tianmu:mysql> SELECT id FROM t1 where id < 1000 limit 20;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
+----+
20 rows in set (0.00 sec)
|
The reason is that mysql has an incremental lock policy, which is innodb_autoinc_lock_moderef: https://dev.mysql.com/doc/refman/5.7/en/innodb-auto-increment-handling.html When innodb_autoinc_lock_mode is set to 0, INNODB autoincrement is increased to 1, the same result as TIANMUmysql> set global innodb_autoinc_lock_mode=0;
ERROR 1238 (HY000): Variable 'innodb_autoinc_lock_mode' is a read only variable
mysql> show global variables like 'innodb_autoinc_lock_mode';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 2
Current database: d51
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| innodb_autoinc_lock_mode | 0 |
+--------------------------+-------+
1 row in set (0.01 sec)
mysql>
mysql>
mysql> drop table t1;
Query OK, 0 rows affected (0.01 sec)
mysql> CREATE TABLE t1 (id BIGINT NOT NULL PRIMARY KEY auto_increment, pad1 BLOB, pad2 BLOB, pad3 BLOB, int_col INT NOT NULL DEFAULT 0) ENGINE=INNODB AUTO_INCREMENT=1;
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO t1 SELECT NULL, 'abcd', 'abcd', 'abcd', 0 FROM dual;
NULL, 'abcd', 'abcd', 'abcd', 0 FROM t1 a JOIN t1 b JOIN t1 c;
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> INSERT INTO t1 SELECT NULL, 'abcd', 'abcd', 'abcd', 0 FROM t1 a JOIN t1 b JOIN t1 c;
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> INSERT INTO t1 SELECT NULL, 'abcd', 'abcd', 'abcd', 0 FROM t1 a JOIN t1 b JOIN t1 c;
Query OK, 8 rows affected (0.01 sec)
Records: 8 Duplicates: 0 Warnings: 0
mysql> INSERT INTO t1 SELECT NULL, 'abcd', 'abcd', 'abcd', 0 FROM t1 a JOIN t1 b JOIN t1 c;
Query OK, 1000 rows affected (0.00 sec)
Records: 1000 Duplicates: 0 Warnings: 0
mysql> SELECT id FROM t1 where id<1000 limit 20;
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 16 |
| 17 |
| 18 |
| 19 |
| 20 |
+----+
20 rows in set (0.00 sec)
mysql> SELECT count(id) FROM t1 where id<1000;
+-----------+
| count(id) |
+-----------+
| 999 |
+-----------+
1 row in set (0.00 sec)
mysql> show create table t1\G
*************************** 1. row ***************************
Table: t1
Create Table: CREATE TABLE `t1` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`pad1` blob,
`pad2` blob,
`pad3` blob,
`int_col` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1011 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
|
This is a BUG in the testing process and will not be resolved |
We close it now, and feel free to reopen. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you read the Contributing Guidelines on issues?
Please confirm if bug report does NOT exists already ?
Describe the problem
Expected behavior
MySQL(innodb) results:
How To Reproduce
Environment
Are you interested in submitting a PR to solve the problem?
The text was updated successfully, but these errors were encountered: