pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedTransaction control in SECURITY DEFINER procedures
2+ messages / 2 participants
[nested] [flat]
* Transaction control in SECURITY DEFINER procedures
@ 2020-07-07 11:13 Chris Sterritt <chris.sterritt@yobota.xyz>
0 siblings, 1 reply; 2+ messages in thread
From: Chris Sterritt @ 2020-07-07 11:13 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
The documentation for CREATE PROCEDURE informs us "A|SECURITY
DEFINER|procedure cannot execute transaction control statements (for
example,|COMMIT|and|ROLLBACK|, depending on the language)."
Can anyone let me know why this is so and are there any plans to remove
this restriction in future releases?
Regards, Chris Sterritt
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Transaction control in SECURITY DEFINER procedures
@ 2020-07-22 18:06 Bruce Momjian <bruce@momjian.us>
parent: Chris Sterritt <chris.sterritt@yobota.xyz>
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Momjian @ 2020-07-22 18:06 UTC (permalink / raw)
To: Chris Sterritt <chris.sterritt@yobota.xyz>; +Cc: pgsql-general@lists.postgresql.org
On Tue, Jul 7, 2020 at 12:13:42PM +0100, Chris Sterritt wrote:
> The documentation for CREATE PROCEDURE informs us "A SECURITY DEFINER procedure
> cannot execute transaction control statements (for example, COMMIT and ROLLBACK
> , depending on the language)."
>
> Can anyone let me know why this is so and are there any plans to remove this
> restriction in future releases?
I have a reproducible case:
CREATE OR REPLACE PROCEDURE transcheck () AS $$
BEGIN
PERFORM 1;
COMMIT;
END;
$$ LANGUAGE plpgsql;
CALL transcheck ();
ALTER PROCEDURE transcheck SECURITY DEFINER;
CALL transcheck ();
--> ERROR: invalid transaction termination
--> CONTEXT: PL/pgSQL function transcheck() line 4 at COMMIT
and this is the reason:
commit 3884072329 Author: Peter Eisentraut <peter_e@gmx.net>
Date: Wed Jul 4 09:26:19 2018 +0200
Prohibit transaction commands in security definer procedures
Starting and aborting transactions in security definer
procedures doesn't work. StartTransaction() insists that
the security context stack is empty, so this would currently
cause a crash, and AbortTransaction() resets it. This could
be made to work by reorganizing the code, but right now we
just prohibit it.
Reported-by: amul sul <sulamul@gmail.com> Discussion:
https://www.postgresql.org/message-id/flat/CAAJ_b96Gupt_LFL7uNyy3c50-wbhA68NUjiK5%3DrF6_w%3Dpq_T%3DQ...
so, yes, it is possible, but no one has implemented it. This is the
first complaint I have heard about this.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-07-22 18:06 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 11:13 Transaction control in SECURITY DEFINER procedures Chris Sterritt <chris.sterritt@yobota.xyz>
2020-07-22 18:06 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox