2D000 — invalid_transaction_termination
2D000 is the SPI guard used when a procedure or subtransaction context attempts an invalid transaction termination. The fixed 18.6 path distinguishes invalid termination from a normal explicit COMMIT; this batch does not claim that every procedure-level transaction error is 2D000, and it does not fabricate a RAISE-based SQL example.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- Invalid Transaction Termination
- condition name
- invalid_transaction_termination
- lang
- en
- sqlstate
- 2D000
Definition PG 18
2D000 — invalid_transaction_termination
At a glance {#at-a-glance}
2D000 is the SPI guard used when a procedure or subtransaction context attempts an invalid transaction termination. The fixed 18.6 path distinguishes invalid termination from a normal explicit COMMIT; this batch does not claim that every procedure-level transaction error is 2D000, and it does not fabricate a RAISE-based SQL example.
Meaning {#meaning}
2D000 is the SPI invalid transaction termination condition. In the fixed spi.c path, SPI_commit and SPI_rollback reject termination in an atomic SPI context; they also reject commit or rollback while a subtransaction is active. The source comments tie that restriction to procedural languages that use subtransactions for exception blocks.
Diagnosis {#diagnosis}
Locate the routine and SPI caller that attempted transaction control. Distinguish a top-level CALL that is allowed to control a transaction from a function or exception block whose SPI context is atomic, and check whether a nested subtransaction is active. The fixed source templates are invalid transaction termination, cannot commit while a subtransaction is active, and cannot roll back while a subtransaction is active; an ordinary client COMMIT error is not enough to classify this path.
Response {#response}
Move transaction control to an allowed procedure boundary, or let the surrounding procedure/exception block finish its subtransaction before terminating the top-level transaction. Do not issue COMMIT or ROLLBACK again inside the same forbidden SPI context, and do not apply a generic retry recipe. This batch records the source path only; no artificial RAISE or unfaithful SQL reproduction is used.
Versions {#versions}
The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.
Related {#related}
Compare 25P01 no active SQL transaction and 24000 invalid cursor state before changing procedure or transaction boundaries.
Sources {#sources}
src.errcodes.18.6(SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)source path(SHA-2567244b45f632583c72530832df901b788fe403c8857425dd13edb49d9f84b0c78)
Compare versions
SQLSTATE evidence and recorded runtime versions
cases · invalid_transaction_termination_boundary
{
"assertions": [],
"case_id": "invalid_transaction_termination_boundary",
"cleanup": "Drop the case schema with an owner connection.",
"has_snippet": false,
"position": 0,
"preconditions": [
"A runner-owned disposable target is provisioned."
],
"repair": "Keep transaction control at the procedure boundary supported by the server; do not add COMMIT/ROLLBACK inside a context that forbids termination.",
"trigger": "No generic SQL-only transaction-termination case is executed; the fixed SPI procedure/subtransaction guard is recorded as a source boundary.",
"versions": [
"10",
"18"
]
}claims · identity
{
"claim_id": "identity",
"limits": "This records the protocol definition and does not imply a natural PostgreSQL throw path.",
"method": "Read the fixed errcodes.txt row and macro mapping.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "2D000 is the invalid_transaction_termination condition in Class 2D."
}claims · source-boundary
{
"claim_id": "source-boundary",
"limits": "No representative runtime case is claimed; the path requires a specialized internal or trigger/procedure context.",
"method": "Trace the fixed source call scan and classify the path before selecting a safe runner case.",
"position": 1,
"runtime": [],
"sources": [
"src.spi.18.6",
"src.calls.REL_18_6"
],
"statement": "invalid transaction termination is a source-confirmed path for 2D000."
}messages · message.invalid-transaction-termination
{
"limits": "The same source path also emits more specific subtransaction messages.",
"message_id": "message.invalid-transaction-termination",
"path": "",
"position": 0,
"raw": {
"id": "message.invalid-transaction-termination",
"limits": "The same source path also emits more specific subtransaction messages.",
"primary_template": "invalid transaction termination",
"severity_source": "ERROR",
"sources": [
"src.spi.18.6"
],
"sqlstate": "2D000"
},
"severity": "ERROR",
"sources": [
"src.spi.18.6"
],
"templates": [
{
"kind": "primary",
"literal": "invalid transaction termination",
"position": 0,
"role": "",
"template": "invalid transaction termination"
}
]
}messages · message.commit-subtransaction
{
"limits": "Only the active-subtransaction branch uses this wording.",
"message_id": "message.commit-subtransaction",
"path": "",
"position": 1,
"raw": {
"id": "message.commit-subtransaction",
"limits": "Only the active-subtransaction branch uses this wording.",
"primary_template": "cannot commit while a subtransaction is active",
"severity_source": "ERROR",
"sources": [
"src.spi.18.6"
],
"sqlstate": "2D000"
},
"severity": "ERROR",
"sources": [
"src.spi.18.6"
],
"templates": [
{
"kind": "primary",
"literal": "cannot commit while a subtransaction is active",
"position": 0,
"role": "",
"template": "cannot commit while a subtransaction is active"
}
]
}messages · message.rollback-subtransaction
{
"limits": "Only the active-subtransaction rollback branch uses this wording.",
"message_id": "message.rollback-subtransaction",
"path": "",
"position": 2,
"raw": {
"id": "message.rollback-subtransaction",
"limits": "Only the active-subtransaction rollback branch uses this wording.",
"primary_template": "cannot roll back while a subtransaction is active",
"severity_source": "ERROR",
"sources": [
"src.spi.18.6"
],
"sqlstate": "2D000"
},
"severity": "ERROR",
"sources": [
"src.spi.18.6"
],
"templates": [
{
"kind": "primary",
"literal": "cannot roll back while a subtransaction is active",
"position": 0,
"role": "",
"template": "cannot roll back while a subtransaction is active"
}
]
}sources · src.errcodes.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt"
}sources · src.calls.REL_18_6
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 1,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6",
"tag": "",
"url": ""
}sources · src.spi.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "",
"path": "src/backend/executor/spi.c",
"position": 2,
"sha256": "7244b45f632583c72530832df901b788fe403c8857425dd13edb49d9f84b0c78",
"source_id": "src.spi.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/executor/spi.c#L239-L241"
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:bb1bd49aea8db88a3121a25e083d1af478858ce5bcdd7dec1550c4b62bcf6157
Text language: en · english-manuals:bb1bd49aea8db88a3121a25e083d1af478858ce5bcdd7dec1550c4b62bcf6157