-
Notifications
You must be signed in to change notification settings - Fork 313
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
Compatible with Postgres system catalog #3560
Comments
Not quite easy. Seems related to some internal functions also:
|
And this is the query for "show tables" (
|
I did some research about this before, it needs a lot work, and most of them had been done by risingwave, maybe you can use some code from them, and make less effort for this. FYI: you can refer this issue. |
Yes, we are doing a lot of work to be compatible with MySQL, pg is our next goal. |
One thing came to my mind that databend, risgingwave and greptime all using rust and all maybe have the need to implement protocols risingwave mainly for pg, and databend mainly for mysql, maybe you can extract something common and help each other, maybe its a triple-win thing. |
Let's add pgwrite into databend! |
I would like to get involved in this work.😊 |
@J0HN50N133 Welcome! You can take a look at how we implement the "information_schema" tables as a reference. But I'm also still unaware of how to add the necessary functions or work it around. |
@tisonkun I will try to add a new schema called Although Goals
System Catalogs implementation planIn the current version, tables following are possible to support:
The first three tables will be implemented first since they are basis. Implementationpg_catalog management
pg_catalog related system functionImplement them with datafusion udf. Like:
|
I'll manage to provide similar features in #2931. Tasks
|
While supporting SELECT n.nspname as "Schema",
c.relname as "Name",
CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partitioned index' END as "Type",
pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','p','')
AND n.nspname <> 'pg_catalog'
AND n.nspname !~ '^pg_toast'
AND n.nspname <> 'information_schema'
AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
@tisonkun WDYT? |
@J0HN50N133 Thanks for pushing forward this ticket!
Yeah. This is reasonable as a first implementation. cc @shuiyisong @zyy17 later we may consider how to integrate it with the plugin system to allow populate user info in this case.
Adding ID for schema can be a breaking change and introduce overload burden to overcome in this issue. cc @killme2008 @waynexia please take a look at this information schema related logics. A workaround can be using the schema name as "oid" in this place. |
The shortcomings is the potential incompatibility with existing pg eco. |
Yeah. Some how the type is different, but comparing should work. cc @killme2008 @waynexia what's the affect if we try to add id to each schema? |
Next I will try to support dbeaver connection to greptime, via pg protocol. The following sql is the statements fail. SELECT typcategory FROM pg_catalog.pg_type WHERE 1<>1 LIMIT 1 SELECT t.oid,t.*,c.relkind,NULL as base_type_name, d.description
FROM pg_catalog.pg_type t
LEFT OUTER JOIN pg_catalog.pg_class c ON c.oid=t.typrelid
LEFT OUTER JOIN pg_catalog.pg_description d ON t.oid=d.objoid
WHERE t.typname IS NOT NULL
AND (c.relkind IS NULL OR c.relkind = 'c') |
@J0HN50N133 I just found that tables like
without calling One idea is to resolve those table like |
@sunng87 Yeah, #4543 maybe also relate to this, for example, this hidden table should not appear in MySQL client. Maybe we modify DfTableSourceProvider to solve both problems. |
* fix: table resolving logic related to pg_catalog refer to #3560 (comment) and #4543 * refactor: remove CatalogProtocol type * fix: sqlness * fix: forbid create database pg_catalog with mysql client * refactor: use QueryContext as arguments rather than Channel * refactor: pass None as default behaviour in information_schema * test: fix test
* fix: table resolving logic related to pg_catalog refer to GreptimeTeam#3560 (comment) and GreptimeTeam#4543 * refactor: remove CatalogProtocol type * fix: sqlness * fix: forbid create database pg_catalog with mysql client * refactor: use QueryContext as arguments rather than Channel * refactor: pass None as default behaviour in information_schema * test: fix test
What type of enhancement is this?
User experience
What does the enhancement do?
Since we want to support users to access GreptimeDB with psql, we'd better be more compatible when possible.
Currently, when you run
psql -l
against GreptimeDB, it would fail with:Implementation challenges
This should be similar to MySQL's information
The text was updated successfully, but these errors were encountered: