Skip to content

PLPGSQL Procedures and Transactions #9524

Answered by GaryAustin1
wolframm asked this question in Questions
Discussion options

You must be logged in to vote

PostgREST surrounds rpc functions with transaction logic but the function itself (if run in sql window is not). All operations must succeed or all are rolled back.

From Postgres docs
It is important not to confuse the use of BEGIN/END for grouping statements in PL/pgSQL with the similarly-named SQL commands for transaction control. PL/pgSQL's BEGIN/END are only for grouping; they do not start or end a transaction.

From PostgREST docs (POST is used for rpc call): PostgREST executes POST requests in a read/write transaction except for functions marked as IMMUTABLE or STABLE. Those must not modify the database and are executed in a read-only transaction compatible for read-replicas.

"Trappi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wolframm
Comment options

Answer selected by wolframm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants