3F000
Read PG 18 manual ↗invalid_schema_name
- SQLSTATE
- 3F000
- Condition name
- invalid_schema_name
- Class
- Invalid Schema Name
- Source macro
- ERRCODE_INVALID_SCHEMA_NAME
- Evidence
- Observed at runtime in the source evidence
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
At a glance
SQLSTATE 3F000 is invalid_schema_name in Class 3F. 3F000 means a schema name cannot be resolved in an established session. The selected qualified-table path receives schema "<generated>" does not exist, while fixed namespace and schema-command paths cover resolution during object creation and other SQL commands; it is not simply a search_path hint.
Meaning
The namespace lookup raises this condition when a schema name itself cannot be resolved. A qualified reference to an absent schema uses schema "%s" does not exist; an unqualified CREATE path with no usable creation namespace uses no schema has been selected to create in. Both are schema-resolution branches. An ordinary unqualified relation lookup that finds no relation is 42P01, even when the reason is an unsuitable search_path; a privilege denial follows 42501.
The first question is whether the failing name is a schema or a relation. A qualified reference such as missing_schema.repaired_table asks the namespace code for that exact schema and can produce 3F000. A CREATE with no explicit schema can produce 3F000 when no schema is selected for creation. By contrast, SELECT * FROM missing_table is an unqualified relation lookup and normally produces 42P01; search_path helps explain which relations are searched but does not change that SQLSTATE into 3F000. A role that lacks the required privilege follows 42501. These are different repairs even when the application reports them as “schema not found”.
Diagnosis
Distinguish an explicitly missing schema, a CREATE with no selected creation schema, an unqualified relation lookup, and 42501 privilege denial. The selected autocommit session is IDLE after the ERROR; the owner creates the intended schema and table, inserts one row, and verifies it under the explicit namespace. Check the same role and database used by the failing command.
Inspect the failing identifier with the same role and database, for example by checking current_schemas(true) and whether the intended schema resolves in the catalog. Then verify the command's qualification: the selected case deliberately uses a missing qualified schema. If the statement is CREATE without a schema, inspect whether search_path has any usable creation target; if it is an unqualified relation read, classify a missing relation as 42P01 rather than 3F000. In an explicit transaction, the selected ERROR can leave the transaction in INERROR; the autocommit IDLE observation is not a universal recovery result.
Response
Use the migration or owner-controlled CREATE SCHEMA, set or qualify the intended namespace, and verify the object under the same role. For no schema has been selected to create in, choose an allowed creation schema or qualify the CREATE statement. For an unqualified missing relation, repair the relation name or its intended search_path and expect 42P01 until the relation resolves. Keep schema creation separate from adding unrelated entries to search_path; if the name was intentionally removed, repair the migration or target rather than retrying unchanged.
After creating or exposing the schema, rerun the exact qualified statement and verify the resulting object with the same role. If the failed statement is inside an explicit transaction, roll back or return to a planned savepoint before issuing unrelated DDL. Do not grant broad schema privileges as a substitute for checking whether the application used the right database or identifier.
Observed diagnostics
The fixed namespace paths emit ERROR with primary schema "%s" does not exist for an explicitly missing schema and no schema has been selected to create in when an unqualified CREATE has no active creation namespace. The selected qualified-table case has no fixed DETAIL or HINT. An unqualified relation miss is the separate 42P01 relation "%s" does not exist path, while a role's lack of privilege is 42501.
The selected dynamic name is c3f000_invalid_schema_name_missing, and the error occurred after session establishment with no fixed DETAIL or HINT. This is distinct from the source-defined schema-command paths and from a client startup failure.
Representative case
The SQL block qualifies a missing schema, creates the schema and table, inserts one row, verifies it, and drops the disposable schema.
CREATE TABLE missing_schema.repaired_table (id integer);
CREATE SCHEMA missing_schema;
CREATE TABLE missing_schema.repaired_table (id integer);
INSERT INTO missing_schema.repaired_table VALUES (1);
SELECT count(*) FROM missing_schema.repaired_table;
DROP SCHEMA missing_schema CASCADE;
The selected 18.6 run reports SQLSTATE 3F000, primary schema "c3f000_invalid_schema_name_missing" does not exist, and the asserted recovery state is IDLE before the final probe/repair. Every assertion and cleanup passed on 18.6 and 10.21.
The downloadable case and evidence projections are 3F000 case JSON and authored evidence. The runner manifest is verify/cases/3F000/cases.json; the page SQL is checked against its shared registry before publication.
Versions
The generated facts table records the locked catalogue snapshots and earliest observed definition. The selected natural runtime scope is PostgreSQL 18.6 and 10.21; this does not infer behavior for every intermediate release.
Sources
src.namespace-missing-schema.18.6—src/backend/catalog/namespace.catREL_18_6commit724edf9bde9d356724ad384a2e196edc3c9f80f7; fixed blob SHA-2568c9e6a99e84fa2cec8a9b1de2ecbe3966a13f4ad68c6ccfbfb8134a754d73e56(source).src.namespace-missing-schema.10.23—src/backend/catalog/namespace.catREL_10_23commit02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-25674833354740d0e5679507d07b3c6e41aea01c2cb30adcd1e238bed3ebf96ddc6(source).src.namespace-creation-no-schema.10.23—src/backend/catalog/namespace.catREL_10_23commit02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-25674833354740d0e5679507d07b3c6e41aea01c2cb30adcd1e238bed3ebf96ddc6(source).src.parse-relation-undefined-table.10.23—src/backend/parser/parse_relation.catREL_10_23commit02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4; fixed blob SHA-256a34f40fc93fa5df0015fe5af5ee7761ccba2d16a791cda69ae07848ed27616b5(source).src.calls.REL_18_6/src.calls.REL_10_23— fixed local call scans, SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf/00d16d3eb01b71ccf1b245c8f3102f9d0ec9f36fb02777b8dd1b99fcb263040c; these scans preserve the resolved call context used by the claims.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
3F000 is the invalid_schema_name condition in Class 3F.
Method: Read the fixed errcodes.txt definition and the locked catalogue metadata.
Limits: Directory identity does not identify every backend or client path.
The fixed source paths associated with 3F000 report the condition in the mechanism selected for this page.
Method: Trace the resolved source call records at the fixed release commits and compare their dynamic message fields.
Limits: Other calls can retain the same SQLSTATE with different context or text.
src.namespace-missing-schema.18.6 src.namespace-missing-schema.10.23
The selected invalid_schema_name case passed with the expected structured diagnostics, recovery assertions, and cleanup on PostgreSQL 18.6 and 10.21.
Method: Run the shared registry case on isolated runner-owned latest and PG10 targets; inspect the final summaries and raw results.
Limits: This covers the selected case and versions only; it does not generalize to every driver, proxy, or intermediate release.
The fixed namespace branches distinguish an explicitly missing schema, which reports 3F000 with schema "%s" does not exist, from an unqualified CREATE with no active creation namespace, which reports 3F000 with no schema has been selected to create in. An unqualified relation miss is the parser's 42P01 relation "%s" does not exist path, and privilege denial is 42501; search_path does not turn those relation or privilege branches into 3F000.
Method: Read the complete fixed namespace creation and explicit-lookup branches together with parserOpenTable, then compare the selected runtime diagnostics and transaction recovery contract.
Limits: The selected runtime covers one qualified missing-schema reference; the creation-no-schema and 42P01 contrast branches are source-only and no new runtime was selected.
src.namespace-missing-schema.18.6 src.namespace-missing-schema.10.23 src.namespace-creation-no-schema.10.23 src.parse-relation-undefined-table.10.23 doc.transactions.18
The locked catalogue records 3F000 in the listed snapshots; the runtime comparison here is limited to PostgreSQL 18.6 and 10.21.
Method: Read the generated facts block and locked manifest, then compare the selected target summaries.
Limits: Presence in a definition file is not an exact behavioral introduction; the two runtime targets do not prove all middle versions.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 raw/calls/REL_18_6.jsonl· REL_18_6 ·raw/calls/REL_10_23.jsonl· REL_10_23 ·- src/backend/catalog/namespace.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/backend/catalog/namespace.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 - src/backend/catalog/namespace.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 - src/backend/parser/parse_relation.c · REL_10_23 ·
02991e79f8f58bc208f05dcc8af0c62dbe0a6ea4 - doc/src/sgml/xact.sgml · PG18-docs ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - verify/cases/3F000/cases.json · workspace ·
- verify/cases/3F000/snippets.json · workspace ·
Message templates
explicit ERROR · message.missing-schema
Primary
schema "%s" does not exist
explicit ERROR · message.creation-no-schema
Primary
no schema has been selected to create in
Reproduction & repair cases
invalid_schema_name · PG 10, 18
Preconditions
- A runner-owned disposable target is provisioned.
Trigger: Use a missing schema-qualified table, create the schema explicitly, and verify one repaired row.
Expected assertions
- The selected server diagnostic has the expected SQLSTATE
- The selected recovery/probe assertions pass
- Runner-owned resources are cleaned up
Repair: Follow the case-specific repair statements and verify the resulting state.
Cleanup: Drop the case schema with an owner connection.
Recorded runtime evidence
18.6 (Homebrew) · passed
Run: 3F000-conn-test-latest
Disposable runner-owned target only; this is a bounded mechanism case, not a guarantee for every client or network path.
{
"statuses": {
"final": "IDLE",
"after_error": "IDLE"
},
"row_count": 1,
"diagnostic": {
"text": "schema \"c3f000_invalid_schema_name_missing\" does not exist\nLINE 1: CREATE TABLE \"c3f000_invalid_schema_name_missing\".\"repaired_...\n ^",
"context": null,
"severity": "ERROR",
"sqlstate": "3F000",
"table_name": null,
"column_name": null,
"schema_name": null,
"source_file": "namespace.c",
"source_line": "3547",
"message_hint": null,
"datatype_name": null,
"exception_type": "InvalidSchemaName",
"internal_query": null,
"message_detail": null,
"constraint_name": null,
"message_primary": "schema \"c3f000_invalid_schema_name_missing\" does not exist",
"source_function": "get_namespace_oid",
"internal_position": null,
"statement_position": "14",
"severity_nonlocalized": "ERROR"
},
"missing_schema": "c3f000_invalid_schema_name_missing",
"repaired_table": "c3f000_invalid_schema_name_missing.repaired_table",
"connection_autocommit": true
}10.21 (Debian 10.21-1.pgdg90+1) · passed
Run: 3F000-conn-test-pg10
Disposable runner-owned target only; this is a bounded mechanism case, not a guarantee for every client or network path.
{
"statuses": {
"final": "IDLE",
"after_error": "IDLE"
},
"row_count": 1,
"diagnostic": {
"text": "schema \"c3f000_invalid_schema_name_missing\" does not exist\nLINE 1: CREATE TABLE \"c3f000_invalid_schema_name_missing\".\"repaired_...\n ^",
"context": null,
"severity": "ERROR",
"sqlstate": "3F000",
"table_name": null,
"column_name": null,
"schema_name": null,
"source_file": "namespace.c",
"source_line": "3024",
"message_hint": null,
"datatype_name": null,
"exception_type": "InvalidSchemaName",
"internal_query": null,
"message_detail": null,
"constraint_name": null,
"message_primary": "schema \"c3f000_invalid_schema_name_missing\" does not exist",
"source_function": "get_namespace_oid",
"internal_position": null,
"statement_position": "14",
"severity_nonlocalized": "ERROR"
},
"missing_schema": "c3f000_invalid_schema_name_missing",
"repaired_table": "c3f000_invalid_schema_name_missing.repaired_table",
"connection_autocommit": true
}Definition snapshot: english-manuals:b6a86d891846cd2e1decc4651e2… · English manual source