pglite icon indicating copy to clipboard operation
pglite copied to clipboard

Missing "pg_catalog.pg_tables" and "information_schema.tables"

Open simonw opened this issue 1 year ago • 4 comments

I tried running this SQL query:

select * from pg_catalog.pg_tables

But I got this error:

RuntimeError: relation "pg_catalog.pg_tables" does not exist at character 15

Is there a way to do this at the moment? If not, could there be?

simonw avatar Feb 23 '24 16:02 simonw

Interesting - most of the catalog tables are there, but not this one (src )

Could be due to the way the underlying fork handles the storage?

Full list of catalog image

kiwicopple avatar Feb 23 '24 17:02 kiwicopple

Huh, yeah - this works for me

select * from pg_catalog.pg_type

simonw avatar Feb 23 '24 17:02 simonw

This query works for me to list tables:

select relname from pg_class
join pg_namespace on pg_namespace.oid = pg_class.relnamespace
where pg_class.relkind = 'r'
and relname not like 'pg_%'

simonw avatar Feb 23 '24 17:02 simonw

I've been playing around with this in an Observable Framework notebook here: https://simonw.github.io/observable-framework-experiments/postgresql

Source code here: https://github.com/simonw/observable-framework-experiments/blob/main/docs/postgresql.md?plain=1

simonw avatar Feb 23 '24 17:02 simonw

I believe this is due to the simplified initdb.ts that replaces the conventional initdb command that comes with Postgres. It's not fully creating all the catalog tables.

We should look at compiling initdb to wasm, although it runs postgres --boot which we would need to do separately which creates a little complexity.

samwillis avatar Mar 05 '24 13:03 samwillis

fyi also seeing this with await new PGlite("./pgdata").query('select * from pg_catalog.pg_roles'); Would be really awesome if pglite could work with postgraphile. I have a PoC repo I can share for testing if you're interested.

kzlar avatar Mar 13 '24 17:03 kzlar

The missing "pg_catalog.pg_tables" and "information_schema.tables" (among others) are fixed in #41 and we plan to do a release early next week after a few finals checks.

If anyone wants to take it for a spin, there is dev build linked in PR #48 which is the tip of a stack of PRs.

samwillis avatar Mar 23 '24 13:03 samwillis