From: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | portal pinning |
Date: | 2017-12-12 15:34:14 |
Message-ID: | be6ee09b-fd79-f784-f196-ae9b9ac8b80a@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
While working on transaction control in procedures, I noticed some
inconsistencies in how portal pinning is used.
This mechanism was introduced in
eb81b6509f4c9109ecf8839d8c482cc597270687 to prevent user code from
closing cursors that PL/pgSQL has created internally, mainly for FOR
loops. Otherwise, user code could just write CLOSE '<unnamed portal X>'
to mess with the language internals.
It seems to me that PL/Perl and PL/Python should also use that
mechanism, because the same problem could happen there. (PL/Tcl does
not expose any cursor functionality AFAICT.) Currently, in PL/Perl, if
an internally generated cursor is closed, PL/Perl just thinks the cursor
has been exhausted and silently does nothing. PL/Python comes back with
a slightly bizarre error message "closing a cursor in an aborted
subtransaction", which might apply in some situations but not in all.
Attached is a sample patch that adds portal pinning to PL/Perl and
PL/Python.
But I also wonder whether we shouldn't automatically pin/unpin portals
in SPI_cursor_open() and SPI_cursor_close(). This makes sense if you
consider "pinned" to mean "internally generated". I don't think there
is a scenario in which user code should directly operate on a portal
created by SPI.
Comments?
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachment | Content-Type | Size |
---|---|---|
0001-Use-portal-pinning-in-PL-Perl-and-PL-Python.patch | text/plain | 3.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-12-12 15:42:35 | Re: [HACKERS] Moving relation extension locks out of heavyweight lock manager |
Previous Message | Avinash Kumar | 2017-12-12 15:28:31 | Re: proposal: alternative psql commands quit and exit |