Skip to content

sqld: fix copy-pasted check in legacy HTTP savepoint guard - #2303

Open
freedom-winds wants to merge 1 commit into
tursodatabase:mainfrom
freedom-winds:fix-legacy-http-savepoint-guard
Open

freedom-winds wants to merge 1 commit into
tursodatabase:mainfrom
freedom-winds:fix-legacy-http-savepoint-guard

Conversation

@freedom-winds

Copy link
Copy Markdown

The guard in parse_queries is supposed to forbid savepoint statements in the legacy HTTP API ("It's too complicated to predict the state of a transaction with savepoints"), but the predicate checked is_release() twice, so SAVEPOINT statements slipped through.

I noticed this while poking the legacy HTTP API with transaction-ish statements: {"statements": ["SAVEPOINT sp", "INSERT INTO t VALUES (1)"]} responds with both statements succeeding, yet nothing is committed — the write lives in a never-released savepoint, and since each request gets a fresh connection that is dropped afterwards, SQLite rolls the transaction back. The client is told the row was persisted when it wasn't. (RELEASE/ROLLBACK TO are correctly rejected, so the same batch cannot make the write durable either.)

This fixes the second term to is_savepoint() and adds unit tests for the guard.

parse_queries() tested is_release() twice, so SAVEPOINT statements slipped
through the guard that is supposed to forbid them: the batch reported
success while the write stayed uncommitted inside a never-released
savepoint and was rolled back when the connection closed at the end of
the request. Check is_savepoint() as well, and cover the guard with
unit tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant