Skip to content

regclass cast does not strip quoted-identifier syntax — '"name"'::regclass silently resolves to NULL #191

Description

@mkhairi

Version / build tested against

origin/main @ eea86b279

Deployment mode

Origin — single node (local)

Engine(s) involved

Not engine-specific / unsure

Summary

The virtual pg_catalog's regclass cast only resolves bare relation names. A quoted-identifier literal — '"g_probe"'::regclass — is not unquoted before lookup and silently resolves to NULL, so catalog queries filtered on it return 0 rows. PostgreSQL strips the double quotes and resolves the relation; standard client libraries and ORMs quote defensively and emit exactly this form for their schema-reflection queries, which therefore silently return nothing. Secondary symptom: a bare SELECT 'name'::regclass renders an empty cell in both quoting forms (PostgreSQL renders the relation name), though the unquoted cast works as a join/filter value.

Steps to reproduce

-- fresh data directory, psql on 6432
CREATE COLLECTION bug042_probe (id BIGINT PRIMARY KEY, name TEXT DEFAULT 'x', qty INT)
  WITH (engine = document_strict);

-- unquoted form: works as a filter
SELECT attname FROM pg_attribute WHERE attrelid = 'bug042_probe'::regclass;
--  id / name / qty  (3 rows)

-- quoted-identifier form (what defensive clients emit): silently matches nothing
SELECT attname FROM pg_attribute WHERE attrelid = '"bug042_probe"'::regclass;
-- (0 rows)            -- expected: same 3 rows

-- bare cast renders empty in both forms
SELECT 'bug042_probe'::regclass;
-- (1 row, empty cell)  -- expected: bug042_probe

Expected behavior

'"name"'::regclass unquotes the identifier and resolves like 'name'::regclass (PostgreSQL semantics: double quotes stripped, case preserved). Bare SELECT ...::regclass renders the relation name.

Actual behavior

Quoted form silently resolves to NULL — filtered catalog queries return 0 rows with no error. Bare cast renders an empty cell in both forms.

What actually happened? (check all that are true)

  • A workaround exists (rewrite the query, avoid one path, etc.)

Proposed severity

SEV-2 — High: silently-empty catalog results for the quoting standard clients emit; stored data intact. (Workaround — emit the unquoted form — is available to hand-written SQL but not to stock client libraries.)

Reproducibility

Always — every attempt

Last known-good version / commit (if a regression)

(blank — never worked; the surrounding catalog tables became queryable on 3eaa49873)

Environment & logs

Linux x86_64, release build.

Before submitting

  • I searched existing issues and this is not a duplicate.
  • I reproduced this on a released tag or a current main build (not a stale local branch).
  • This is not a security vulnerability (those go to a private advisory).

Activity

  1. added
    status:needs-triageAwaiting maintainer triage (severity + priority)
    type:bugA defect — broken, incorrect, or lost data
    sev:3-mediumFeature wrong, but operational and a workaround exists
    priority:P1Fix in the current milestone
    area:sqlParser, planner, SQL semantics
    area:pgwirePostgreSQL wire protocol / client compat
    and removed
    status:needs-triageAwaiting maintainer triage (severity + priority)
    on Jul 20, 2026
  2. farhan-syah commented on Jul 20, 2026

    @farhan-syah
    Member

    Maintainer triage: SEV-3 / P1, confirmed.

    This is PostgreSQL catalog-compatibility behavior with silently empty reflection results for the defensively quoted regclass input commonly emitted by clients and ORMs. It is medium rather than high under the repository taxonomy because rewriting to the unquoted input is a functional workaround; P1 reflects the client-compatibility impact. Bare-cast rendering should be covered by the same root-level correction rather than treated as cosmetic follow-up.

  3. self-assigned this
    on Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:pgwirePostgreSQL wire protocol / client compatarea:sqlParser, planner, SQL semanticssev:3-mediumFeature wrong, but operational and a workaround existsstatus:confirmedReproduced by a maintainertype:bugA defect — broken, incorrect, or lost data

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions