Commit a09245a
committed
Fix INSERT EXEC stale OID errors by closing target table before clearing context
During major version upgrade tests, BABEL-1944 was failing with could not
open relation with OID errors. The root cause was that error cleanup paths
were calling pltsql_clear_insert_exec_context() WITHOUT first calling
pltsql_insert_exec_close_target_table(), leaving insert_exec_target_rel_oid
set to a stale OID.
When a subsequent INSERT EXEC operation tried to use this stale OID, it
would fail because the relation no longer existed with that OID (tables
get recreated with new OIDs during major version upgrades).
Changes:
1. Add early INSERT EXEC context cleanup at the start of error handling
(dispatch_stmt_handle_error), before any transaction state checks.
This ensures the INSERT EXEC state is cleared regardless of transaction
state, preventing stale OID issues.
2. Add pltsql_insert_exec_close_target_table() calls before
pltsql_clear_insert_exec_context() in all error cleanup paths:
- iterative_exec.c: TRY-CATCH cleanup path
- pl_exec-2.c: exec_stmt_try_catch cleanup
3. Simplify the !IsTransactionBlockActive() branch since INSERT EXEC
context is now cleaned up earlier. The skip_abort logic now only
checks pltsql_insert_exec_in_trycatch() without the nested
pltsql_insert_exec_active() check.1 parent 8f14a6e commit a09245a
2 files changed
+36
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1490 | 1490 | | |
1491 | 1491 | | |
1492 | 1492 | | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
1493 | 1512 | | |
1494 | 1513 | | |
1495 | 1514 | | |
| |||
1515 | 1534 | | |
1516 | 1535 | | |
1517 | 1536 | | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
1523 | 1542 | | |
1524 | 1543 | | |
1525 | 1544 | | |
1526 | 1545 | | |
1527 | | - | |
1528 | | - | |
1529 | | - | |
| 1546 | + | |
| 1547 | + | |
1530 | 1548 | | |
1531 | | - | |
| 1549 | + | |
1532 | 1550 | | |
1533 | | - | |
1534 | | - | |
1535 | | - | |
1536 | | - | |
1537 | | - | |
1538 | | - | |
1539 | | - | |
1540 | | - | |
1541 | | - | |
1542 | | - | |
1543 | | - | |
1544 | | - | |
1545 | | - | |
1546 | | - | |
1547 | | - | |
1548 | | - | |
| 1551 | + | |
| 1552 | + | |
1549 | 1553 | | |
1550 | 1554 | | |
1551 | 1555 | | |
| |||
1791 | 1795 | | |
1792 | 1796 | | |
1793 | 1797 | | |
1794 | | - | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
1795 | 1802 | | |
1796 | 1803 | | |
1797 | 1804 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2922 | 2922 | | |
2923 | 2923 | | |
2924 | 2924 | | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
2925 | 2928 | | |
2926 | 2929 | | |
2927 | 2930 | | |
| |||
0 commit comments