Skip to content

42P15 — Invalid schema definition

Source-backed reference for PostgreSQL SQLSTATE 42P15.

42P15 — Invalid schema definition

At a glance

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

Field Value
SQLSTATE 42P15
Condition invalid_schema_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_SCHEMA_DEFINITION
Aliases

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)