forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit25d639e
committed
Further refine _SPI_execute_plan's rule for atomic execution.
Commit2dc1dea turns out to have been still a brick shy of a load,because CALL statements executing within a plpgsql exception blockcould still pass the wrong snapshot to stable functions within theCALL's argument list. That happened because standard_ProcessUtilityforces isAtomicContext to true if IsTransactionBlock is true, whichit always will be inside a subtransaction. Then ExecuteCallStmtwould think it does not need to push a new snapshot --- but_SPI_execute_plan didn't do so either, since it thought it was innonatomic mode.The best fix for this seems to be for _SPI_execute_plan to operatein atomic execution mode if IsSubTransaction() is true, even when theSPI context as a whole is non-atomic. This makes _SPI_execute_planhave the same rules about when non-atomic execution is allowed as_SPI_commit/_SPI_rollback have about when COMMIT/ROLLBACK are allowed,which seems appropriately symmetric. (If anyone ever tries to allowCOMMIT/ROLLBACK inside a subtransaction, this would all need to berethought ... but I'm unconvinced that such a thing could be logicallyconsistent at all.)For further consistency, also check IsSubTransaction() inSPI_inside_nonatomic_context. That does not matter for itsone present-day caller StartTransaction, which can't be reachedinside a subtransaction. But if any other callers ever arise,they'd presumably want this definition.Per bug #18656 from Alexander Alehin. Back-patch to allsupported branches, like previous fixes in this area.Discussion:https://postgr.es/m/18656-cade1780866ef66c@postgresql.org1 parent05e982c commit25d639e
File tree
3 files changed
+47
-4
lines changed- src
- backend/executor
- pl/plpgsql/src
- expected
- sql
3 files changed
+47
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
338 | | - | |
| 338 | + | |
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
| 586 | + | |
586 | 587 | | |
587 | 588 | | |
| 589 | + | |
| 590 | + | |
588 | 591 | | |
589 | 592 | | |
590 | 593 | | |
| |||
2410 | 2413 | | |
2411 | 2414 | | |
2412 | 2415 | | |
2413 | | - | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
2414 | 2419 | | |
2415 | | - | |
| 2420 | + | |
| 2421 | + | |
2416 | 2422 | | |
2417 | 2423 | | |
2418 | 2424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
600 | 620 | | |
601 | 621 | | |
602 | 622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
560 | 577 | | |
561 | 578 | | |
562 | 579 | | |
| |||
0 commit comments
Comments
(0)