Open zhangysh1995 opened 4 years ago
Furthermore:
mysql> select * from t1 where a = 'abcd';
+------+------+
| a | b |
+------+------+
| abcd | 1 |
+------+------+
1 row in set (0.00 sec)
mysql> select * from t1;
+-------+------+
| a | b |
+-------+------+
| abcd | 1 |
| abcd | 1 |
+-------+------+
2 rows in set (0.00 sec)
And,
mysql> select * from t1 where a like 'abcd';
+------+------+
| a | b |
+------+------+
| abcd | 1 |
+------+------+
1 row in set (0.00 sec)
/bug P0
I don't believe this is a bug. The two missing rows have an extra space to the right. Here is the testcase in MySQL 8.0.20 (with InnoDB):
mysql [localhost:8020] {msandbox} (test) > -- 2, incorrect
mysql [localhost:8020] {msandbox} (test) > SELECT COUNT(*) x FROM t2 WHERE a = 'abcd' AND b = 2;
+---+
| x |
+---+
| 2 |
+---+
1 row in set (0.00 sec)
I don't believe this is a bug. The two missing rows have an extra space to the right.
But in your example it only have two rows, it should have four rows.
@wwar Please see the example here https://bugs.mysql.com/bug.php?id=24342 (the comment [16 Nov 2006 17:10] Dean Ellis
). If the result you gave is correct, then there is a bug in the current version or there was a bug in the old version. I mean for MySQL.
Please make sure you ran the last line of this test case, t2
has four rows.
FLUSH TABLES;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 ( a VARCHAR(255), b INT, INDEX (a,b) ) ENGINE=MyISAM;
CREATE TABLE t2 LIKE t1;
INSERT INTO t1 VALUES ('abcd ',1);
INSERT INTO t1 VALUES ('abcd',1);
INSERT INTO t2 VALUES ('abcd ',2);
INSERT INTO t2 VALUES ('abcd',2);
INSERT INTO t2 SELECT * FROM t2;
This is the behavior of MySQL 5.7.29:
mysql> select 'abcd' = 'abcd ';
+------------------+
| 'abcd' = 'abcd ' |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
For MySQL 8, I cannot create the table:
mysql> CREATE TABLE t1 ( a VARCHAR(255), b INT, INDEX (a,b) ) ENGINE=MyISAM;
ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes
mysql> select 'abcd' = 'abcd ';
+------------------+
| 'abcd' = 'abcd ' |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
Bug Report
1. What did you do?
2. What did you expect to see?
Four rows returned.
3. What did you see instead?
4. What version of TiDB are you using? (
tidb-server -V
or runselect tidb_version();
on TiDB)Reproducible on master branch.