Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: schema search path is not followed in SHOW TABLES #16335

Closed
BugenZhao opened this issue Apr 16, 2024 · 2 comments · Fixed by #16891
Closed

bug: schema search path is not followed in SHOW TABLES #16335

BugenZhao opened this issue Apr 16, 2024 · 2 comments · Fixed by #16891
Assignees
Labels
component/frontend Protocol, parsing, binder. type/bug Something isn't working
Milestone

Comments

@BugenZhao
Copy link
Member

Currently when running SHOW TABLES in RisingWave, the schema search path is not followed and the default schema public will always be used.

// If not include schema name, use default schema name
ShowObject::Table { schema } => catalog_reader
.read_guard()
.get_schema_by_name(session.database(), &schema_or_default(&schema))?

Although SHOW TABLES is not a standard command in Postgres, users may still expect SHOW TABLES to behave the same as \dt. Besides, CockroachDB provide support for SHOW TABLES and it'll follow the search path.

https://www.cockroachlabs.com/docs/stable/show-tables#parameters

SHOW TABLES will attempt to find a schema with the specified name first. If that fails, it will try to find a database with that name instead, and list the tables of its public schema. For more details, see Name Resolution.


Furthermore, should we delegate the implementation of 'SHOW' commands directly to the system tables for catalogs (i.e. \dt)?

@BugenZhao BugenZhao added type/bug Something isn't working component/frontend Protocol, parsing, binder. labels Apr 16, 2024
@github-actions github-actions bot added this to the release-1.9 milestone Apr 16, 2024
@fuyufjh fuyufjh modified the milestones: release-1.9, release-1.10 May 14, 2024
@tabVersion
Copy link
Contributor

@BugenZhao can you share more on the topic?

Currently when running SHOW TABLES in RisingWave, the schema search path is not followed and the default schema public will always be used.

Do you mean the fallback path should be current schema -> current database -> other database?

@BugenZhao
Copy link
Member Author

BugenZhao commented May 20, 2024

Do you mean the fallback path should be current schema -> current database -> other database?

Should follow the behavior described in the manual: https://www.postgresql.org/docs/current/ddl-schemas.html#DDL-SCHEMAS-PATH . We've implemented it before, so the only stuff to do is to utilize it.

/// see <https://www.postgresql.org/docs/14/runtime-config-client.html#GUC-SEARCH-PATH>
///
/// 1. when we `select` or `drop` object and don't give a specified schema, it will search the
/// object from the valid items in schema `rw_catalog`, `pg_catalog` and `search_path`. If schema
/// `rw_catalog` and `pg_catalog` are not in `search_path`, we will search them firstly. If they're
/// in `search_path`, we will follow the order in `search_path`.
///
/// 2. when we `create` a `source` or `mv` and don't give a specified schema, it will use the first
/// valid schema in `search_path`.
///
/// 3. when we `create` a `index` or `sink`, it will use the schema of the associated table.
#[derive(Clone, Debug, PartialEq)]
pub struct SearchPath {
origin_str: String,
/// The path will implicitly includes `rw_catalog` and `pg_catalog` if user does specify them.
path: Vec<String>,
real_path: Vec<String>,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/frontend Protocol, parsing, binder. type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants