Skip to content

feat: add S suffix for system-object variants of relation commands#162

Open
devadathanmb wants to merge 7 commits into
dbcli:mainfrom
devadathanmb:fix/system-object-suffix
Open

feat: add S suffix for system-object variants of relation commands#162
devadathanmb wants to merge 7 commits into
dbcli:mainfrom
devadathanmb:fix/system-object-suffix

Conversation

@devadathanmb

@devadathanmb devadathanmb commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Description

Continues the work started in #160.

psql lets you append S to \d-family commands to include system objects. Running \dS in pgcli currently produces an error.

This adds S variants for all relation-listing commands:

Command Description
\dS List or describe user and system relations
\dtS List user and system tables
\dvS List user and system views
\dmS List user and system materialized views
\dsS List user and system sequences
\diS List user and system indexes
\dES List user and system foreign tables

All variants support the + verbose modifier, such as \dtS+.

Closes dbcli/pgcli#1523

Checklist

  • I've added this contribution to the changelog.rst.
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install).
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

- add S variants for relation listing and description while preserving schema visibility
- match psql pattern, special-relation, TOAST, and partitioned-index behavior
- add catalog, visibility, detail, and TOAST tests plus a changelog entry
- add a partitioned table and index to the shared database fixture
- verify `\diS` includes partitioned indexes
- verify `\dtS+` returns verbose relation metadata
- remove partitioned-index objects from the shared database setup
- create and clean up the objects within the relevant test
- skip the test when partitioned indexes are unsupported
- Route \dE and \dES through a shared private helper.
- Omit system-schema exclusions for \dES and advertise its S modifier.
- Add FDW integration coverage for \dES.
- route `\dE` and `\dES` through the shared relation-listing implementation
- add FDW coverage for a schema-qualified foreign table outside the search path
Comment thread pgspecial/dbcommands.py

"""
schema_pattern, table_pattern = sql_name_pattern(pattern)
include_system_relations = show_system or bool(pattern)

@devadathanmb devadathanmb Jul 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

psql includes system relations when the user supplies either S or an explicit pattern.

Keeping that rule in list_objects() removes the need for \dv, \dm, \ds, and \di to request the legacy s relation kind themselves. Unpatterned non-S commands no longer request special relations, while S variants and explicit-pattern searches still include them.

psql applies the same relation-kind filtering in listTables()

Comment thread pgspecial/dbcommands.py
ORDER BY 1,2;
"""
)
return list_objects(cur, pattern, verbose, ["f", ""])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The old _list_foreign_tables() query duplicated most of list_objects() and handled patterns differently.

It discarded the schema returned by sql_name_pattern() and always applied pg_table_is_visible(). That made schema-qualified patterns fail when the schema was outside search_path.

Using list_objects() here fixes the pattern handling and removes the duplicate query.

@devadathanmb devadathanmb marked this pull request as ready for review July 12, 2026 15:56
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.

\dS command not recognized in pgcli (works in psql)

1 participant