Fix SQL in online delete cleanup:

* SQL statement is corrected to perform an implicit JOIN
* Add unit test
This commit is contained in:
seelabs
2015-03-30 13:02:17 -07:00
committed by Tom Ritchford
parent b3254e2b18
commit 7e25a3a942
2 changed files with 87 additions and 2 deletions

View File

@@ -573,8 +573,10 @@ SHAMapStoreImp::clearPrior (LedgerIndex lastRotated)
// the validations table
clearSql (*ledgerDb_, lastRotated,
"SELECT MIN(LedgerSeq) FROM Ledgers;",
"DELETE FROM Validations WHERE Ledgers.LedgerSeq < %u"
" AND Validations.LedgerHash = Ledgers.LedgerHash;");
"DELETE FROM Validations WHERE LedgerHash IN "
"(SELECT Ledgers.LedgerHash FROM Validations JOIN Ledgers ON "
"Validations.LedgerHash=Ledgers.LedgerHash WHERE Ledgers.LedgerSeq < %u);");
if (health())
return;