42P06 — Duplicate schema
42P06 (duplicate_schema) is a schema-definition collision. Plain CREATE SCHEMA errors; IF NOT EXISTS can emit NOTICE and continue, but that conditional path only skips creation and does not reconcile the existing schema.
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
- duplicate_schema
- lang
- en
- sqlstate
- 42P06
Definition PG 18
42P06 — Duplicate schema
At a glance {#at-a-glance}
42P06 (duplicate_schema) is a schema-definition collision. Plain CREATE SCHEMA errors; IF NOT EXISTS can emit NOTICE and continue, but that conditional path only skips creation and does not reconcile the existing schema.
Meaning {#meaning}
NamespaceCreate reports ERROR schema "%s" already exists when the pg_namespace name lookup finds a row. CREATE SCHEMA IF NOT EXISTS checks the same namespace and reports NOTICE schema "%s" already exists, skipping before creation. Both messages identify the schema itself, not a relation inside it. The fixed command path performs the creation-permission checks before the conditional skip; the NOTICE is not an ownership or definition comparison.
Diagnosis {#diagnosis}
Resolve the target database and schema, then inspect pg_namespace.nspname, owner/ACL, contents, and the exact migration statement. Preserve severity: NOTICE is conditional behavior and lets the command continue; plain CREATE's ERROR aborts an explicit transaction. Do not infer that a NOTICE schema has the requested owner, grants, extensions, tables, or migration version.
Response {#response}
Reuse only when owner, privileges, and contents meet the application contract. IF NOT EXISTS does not verify or reconcile those properties; follow it with explicit ownership/grant or migration checks when required. Do not drop a schema merely to pass a migration. If plain CREATE produced an ERROR in an explicit transaction, roll back to a suitable savepoint or roll back the transaction before continuing.
Messages {#messages}
The selected variants are schema "%s" already exists (explicit ERROR) and schema "%s" already exists, skipping (explicit NOTICE). %s is the dynamic schema name; neither message certifies the existing schema's owner or definition.
Versions {#versions}
From 7.4 through 18.6 and 19beta3; that catalogue range is not a precise introduction claim. The selected ERROR and NOTICE branches are fixed 18.6 source paths, and runtime was not run.
Related {#related}
Sources {#sources}
-
src.errcodes.42P06.18.6—src/backend/utils/errcodes.txtline 382, fixed at724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba(source). -
src.call.42P06.4d5505b63e38ef1b25836623—src/backend/catalog/pg_namespace.clines 62-64, fixed at724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-25689675ba1bb9c531ab4f43db8a6f7cac00956561b342e42ea6eaae6b8d0b50d78(source). -
src.call.42P06.373538bec86ad8eedfce8d7a—src/backend/commands/schemacmds.clines 132-135, fixed at724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-2565fd5f43dce5f36f06ed390014c06f244564072227d25a22735f594d2170626b1(source). -
src.calls.REL_18_6.42P06— resolved core call groups; SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf. -
authored evidence— source claims, message roles, and runtime boundary.
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.42P06.18.6"
],
"statement": "42P06 is the duplicate_schema 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 complete resolved REL_18_6 report groups and message roles.",
"position": 1,
"runtime": [],
"sources": [
"src.call.42P06.4d5505b63e38ef1b25836623",
"src.call.42P06.373538bec86ad8eedfce8d7a"
],
"statement": "NamespaceCreate reports ERROR `schema \"%s\" already exists` when pg_namespace already contains the name. CREATE SCHEMA IF NOT EXISTS checks the namespace and reports NOTICE `schema \"%s\" already exists, skipping` before creation; the conditional path does not compare or reconcile owner, ACL, or contents."
}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 snapshots.",
"position": 2,
"runtime": [],
"sources": [
"src.errcodes.42P06.18.6"
],
"statement": "From 7.4 through 18.6 and 19beta3; this catalogue range is not a precise introduction claim. The selected ERROR and NOTICE branches are fixed 18.6 source paths and runtime was not run."
}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": "schema \"%s\" already exists",
"roles": [
{
"role": "errmsg",
"template": "schema \"%s\" already exists"
}
],
"severity_source": "explicit ERROR",
"sources": [
"src.call.42P06.4d5505b63e38ef1b25836623"
],
"sqlstate": "42P06"
},
"severity": "explicit ERROR",
"sources": [
"src.call.42P06.4d5505b63e38ef1b25836623"
],
"templates": [
{
"kind": "primary",
"literal": "schema \" \" already exists",
"position": 0,
"role": "",
"template": "schema \"%s\" already exists"
}
]
}messages · message.variant-2
{
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"message_id": "message.variant-2",
"path": "",
"position": 1,
"raw": {
"detail_templates": [],
"hint_templates": [],
"id": "message.variant-2",
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"primary_template": "schema \"%s\" already exists, skipping",
"roles": [
{
"role": "errmsg",
"template": "schema \"%s\" already exists, skipping"
}
],
"severity_source": "explicit NOTICE",
"sources": [
"src.call.42P06.373538bec86ad8eedfce8d7a"
],
"sqlstate": "42P06"
},
"severity": "explicit NOTICE",
"sources": [
"src.call.42P06.373538bec86ad8eedfce8d7a"
],
"templates": [
{
"kind": "primary",
"literal": "schema \" \" already exists, skipping",
"position": 0,
"role": "",
"template": "schema \"%s\" already exists, skipping"
}
]
}sources · src.errcodes.42P06.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "line 382",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.42P06.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L382"
}sources · src.call.42P06.4d5505b63e38ef1b25836623
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 62-64",
"path": "src/backend/catalog/pg_namespace.c",
"position": 1,
"sha256": "89675ba1bb9c531ab4f43db8a6f7cac00956561b342e42ea6eaae6b8d0b50d78",
"source_id": "src.call.42P06.4d5505b63e38ef1b25836623",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/pg_namespace.c#L62-L64"
}sources · src.call.42P06.373538bec86ad8eedfce8d7a
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 132-135",
"path": "src/backend/commands/schemacmds.c",
"position": 2,
"sha256": "5fd5f43dce5f36f06ed390014c06f244564072227d25a22735f594d2170626b1",
"source_id": "src.call.42P06.373538bec86ad8eedfce8d7a",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/schemacmds.c#L132-L135"
}sources · src.calls.REL_18_6.42P06
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 3,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6.42P06",
"tag": "",
"url": ""
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:867192f9d416b05d071f1243acf544501328144e33f33798fc55a36bf0af5287
Text language: en · english-manuals:867192f9d416b05d071f1243acf544501328144e33f33798fc55a36bf0af5287