System catalogs and information_schema
SynergyDB does not keep PostgreSQL's catalog tables. It builds the catalog relations a client asks for from its own metadata keys at query time, or returns a fixed, often empty, answer with the right column names. This page lists which relations exist, where their rows come from, and which ones are stubs.
The PostgreSQL wire path that sends a query to the catalog, and the order in which that check happens, is described in PostgreSQL protocol. The sequence and constraint metadata behind several of these relations is described in Constraints, sequences and identity columns.
How a catalog query is answered
There are three ways a catalog query can be answered:
| Path | When | What it does |
|---|---|---|
| Planner over live relations | a plain SELECT or WITH whose catalog relations are all in the served lists and whose pg_* function calls are all ones the engine evaluates |
the engine plans the query normally, so WHERE, joins, GROUP BY, CASE and the select list are applied for real |
| Handler | anything else that SystemCatalog::is_catalog_query recognises |
SystemCatalog::execute matches the query text against known client shapes (pgjdbc, Npgsql, asyncpg, Prisma, Django, Rails, Doctrine, Laravel, psql, pg_dump) and returns a prepared answer |
| Static definition | a catalog relation reached through the executor that SystemCatalog does not build |
virtual_catalog_table or role_catalog_table returns a column list and fixed rows, usually none |
(source: src/protocol/postgres/catalog.rs, SystemCatalog::engine_can_answer, SystemCatalog::is_dedicated_shape, SystemCatalog::execute; src/query/engine.rs, handle_system_query, virtual_catalog_table, role_catalog_table)
engine_can_answer declines queries that use ::regtype, ::regproc, ::regnamespace, ::regrole, a ::regclass cast of anything but a string literal, LATERAL, information_schema._pg_expandarray, or a pg_* function outside the evaluated list. Those go to the handler, which matches on text. A handler answer is only as accurate as the shape it was written for: a query that resembles a known shape but filters differently may get the known shape's rows. (source: src/protocol/postgres/catalog.rs, SystemCatalog::engine_can_answer) Test: engine_declines_catalog_constructs_it_does_not_model.
(source: src/protocol/postgres/catalog.rs, SystemCatalog::execute; src/query/engine.rs, handle_system_query)
Queries that select the tableoid column (as pg_dump does) always go to the planner, so the full column list is returned. pg_dump's own queries are answered by src/protocol/postgres/catalog/pg_dump.rs. (source: src/protocol/postgres/catalog.rs, SystemCatalog::is_dedicated_shape; src/query/engine.rs, handle_system_query)
SELECT current_user and SELECT session_user are answered from the session, so they name the logged-in or SET ROLE role, not a fixed name. (source: src/query/engine.rs, handle_system_query)
Each catalog view is bound to the session's database and schema: table_catalog and current_database() report the database the client connected to. (source: src/protocol/postgres/mod.rs, SystemCatalog::with_database, with_schema call sites; src/query/engine.rs, handle_system_query)
Internal shadow tables that back other protocols (Redis, Bolt, DynamoDB and so on) are left out of table listings. (source: src/protocol/postgres/catalog.rs, get_tables, is_internal_shadow_table)
pg_catalog relations built from live metadata
These are built by SystemCatalog::relation and can be queried with any SQL the planner supports. (source: src/protocol/postgres/catalog.rs, SERVED_RELATIONS, SystemCatalog::relation_raw)
| Relation | Rows |
|---|---|
pg_class |
tables (r), views (v), materialized views (m), indexes including those behind PRIMARY KEY and UNIQUE (i), sequences (S); reltuples is the estimate from the last ANALYZE, 0 before one |
pg_attribute |
one row per column of each table |
pg_type |
built-in types plus user enum and composite types |
pg_enum |
labels of CREATE TYPE ... AS ENUM types |
pg_constraint |
primary key, unique, foreign key and check constraints |
pg_index |
secondary and constraint indexes |
pg_namespace |
pg_catalog, information_schema, public and created schemas |
pg_proc |
a fixed list of 16 built-in functions (abs, length, lower, upper, now, count, sum and others) plus user functions |
pg_trigger |
one row per user trigger |
pg_tables, pg_views, pg_indexes
|
tables, views, indexes |
pg_sequences, pg_sequence
|
sequences made with CREATE SEQUENCE
|
pg_attrdef |
one row per column default; adbin holds the expression text, so pg_get_expr(adbin, adrelid) returns it |
pg_database |
the databases registered in the cluster |
pg_settings |
fixed list, see below |
pg_stat_user_tables, pg_stat_all_tables
|
one row per table, see below |
pg_statio_user_tables, pg_statio_all_tables
|
one row per table, see below |
(source: src/protocol/postgres/catalog.rs, pg_class, pg_attribute, pg_type, pg_enum, pg_constraint, pg_index, pg_namespace, pg_proc, pg_trigger, pg_tables, pg_views, pg_indexes, pg_sequences, pg_sequence, pg_attrdef, pg_database, pg_settings, pg_stat_tables, pg_statio_tables)
Tests in src/query/engine.rs: sequences_are_visible, functions_triggers_and_views_are_visible, pg_constraint_has_primary_and_foreign_keys, pgjdbc_get_primary_keys, column_defaults_reach_pg_attrdef_and_information_schema, catalog_relation_cache_follows_analyze_and_sequences, statement_caches_follow_views_and_sequences_from_other_sessions, pg_sequences_and_multi_ordinal_order_by; tests/pg_class_reltuples.rs.
The built-in rows of pg_proc use OIDs 1 to 16, not PostgreSQL's OIDs, and list only those 16 functions, so a client that looks up other built-in functions there will not find them. (source: src/protocol/postgres/catalog.rs, pg_proc)
A SERIAL or identity column has only an internal counter, not a sequence, so it does not appear in pg_sequences or pg_sequence. (source: src/protocol/postgres/catalog.rs, get_sequences; src/query/engine.rs, execute_create_table)
pg_settings
pg_settings is a fixed list of 19 rows: max_connections 100, max_index_keys 32, shared_buffers 128MB, work_mem 4MB, maintenance_work_mem 64MB, effective_cache_size 4GB, random_page_cost 4.0, seq_page_cost 1.0, default_statistics_target 100, statement_timeout 0, lock_timeout 0, idle_in_transaction_session_timeout 0, timezone UTC, DateStyle ISO, MDY, server_version 15.0, server_encoding and client_encoding UTF8, lc_collate and lc_ctype en_US.UTF-8. (source: src/protocol/postgres/catalog.rs, SystemCatalog::pg_settings)
The list does not reflect SET: a session that runs SET search_path = app still sees no search_path row, and SET work_mem does not change the work_mem row. Use SHOW or current_setting() instead; see Session settings. Most of these values describe PostgreSQL defaults, not anything SynergyDB uses: there is no shared buffer pool sized by shared_buffers, and the effective lock_timeout cap is 300 seconds, not 0. (source: src/protocol/postgres/catalog.rs, SystemCatalog::pg_settings; src/query/engine.rs, lock_wait_timeout)
Statistics views
The statistics views mix one real figure with fixed numbers:
| Column | Value |
|---|---|
n_live_tup, n_tup_ins, seq_tup_read
|
row count from estimate_row_count
|
idx_tup_fetch |
half of that row count |
seq_scan |
always 100 |
idx_scan |
always 50 |
n_tup_upd, n_tup_del, n_dead_tup
|
always 0 |
pg_statio_*: heap_blks_read, heap_blks_hit, idx_blks_read, idx_blks_hit
|
always 100, 900, 50, 450 |
(source: src/protocol/postgres/catalog.rs, pg_stat_tables, pg_statio_tables)
These numbers are not measurements. Monitoring tools that read scan counts or cache hit ratios from these views will show constant values.
pg_catalog relations with fixed answers
These are known relations whose answer does not come from live metadata. (source: src/protocol/postgres/catalog.rs, ENGINE_STATIC_RELATIONS; src/query/engine.rs, virtual_catalog_table, role_catalog_table)
| Relation | Answer |
|---|---|
pg_roles, pg_authid, pg_user, pg_shadow
|
real roles from the role catalog; the password column never holds the stored password (NULL in pg_authid, ******** in pg_user and pg_shadow) |
pg_extension |
plpgsql, plus every extension named in CREATE EXTENSION
|
pg_am |
PostgreSQL 16's built-in access methods plus hnsw and ivfflat
|
pg_ts_config |
the built-in text search configurations |
pg_namespace (executor path) |
fixed list |
pg_locks |
always empty |
pg_stat_activity |
always empty |
pg_description, pg_shdescription
|
always empty |
pg_policy |
always empty |
pg_matviews |
always empty |
pg_depend, pg_inherits, pg_partitioned_table, pg_rewrite
|
always empty |
pg_collation, pg_language, pg_operator, pg_opclass, pg_range, pg_conversion
|
always empty |
pg_statistic, pg_stats, pg_statistic_ext
|
always empty |
pg_init_privs, pg_default_acl, pg_db_role_setting, pg_group
|
always empty |
pg_foreign_table, pg_foreign_server, pg_user_mapping
|
always empty |
pg_seclabel, pg_shseclabel, pg_seclabels, pg_largeobject, pg_largeobject_metadata, pg_cursors
|
always empty |
(source: src/query/engine.rs, virtual_catalog_table, role_catalog_table)
Some of these empty answers hide data the engine does hold:
| Relation | Always empty, although |
|---|---|
pg_locks |
pg_advisory_lock and the other advisory lock functions take real locks; the comment beside the definition says "We take no advisory locks" |
pg_policy |
row-level security policies are stored and enforced |
pg_matviews |
materialized views exist and appear in pg_class with relkind m
|
pg_description |
COMMENT ON is stored (and read back by the Snowflake protocol) |
pg_language |
pg_extension lists plpgsql and CREATE FUNCTION ... LANGUAGE plpgsql works |
pg_stat_activity |
sessions exist; application_name is stored per session |
(source: src/query/engine.rs, virtual_catalog_table, try_handle_advisory_lock, set_object_comment, all_object_comments; src/plan/rls_injector.rs, RlsInjector)
A catalog relation that is in neither list, for example pg_publication or pg_event_trigger, is looked up as an ordinary table and fails with "Table not found" unless the handler recognises the query shape. Not verified: no test lists which unlisted relations the handler covers. (source: src/query/engine.rs, handle_system_query, virtual_catalog_table)
Catalog functions
The engine evaluates these pg_* functions inside planner queries: pg_table_is_visible, pg_type_is_visible, pg_function_is_visible, pg_get_userbyid, pg_get_expr, pg_encoding_to_char, pg_backend_pid, pg_is_in_recovery. (source: src/protocol/postgres/catalog.rs, ENGINE_PG_FUNCTIONS)
| Function | Behaviour |
|---|---|
pg_get_userbyid(oid) |
always postgres for a non-NULL argument |
pg_get_expr(adbin, relid) |
returns its first argument, since adbin already holds the expression text |
obj_description, col_description, shobj_description
|
always NULL |
pg_get_indexdef, pg_get_constraintdef, pg_total_relation_size
|
answered only inside query shapes the handler recognises; not general functions |
(source: src/query/engine.rs, evaluate_row_expr arms "pg_get_userbyid", "pg_get_expr", "obj_description"; src/protocol/postgres/catalog.rs, SystemCatalog::execute_inner_raw, obj_description)
obj_description and col_description return NULL on both paths: the engine arm carries the comment "COMMENT ON is not stored, so no object has a comment", and the handler's obj_description answer is a single NULL row. (source: src/query/engine.rs, "obj_description" arm; src/protocol/postgres/catalog.rs, obj_description)
Other functions such as format_type, current_schema, current_schemas, version(), to_regclass and has_table_privilege are covered in Functions and operators. An unknown function evaluates to NULL, which is why engine_can_answer sends queries with unknown pg_* calls to the handler instead. (source: src/protocol/postgres/catalog.rs, ENGINE_PG_FUNCTIONS doc comment)
information_schema on the PostgreSQL wire
| View | Rows |
|---|---|
tables |
tables (BASE TABLE) and views (VIEW) of the current database |
columns |
one row per column; column_default in PostgreSQL's spelling |
schemata |
schemas |
views |
views with their definition |
table_constraints |
PRIMARY KEY, UNIQUE, FOREIGN KEY and CHECK constraints |
key_column_usage |
key columns of those constraints |
referential_constraints |
foreign keys with their update and delete rules |
constraint_column_usage |
referenced columns |
triggers |
user triggers |
routines |
user functions |
sequences |
CREATE SEQUENCE sequences |
(source: src/protocol/postgres/catalog.rs, SERVED_RELATIONS, information_schema_tables, information_schema_columns, information_schema_schemata, information_schema_views, information_schema_table_constraints, information_schema_key_column_usage, information_schema_referential_constraints, information_schema_constraint_column_usage, information_schema_triggers, information_schema_routines, information_schema_sequences)
Other views, such as information_schema.check_constraints, column_privileges and role_table_grants, are not built. The engine's own test lists check_constraints as a view it does not build. (source: src/protocol/postgres/catalog.rs, test engine_declines_catalog_constructs_it_does_not_model) The security guide notes that column_privileges does not report column grants; see Security.
information_schema and system schemas on the MySQL wire
On the MySQL wire the catalog is built with with_mysql_dialect(true), which changes the shape and content of several views. (source: src/protocol/postgres/catalog.rs, SystemCatalog::with_mysql_dialect)
| View | Rows on the MySQL wire |
|---|---|
TABLES |
TABLE_CATALOG is def, TABLE_SCHEMA is the database name |
COLUMNS |
MySQL shape: COLUMN_TYPE, COLUMN_KEY and the length and precision columns come from the declared MySQL types; COLUMN_DEFAULT is the raw value |
SCHEMATA |
mysql, information_schema, performance_schema, sys and every created database; answered by the planner so WHERE SCHEMA_NAME = DATABASE() works |
VIEWS |
MySQL columns (DEFINER, SECURITY_TYPE, …); answered by the planner |
STATISTICS |
one row per column per secondary index; primary keys are not listed |
USER_PRIVILEGES, SCHEMA_PRIVILEGES
|
built from the role catalog |
COLUMN_STATISTICS, PARTITIONS, FILES
|
always empty |
TABLE_CONSTRAINTS, KEY_COLUMN_USAGE, REFERENTIAL_CONSTRAINTS, CONSTRAINT_COLUMN_USAGE, TRIGGERS, ROUTINES
|
always empty |
(source: src/protocol/postgres/catalog.rs, information_schema_tables, information_schema_columns, mysql_column_meta, mysql_schemata, mysql_engine_served, information_schema_statistics, information_schema_table_constraints, information_schema_key_column_usage, information_schema_referential_constraints, information_schema_constraint_column_usage, information_schema_triggers, information_schema_routines; src/query/engine.rs, handle_system_query, role_catalog_table, mysql_privilege_view)
Because KEY_COLUMN_USAGE and TABLE_CONSTRAINTS are empty on the MySQL wire, MySQL tools and ORMs that read primary and foreign keys from them find none, even though the constraints are enforced. SHOW INDEX and SHOW CREATE TABLE are the other places to look; see MySQL protocol. Not verified: no test covers these views over the MySQL wire. (source: src/protocol/postgres/catalog.rs, information_schema_key_column_usage, information_schema_table_constraints)
The mysql, performance_schema and sys schemas are listed by SHOW DATABASES and SCHEMATA and are accepted as database qualifiers, but they hold no tables except one: mysql.global_priv returns one row per login role, with Host always % and Priv holding only the superuser flag. mysql.user is not available; the code deliberately does not map a bare user table name to it, so an application's own user table is not shadowed. (source: src/query/engine.rs, role_catalog_table; src/protocol/mysql/mod.rs, database-qualifier handling; src/protocol/postgres/catalog.rs, mysql_schemata)
synergydb_debug_keys
SELECT * FROM synergydb_debug_keys and SELECT * FROM synergydb_debug_keys('prefix') are diagnostic queries that list raw storage key names with a scope column (namespaced or global), up to 2,000 rows. The PostgreSQL handler answers them before the engine sees the query. (source: src/protocol/postgres/catalog.rs, SystemCatalog::synergydb_debug_keys, is_catalog_query; src/protocol/postgres/mod.rs, catalog routing)
The doc comment says the query returns "key names only, never values, so it exposes no row data". Key names do carry data: a row's storage key contains its primary key value, and the __uniq__ keys contain every value of a UNIQUE column (for example e-mail addresses). The global scope scans the whole store, so key names from other databases are included. No privilege check is applied on this path. Not verified: there is no test for synergydb_debug_keys. (source: src/protocol/postgres/catalog.rs, synergydb_debug_keys; src/storage/namespaced.rs, NamespacedStorage::global; src/query/engine.rs, pk_storage_key, unique_index_key)