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

Feat: Support variable input of System Administration Functions #11752

Closed
st1page opened this issue Aug 17, 2023 · 4 comments
Closed

Feat: Support variable input of System Administration Functions #11752

st1page opened this issue Aug 17, 2023 · 4 comments
Assignees
Milestone

Comments

@st1page
Copy link
Contributor

st1page commented Aug 17, 2023

Background

We have supported some PG's System Administration Functions https://www.postgresql.org/docs/9.1/functions-admin.html. But we only support literal input now.

In PG

dev=# create table t_names(name varchar);
CREATE TABLE
dev=# insert into t_names values ('a'), ('t');
INSERT 0 2
dev=# select pg_table_size(name) from t_names;
 pg_table_size 
---------------
         16384
         16384
(2 rows)

In RW

dev=> select pg_table_size(name) from t_names;
ERROR:  QueryError: Bind error: failed to bind expression: pg_table_size(name)

Caused by:
  Expr error: Expected an integer or varchar literal

The usage is found in bytebase's PG connector currently.
https://github.com/bytebase/bytebase/blob/b871987854e842d2adf21e7278594af38a3b1b6f/backend/plugin/db/pg/sync.go#L414-L423

implementation

We can bind it with nested subquery

dev=> explain (trace) select 
    name, 
    (select total_key_size + total_value_size from rw_catalog.rw_table_stats 
        where rw_catalog.rw_table_stats.id = (
            select id from rw_catalog.rw_tables where rw_catalog.rw_tables.name = t_names.name limit 1
        )
    ) as pg_table_size
from t_names;

Alternative

Another solution is to implement a special SystemProject executor in LocalExecution(Frontend) which can read from the catalog during processing.

@github-actions github-actions bot added this to the release-1.2 milestone Aug 17, 2023
@st1page
Copy link
Contributor Author

st1page commented Aug 17, 2023

Not sure if it can cover all Administration Functions. I am only sure it can solve "xxx_size" functions.
c.c. @yezizp2012 @xiangjinwu

@TennyZhuang
Copy link
Contributor

#11522

@st1page st1page self-assigned this Aug 17, 2023
@st1page
Copy link
Contributor Author

st1page commented Sep 11, 2023

need discuss if we still need this after risingwavelabs/rfcs#75

Copy link
Contributor

github-actions bot commented Jul 3, 2024

This issue has been open for 60 days with no activity.

If you think it is still relevant today, and needs to be done in the near future, you can comment to update the status, or just manually remove the no-issue-activity label.

You can also confidently close this issue as not planned to keep our backlog clean.
Don't worry if you think the issue is still valuable to continue in the future.
It's searchable and can be reopened when it's time. 😄

@st1page st1page closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants