It’s our goal to make Doltgres, a Postgres-flavored version
of Dolt, a drop-in replacement for Postgres. A few
weeks ago Zach wrote a
blog about our design dilemma for implementing the
pg_catalog schema: should we diverge from Postgres and make it read-only? After some
internal debate and feedback from
Redditors,
we have since decided to follow Cockroach DB’s
footsteps and make pg_catalog
read-only. Manually editing system tables seems not very common and bad practice anyway.
Since then, we’ve been making progress implementing pg_catalog features, starting with
the ones we found by testing popular SQL workbenches and ORMs. This blog gives an update of
our progress.
What is the pg_catalog schema?#
In Postgres, metadata about the tables, functions, and other schema elements are exposed
via the system catalogs,
accessed through the pg_catalog schema in each database. Here are a few examples:
pg_class: contains information about the relations (tables, indexes, etc.) in the databasepg_enum: contains enum label and value definitionspg_proc: contains function and procedure definitions
Additionally, there are tables that expose and configure the server’s behavior, like users
and their permission to access particular tables, such as the pg_authid table.
Here’s an example of querying these tables.
db1=# select oid, relname from pg_class;
oid | relname
-------+------------------------------------------------
61501 | test
61504 | test_pkey
61506 | test2
61509 | test2_pkey
2619 | pg_statistic
1247 | pg_type
62229 | test
62232 | test_pkey
62235 | test
62238 | test_pkey
2836 | pg_toast_1255
2837 | pg_toast_1255_index
The pg_catalog schema is used in many workbenches, including the Dolt
Workbench, making it a vital feature to
Doltgres’s usability as a database.
Current pg_catalog status#
We have been making steady progress implementing pg_catalog. Here’s an overview of our
progress as of Doltgres
v0.10.0. See the
appendix for a more detailed status of pg_catalog tables and views.
- Implemented an interface for exposing
pg_catalogsystem tables as virtual tables. - Added schemas for all
pg_catalogtables and views so that they will at least parse with no rows. - Implemented a temporary OID system using an on-demand hashing strategy using the name of the schema element.
- Populated partial columns and rows for some tables (
pg_attribute,pg_class,pg_constraint,pg_database,pg_index,pg_sequence,pg_type) and views (pg_indexes,pg_tables,pg_views) we know some popular SQL workbenches utilize.
Conclusion#
You’ll notice there’s a lot of red below, but we’re just getting started with Doltgres and
pg_catalog support. Let us know if you have any pg_catalog features you want us to
prioritize by filing an issue or reaching
out on Discord. Stay tuned!
Appendix#
Here’s a list of all pg_catalog tables and views and their current status as of
Doltgres v0.10.0. We will
update this list in our docs as we
continue to make progress.
These tables show:
- ✅ Full support for the feature.
- 🟠 Partial support for the feature.
- ❌ No support for the feature.
