Skip to content

feat: add \dS suffix for system objects (pg_catalog, information_schema)#160

Open
Pawansingh3889 wants to merge 2 commits intodbcli:mainfrom
Pawansingh3889:feat/add-system-object-suffix
Open

feat: add \dS suffix for system objects (pg_catalog, information_schema)#160
Pawansingh3889 wants to merge 2 commits intodbcli:mainfrom
Pawansingh3889:feat/add-system-object-suffix

Conversation

@Pawansingh3889
Copy link
Copy Markdown

Adds \dtS, \dvS, \dmS, \dsS, \diS, and \dS metacommands that include system objects from pg_catalog and information_schema, matching psql behavior.

Changes:

  • Added show_system parameter to list_objects() (default False, backward compatible)
  • When show_system=True, skips pg_catalog/information_schema exclusion (pg_toast still excluded)
  • Registered 7 new special commands: \dtS, \dvS, \dmS, \dsS, \diS, and \dS
  • Existing \dt, \dv, etc. behavior unchanged

Adds \dtS, \dvS, \dmS, \dsS, \diS, and \dS metacommands that include
system objects from pg_catalog and information_schema, matching psql
behavior. The existing \dt, \dv, etc. continue to exclude system objects.

Implements this by adding a show_system parameter to list_objects().
When True, the pg_catalog/information_schema exclusion filter is skipped
(pg_toast is still excluded).

Closes dbcli/pgcli#1523
elif show_system:
params["schema_pattern"] = SQL(
"""
AND n.nspname !~ '^pg_toast' """
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the intent was to include both regular and system objects, right? Here, you're going to ignore user-provided pattern, and only show what matches your pattern. Tests would catch this, but the PR contains no tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so the S modifier does this (from https://www.postgresql.org/docs/current/app-psql.html):

By default, only user-created objects are shown; supply a pattern or the S modifier to include system objects.

The fallback condition on lines 490-493 excludes system objects:

AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
AND n.nspname !~ '^pg_toast'
AND pg_catalog.pg_table_is_visible(c.oid)

so in your elif show_system, you only want to keep this one:

AND pg_catalog.pg_table_is_visible(c.oid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my first comment was not accurate, I misread the condition. But the condition does not do what you want. And you still need tests.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants