Skip to content

Conversation

@yezizp2012
Copy link
Member

@yezizp2012 yezizp2012 commented Dec 20, 2022

I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.

What's changed and what's your intention?

Introduced several system tables and function to support DBeaver:

  • add system table: pg_roles, return all users information.
  • add system tables: pg_attrdef and pg_shdescription, return empty rows as a workaround.
  • add function pg_get_expr, return empty string as a workaround.

Examples

dev=> create table t1 (v1 int, v2 int);
CREATE_TABLE
dev=> create index t1_idx1 on t1(v1);
CREATE_INDEX
dev=> create materialized view mv1 as select * from t1;
CREATE_MATERIALIZED_VIEW
dev=> SELECT c.relname,a.*,pg_catalog.pg_get_expr(ad.adbin, ad.adrelid, true) as def_value,dsc.description
FROM pg_catalog.pg_attribute a
INNER JOIN pg_catalog.pg_class c ON (a.attrelid=c.oid)
LEFT OUTER JOIN pg_catalog.pg_attrdef ad ON (a.attrelid=ad.adrelid AND a.attnum = ad.adnum)
LEFT OUTER JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid AND a.attnum = dsc.objsubid)
WHERE NOT a.attisdropped ORDER BY a.attnum;
 relname | attrelid | attname | atttypid | attlen | attnum | attnotnull | attisdropped | def_value | description
---------+----------+---------+----------+--------+--------+------------+--------------+-----------+-------------
 mv1     |     1663 | v1      |       23 |      4 |      1 | f          | f            |           |
 t1      |     1660 | v1      |       23 |      4 |      1 | f          | f            |           |
 t1_idx1 |     1662 | v1      |       23 |      4 |      1 | f          | f            |           |
 mv1     |     1663 | v2      |       23 |      4 |      2 | f          | f            |           |
 t1      |     1660 | v2      |       23 |      4 |      2 | f          | f            |           |
 t1_idx1 |     1662 | v2      |       23 |      4 |      2 | f          | f            |           |
(6 rows)

dev=> SELECT a.oid,a.*,pd.description FROM pg_catalog.pg_roles a
left join pg_catalog.pg_shdescription pd on a.oid = pd.objoid
ORDER BY a.rolname;
 oid | oid | rolname  | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolpassword | description
-----+-----+----------+----------+------------+---------------+-------------+-------------+-------------+-------------
   2 |   2 | postgres | t        | t          | t             | t           | t           | ********    |
   1 |   1 | root     | t        | t          | t             | t           | t           | ********    |
(2 rows)

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

If your pull request contains user-facing changes, please specify the types of the changes, and create a release note. Otherwise, please feel free to remove this section.

Types of user-facing changes

Please keep the types that apply to your changes, and remove those that do not apply.

  • SQL commands, functions, and operators

add system table pg_roles to return all users information.

Release note

Please create a release note for your changes. In the release note, focus on the impact on users, and mention the environment or conditions where the impact may occur.

Refer to a related PR or issue link (optional)

Resolve #6879
Resolve #6880
Resolve #6881

@github-actions github-actions bot added the type/feature Type: New feature. label Dec 20, 2022
Copy link
Contributor

@HuaHuaY HuaHuaY left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

Merging #6982 (6f04e89) into main (e2fb20a) will decrease coverage by 0.01%.
The diff coverage is 10.81%.

@@            Coverage Diff             @@
##             main    #6982      +/-   ##
==========================================
- Coverage   72.95%   72.93%   -0.02%     
==========================================
  Files        1038     1038              
  Lines      166967   167004      +37     
==========================================
+ Hits       121803   121809       +6     
- Misses      45164    45195      +31     
Flag Coverage Δ
rust 72.93% <10.81%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ntend/src/catalog/system_catalog/pg_catalog/mod.rs 0.00% <0.00%> (ø)
src/frontend/src/binder/expr/function.rs 81.44% <14.28%> (-1.24%) ⬇️
src/frontend/src/catalog/system_catalog/mod.rs 69.35% <100.00%> (+1.55%) ⬆️
src/stream/src/executor/aggregation/minput.rs 96.39% <0.00%> (-0.11%) ⬇️
src/storage/src/hummock/sstable_store.rs 63.77% <0.00%> (+0.19%) ⬆️
src/object_store/src/object/mod.rs 51.19% <0.00%> (+0.21%) ⬆️
src/object_store/src/object/mem.rs 87.50% <0.00%> (+0.37%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@yezizp2012 yezizp2012 changed the title feat: introduce several system tables and function to support DBeaver feat(frontend): introduce several system tables and function to support DBeaver Dec 20, 2022
@yezizp2012 yezizp2012 added the user-facing-changes Contains changes that are visible to users label Dec 20, 2022
@mergify mergify bot merged commit 14cf26b into main Dec 20, 2022
@mergify mergify bot deleted the feat/support-dbeaver branch December 20, 2022 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/feature Type: New feature. user-facing-changes Contains changes that are visible to users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DBeaver: Viewing permissions DBeaver: Viewing index DBeaver: Viewing details on column definition (for table/mv/view)

4 participants