select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 42 · SYNTAX ERROR OR ACCESS RULE VIOLATION

undefined_column

SQLSTATE
42703
Condition name
undefined_column
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_UNDEFINED_COLUMN
Evidence
Observed at runtime in the source evidence
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>42703</h1>

At a glance

SQLSTATE 42703 is undefined_column in Class 42. 42703 is undefined_column. The selected query names missing_column on a real table and reports column "%s" does not exist; selecting the defined id then succeeds.

Meaning

42703 is undefined_column. When a relation has been found but a referenced column is absent from the visible query scope, errorMissingColumn searches the range table for useful suggestions and raises ERROR column "%s" does not exist (or a qualified form when the relation was named). The selected query names missing_column on a real table and succeeds after changing to its defined id column.

Diagnosis

Check the exact relation, alias, search scope, quoted spelling/case, and migration version. If the parser finds a close candidate it may add a HINT, but the selected path has no hint. The parser reports the error before execution and leaves the autocommit session IDLE; inside an explicit BEGIN, it leaves the transaction INERROR until ROLLBACK or a suitable savepoint rollback before retrying. Distinguish a missing column from 42P01 (the unqualified relation is absent), 3F000 (the schema/creation namespace is absent), and 42702 (more than one visible column matches).

Response

Correct the column or migration and rerun against the intended relation. If the application supports multiple schemas or versions, qualify the relation and deploy the matching migration before retrying. A quoted identifier with different case is a different name; use the catalog or an introspection query to confirm the deployed spelling before changing application SQL.

Messages

The selected errorMissingColumn branch emits an explicit ERROR with primary column "%s" does not exist; %s is the unresolved column, and other source branches may add a suggestion HINT or use a qualified relation form. A client exception without the server SQLSTATE and primary is not sufficient to claim 42703.

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.column_table (id integer);
INSERT INTO syntax_schema.column_table VALUES (1);
SELECT missing_column FROM syntax_schema.column_table;
SELECT id FROM syntax_schema.column_table;

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 42703 case JSON and authored evidence. The runner manifest is verify/cases/42703/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 — fixed errcodes.txt definition at commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).
  • src.undefined-column.18.6src/backend/parser/parse_relation.c at REL_18_6 commit 724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-256 0d9c88f4a8def4c2d982c33f13208590e21ecf5e6f8cd9d7faa223dc771c9a9a (source).
  • src.undefined-column.10.23src/backend/parser/parse_relation.c at REL_10_23 commit 02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256 a34f40fc93fa5df0015fe5af5ee7761ccba2d16a791cda69ae07848ed27616b5 (source).
  • src.calls.REL_18_6 / src.calls.REL_10_23 — fixed call scans, SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf / 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.

42703 is the undefined_column condition in Class 42.

Method: Read fixed errcodes.txt and the locked catalogue metadata.

Limits: Directory identity does not identify every backend path.

src.errcodes.18.6

The fixed source calls for 42703 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.undefined-column.18.6 src.undefined-column.10.23

The selected undefined_column 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.

manifest.42703 snippet-registry.42703

The locked catalogue records 42703; 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.errcodes.18.6 src.calls.REL_18_6 src.calls.REL_10_23

Message templates

explicit ERROR · message.undefined-column

Primary

column "%s" does not exist

Reproduction & repair cases

undefined_column · PG 10, 18

Preconditions

  • A runner-owned disposable target is provisioned.

Trigger: Select a column name that is absent from a real table.

Expected assertions

  • SQLSTATE is 42703 with the undefined-column diagnostic
  • The session remains IDLE
  • Selecting the defined id column succeeds

Repair: Correct the column name or migration, then rerun the query against the intended relation.

Cleanup: Drop the case schema with an owner connection.

Recorded runtime evidence

18.6 (Homebrew) · passed

Run: 42703-syntax-latest2

{
  "diagnostic": {
    "text": "column \"missing_column\" does not exist\nLINE 1: SELECT missing_column FROM \"c42703_undefined_column\".\"column...\n               ^",
    "context": null,
    "severity": "ERROR",
    "sqlstate": "42703",
    "table_name": null,
    "column_name": null,
    "schema_name": null,
    "source_file": "parse_relation.c",
    "source_line": "3859",
    "message_hint": null,
    "datatype_name": null,
    "exception_type": "UndefinedColumn",
    "internal_query": null,
    "message_detail": null,
    "constraint_name": null,
    "message_primary": "column \"missing_column\" does not exist",
    "source_function": "errorMissingColumn",
    "internal_position": null,
    "statement_position": "8",
    "severity_nonlocalized": "ERROR"
  },
  "repair_value": 1,
  "failed_status": "IDLE",
  "repair_status": "IDLE",
  "connection_autocommit": true
}
10.21 (Debian 10.21-1.pgdg90+1) · passed

Run: 42703-syntax-pg10

{
  "diagnostic": {
    "text": "column \"missing_column\" does not exist\nLINE 1: SELECT missing_column FROM \"c42703_undefined_column\".\"column...\n               ^",
    "context": null,
    "severity": "ERROR",
    "sqlstate": "42703",
    "table_name": null,
    "column_name": null,
    "schema_name": null,
    "source_file": "parse_relation.c",
    "source_line": "3293",
    "message_hint": null,
    "datatype_name": null,
    "exception_type": "UndefinedColumn",
    "internal_query": null,
    "message_detail": null,
    "constraint_name": null,
    "message_primary": "column \"missing_column\" does not exist",
    "source_function": "errorMissingColumn",
    "internal_position": null,
    "statement_position": "8",
    "severity_nonlocalized": "ERROR"
  },
  "repair_value": 1,
  "failed_status": "IDLE",
  "repair_status": "IDLE",
  "connection_autocommit": true
}

Definition snapshot: english-manuals:c1f53bceeaf724af56438801082… · English manual source