forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd747dc8
committed
In plpgsql, don't preassign portal names to bound cursor variables.
A refcursor variable that is bound to a specific query (by declaringit with "CURSOR FOR") now chooses a portal name in the same way as anunbound, plain refcursor variable. Its string value starts out asNULL, and unless that's overridden by manual assignment, it will bereplaced by a unique-within-session portal name during OPEN.The previous behavior was to initialize such variables to containtheir own name, resulting in that also being the portal name unlessthe user overwrote it before OPEN. The trouble with this is thatit causes failures due to conflicting portal names if the samecursor variable name is used in different functions. It is prettynon-orthogonal to have bound and unbound refcursor variables behavedifferently on this point, too, so let's change it.This change can cause compatibility problems for applications thatopen a bound cursor in a plpgsql function and then use it in thecalling code without explicitly passing back the refcursor value(portal name). If the calling code simply assumes that the portalname matches the called function's variable name, it will now fail.That can be fixed by explicitly assigning a string value to therefcursor 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 usagepattern, 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.us1 parent14d63dd commitd747dc8
File tree
5 files changed
+87
-37
lines changed- doc/src/sgml
- ref
- src
- pl/plpgsql/src
- test/regress
- expected
- sql
5 files changed
+87
-37
lines changedLines changed: 32 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3177 | 3177 |
| |
3178 | 3178 |
| |
3179 | 3179 |
| |
3180 |
| - | |
| 3180 | + | |
| 3181 | + | |
| 3182 | + | |
3181 | 3183 |
| |
3182 | 3184 |
| |
3183 | 3185 |
| |
| |||
3187 | 3189 |
| |
3188 | 3190 |
| |
3189 | 3191 |
| |
| 3192 | + | |
| 3193 | + | |
3190 | 3194 |
| |
3191 | 3195 |
| |
3192 | 3196 |
| |
| 3197 | + | |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
3193 | 3214 |
| |
3194 | 3215 |
| |
3195 | 3216 |
| |
| |||
3338 | 3359 |
| |
3339 | 3360 |
| |
3340 | 3361 |
| |
3341 |
| - | |
| 3362 | + | |
3342 | 3363 |
| |
3343 | 3364 |
| |
3344 | 3365 |
| |
| |||
3480 | 3501 |
| |
3481 | 3502 |
| |
3482 | 3503 |
| |
3483 |
| - | |
| 3504 | + | |
3484 | 3505 |
| |
3485 | 3506 |
| |
3486 | 3507 |
| |
| |||
3500 | 3521 |
| |
3501 | 3522 |
| |
3502 | 3523 |
| |
3503 |
| - | |
| 3524 | + | |
| 3525 | + | |
3504 | 3526 |
| |
3505 | 3527 |
| |
3506 | 3528 |
| |
3507 | 3529 |
| |
3508 | 3530 |
| |
3509 | 3531 |
| |
3510 | 3532 |
| |
3511 |
| - | |
3512 |
| - | |
3513 |
| - | |
3514 |
| - | |
3515 |
| - | |
3516 |
| - | |
| 3533 | + | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
3517 | 3539 |
| |
3518 | 3540 |
| |
3519 | 3541 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 |
| |
17 | 22 |
| |
18 | 23 |
| |
| |||
61 | 66 |
| |
62 | 67 |
| |
63 | 68 |
| |
| 69 | + | |
| 70 | + | |
64 | 71 |
| |
65 | 72 |
| |
66 | 73 |
| |
| |||
305 | 312 |
| |
306 | 313 |
| |
307 | 314 |
| |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
308 | 324 |
| |
309 | 325 |
| |
310 | 326 |
| |
|
Lines changed: 0 additions & 27 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
534 | 534 |
| |
535 | 535 |
| |
536 | 536 |
| |
537 |
| - | |
538 |
| - | |
539 |
| - | |
540 |
| - | |
541 | 537 |
| |
542 | 538 |
| |
543 | 539 |
| |
| |||
550 | 546 |
| |
551 | 547 |
| |
552 | 548 |
| |
553 |
| - | |
554 |
| - | |
555 |
| - | |
556 |
| - | |
557 |
| - | |
558 |
| - | |
559 |
| - | |
560 |
| - | |
561 |
| - | |
562 |
| - | |
563 |
| - | |
564 |
| - | |
565 |
| - | |
566 |
| - | |
567 |
| - | |
568 |
| - | |
569 |
| - | |
570 |
| - | |
571 |
| - | |
572 |
| - | |
573 |
| - | |
574 |
| - | |
575 |
| - | |
576 | 549 |
| |
577 | 550 |
| |
578 | 551 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3482 | 3482 |
| |
3483 | 3483 |
| |
3484 | 3484 |
| |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
3485 | 3488 |
| |
3486 | 3489 |
| |
3487 | 3490 |
| |
| |||
3624 | 3627 |
| |
3625 | 3628 |
| |
3626 | 3629 |
| |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
3627 | 3646 |
| |
3628 | 3647 |
| |
3629 | 3648 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2929 | 2929 |
| |
2930 | 2930 |
| |
2931 | 2931 |
| |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
2932 | 2935 |
| |
2933 | 2936 |
| |
2934 | 2937 |
| |
| |||
3002 | 3005 |
| |
3003 | 3006 |
| |
3004 | 3007 |
| |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
3005 | 3025 |
| |
3006 | 3026 |
| |
3007 | 3027 |
| |
|
0 commit comments
Comments
(0)