forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0d83ced
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 parentcb988b0 commit0d83ced
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 | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
| 590 | + | |
590 | 591 | | |
591 | 592 | | |
| 593 | + | |
| 594 | + | |
592 | 595 | | |
593 | 596 | | |
594 | 597 | | |
| |||
2212 | 2215 | | |
2213 | 2216 | | |
2214 | 2217 | | |
2215 | | - | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
2216 | 2221 | | |
2217 | | - | |
| 2222 | + | |
| 2223 | + | |
2218 | 2224 | | |
2219 | 2225 | | |
2220 | 2226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
493 | 513 | | |
494 | 514 | | |
495 | 515 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
463 | 480 | | |
464 | 481 | | |
465 | 482 | | |
| |||
0 commit comments
Comments
(0)