You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(apps): keep app migrations atomic when SQL uses a begin identifier #653
App migrations must run in one transaction, but a function named begin can hide transaction control from the check.
plain_sql() in core/src/app_manager/migration.rs:157-268 counts any begin word inside CREATE FUNCTION/PROCEDURE as a routine body opener, not only BEGIN ATOMIC, and does not require a balanced state at end of file (:219).
Example: CREATE FUNCTION begin() RETURNS void LANGUAGE sql AS ''; COMMIT; passes. Adding a balanced END; also passes, so an end-of-file check alone does not close it.
psql groups the text the same way and sends it as one multi-statement query, so the server runs the COMMIT and the migration loses atomicity.
Impact is limited to the app's own database and role.
Proposal
Treat only the token pair BEGIN ATOMIC as a routine body opener.
Require routine == 0 && parentheses == 0 at end of file.
Acceptance
Tests: the example and its END; variant are rejected; real BEGIN ATOMIC bodies still pass.
Activity