Skip to content

obj_description() can never match: comment OIDs use a different formula than pg_class.oid #98

Description

@erans

Found during the final review of #87.

src/metadata/object_resolver.rs computes a table OID with Rust's DefaultHasher. src/ddl/comment_ddl_handler.rs writes that value into __pgsqlite_comments.object_oid, which is exposed as pg_description.objoid.

Since #87, pg_class.oid comes from the canonical 3-character-prefix formula (crate::utils::generate_table_oid), which the SQLite views and the persisted pg_constraint/pg_index/pg_attrdef/pg_depend OIDs all share. The two never agree, so:

SELECT obj_description(c.oid, 'pg_class') FROM pg_class c WHERE relname = 'users';

returns NULL for every table that has a comment. This is what psql \d+ uses to show table comments.

A comment in object_resolver.rs claimed it used "the same algorithm as pg_class view". That was false and has been corrected on the #87 branch; the formula itself was deliberately left alone, because changing it would orphan every already-persisted __pgsqlite_comments row.

Fixing it properly needs a data migration that rewrites __pgsqlite_comments.object_oid to the canonical formula, alongside the code change.

Related: src/functions/catalog_functions.rs has the same problem for the regclass UDF — see the companion issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions