Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2948
Problem
ROLLBACK TRANSACTIONon a FILESTORAGE database withAUTOCOMMIT OFFthrows, restores nothing, and never calls the callback.INSERT INTO t VALUES (1); COMMIT TRANSACTION; INSERT INTO t VALUES (2))alasql('ROLLBACK TRANSACTION')TypeError: alasql.loadFile is not a function1alasql('SELECT * FROM t')afterwards[{a: 1}, {a: 2}][{a: 1}]alasql('ROLLBACK TRANSACTION', [], cb)cbnever calledcb(1)after the rows are restoredCause
FS.rollbackinsrc/94filestorage.jscalledalasql.loadFile, which does not exist (the loader isalasql.utils.loadFile,loadFilein the bundle). Behind that, the file content was assigned todb.datawithoutJSON.parse, and the function never returned its result.What changed
FS.rollbackloads the file withloadFile, parses it, and rebuildsdb.dataanddb.tablesthe wayFS.attachDatabasedoes, so a rolled back database looks like a freshly attached one.1is returned. With a callback the existing wait for a save in progress is kept, and the callback runs once the rows are restored.Test
test/test2948.js:ROLLBACK TRANSACTIONreturns1and restores the rows of the lastCOMMITROLLBACK TRANSACTIONwith a callback calls it with1after the rows are restoredWithout the change in
src/(restored fromdevelopand rebuilt), A and B fail withTypeError: alasql.loadFile is not a function. With the change, all 3 pass.Full suite: 2543 pass, 213 skip, 0 fail.
Reported by email from a Perch Scan run.
Related: #2625 (rollback on in-memory databases).