aboutsummaryrefslogtreecommitdiff
path: root/contrib/jsonb_plpython/sql/jsonb_plpython.sql
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-01-01 13:22:34 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2023-01-01 13:22:34 -0500
commitd747dc85aec536c471fd7c739695e155627b08fd (patch)
treebad92587aa637490d6d882a94902447fdbfa0b1a /contrib/jsonb_plpython/sql/jsonb_plpython.sql
parent14d63dd2523c5292c4fcab4f45a7f534859c4518 (diff)
downloadpostgresql-d747dc85aec536c471fd7c739695e155627b08fd.tar.gz
postgresql-d747dc85aec536c471fd7c739695e155627b08fd.zip
In plpgsql, don't preassign portal names to bound cursor variables.
A refcursor variable that is bound to a specific query (by declaring it with "CURSOR FOR") now chooses a portal name in the same way as an unbound, plain refcursor variable. Its string value starts out as NULL, and unless that's overridden by manual assignment, it will be replaced by a unique-within-session portal name during OPEN. The previous behavior was to initialize such variables to contain their own name, resulting in that also being the portal name unless the user overwrote it before OPEN. The trouble with this is that it causes failures due to conflicting portal names if the same cursor variable name is used in different functions. It is pretty non-orthogonal to have bound and unbound refcursor variables behave differently on this point, too, so let's change it. This change can cause compatibility problems for applications that open a bound cursor in a plpgsql function and then use it in the calling code without explicitly passing back the refcursor value (portal name). If the calling code simply assumes that the portal name matches the called function's variable name, it will now fail. That can be fixed by explicitly assigning a string value to the refcursor variable before OPEN, e.g. DECLARE myc CURSOR FOR SELECT ...; BEGIN myc := 'myc'; -- add this OPEN myc; We have no documentation examples showing the troublesome usage pattern, so we can hope it's rare in practice. Patch by me; thanks to Pavel Stehule and Jan Wieck for review. Discussion: https://postgr.es/m/1465101.1667345983@sss.pgh.pa.us
Diffstat (limited to 'contrib/jsonb_plpython/sql/jsonb_plpython.sql')
0 files changed, 0 insertions, 0 deletions