forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8561e48
committed
Transaction control in PL procedures
In each of the supplied procedural languages (PL/pgSQL, PL/Perl,PL/Python, PL/Tcl), add language-specific commit and rollbackfunctions/commands to control transactions in procedures in thatlanguage. Add similar underlying functions to SPI. Some additionalcleanup so that transaction commit or abort doesn't blow away datastructures still used by the procedure call. Add execution contexttracking to CALL and DO statements so that transaction control commandscan only be issued in top-level procedure and block calls, not functioncalls or other procedure or block calls.- SPIAdd a new function SPI_connect_ext() that is like SPI_connect() butallows passing option flags. The only option flag right now isSPI_OPT_NONATOMIC. A nonatomic SPI connection can execute transactioncontrol commands, otherwise it's not allowed. This is meant to bepassed down from CALL and DO statements which themselves know in whichcontext they are called. A nonatomic SPI connection uses differentmemory management. A normal SPI connection allocates its memory inTopTransactionContext. For nonatomic connections we use PortalContextinstead. As the comment in SPI_connect_ext() (previously SPI_connect())indicates, one could potentially use PortalContext in all cases, but itseems safest to leave the existing uses alone, because this stuff iscomplicated enough already.SPI also gets new functions SPI_start_transaction(), SPI_commit(), andSPI_rollback(), which can be used by PLs to implement their transactioncontrol logic.- portalmem.cSome adjustments were made in the code that cleans up portals attransaction abort. The portal code could already handle a command*committing* a transaction and continuing (e.g., VACUUM), but it was notquite prepared for a command *aborting* a transaction and continuing.In AtAbort_Portals(), remove the code that marks an active portal asfailed. As the comment there already predicted, this doesn't work ifthe running command wants to keep running after transaction abort. Andit's actually not necessary, because pquery.c is careful to run allportal code in a PG_TRY block and explicitly runs MarkPortalFailed() ifthere is an exception. So the code in AtAbort_Portals() is never usedanyway.In AtAbort_Portals() and AtCleanup_Portals(), we need to be careful notto clean up active portals too much. This mirrors similar code inPreCommit_Portals().- PL/PerlGets new functions spi_commit() and spi_rollback()- PL/pgSQLGets new commands COMMIT and ROLLBACK.Update the PL/SQL porting example in the documentation to reflect thattransactions are now possible in procedures.- PL/PythonGets new functions plpy.commit and plpy.rollback.- PL/TclGets new commands commit and rollback.Reviewed-by: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>1 parentb9ff79b commit8561e48
File tree
43 files changed
+2149
-96
lines changed- doc/src/sgml
- ref
- src
- backend
- commands
- executor
- tcop
- utils/mmgr
- include
- commands
- executor
- nodes
- utils
- pl
- plperl
- expected
- sql
- plpgsql/src
- expected
- sql
- plpython
- expected
- sql
- tcl
- expected
- sql
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
43 files changed
+2149
-96
lines changedLines changed: 54 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
661 | 661 |
| |
662 | 662 |
| |
663 | 663 |
| |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
664 | 718 |
| |
665 | 719 |
| |
666 | 720 |
| |
|
Lines changed: 47 additions & 44 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3449 | 3449 |
| |
3450 | 3450 |
| |
3451 | 3451 |
| |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
| 3480 | + | |
| 3481 | + | |
| 3482 | + | |
| 3483 | + | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
| 3489 | + | |
| 3490 | + | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
3452 | 3494 |
| |
3453 | 3495 |
| |
3454 | 3496 |
| |
| |||
5432 | 5474 |
| |
5433 | 5475 |
| |
5434 | 5476 |
| |
5435 |
| - | |
5436 | 5477 |
| |
5437 |
| - | |
| 5478 | + | |
5438 | 5479 |
| |
5439 | 5480 |
| |
5440 | 5481 |
| |
5441 | 5482 |
| |
5442 |
| - | |
| 5483 | + | |
5443 | 5484 |
| |
5444 | 5485 |
| |
5445 | 5486 |
| |
| |||
5459 | 5500 |
| |
5460 | 5501 |
| |
5461 | 5502 |
| |
5462 |
| - | |
5463 |
| - | |
5464 |
| - | |
5465 |
| - | |
5466 |
| - | |
5467 |
| - | |
5468 |
| - | |
5469 |
| - | |
5470 |
| - | |
5471 |
| - | |
5472 |
| - | |
5473 |
| - | |
5474 |
| - | |
5475 |
| - | |
5476 |
| - | |
5477 |
| - | |
5478 |
| - | |
5479 |
| - | |
5480 |
| - | |
5481 |
| - | |
5482 |
| - | |
5483 |
| - | |
5484 |
| - | |
5485 |
| - | |
5486 |
| - | |
5487 |
| - | |
5488 |
| - | |
5489 |
| - | |
5490 |
| - | |
5491 |
| - | |
5492 |
| - | |
5493 |
| - | |
5494 |
| - | |
5495 |
| - | |
5496 | 5503 |
| |
5497 | 5504 |
| |
5498 | 5505 |
| |
5499 | 5506 |
| |
5500 |
| - | |
| 5507 | + | |
5501 | 5508 |
| |
5502 | 5509 |
| |
5503 | 5510 |
| |
| |||
5506 | 5513 |
| |
5507 | 5514 |
| |
5508 | 5515 |
| |
| 5516 | + | |
5509 | 5517 |
| |
5510 | 5518 |
| |
5511 | 5519 |
| |
| |||
5518 | 5526 |
| |
5519 | 5527 |
| |
5520 | 5528 |
| |
| 5529 | + | |
5521 | 5530 |
| |
5522 | 5531 |
| |
5523 | 5532 |
| |
| |||
5541 | 5550 |
| |
5542 | 5551 |
| |
5543 | 5552 |
| |
5544 |
| - | |
5545 |
| - | |
5546 |
| - | |
5547 |
| - | |
5548 |
| - | |
5549 |
| - | |
5550 | 5553 |
| |
5551 | 5554 |
| |
5552 | 5555 |
| |
|
Lines changed: 41 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1370 | 1370 |
| |
1371 | 1371 |
| |
1372 | 1372 |
| |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
1373 | 1414 |
| |
1374 | 1415 |
| |
1375 | 1416 |
| |
|
Lines changed: 41 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1002 | 1002 |
| |
1003 | 1003 |
| |
1004 | 1004 |
| |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
1005 | 1046 |
| |
1006 | 1047 |
| |
1007 | 1048 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
73 | 80 |
| |
74 | 81 |
| |
75 | 82 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
228 | 228 |
| |
229 | 229 |
| |
230 | 230 |
| |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
231 | 238 |
| |
232 | 239 |
| |
233 | 240 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
94 | 101 |
| |
95 | 102 |
| |
96 | 103 |
| |
|
0 commit comments
Comments
(0)