forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2e51781
committed
Fix SPI's handling of errors during transaction commit.
SPI_commit previously left it up to the caller to recover from any erroroccurring during commit. Since that's complicated and requires use oflow-level xact.c facilities, it's not too surprising that no caller gotit right. Let's move the responsibility for cleanup into spi.c. Doingthat requires redefining SPI_commit as starting a new transaction, sothat it becomes equivalent to SPI_commit_and_chain except that you getdefault transaction characteristics instead of preserving the priortransaction's characteristics. We can make this pretty transparentAPI-wise by redefining SPI_start_transaction() as a no-op. Callersthat expect to do something in between might be surprised, butavailable evidence is that no callers do so.Having made that API redefinition, we can fix this mess by havingSPI_commit[_and_chain] trap errors and start a new, clean transactionbefore re-throwing the error. Likewise for SPI_rollback[_and_chain].Some cleanup is also needed in AtEOXact_SPI, which was nowhere nearsmart enough to deal with SPI contexts nested inside a committingcontext.While plperl and pltcl need no changes beyond removing their now-uselessSPI_start_transaction() calls, plpython needs some more work because ithadn't gotten the memo about catching commit/rollback errors in thefirst place. Such an error resulted in longjmp'ing out of the Pythoninterpreter, which leaks Python stack entries at present and is reportedto crash Python 3.11 altogether. Add the missing logic to catch sucherrors and convert them into Python exceptions.We are probably going to have to back-patch this once Python 3.11 ships,but it's a sufficiently basic change that I'm a bit nervous about doingso immediately. Let's let it bake awhile in HEAD first.Peter Eisentraut and Tom LaneDiscussion:https://postgr.es/m/3375ffd8-d71c-2565-e348-a597d6e739e3@enterprisedb.comDiscussion:https://postgr.es/m/17416-ed8fe5d7213d6c25@postgresql.org1 parentb15f254 commit2e51781
File tree
17 files changed
+535
-142
lines changed- doc/src/sgml
- src
- backend
- executor
- tcop
- utils/mmgr
- include/executor
- pl
- plperl
- expected
- sql
- plpgsql/src
- plpython
- expected
- sql
- tcl
- expected
- sql
17 files changed
+535
-142
lines changedLines changed: 23 additions & 28 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
99 | 99 |
| |
100 | 100 |
| |
101 | 101 |
| |
102 |
| - | |
103 |
| - | |
104 |
| - | |
105 |
| - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
106 | 105 |
| |
107 | 106 |
| |
108 | 107 |
| |
| |||
5040 | 5039 |
| |
5041 | 5040 |
| |
5042 | 5041 |
| |
5043 |
| - | |
5044 |
| - | |
5045 |
| - | |
5046 |
| - | |
| 5042 | + | |
| 5043 | + | |
| 5044 | + | |
| 5045 | + | |
| 5046 | + | |
| 5047 | + | |
5047 | 5048 |
| |
5048 | 5049 |
| |
5049 | 5050 |
| |
5050 |
| - | |
5051 |
| - | |
| 5051 | + | |
| 5052 | + | |
5052 | 5053 |
| |
5053 | 5054 |
| |
5054 | 5055 |
| |
| |||
5093 | 5094 |
| |
5094 | 5095 |
| |
5095 | 5096 |
| |
5096 |
| - | |
5097 |
| - | |
5098 |
| - | |
5099 |
| - | |
| 5097 | + | |
| 5098 | + | |
| 5099 | + | |
5100 | 5100 |
| |
5101 | 5101 |
| |
5102 |
| - | |
5103 |
| - | |
| 5102 | + | |
| 5103 | + | |
5104 | 5104 |
| |
5105 | 5105 |
| |
5106 | 5106 |
| |
| |||
5124 | 5124 |
| |
5125 | 5125 |
| |
5126 | 5126 |
| |
5127 |
| - | |
| 5127 | + | |
5128 | 5128 |
| |
5129 | 5129 |
| |
5130 | 5130 |
| |
| |||
5137 | 5137 |
| |
5138 | 5138 |
| |
5139 | 5139 |
| |
5140 |
| - | |
5141 |
| - | |
5142 |
| - | |
5143 |
| - | |
5144 |
| - | |
5145 |
| - | |
5146 |
| - | |
5147 |
| - | |
5148 |
| - | |
5149 |
| - | |
5150 |
| - | |
| 5140 | + | |
| 5141 | + | |
| 5142 | + | |
| 5143 | + | |
| 5144 | + | |
| 5145 | + | |
5151 | 5146 |
| |
5152 | 5147 |
| |
5153 | 5148 |
| |
|
Lines changed: 157 additions & 64 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
156 | 156 |
| |
157 | 157 |
| |
158 | 158 |
| |
159 |
| - | |
| 159 | + | |
| 160 | + | |
160 | 161 |
| |
161 | 162 |
| |
162 | 163 |
| |
| |||
214 | 215 |
| |
215 | 216 |
| |
216 | 217 |
| |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
217 | 222 |
| |
218 | 223 |
| |
219 | 224 |
| |
220 |
| - | |
221 |
| - | |
222 |
| - | |
223 |
| - | |
224 | 225 |
| |
225 | 226 |
| |
226 | 227 |
| |
227 | 228 |
| |
228 | 229 |
| |
229 | 230 |
| |
230 | 231 |
| |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
231 | 238 |
| |
232 | 239 |
| |
233 | 240 |
| |
| |||
240 | 247 |
| |
241 | 248 |
| |
242 | 249 |
| |
243 |
| - | |
| 250 | + | |
| 251 | + | |
244 | 252 |
| |
245 | 253 |
| |
246 | 254 |
| |
247 | 255 |
| |
248 | 256 |
| |
249 | 257 |
| |
250 |
| - | |
251 |
| - | |
252 |
| - | |
253 |
| - | |
254 |
| - | |
255 |
| - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
256 | 261 |
| |
257 |
| - | |
258 |
| - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
259 | 267 |
| |
260 |
| - | |
261 |
| - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
262 | 274 |
| |
263 |
| - | |
264 |
| - | |
| 275 | + | |
| 276 | + | |
265 | 277 |
| |
266 |
| - | |
| 278 | + | |
| 279 | + | |
267 | 280 |
| |
268 |
| - | |
269 |
| - | |
| 281 | + | |
270 | 282 |
| |
271 |
| - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
272 | 289 |
| |
| 290 | + | |
| 291 | + | |
| 292 | + | |
273 | 293 |
| |
274 |
| - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
275 | 298 |
| |
276 |
| - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
277 | 318 |
| |
278 | 319 |
| |
279 | 320 |
| |
| |||
293 | 334 |
| |
294 | 335 |
| |
295 | 336 |
| |
| 337 | + | |
296 | 338 |
| |
297 | 339 |
| |
298 | 340 |
| |
| |||
304 | 346 |
| |
305 | 347 |
| |
306 | 348 |
| |
307 |
| - | |
308 |
| - | |
309 |
| - | |
310 |
| - | |
311 |
| - | |
312 |
| - | |
313 |
| - | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
314 | 352 |
| |
315 |
| - | |
316 |
| - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
317 | 358 |
| |
318 |
| - | |
319 |
| - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
320 | 366 |
| |
321 |
| - | |
322 |
| - | |
| 367 | + | |
| 368 | + | |
323 | 369 |
| |
324 |
| - | |
| 370 | + | |
| 371 | + | |
325 | 372 |
| |
326 |
| - | |
327 |
| - | |
| 373 | + | |
328 | 374 |
| |
329 |
| - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
330 | 381 |
| |
| 382 | + | |
| 383 | + | |
| 384 | + | |
331 | 385 |
| |
332 |
| - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
333 | 390 |
| |
334 |
| - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
335 | 411 |
| |
336 | 412 |
| |
337 | 413 |
| |
| |||
346 | 422 |
| |
347 | 423 |
| |
348 | 424 |
| |
349 |
| - | |
350 |
| - | |
351 |
| - | |
352 |
| - | |
353 |
| - | |
354 |
| - | |
355 |
| - | |
356 |
| - | |
357 |
| - | |
358 |
| - | |
359 |
| - | |
360 |
| - | |
361 |
| - | |
362 |
| - | |
363 |
| - | |
364 | 425 |
| |
365 | 426 |
| |
366 | 427 |
| |
367 | 428 |
| |
368 | 429 |
| |
369 | 430 |
| |
370 |
| - | |
371 |
| - | |
372 |
| - | |
| 431 | + | |
373 | 432 |
| |
374 |
| - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
375 | 470 |
| |
376 | 471 |
| |
377 | 472 |
| |
378 | 473 |
| |
379 |
| - | |
380 |
| - | |
381 | 474 |
| |
382 | 475 |
| |
383 | 476 |
| |
|
0 commit comments
Comments
(0)