42P06
Read PG 18 manual ↗duplicate_schema
- SQLSTATE
- 42P06
- Condition name
- duplicate_schema
- Class
- Syntax Error or Access Rule Violation
- Source macro
- ERRCODE_DUPLICATE_SCHEMA
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
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
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
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
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
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
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.
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.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
42P06 is the duplicate_schema 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.
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.
Method: Read complete resolved REL_18_6 report groups and message roles.
Limits: Representative confirmed core paths only; not exhaustive historical or extension coverage.
src.call.42P06.4d5505b63e38ef1b25836623 src.call.42P06.373538bec86ad8eedfce8d7a
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.
Method: Read locked catalogue facts and definition snapshots.
Limits: First observed release is a lower bound, not precise behavioral introduction.
- src/backend/utils/errcodes.txt · REL_18_6 · line 382
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/catalog/pg_namespace.c · REL_18_6 · lines 62-64
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/commands/schemacmds.c · REL_18_6 · lines 132-135
724edf9bde9d356724ad384a2e196edc3c9f80f7 raw/calls/REL_18_6.jsonl· ·
Message templates
explicit ERROR · message.variant-1
Primary
schema "%s" already exists
Placeholders remain dynamic source fields; no concrete runtime value is claimed.
explicit NOTICE · message.variant-2
Primary
schema "%s" already exists, skipping
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:483f8e3a2ed0683fb3a169d3e9a… · English manual source