forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2dc1dea
committed
Fix behavior of stable functions called from a CALL's argument list.
If the CALL is within an atomic context (e.g. there's an outertransaction block), _SPI_execute_plan should acquire a fresh snapshotto execute any such functions with. We failed to do that and insteadpassed them the Portal snapshot, which had been acquired at the startof the current SQL command. This'd lead to seeing stale values ofrows modified since the start of the command.This is arguably a bug in84f5c29: I failed to see that "are we innon-atomic mode" needs to be defined the same way as it is furtherdown in _SPI_execute_plan, i.e. check !_SPI_current->atomic not justoptions->allow_nonatomic. Alternatively the blame could be laid onplpgsql, which is unconditionally passing allow_nonatomic = truefor CALL/DO even when it knows it's in an atomic context. However,fixing it in spi.c seems like a better idea since that will also fixthe problem for any extensions that may have copied plpgsql's codingpattern.While here, update an obsolete comment about _SPI_execute_plan'ssnapshot management.Per report from Victor Yegorov. Back-patch to all supported versions.Discussion:https://postgr.es/m/CAGnEboiRe+fG2QxuBO2390F7P8e2MQ6UyBjZSL_w1Cej+E4=Vw@mail.gmail.com1 parentd92573a commit2dc1dea
File tree
4 files changed
+130
-14
lines changed- doc/src/sgml
- src
- backend/executor
- pl/plpgsql/src
- expected
- sql
4 files changed
+130
-14
lines changedLines changed: 6 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
752 | 752 |
| |
753 | 753 |
| |
754 | 754 |
| |
755 |
| - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
756 | 758 |
| |
757 | 759 |
| |
758 | 760 |
| |
| |||
1893 | 1895 |
| |
1894 | 1896 |
| |
1895 | 1897 |
| |
1896 |
| - | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
1897 | 1901 |
| |
1898 | 1902 |
| |
1899 | 1903 |
| |
|
Lines changed: 24 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2399 | 2399 |
| |
2400 | 2400 |
| |
2401 | 2401 |
| |
| 2402 | + | |
2402 | 2403 |
| |
2403 | 2404 |
| |
2404 | 2405 |
| |
2405 | 2406 |
| |
2406 | 2407 |
| |
2407 | 2408 |
| |
2408 | 2409 |
| |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
2409 | 2416 |
| |
2410 | 2417 |
| |
2411 | 2418 |
| |
| |||
2425 | 2432 |
| |
2426 | 2433 |
| |
2427 | 2434 |
| |
2428 |
| - | |
2429 |
| - | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
2430 | 2439 |
| |
2431 |
| - | |
2432 |
| - | |
2433 |
| - | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
2434 | 2446 |
| |
2435 | 2447 |
| |
2436 | 2448 |
| |
| |||
2440 | 2452 |
| |
2441 | 2453 |
| |
2442 | 2454 |
| |
| 2455 | + | |
2443 | 2456 |
| |
2444 | 2457 |
| |
2445 | 2458 |
| |
| |||
2585 | 2598 |
| |
2586 | 2599 |
| |
2587 | 2600 |
| |
2588 |
| - | |
| 2601 | + | |
2589 | 2602 |
| |
2590 | 2603 |
| |
2591 | 2604 |
| |
| |||
2685 | 2698 |
| |
2686 | 2699 |
| |
2687 | 2700 |
| |
2688 |
| - | |
2689 |
| - | |
2690 |
| - | |
| 2701 | + | |
| 2702 | + | |
2691 | 2703 |
| |
2692 |
| - | |
2693 |
| - | |
2694 |
| - | |
| 2704 | + | |
2695 | 2705 |
| |
| 2706 | + | |
| 2707 | + | |
2696 | 2708 |
| |
2697 | 2709 |
| |
2698 | 2710 |
| |
|
Lines changed: 50 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
564 | 564 |
| |
565 | 565 |
| |
566 | 566 |
| |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + |
Lines changed: 50 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
522 | 522 |
| |
523 | 523 |
| |
524 | 524 |
| |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + |
0 commit comments
Comments
(0)