System views
System views are the read-only SQL contract for Amphi metadata. They live in the sys schema, are created during catalog bootstrap, and can be queried by tools such as amphi-console.
The public contract is formed by sys.catalog_* views. Physical catalog relations remain implementation details and should not be queried directly by new applications.
SELECT schema, name, kind, engine
FROM sys.catalog_objects
ORDER BY schema, name;
sys.catalog_object_comments
Lists comments for entities with catalog OID identities. Relations and columns
are also available through sys.catalog_objects and sys.catalog_columns;
this view covers relations and other commentable families, including schemas,
types, domains, routines, roles, groups, tablespaces, policies, constraints,
triggers, and installed extensions.
| Column | Type | Description |
|---|---|---|
object_oid | int4 | Stable object identity |
object_kind | text | Object family |
schema_name | text | Schema, when applicable |
object_name | text | Object name |
owner_name | text | Owning relation for constraints/triggers |
comment | text | Stored comment |
SELECT object_kind, schema_name, object_name, comment
FROM sys.catalog_object_comments
ORDER BY object_kind, schema_name, object_name;
sys.catalog_object_tags
Lists tags for relations and catalog object families with OIDs (schemas, types,
domains, functions/aggregates, roles/groups, tablespaces, policies, constraints,
triggers, and named OID-backed objects), with one row per key. Filter by
key/value. Not all these families appear in
sys.catalog_objects, which continues to represent relations.
| Column | Type | Description |
|---|---|---|
object_oid | int4 | Stable object identity |
object_kind | text | Relation kind |
schema_name | text | Object schema |
object_name | text | Object name |
owner_name | text | Parent relation for constraints/triggers; NULL otherwise |
key | text | Tag key |
value | text | Tag value |
SELECT schema_name, object_name, object_kind
FROM sys.catalog_object_tags
WHERE key = 'env' AND value = 'prod'
ORDER BY schema_name, object_name;
ALTER TABLE ... ADD TAG key = 'value' creates or replaces a key;
ALTER TABLE ... DROP TAG key removes it. ALTER OBJECT manages non-relation
families; end-to-end validated coverage is listed in
Object tags.
Use the catalog views to inspect schemas, objects, columns, indexes, functions, and extensions. Changes must be made through the corresponding DDL commands.
sys.language
Lists procedural languages installed and active in the current process. A
language is registered by the extension that provides it; for example,
CREATE EXTENSION plamphi adds plamphi to this view.
| Column | Type | Description |
|---|---|---|
name | text | Language name used by LANGUAGE |
extension | text | Extension providing the handler |
status | text | Current handler state |
SELECT name, extension, status
FROM sys.language
ORDER BY name;
This is a virtual view of the current runtime. It is empty for a language that
is available but has not been installed with CREATE EXTENSION.
sys.catalog_functions.schema identifies the owning schema. arg_types remains encoded as
bytea; use the function history page for complete SQL definitions.
security_definer records the SECURITY DEFINER declaration; the owner is used as
current_user during execution.
sys.object_revision
Read-only history for versioned objects. For functions, source contains the complete DDL for
the revision and created_by identifies the role that made the change.
| Column | Type | Description |
|---|---|---|
object_oid | int4 | Stable object identity |
object_kind | text | Object type, currently function |
version | int8 | Revision number |
source | text | Complete DDL |
arg_names | bytea | Encoded argument names |
created_at | int8 | Timestamp in microseconds |
created_by | int4 | Author role OID |
ddl_seq | int8 | DDL sequence, when available |
sys.catalog_domains
Lists domains defined outside the sys schema. The checks column keeps the
catalog’s bytea representation so the public view can expose the complete
metadata without changing its one-row-per-domain shape; DDL and ampdump
decode that value when they need the named checks.
| Column | Type | Description |
|---|---|---|
oid | int4 | Domain identifier |
schema | text | Domain schema |
name | text | Domain name |
base_type | text | Base type |
default_expression | text | Domain default, when defined |
not_null | bool | Whether null values are rejected |
checks | bytea | Encoded named domain checks |
SELECT schema, name, base_type, default_expression, not_null
FROM sys.catalog_domains
ORDER BY schema, name;
sys.catalog_triggers
Exposes trigger descriptors stored in the catalog. This is the metadata contract of Epic 1; SQL creation and execution belong to later epics.
| Column | Type | Description |
|---|---|---|
oid | int4 | Trigger identifier |
rel | int4 | Relation owning the trigger |
name | text | Trigger name |
function | int4 | Function executed by the trigger |
timing | text | BEFORE, AFTER, or INSTEAD OF |
level | text | ROW or STATEMENT |
events | int2 | Mask of INSERT, UPDATE, DELETE, and TRUNCATE |
scope | text | LOGICAL or PHYSICAL |
arguments | bytea | Persisted trigger arguments |
enabled | bool | Whether the trigger is enabled |
scope = LOGICAL is reserved for a trigger that follows the logical operation
of a partitioned table; PHYSICAL follows a specific physical relation. This
is distinct from relation inheritance.
sys.catalog_partitions
Lists physical relations attached to a partitioned table.
| Column | Type | Description |
|---|---|---|
relation | int4 | Child relation |
parent | int4 | Parent partitioned table |
bound | text | Persisted canonical bound; typed semantics are still evolving |
sys.catalog_acls
Exposes persisted object privilege grants.
| Column | Type | Description |
|---|---|---|
relation | int4 | Protected relation OID |
grantee_kind | text | PUBLIC, ROLE, or GROUP |
grantee | int4 | Grantee OID; null for PUBLIC |
grantor | int4 | Granting role OID |
privilege | text | Granted privilege |
scope_kind | text | ALL, COLUMNS, or ALL_EXCEPT |
columns | bytea | Encoded attno list when applicable |
grant_option | bool | Whether the grantee can regrant it |
sys.catalog_default_acls
Exposes default privileges configured by a role for new tables, schemas, and
sequences. They are applied when the object is created. It has the same scope
and grantee columns as sys.catalog_acls; owner identifies the role that owns
the default rule and object identifies TABLES, SCHEMAS, or SEQUENCES.
sys.stat_activity
Shows active sessions and workers. SQL sessions use backend_type = 'client';
the internal worker uses backend_type = 'worker', worker_kind = 'partition',
and its alarm_id.
SELECT id, backend_type, worker_kind, alarm_id, state, query, relation
FROM sys.stat_activity
WHERE state = 'active';
Rows are ephemeral and disappear when the session or worker finishes.
sys.stat_progress
Shows current and recent progress for internal operations. It is an in-memory
view; durable outcome and errors remain in sys.system_alarm_status.
SELECT kind, state, phase, rows_done, rows_total, error
FROM sys.stat_progress;
Columns include operation_id, kind, state, phase, alarm_id, relation,
rows_done, rows_total, bytes_done, bytes_total, started_at, updated_at, and error.
sys.system_alarms
Shows occurrences of core-owned internal alarms. Users, extensions, and plugins cannot register new alarm kinds or handlers.
| Column | Type | Description |
|---|---|---|
| id | int8 | Occurrence identifier |
| kind | text | Internal kind, initially partition |
| owner | int4 | Associated core object, such as the parent relation |
| scheduled_at | int8 | Scheduled Unix time in microseconds |
| state | text | waiting, running, success, or failed |
| attempt | int4 | Current attempt |
| started_at | int8 | Execution start, when started |
| finished_at | int8 | Execution finish, when completed |
| error | text | Last attempt error |
| affected_objects | int4 | Objects created or changed |
| lease_owner | int8 | Worker holding the lease, when running |
| lease_until | int8 | Lease expiry as Unix microseconds |
sys.system_alarm_status exposes the same operational contract for health checks and monitoring;
users cannot create or alter system alarms. A minimal monitoring query is:
SELECT kind, state, attempt, scheduled_at, lease_owner, lease_until, error
FROM sys.system_alarm_status
WHERE state IN ('waiting', 'running', 'failed')
ORDER BY scheduled_at;
Alarm occurrences are durable and survive restart. A running row with an expired lease is
eligible for worker reclaim; failed retains the last error and may produce a new occurrence with
bounded backoff.
sys.partition_policies
Shows declarative partition policies persisted in the catalog. scope = database
represents the database policy; other values identify the schema where the policy
applies.
| Column | Type | Description |
|---|---|---|
| oid | int4 | Policy identifier |
| name | text | Policy name |
| scope | text | database or schema scope |
| relation_kind | text | table or collection |
| match_column | text | Column used for matching |
| match_type | text | Resolved column type |
| strategy | text | range, hash, or list |
| key | text | Partition key |
| every | text | Automatic interval |
| retention | text | Declared retention |
| sub_strategy | text | Subpartition strategy |
| sub_key | text | Subpartition key |
| subpartitions | int2 | Number of subpartitions |
| retention_action | text | detach or export_then_detach |
| retention_server | text | SERVER used by export, when applicable |
sys.prepared_transactions
Shows transactions retained by two-phase commit in the current cluster, including after recovery.
| Column | Type | Description |
|---|---|---|
| gid | text | Global identifier of the prepared transaction |
| xid | int8 | Transaction ID |
| prepared_at | int8 | Preparation time in microseconds since the Unix epoch |
| owner | text | User that executed PREPARE TRANSACTION |
2PC must be enabled with max_prepared_transactions greater than zero.
Logical backup neither exports nor recreates prepared transactions: ampdump refuses a dump while
the view has rows.
sys.function_cache_stats
Shows counters for the process-local cache of bound SQL-function bodies:
hits | misses | entries | capacity
hits and misses count reused and newly bound queries; entries shows the current number of
entries and capacity the LRU limit. Counters reset when the server process restarts.