42704
Read PG 18 manual ↗undefined_object
- SQLSTATE
- 42704
- Condition name
- undefined_object
- Class
- Syntax Error or Access Rule Violation
- Source macro
- ERRCODE_UNDEFINED_OBJECT
- Evidence
- Observed at runtime in the source evidence
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
At a glance
SQLSTATE 42704 is undefined_object in Class 42. 42704 is undefined_object. The selected DROP TRIGGER path names a trigger absent from a real table and reports trigger "%s" for table "%s" does not exist; a real trigger can then be created and dropped.
Meaning
42704 is undefined_object. The object kind determines the lookup and the message: fixed branches include type "%s" does not exist after type-name resolution, role "%s" does not exist when a role lookup misses, constraint "%s" for table "%s" does not exist after scanning constraints for a relation OID, and operator class "%s" does not exist for access method "%s" after resolving a qualified or search-path opclass. The selected path is narrower: get_trigger_oid scans pg_trigger for the resolved relation OID and trigger name; when DROP TRIGGER requires an object and no row matches, it raises trigger "%s" for table "%s" does not exist, then the case creates and drops a real trigger as its repair lifecycle.
Diagnosis
Classify the primary before changing anything. For the selected trigger branch, inspect the schema-qualified relation resolved by the DDL, exact trigger name (including quoted case), and migration order; a trigger can exist on another table while remaining absent from this relation because the source lookup is keyed by relation OID and name. For a type or role message, inspect the exact qualified name and the type/role catalog; for a constraint message, inspect the relation OID/name pair and migration order; for an opclass message, inspect the access method and schema/search_path used by the opclass lookup. A missing schema or unqualified relation is a different namespace/undefined-relation diagnosis, and a privilege failure is 42501. The missing-object ERROR leaves the selected autocommit session IDLE; inside an explicit BEGIN, it leaves the transaction INERROR until ROLLBACK or a suitable savepoint rollback. Distinguish it from 08003, which concerns a dblink handle, and 26000, which concerns a prepared statement name.
Response
Repair the object category named by the message: correct the qualified name or search path, apply the prerequisite migration in dependency order, or create/rename the intended type, role, constraint, or operator class under its owning migration. For the selected trigger case only, operate on the intended relation explicitly, check owner, timing/event, row-level versus statement-level definition, and function, and then drop that exact trigger when the migration requires it. If an object is intentionally optional, choose an idempotent migration policy deliberately; do not use CASCADE, an unrelated object, or a generic create-then-drop sequence as a repair. After an explicit-transaction error, roll back the transaction or a suitable savepoint before retrying.
Messages
The selected get_trigger_oid branch emits an explicit ERROR with primary trigger "%s" for table "%s" does not exist; both trigger and table names are dynamic. Other fixed undefined-object branches emit type "%s" does not exist, role "%s" does not exist, constraint "%s" for table "%s" does not exist, or operator class "%s" does not exist for access method "%s". A client exception without the server SQLSTATE and the primary for its object category is not sufficient to identify 42704.
Representative case
The page uses the same statements as the runner registry. Generated names such as syntax_schema and syntax_role are replaced by disposable runner values when executed.
CREATE TABLE syntax_schema.trigger_table (id integer);
DROP TRIGGER missing_trigger ON syntax_schema.trigger_table;
CREATE FUNCTION syntax_schema.trigger_function() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RETURN NEW; END $$;
CREATE TRIGGER valid_trigger BEFORE INSERT ON syntax_schema.trigger_table FOR EACH ROW EXECUTE PROCEDURE syntax_schema.trigger_function();
DROP TRIGGER valid_trigger ON syntax_schema.trigger_table;
SELECT count(*) FROM pg_trigger WHERE tgrelid = 'syntax_schema.trigger_table'::regclass AND NOT tgisinternal;
The selected 18.6 run reports the structured diagnostic and passes the repair assertions; the 10.21 run passes the same case-specific checks. The downloadable case and evidence projections are 42704 case JSON and authored evidence. The runner manifest is verify/cases/42704/cases.json, and the page SQL is checked against its shared registry.
Versions
The selected natural runtime scope is PostgreSQL 18.6 and 10.21; it does not infer behavior for every intermediate release.
Sources
src.errcodes.18.6— fixederrcodes.txtdefinition at commit724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba(source).src.missing-trigger.18.6—src/backend/commands/trigger.catREL_18_6commit724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-2560a539af85b0de1a04779f92202e7bfc77d85ae6da1747ea32527c67f39084fbd(source).src.missing-trigger.10.23—src/backend/commands/trigger.catREL_10_23commit02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256dac7cdcbe2df1a1bbc77daa23e808b0c81ba8891c9895f10e8b270a15316e225(source).src.undefined-type.18.6/src.undefined-type.10.23— fixed type-name lookup branches; blob SHA-256fe4670d2401141761096077c6495dd1b7d6a0baf33c9b903f25baee2f88ffd1e/729d30e50cea059ccfe13491fdc5f997ff98c227795693bf166a163925beb663(18.6 source, 10.23 source).src.undefined-role.18.6/src.undefined-role.10.23— fixedDROP ROLElookup branches; blob SHA-256aa8769a2577fff287301d6c82169262cca328515ae940d5a2be4b3e8c21617ed/9fc68a5a18c4bb5388cc817d2f3f2fcdc64f2752eaa429f78f54b0b443fb59ec(18.6 source, 10.23 source).src.undefined-constraint.18.6/src.undefined-constraint.10.23— fixed relation-constraint lookup branches; blob SHA-2560aa324acd355da955f8eb6cec17f1a0138277a8bebd2c6e999cd2a603d3bfa01/c90dff2d1d863e6b43102d762cec6e08b6c4ba40458045b525a14b49865d8a65(18.6 source, 10.23 source).src.undefined-opclass.18.6/src.undefined-opclass.10.23— fixed access-method/opclass lookup branches; blob SHA-256f28ac0580c805553724dc623dd4e20f32de1a84db637e6ac3c6e3d296bd2fae5/85c646706908d13dc449bcffa6690d6ead8d326498051fef6b08f817347fa947(18.6 source, 10.23 source).src.calls.REL_18_6/src.calls.REL_10_23— fixed call scans, SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf/00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
42704 is the undefined_object condition in Class 42.
Method: Read fixed errcodes.txt and the locked catalogue metadata.
Limits: Directory identity does not identify every backend path.
The fixed source calls for 42704 include the mechanism and message boundary selected for this page.
Method: Trace the resolved REL_18_6 and REL_10_23 source call records at the locked commits.
Limits: Other calls can use the same SQLSTATE with different context or dynamic fields.
src.missing-trigger.18.6 src.missing-trigger.10.23 src.undefined-type.18.6 src.undefined-type.10.23 src.undefined-role.18.6 src.undefined-role.10.23 src.undefined-constraint.18.6 src.undefined-constraint.10.23 src.undefined-opclass.18.6 src.undefined-opclass.10.23
Fixed 42704 producers resolve different object categories at different lookup points, including type, role, relation constraint, and access-method operator class; the selected runtime covers only the relation-scoped trigger branch.
Method: Read the complete fixed lookup functions and their undefined-object error branches at REL_18_6 and REL_10_23.
Limits: Only missing_trigger has an accepted natural runtime in this batch; the other messages are source-confirmed boundaries.
src.undefined-type.18.6 src.undefined-type.10.23 src.undefined-role.18.6 src.undefined-role.10.23 src.undefined-constraint.18.6 src.undefined-constraint.10.23 src.undefined-opclass.18.6 src.undefined-opclass.10.23
The selected missing_trigger case passed on isolated PostgreSQL 18.6 and 10.21 targets.
Method: Run the shared registry case and inspect structured diagnostics, state/recovery assertions, and cleanup.
Limits: This covers the selected case and targets only; it does not generalize to all drivers or intermediate releases.
The locked catalogue records 42704; runtime scope is limited to the selected targets.
Method: Read generated facts and selected summaries.
Limits: Definition presence is not an exact behavioral introduction.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 raw/calls/REL_18_6.jsonl· ·raw/calls/REL_10_23.jsonl· ·- src/backend/commands/trigger.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/commands/trigger.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 - src/backend/catalog/objectaddress.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/catalog/objectaddress.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 - src/backend/commands/user.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/commands/user.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 - src/backend/catalog/pg_constraint.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/catalog/pg_constraint.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 - src/backend/commands/opclasscmds.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/commands/opclasscmds.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 verify/cases/42704/cases.json· ·verify/cases/42704/snippets.json· ·
Message templates
explicit ERROR · message.missing-trigger
Primary
trigger "%s" for table "%s" does not exist
explicit ERROR · message.undefined-type
Primary
type "%s" does not exist
Source-only type lookup branch; no natural runtime is claimed.
explicit ERROR · message.undefined-role
Primary
role "%s" does not exist
Source-only DROP ROLE lookup branch; NOTICE missing_ok paths are not selected here.
explicit ERROR · message.undefined-constraint
Primary
constraint "%s" for table "%s" does not exist
Source-only relation constraint lookup branch; no natural runtime is claimed.
explicit ERROR · message.undefined-opclass
Primary
operator class "%s" does not exist for access method "%s"
Source-only access-method/operator-class lookup branch; no natural runtime is claimed.
Reproduction & repair cases
missing_trigger · PG 10, 18
Preconditions
- A runner-owned disposable target is provisioned.
- PL/pgSQL is available for the repair trigger function.
Trigger: Drop a named trigger that does not exist on a real table.
Expected assertions
- SQLSTATE is 42704 with a missing-trigger diagnostic
- The session remains IDLE
- Creating and dropping a real trigger completes the repair lifecycle
Repair: Inspect the relation and trigger name; create or drop the intended trigger explicitly rather than changing unrelated objects.
Cleanup: Drop the case schema with an owner connection.
Recorded runtime evidence
18.6 (Homebrew) · passed
Run: 42704-syntax-latest1
{
"diagnostic": {
"text": "trigger \"missing_trigger\" for table \"trigger_table\" does not exist",
"context": null,
"severity": "ERROR",
"sqlstate": "42704",
"table_name": null,
"column_name": null,
"schema_name": null,
"source_file": "trigger.c",
"source_line": "1409",
"message_hint": null,
"datatype_name": null,
"exception_type": "UndefinedObject",
"internal_query": null,
"message_detail": null,
"constraint_name": null,
"message_primary": "trigger \"missing_trigger\" for table \"trigger_table\" does not exist",
"source_function": "get_trigger_oid",
"internal_position": null,
"statement_position": null,
"severity_nonlocalized": "ERROR"
},
"failed_status": "IDLE",
"repair_status": "IDLE",
"trigger_count": 0,
"connection_autocommit": true
}10.21 (Debian 10.21-1.pgdg90+1) · passed
Run: 42704-syntax-pg10
{
"diagnostic": {
"text": "trigger \"missing_trigger\" for table \"trigger_table\" does not exist",
"context": null,
"severity": "ERROR",
"sqlstate": "42704",
"table_name": null,
"column_name": null,
"schema_name": null,
"source_file": "trigger.c",
"source_line": "1386",
"message_hint": null,
"datatype_name": null,
"exception_type": "UndefinedObject",
"internal_query": null,
"message_detail": null,
"constraint_name": null,
"message_primary": "trigger \"missing_trigger\" for table \"trigger_table\" does not exist",
"source_function": "get_trigger_oid",
"internal_position": null,
"statement_position": null,
"severity_nonlocalized": "ERROR"
},
"failed_status": "IDLE",
"repair_status": "IDLE",
"trigger_count": 0,
"connection_autocommit": true
}Definition snapshot: english-manuals:21a7caf1b4d4abef42d3e8655ba… · English manual source