↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / SQLSTATE

42P15 — Invalid schema definition

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

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
Syntax Error or Access Rule Violation
condition name
invalid_schema_definition
lang
en
sqlstate
42P15

Definition PG 18

42P15 — Invalid schema definition

At a glance {#at-a-glance}

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

Meaning {#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 {#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 {#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 {#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 {#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.

Related {#related}

Sources {#sources}

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

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

Compare versions

SQLSTATE evidence and recorded runtime versions

claims · identity.class-and-condition
{
  "claim_id": "identity.class-and-condition",
  "limits": "Identity does not enumerate all source branches or client failures.",
  "method": "Read fixed REL_18_6 errcodes.txt and locked facts.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.42P15.18.6"
  ],
  "statement": "42P15 is the invalid_schema_definition condition in Class 42."
}
claims · mechanism.selected-source-path
{
  "claim_id": "mechanism.selected-source-path",
  "limits": "Representative confirmed core paths only; not exhaustive historical or extension coverage.",
  "method": "Read selected resolved REL_18_6 report groups and message roles.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.call.42P15.2db5c33b3c90c42ac6dd7a34"
  ],
  "statement": "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."
}
claims · versions.catalogue-boundary
{
  "claim_id": "versions.catalogue-boundary",
  "limits": "First observed release is a lower bound, not precise behavioral introduction.",
  "method": "Read locked catalogue facts and definition snapshot.",
  "position": 2,
  "runtime": [],
  "sources": [
    "src.errcodes.42P15.18.6"
  ],
  "statement": "Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6."
}
messages · message.variant-1
{
  "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
  "message_id": "message.variant-1",
  "path": "",
  "position": 0,
  "raw": {
    "detail_templates": [],
    "hint_templates": [],
    "id": "message.variant-1",
    "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
    "primary_template": "CREATE specifies a schema (%s) different from the one being created (%s)",
    "roles": [
      {
        "role": "errmsg",
        "template": "CREATE specifies a schema (%s) different from the one being created (%s)"
      }
    ],
    "severity_source": "ERROR",
    "sources": [
      "src.call.42P15.2db5c33b3c90c42ac6dd7a34"
    ],
    "sqlstate": "42P15"
  },
  "severity": "ERROR",
  "sources": [
    "src.call.42P15.2db5c33b3c90c42ac6dd7a34"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "CREATE specifies a schema ( ) different from the one being created ( )",
      "position": 0,
      "role": "",
      "template": "CREATE specifies a schema (%s) different from the one being created (%s)"
    }
  ]
}
sources · src.errcodes.42P15.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "line 396",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.42P15.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L396"
}
sources · src.call.42P15.2db5c33b3c90c42ac6dd7a34
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 4229-4233",
  "path": "src/backend/parser/parse_utilcmd.c",
  "position": 1,
  "sha256": "6758a539fdd493127dfd98e58b995ffcfc3068194bdacdf168ba495caa6cacbf",
  "source_id": "src.call.42P15.2db5c33b3c90c42ac6dd7a34",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/parse_utilcmd.c#L4229-L4233"
}
sources · src.calls.REL_18_6.42P15
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 2,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6.42P15",
  "tag": "",
  "url": ""
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:5911f4601d02ffcd0e8e853c6ea32a56bdcf73e6ffa5ab04199bdfa9bd1e2ebf

Text language: en · english-manuals:5911f4601d02ffcd0e8e853c6ea32a56bdcf73e6ffa5ab04199bdfa9bd1e2ebf