# 42939 — Reserved name

> PostgreSQL SQLSTATE 42939: Reserved name (reserved_name), source-backed diagnosis and recovery guidance.
---

# 42939 — Reserved name

## At a glance {#at-a-glance}

`42939` (**reserved_name**) rejects a name under an object-specific PostgreSQL rule. The selected 18.6 paths cover schemas, tablespaces, role creation, and role-specification grammar; the object named in the message determines which rule fired.

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| Field | Value |
| --- | --- |
| SQLSTATE | `42939` |
| Condition | `reserved_name` |
| 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_RESERVED_NAME` |
| Aliases | `—` |

<!-- source facts: data/errcodes/42939.json -->
<!-- END SQLSTATE FACTS -->

## Meaning {#meaning}

Schema creation rejects a reserved `pg_` prefix with `unacceptable schema name "%s"` and a system-schema DETAIL. Tablespace creation has the parallel system-tablespace message. `CREATE ROLE` rejects the `pg_` prefix with `role name "%s" is reserved`. Separately, the grammar's `RoleId` conversion rejects `public`, `none`, `SESSION_USER`, `CURRENT_USER`, and `CURRENT_ROLE` in role-name positions: `public` and `none` use the reserved-role-name primary, while the three current/session tokens use `%s cannot be used as a role name here`. These grammar rules do not make those words reserved in every identifier position.

## Diagnosis {#diagnosis}

Start with the exact primary and DETAIL. `unacceptable schema name` points to the schema prefix guard; `unacceptable tablespace name` points to the tablespace guard; `role name ... is reserved` can be a `pg_` role or the grammar's `public`/`none` path; and `%s cannot be used as a role name here` identifies a role-specification token. For a grammar failure, inspect the command's role position rather than searching `pg_namespace` or `pg_authid`. Do not infer a role failure from a tablespace message.

## Response {#response}

Choose an allowed object name after checking migration and ownership. For a role-specification error, replace the role token with an actual allowed role identifier in that grammar position; quoting or changing `search_path` is not a substitute for fixing the command. Do not rename or drop system objects to force success; update dependent grants and configuration deliberately. If an object-level `ERROR` occurred inside an explicit transaction, use a savepoint rollback or transaction rollback before retrying.

## Messages {#messages}

The selected paths are explicit `ERROR`s. Their exact primary/detail roles are:

- schema: `unacceptable schema name "%s"` with `The prefix "pg_" is reserved for system schemas.`
- tablespace: `unacceptable tablespace name "%s"` with `The prefix "pg_" is reserved for system tablespaces.`
- role prefix: `role name "%s" is reserved` with `Role names starting with "pg_" are reserved.`
- role grammar: `role name "%s" is reserved` for `public`/`none`, or `%s cannot be used as a role name here` for `SESSION_USER`, `CURRENT_USER`, and `CURRENT_ROLE`.

## Versions {#versions}

From the locked 7.4 lower bound through 18.6 and 19beta3; that catalogue range is a condition bound, not one introduction point for every object-specific rule. The selected mechanisms are source-only and runtime was not run.

## Related {#related}

- [`42704`](../42704/)
- [`42P06`](../42p06/)
- [`42710`](../42710/)

## Sources {#sources}
- `src.errcodes.42939.18.6` — `src/backend/utils/errcodes.txt` line 349, fixed at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; SHA-256 `6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L349)).

- `src.call.42939.baa3c4599e167695f281cfe8` — `src/backend/commands/schemacmds.c` lines 107-110, fixed at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; SHA-256 `5fd5f43dce5f36f06ed390014c06f244564072227d25a22735f594d2170626b1` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/schemacmds.c#L107-L110)).
- `src.call.42939.aed179efd45a7ca409d59fd6` — `src/backend/commands/tablespace.c` lines 281-285, fixed at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; SHA-256 `f0369bece6339d18cd7d4a29b5fa3010447c3b8ece235c64b0d4fbf5f96a5317` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/tablespace.c#L281-L285)).
- `src.call.42939.419595a34cae2a69b2e21624` — `src/backend/commands/user.c` lines 352-356, fixed at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; SHA-256 `aa8769a2577fff287301d6c82169262cca328515ae940d5a2be4b3e8c21617ed` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/user.c#L352-L356)).
- `src.call.42939.role-grammar` — `src/backend/parser/gram.y` lines 17460-17542, fixed at `724edf9bde9d356724ad384a2e196edc3c9f80f7`; SHA-256 `7e548b673a1e03eb3a56c5eb9ad92d8e11095fac76e14cb258ca851f58274724` ([source](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/parser/gram.y#L17460-L17542)).
- `src.calls.REL_18_6.42939` — resolved core call groups; SHA-256 `9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf`.
- [`authored evidence`](../data/evidence/42939.json) — source claims, message roles, and runtime boundary.
