lealone / Lealone

比 MySQL 和 MongoDB 快10倍的 OLTP 关系数据库和文档数据库
Other
2.44k stars 513 forks source link

单步调试时,插入之后立马查询会查到之前的数据 #99

Closed jiamo closed 4 years ago

jiamo commented 4 years ago
sql> INSERT INTO test(f1, f2) VALUES(8, 2);
Error: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.TEST(F1)"; SQL statement:
INSERT INTO test(f1, f2) VALUES(8, 2) [23505-0]

sql>  INSERT INTO test(f1, f2) VALUES(9, 2);
(Update count: 1, 18500 ms)

sql> select * from test;
+----+----+
| F1 | F2 |
+----+----+
| 1  | 2  |
| 2  | 2  |
| 3  | 2  |
| 4  | 2  |
| 5  | 2  |
| 7  | 2  |
+----+----+
(6 rows, 8751 ms)

感觉像是插入之后没有清掉缓存?

codefollower commented 4 years ago

你的本地源代码是不是老的? 我这里无法重现你说的问题:

Welcome to Lealone Shell 5.0.0
Exit with Ctrl+C
Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit

sql> CREATE TABLE SelectTest(pk varchar(100) NOT NULL PRIMARY KEY, f1 varchar(100), f2 varchar(100), f3 int);
(Update count: 0, 137 ms)

sql> INSERT INTO SelectTest(pk, f1, f2, f3) VALUES('01', 'a1', 'a', 51);
(Update count: 1, 19 ms)

sql> INSERT INTO SelectTest(pk, f1, f2, f3) VALUES('01', 'a1', 'a', 51);
Error: Unique index or primary key violation: "PRIMARY_KEY_B ON PUBLIC.SELECTTEST(PK) VALUES ('01', 2)"; SQL statement:
INSERT INTO SelectTest(pk, f1, f2, f3) VALUES('01', 'a1', 'a', 51) [23505-0]

sql> INSERT INTO SelectTest(pk, f1, f2, f3) VALUES('51', 'a2', 'h', 12);
(Update count: 1, 7 ms)

sql> SELECT * FROM SelectTest;
+----+----+----+----+
| PK | F1 | F2 | F3 |
+----+----+----+----+
| 01 | a1 | a  | 51 |
| 51 | a2 | h  | 12 |
+----+----+----+----+
(2 rows, 62 ms)

sql> INSERT INTO SelectTest(pk, f1, f2, f3) VALUES('61', 'a2', 'h', 12);
(Update count: 1, 10 ms)

sql> SELECT * FROM SelectTest;
+----+----+----+----+
| PK | F1 | F2 | F3 |
+----+----+----+----+
| 01 | a1 | a  | 51 |
| 51 | a2 | h  | 12 |
| 61 | a2 | h  | 12 |
+----+----+----+----+
(3 rows, 13 ms)

sql> 
jiamo commented 4 years ago

可能是单步调试的问题。

我重试可以复现。 select * from test 要执行两遍。

codefollower commented 4 years ago

修复了,更新一下代码重试一下看看。

jiamo commented 4 years ago

可以了