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

invalid_schema_definition

SQLSTATE
42P15
Condition name
invalid_schema_definition
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_INVALID_SCHEMA_DEFINITION
Evidence
Source path confirmed
Analysis & operational context

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

<h1>42P15 — Invalid schema definition</h1>

At a glance

42P15 (invalid_schema_definition) CREATE SCHEMA can be rejected when its schema declarations disagree.

Meaning

Schema-definition validation applies while transforming the objects contained by CREATE SCHEMA. The setSchemaName helper rejects a contained object's explicitly specified schema when it differs from the one CREATE SCHEMA is currently creating. This is a contained-object declaration mismatch, not two independent top-level schemas or a missing-schema lookup.

Diagnosis

Read both schema identifiers from the message and the complete CREATE SCHEMA statement. Find which contained CREATE TABLE, sequence, view, or other object supplied the conflicting qualification. Check generated DDL and search_path separately; changing search_path cannot reconcile two names that the statement explicitly supplies.

Response

Generate CREATE SCHEMA with one intended name and keep each contained object's explicit qualification under that name, or omit the qualification where the command supplies the context. Correct the migration generator or quoting. A failed CREATE SCHEMA does not by itself prove that a partial schema was committed; inspect the catalog only when cleanup or a prior transaction requires it. If this ERROR occurs inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before retrying.

Messages

Representative source messages include: message: CREATE specifies a schema (%s) different from the one being created (%s). Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

  • src/backend/parser/parse_utilcmd.c:4229-4233 (fixed source)

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

42P15 is the invalid_schema_definition condition in Class 42.

Method: Read fixed REL_18_6 errcodes.txt and locked facts.

Limits: Identity does not enumerate all source branches or client failures.

src.errcodes.42P15.18.6

The setSchemaName helper runs while transforming CREATE SCHEMA contents and rejects a contained object whose explicit schema differs from the schema being created. This is a contained-object declaration mismatch, not two top-level schemas or a missing-schema lookup.

Method: Read selected resolved REL_18_6 report groups and message roles.

Limits: Representative confirmed core paths only; not exhaustive historical or extension coverage.

src.call.42P15.2db5c33b3c90c42ac6dd7a34

Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6.

Method: Read locked catalogue facts and definition snapshot.

Limits: First observed release is a lower bound, not precise behavioral introduction.

src.errcodes.42P15.18.6

Message templates

ERROR · message.variant-1

Primary

CREATE specifies a schema (%s) different from the one being created (%s)

Placeholders remain dynamic source fields; no concrete runtime value is claimed.

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Definition snapshot: english-manuals:4a00332d771b020bd123cb0978f… · English manual source