Commit 275f99c
committed
fix(db2): _truncate_table — IMMEDIATE outside transactions, DELETE inside
Two separate Db2 constraints require this dual approach:
SQL0104N — TRUNCATE TABLE without IMMEDIATE fails; the keyword is
mandatory in Db2 syntax and the base class does not add it.
SQL0428N — TRUNCATE TABLE ... IMMEDIATE commits instantly and must be
the first statement in a unit of work; it cannot run inside
an open transaction and cannot be rolled back.
When a transaction is already active, fall back to DELETE which
participates in the transaction normally and can be rolled back.
When no transaction is active, TRUNCATE TABLE ... IMMEDIATE runs as
the first statement in a fresh unit of work and succeeds.
This mirrors the intent of NonTransactionalTruncateMixin (used by
MySQL and Redshift) but that mixin delegates to base._truncate_table()
which omits IMMEDIATE — making it unsuitable for Db2 without an
additional override.1 parent cd67d73 commit 275f99c
1 file changed
Lines changed: 13 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
741 | 749 | | |
742 | 750 | | |
743 | 751 | | |
| |||
0 commit comments