forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcfc86f9
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.This is a back-patch of commit2e51781. That's now aged long enoughto reduce the concerns about whether it will break something, and wedo need to ensure that supported branches will work with Python 3.11.Peter Eisentraut and Tom LaneDiscussion:https://postgr.es/m/3375ffd8-d71c-2565-e348-a597d6e739e3@enterprisedb.comDiscussion:https://postgr.es/m/17416-ed8fe5d7213d6c25@postgresql.org1 parent419c727 commitcfc86f9
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 |
| |
| |||
4414 | 4413 |
| |
4415 | 4414 |
| |
4416 | 4415 |
| |
4417 |
| - | |
4418 |
| - | |
4419 |
| - | |
4420 |
| - | |
| 4416 | + | |
| 4417 | + | |
| 4418 | + | |
| 4419 | + | |
| 4420 | + | |
| 4421 | + | |
4421 | 4422 |
| |
4422 | 4423 |
| |
4423 | 4424 |
| |
4424 |
| - | |
4425 |
| - | |
| 4425 | + | |
| 4426 | + | |
4426 | 4427 |
| |
4427 | 4428 |
| |
4428 | 4429 |
| |
| |||
4467 | 4468 |
| |
4468 | 4469 |
| |
4469 | 4470 |
| |
4470 |
| - | |
4471 |
| - | |
4472 |
| - | |
4473 |
| - | |
| 4471 | + | |
| 4472 | + | |
| 4473 | + | |
4474 | 4474 |
| |
4475 | 4475 |
| |
4476 |
| - | |
4477 |
| - | |
| 4476 | + | |
| 4477 | + | |
4478 | 4478 |
| |
4479 | 4479 |
| |
4480 | 4480 |
| |
| |||
4498 | 4498 |
| |
4499 | 4499 |
| |
4500 | 4500 |
| |
4501 |
| - | |
| 4501 | + | |
4502 | 4502 |
| |
4503 | 4503 |
| |
4504 | 4504 |
| |
| |||
4511 | 4511 |
| |
4512 | 4512 |
| |
4513 | 4513 |
| |
4514 |
| - | |
4515 |
| - | |
4516 |
| - | |
4517 |
| - | |
4518 |
| - | |
4519 |
| - | |
4520 |
| - | |
4521 |
| - | |
4522 |
| - | |
4523 |
| - | |
4524 |
| - | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
4525 | 4520 |
| |
4526 | 4521 |
| |
4527 | 4522 |
| |
|
Lines changed: 157 additions & 64 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
150 | 150 |
| |
151 | 151 |
| |
152 | 152 |
| |
153 |
| - | |
| 153 | + | |
| 154 | + | |
154 | 155 |
| |
155 | 156 |
| |
156 | 157 |
| |
| |||
208 | 209 |
| |
209 | 210 |
| |
210 | 211 |
| |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
211 | 216 |
| |
212 | 217 |
| |
213 | 218 |
| |
214 |
| - | |
215 |
| - | |
216 |
| - | |
217 |
| - | |
218 | 219 |
| |
219 | 220 |
| |
220 | 221 |
| |
221 | 222 |
| |
222 | 223 |
| |
223 | 224 |
| |
224 | 225 |
| |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
225 | 232 |
| |
226 | 233 |
| |
227 | 234 |
| |
| |||
234 | 241 |
| |
235 | 242 |
| |
236 | 243 |
| |
237 |
| - | |
| 244 | + | |
| 245 | + | |
238 | 246 |
| |
239 | 247 |
| |
240 | 248 |
| |
241 | 249 |
| |
242 | 250 |
| |
243 | 251 |
| |
244 |
| - | |
245 |
| - | |
246 |
| - | |
247 |
| - | |
248 |
| - | |
249 |
| - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
250 | 255 |
| |
251 |
| - | |
252 |
| - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
253 | 261 |
| |
254 |
| - | |
255 |
| - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
256 | 268 |
| |
257 |
| - | |
258 |
| - | |
| 269 | + | |
| 270 | + | |
259 | 271 |
| |
260 |
| - | |
| 272 | + | |
| 273 | + | |
261 | 274 |
| |
262 |
| - | |
263 |
| - | |
| 275 | + | |
264 | 276 |
| |
265 |
| - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
266 | 283 |
| |
| 284 | + | |
| 285 | + | |
| 286 | + | |
267 | 287 |
| |
268 |
| - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
269 | 292 |
| |
270 |
| - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
271 | 312 |
| |
272 | 313 |
| |
273 | 314 |
| |
| |||
287 | 328 |
| |
288 | 329 |
| |
289 | 330 |
| |
| 331 | + | |
290 | 332 |
| |
291 | 333 |
| |
292 | 334 |
| |
| |||
298 | 340 |
| |
299 | 341 |
| |
300 | 342 |
| |
301 |
| - | |
302 |
| - | |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
307 |
| - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
308 | 346 |
| |
309 |
| - | |
310 |
| - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
311 | 352 |
| |
312 |
| - | |
313 |
| - | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
314 | 360 |
| |
315 |
| - | |
316 |
| - | |
| 361 | + | |
| 362 | + | |
317 | 363 |
| |
318 |
| - | |
| 364 | + | |
| 365 | + | |
319 | 366 |
| |
320 |
| - | |
321 |
| - | |
| 367 | + | |
322 | 368 |
| |
323 |
| - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
324 | 375 |
| |
| 376 | + | |
| 377 | + | |
| 378 | + | |
325 | 379 |
| |
326 |
| - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
327 | 384 |
| |
328 |
| - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
329 | 405 |
| |
330 | 406 |
| |
331 | 407 |
| |
| |||
340 | 416 |
| |
341 | 417 |
| |
342 | 418 |
| |
343 |
| - | |
344 |
| - | |
345 |
| - | |
346 |
| - | |
347 |
| - | |
348 |
| - | |
349 |
| - | |
350 |
| - | |
351 |
| - | |
352 |
| - | |
353 |
| - | |
354 |
| - | |
355 |
| - | |
356 |
| - | |
357 |
| - | |
358 | 419 |
| |
359 | 420 |
| |
360 | 421 |
| |
361 | 422 |
| |
362 | 423 |
| |
363 | 424 |
| |
364 |
| - | |
365 |
| - | |
366 |
| - | |
| 425 | + | |
367 | 426 |
| |
368 |
| - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 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 | + | |
369 | 464 |
| |
370 | 465 |
| |
371 | 466 |
| |
372 | 467 |
| |
373 |
| - | |
374 |
| - | |
375 | 468 |
| |
376 | 469 |
| |
377 | 470 |
| |
|
0 commit comments
Comments
(0)