-
Notifications
You must be signed in to change notification settings - Fork 79
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
dbListObjects()
does not list empty schemata
#388
Comments
Thanks. I wonder if it's worth fixing here. In dm I'm working on an abstraction of |
Agree, the practical relevance is rather limited (though not entirely absent e.g. like in my reprex: creating a schema, then checking whether it's there). Maybe I can tackle this together with #251 / #261.
This certainly looks interesting, but I'd have to dig in deeper to add something meaningful and cannot promise if/when that'll happen. I'll just state the (now) obvious, that |
Note to self: We need to filter DetailsFrom an "empty" DB after running the RPostgres tests (i.e. adding and removing some tables).> dbListObjects(pg_con)
table is_prefix
1 <Id> schema = information_schema TRUE
2 <Id> schema = pg_catalog TRUE
> dbGetQuery(pg_con, 'SELECT * FROM pg_catalog.pg_namespace;')
oid nspname nspowner nspacl
1 99 pg_toast 10 <NA>
2 11 pg_catalog 10 {postgres=UC/postgres,=U/postgres}
3 2200 public 6171 {pg_database_owner=UC/pg_database_owner,=U/pg_database_owner}
4 13186 information_schema 10 {postgres=UC/postgres,=U/postgres}
5 16388 pg_temp_4 10 <NA>
6 16389 pg_toast_temp_4 10 <NA>
7 16395 pg_temp_5 10 <NA>
8 16396 pg_toast_temp_5 10 <NA>
9 18767 pg_temp_10 10 <NA>
10 18768 pg_toast_temp_10 10 <NA>
11 18824 pg_temp_7 10 <NA>
12 18825 pg_toast_temp_7 10 <NA>
13 20812 pg_temp_9 10 <NA>
14 20813 pg_toast_temp_9 10 <NA>
15 27016 pg_temp_3 10 <NA>
16 27017 pg_toast_temp_3 10 <NA>
17 27024 Robert 10 <NA>
> dbGetQuery(pg_con, 'SELECT schema_name FROM information_schema.schemata;')
schema_name
1 public
2 Robert
3 pg_toast_temp_3
4 pg_temp_3
5 pg_toast_temp_9
6 pg_temp_9
7 pg_toast_temp_7
8 pg_temp_7
9 pg_toast_temp_10
10 pg_temp_10
11 pg_toast_temp_5
12 pg_temp_5
13 pg_toast_temp_4
14 pg_temp_4
15 information_schema
16 pg_catalog
17 pg_toast |
Then again, we may need to list the We cannot tell from SELECT schema_name AS schema, NULL::varchar AS table
FROM information_schema.schemata
WHERE schema_name NOT LIKE 'pg_toast%' AND schema_name NOT LIKE 'pg_temp%'
UNION
SELECT DISTINCT table_schema AS schema, NULL::varchar AS table
FROM (SELECT table_schema, table_name FROM information_schema.tables) as schema_query When using the system catalogs, we can get the temp schema with also with: SELECT nspname
FROM pg_namespace
WHERE oid = pg_my_temp_schema(); The question remains, whether returning the temp schema is really necessary/useful, see https://dba.stackexchange.com/a/76516. |
dbListObjects()
does not list empty schemata, i.e. a schema without a table.The schema is listed in
information_schema.schemata
orpg_catalog.pg_namespace
(the (empty)public
schema is also not listed bydbListObjects()
BTW)The schema is also listed by
dbListObjects()
after adding a tableThe reason for this is that
dbListObjects()
usesinformation_schema.tables
to look up tables and schemata, but naturally theinformation_schema.tables
view does not list schemata if they do not contain a table.Session info
The text was updated successfully, but these errors were encountered: