forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitae47f8a
committed
Rethink handling of [Prevent|Is]InTransactionBlock in pipeline mode.
Commitsf929441 et al. made IsInTransactionBlock() set theXACT_FLAGS_NEEDIMMEDIATECOMMIT flag before returning "false",on the grounds that that kept its API promises equivalent to those ofPreventInTransactionBlock(). This turns out to be a bad idea though,because it allows an ANALYZE in a pipelined series of commands tocause an immediate commit, which is unexpected.Furthermore, if we return "false" then we have another issue,which is that ANALYZE will decide it's allowed to do internalcommit-and-start-transaction sequences, thus possibly unexpectedlycommitting the effects of previous commands in the pipeline.To fix the latter situation, invent another transaction state flagXACT_FLAGS_PIPELINING, which explicitly records the fact that wehave executed some extended-protocol command and not yet seen acommit for it. Then, require that flag to not be set before allowingInTransactionBlock() to return "false".Having done that, we can remove its setting of NEEDIMMEDIATECOMMITwithout fear of causing problems. This means that the API guaranteesof IsInTransactionBlock now diverge from PreventInTransactionBlock,which is mildly annoying, but it seems OK given the very limited usageof IsInTransactionBlock. (In any case, a caller preferring the oldbehavior could always set NEEDIMMEDIATECOMMIT for itself.)For consistency also require XACT_FLAGS_PIPELINING to not be setin PreventInTransactionBlock. This too is meant to prevent commandssuch as CREATE DATABASE from silently committing previous commandsin a pipeline.Per report from Peter Eisentraut. As before, back-patch to allsupported branches (which sadly no longer includes v10).Discussion:https://postgr.es/m/65a899dd-aebc-f667-1d0a-abb89ff3abf8@enterprisedb.com1 parenta18328b commitae47f8a
File tree
5 files changed
+45
-16
lines changed- doc/src/sgml
- src
- backend
- access/transam
- tcop
- include/access
5 files changed
+45
-16
lines changedLines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5024 | 5024 |
| |
5025 | 5025 |
| |
5026 | 5026 |
| |
5027 |
| - | |
| 5027 | + | |
5028 | 5028 |
| |
5029 | 5029 |
| |
5030 |
| - | |
| 5030 | + | |
| 5031 | + | |
5031 | 5032 |
| |
5032 | 5033 |
| |
5033 | 5034 |
| |
|
Lines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1093 | 1093 |
| |
1094 | 1094 |
| |
1095 | 1095 |
| |
1096 |
| - | |
1097 |
| - | |
1098 |
| - | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1099 | 1100 |
| |
1100 | 1101 |
| |
1101 | 1102 |
| |
1102 | 1103 |
| |
1103 | 1104 |
| |
1104 | 1105 |
| |
1105 | 1106 |
| |
1106 |
| - | |
| 1107 | + | |
1107 | 1108 |
| |
1108 | 1109 |
| |
1109 | 1110 |
| |
|
Lines changed: 18 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3426 | 3426 |
| |
3427 | 3427 |
| |
3428 | 3428 |
| |
| 3429 | + | |
| 3430 | + | |
| 3431 | + | |
| 3432 | + | |
| 3433 | + | |
| 3434 | + | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
| 3438 | + | |
3429 | 3439 |
| |
3430 | 3440 |
| |
3431 | 3441 |
| |
| |||
3515 | 3525 |
| |
3516 | 3526 |
| |
3517 | 3527 |
| |
3518 |
| - | |
3519 |
| - | |
3520 |
| - | |
| 3528 | + | |
| 3529 | + | |
| 3530 | + | |
| 3531 | + | |
| 3532 | + | |
3521 | 3533 |
| |
3522 | 3534 |
| |
3523 | 3535 |
| |
| |||
3535 | 3547 |
| |
3536 | 3548 |
| |
3537 | 3549 |
| |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
3538 | 3553 |
| |
3539 | 3554 |
| |
3540 | 3555 |
| |
3541 | 3556 |
| |
3542 | 3557 |
| |
3543 | 3558 |
| |
3544 | 3559 |
| |
3545 |
| - | |
3546 |
| - | |
3547 |
| - | |
3548 |
| - | |
3549 |
| - | |
3550 |
| - | |
3551 |
| - | |
3552 | 3560 |
| |
3553 | 3561 |
| |
3554 | 3562 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2226 | 2226 |
| |
2227 | 2227 |
| |
2228 | 2228 |
| |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
2229 | 2235 |
| |
2230 | 2236 |
| |
2231 | 2237 |
| |
| |||
2241 | 2247 |
| |
2242 | 2248 |
| |
2243 | 2249 |
| |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
2244 | 2256 |
| |
2245 | 2257 |
| |
2246 | 2258 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
113 | 113 |
| |
114 | 114 |
| |
115 | 115 |
| |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
116 | 123 |
| |
117 | 124 |
| |
118 | 125 |
| |
|
0 commit comments
Comments
(0)