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
99f1a55de2
commit
e00579e1a2
@ -814,6 +814,15 @@ public class HSQLDBDatabaseUpdates {
|
||||
+ "timestamp_signature Signature NOT NULL, " + TRANSACTION_KEYS + ")");
|
||||
break;
|
||||
|
||||
case 33:
|
||||
// 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