mirror of
https://github.com/Qortal/qortal.git
synced 2025-03-15 03:52:31 +00:00
Fix incorrect LatestATStates SQL table definition
This table was previously defined using the TEMPORARY keyword as the rows were used as a cached/index to speed up AT trimming SQL statements. However, the table definition was lacking the "ON COMMIT PRESERVE ROWS" clause, and possibly the "GLOBAL" keyword, which caused the table contents to be emptied, immediately after being filled, when <tt>repository.saveChanges()</tt> was called (i.e. "COMMIT"). This caused latest AT states to be trimmed in error. AtRepositoryTests.testGetLatestATStatePostTrimming also fixed so that it fails with the previous, broken code.
This commit is contained in:
parent
e4e775a107
commit
a66dba767e
@ -771,6 +771,15 @@ public class HSQLDBDatabaseUpdates {
|
||||
stmt.execute("CHECKPOINT");
|
||||
break;
|
||||
|
||||
case 31:
|
||||
// Fix latest AT state cache which was previous created as TEMPORARY
|
||||
stmt.execute("DROP TABLE IF EXISTS LatestATStates");
|
||||
stmt.execute("CREATE TABLE IF NOT EXISTS LatestATStates ("
|
||||
+ "AT_address QortalAddress NOT NULL, "
|
||||
+ "height INT NOT NULL"
|
||||
+ ")");
|
||||
break;
|
||||
|
||||
default:
|
||||
// nothing to do
|
||||
return false;
|
||||
|
@ -130,6 +130,9 @@ public class AtRepositoryTests extends Common {
|
||||
|
||||
// Trim AT state data
|
||||
repository.getATRepository().prepareForAtStateTrimming();
|
||||
// COMMIT to check latest AT states persist / TEMPORARY table interaction
|
||||
repository.saveChanges();
|
||||
|
||||
repository.getATRepository().trimAtStates(2, maxHeight, 1000);
|
||||
|
||||
ATStateData atStateData = repository.getATRepository().getLatestATState(atAddress);
|
||||
|
Loading…
x
Reference in New Issue
Block a user