Skip to content

Commit c6a1cb2

Browse files
antiguruclaude
andauthored
catalog: Add mz_overridden_system_parameters relation (#37302)
Adds `mz_internal.mz_overridden_system_parameters`, a materialized view exposing environment-wide system parameter overrides set via `ALTER SYSTEM`. It mirrors the existing `mz_cluster_system_parameters` and `mz_replica_system_parameters` views, projecting the durable `system_configurations` collection out of `mz_catalog_raw` where the record kind is `ServerConfiguration`. Today the only way to observe environment-wide system parameters is `SHOW ALL`, which surfaces a limited set unless the session is the `mz_system` user. That user is too privileged for merely inspecting effective parameter values. This view is `PUBLIC_SELECT`, so any user can read the overrides. Like the cluster- and replica-scoped views, it lists only parameters with an explicit environment-wide override. Parameters left at their default are absent. Surfacing the effective value of every parameter, including unset defaults, would require reading live `SystemVars` rather than the durable overrides, and is left as a follow-up. Tests: extends the catalog testdrive listing and the autogenerated mz_internal, oid, information_schema_tables, and catalog_server_explain sqllogictest snapshots. The catalog_server_explain snapshot is made hermetic with a `reset-server` directive so role OIDs from preceding files no longer leak into its constant-folded plans. This release will add the `mz_overridden_system_parameters` system catalog relation, listing environment-wide system parameter overrides. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5066cda commit c6a1cb2

10 files changed

Lines changed: 150 additions & 58 deletions

File tree

doc/user/content/reference/system-catalog/mz_internal.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,19 @@ The `mz_sessions` table contains a row for each active session in the system.
820820
| `connected_at` | [`timestamp with time zone`] | The time at which the session connected to the system. |
821821

822822

823+
## `mz_overridden_system_parameters`
824+
825+
The `mz_overridden_system_parameters` view contains a row for each system parameter whose
826+
environment-wide value differs from its default, as set by `ALTER SYSTEM`.
827+
Parameters left at their default are not listed.
828+
829+
<!-- RELATION_SPEC mz_internal.mz_overridden_system_parameters -->
830+
| Field | Type | Meaning |
831+
| ------------ | -------- | -------- |
832+
| `name` | [`text`] | The name of the system parameter. |
833+
| `value` | [`text`] | The environment-wide value of the system parameter. |
834+
835+
823836
## `mz_cluster_system_parameters`
824837

825838
The `mz_cluster_system_parameters` view contains a row for each cluster-coherent

src/catalog/src/builtin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ pub static BUILTINS_STATIC: LazyLock<Vec<Builtin<NameReference>>> = LazyLock::ne
11861186
Builtin::Table(&MZ_AWS_CONNECTIONS),
11871187
Builtin::Table(&MZ_SUBSCRIPTIONS),
11881188
Builtin::Table(&MZ_SESSIONS),
1189+
Builtin::MaterializedView(&MZ_OVERRIDDEN_SYSTEM_PARAMETERS),
11891190
Builtin::MaterializedView(&MZ_CLUSTER_SYSTEM_PARAMETERS),
11901191
Builtin::MaterializedView(&MZ_REPLICA_SYSTEM_PARAMETERS),
11911192
Builtin::MaterializedView(&MZ_DEFAULT_PRIVILEGES),

src/catalog/src/builtin/mz_internal.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,6 +2866,49 @@ pub static MZ_SESSIONS: LazyLock<BuiltinTable> = LazyLock::new(|| BuiltinTable {
28662866
}),
28672867
});
28682868

2869+
pub static MZ_OVERRIDDEN_SYSTEM_PARAMETERS: LazyLock<BuiltinMaterializedView> =
2870+
LazyLock::new(|| BuiltinMaterializedView {
2871+
name: "mz_overridden_system_parameters",
2872+
schema: MZ_INTERNAL_SCHEMA,
2873+
oid: oid::MV_MZ_OVERRIDDEN_SYSTEM_PARAMETERS_OID,
2874+
desc: RelationDesc::builder()
2875+
.with_column("name", SqlScalarType::String.nullable(false))
2876+
.with_column("value", SqlScalarType::String.nullable(false))
2877+
.finish(),
2878+
column_comments: BTreeMap::from_iter([
2879+
("name", "The name of the system parameter."),
2880+
(
2881+
"value",
2882+
"The environment-wide value of the system parameter.",
2883+
),
2884+
]),
2885+
// Projects the durable `system_configurations` collection (the
2886+
// `ALTER SYSTEM` set) out of `mz_catalog_raw` (the durable catalog as
2887+
// JSON): the key is `{name}` and the value is `{value}`. This surfaces
2888+
// only parameters with an explicit environment-wide override, mirroring
2889+
// the cluster- and replica-scoped views. Parameters left at their
2890+
// default are absent.
2891+
sql: "
2892+
IN CLUSTER mz_catalog_server
2893+
WITH (
2894+
ASSERT NOT NULL name,
2895+
ASSERT NOT NULL value
2896+
) AS
2897+
SELECT
2898+
data->'key'->>'name' AS name,
2899+
data->'value'->>'value' AS value
2900+
FROM mz_internal.mz_catalog_raw
2901+
WHERE data->>'kind' = 'ServerConfiguration'",
2902+
is_retained_metrics_object: false,
2903+
access: vec![PUBLIC_SELECT],
2904+
ontology: Some(Ontology {
2905+
entity_name: "system_parameter",
2906+
description: "Environment-wide system parameter overrides",
2907+
links: &const { [] },
2908+
column_semantic_types: &[],
2909+
}),
2910+
});
2911+
28692912
pub static MZ_CLUSTER_SYSTEM_PARAMETERS: LazyLock<BuiltinMaterializedView> =
28702913
LazyLock::new(|| BuiltinMaterializedView {
28712914
name: "mz_cluster_system_parameters",

src/pgrepr-consts/src/oid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,3 +805,4 @@ pub const MV_MZ_CLUSTER_SYSTEM_PARAMETERS_OID: u32 = 17091;
805805
pub const MV_MZ_REPLICA_SYSTEM_PARAMETERS_OID: u32 = 17092;
806806
pub const FUNC_MZ_GEN_SERIES_UNOPT_OID: u32 = 17093;
807807
pub const FUNC_MZ_GEN_SERIES_UNOPT_STEP_OID: u32 = 17094;
808+
pub const MV_MZ_OVERRIDDEN_SYSTEM_PARAMETERS_OID: u32 = 17095;

test/sqllogictest/autogenerated/mz_internal.slt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ role_id text The␠role␠ID␠of␠the␠role␠that␠the␠session␠is␠l
452452
client_ip text The␠IP␠address␠of␠the␠client␠that␠initiated␠the␠session.
453453
connected_at timestamp␠with␠time␠zone The␠time␠at␠which␠the␠session␠connected␠to␠the␠system.
454454

455+
query TTT
456+
SELECT name, type, comment FROM objects WHERE schema = 'mz_internal' AND object = 'mz_overridden_system_parameters' ORDER BY position
457+
----
458+
name text The␠name␠of␠the␠system␠parameter.
459+
value text The␠environment-wide␠value␠of␠the␠system␠parameter.
460+
455461
query TTT
456462
SELECT name, type, comment FROM objects WHERE schema = 'mz_internal' AND object = 'mz_cluster_system_parameters' ORDER BY position
457463
----
@@ -812,6 +818,7 @@ mz_ontology_link_types
812818
mz_ontology_properties
813819
mz_ontology_semantic_types
814820
mz_optimizer_notices
821+
mz_overridden_system_parameters
815822
mz_pending_cluster_replicas
816823
mz_postgres_source_tables
817824
mz_postgres_sources

test/sqllogictest/catalog_server_explain.slt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151

5252
mode cockroach
5353

54+
# Start from a pristine server so no user objects (e.g. roles created by a
55+
# preceding file in the same run) leak into the constant-folded plans. Several
56+
# `information_schema` views embed the current set of role OIDs as a literal,
57+
# which would otherwise make this snapshot depend on run order.
58+
reset-server
59+
5460
# `mz_internal.mz_wallclock_global_lag` is a monotonic top-1 over a temporal
5561
# filter; planning it folds `mz_now()` into a literal millisecond timestamp that
5662
# changes on every run. Mask that one literal so the snapshot stays stable. The
@@ -4394,7 +4400,7 @@ mz_catalog.mz_materialized_views:
43944400
Project: #4, #0, #5, #1, #6, #2, #9, #8, #3, #7
43954401
Map: {=r/s1, s1=r/s1}, "s1"
43964402
→Arrange (#1{schema_name}, #2{name})
4397-
→Constant (22 rows)
4403+
→Constant (23 rows)
43984404
→Arrange (empty key) (#0{schema_name}) (#0{schema_name}, #1{name})
43994405
→Fused with Child Map/Filter/Project
44004406
Project: #4, #3, #5
@@ -4803,6 +4809,21 @@ Target cluster: mz_catalog_server
48034809

48044810
EOF
48054811

4812+
query T multiline
4813+
EXPLAIN MATERIALIZED VIEW "mz_internal"."mz_overridden_system_parameters";
4814+
----
4815+
mz_internal.mz_overridden_system_parameters:
4816+
→Read mz_internal.mz_catalog_raw
4817+
4818+
Source mz_internal.mz_catalog_raw
4819+
project=(#1, #2)
4820+
filter=(("ServerConfiguration" = (#0{data} ->> "kind")))
4821+
map=(((#0{data} -> "key") ->> "name"), ((#0{data} -> "value") ->> "value"))
4822+
4823+
Target cluster: mz_catalog_server
4824+
4825+
EOF
4826+
48064827
query T multiline
48074828
EXPLAIN SELECT * FROM "information_schema"."applicable_roles";
48084829
----
@@ -7019,7 +7040,7 @@ query T multiline
70197040
EXPLAIN SELECT * FROM "mz_internal"."mz_builtin_materialized_views";
70207041
----
70217042
Explained Query (fast path):
7022-
→Constant (22 rows)
7043+
→Constant (23 rows)
70237044

70247045
Target cluster: mz_catalog_server
70257046

@@ -8883,7 +8904,7 @@ query T multiline
88838904
EXPLAIN SELECT * FROM "mz_internal"."mz_ontology_entity_types";
88848905
----
88858906
Explained Query (fast path):
8886-
→Constant (131 rows)
8907+
→Constant (132 rows)
88878908

88888909
Target cluster: mz_catalog_server
88898910

@@ -8907,7 +8928,7 @@ Explained Query:
89078928
cte l0 =
89088929
→Differential Join %1:mz_schemas[#0{id}] » %2:mz_objects[#2{schema_id}] » %0[#0{schema_name}, #1{table_name}] » %3:mz_columns[#0{id}]
89098930
→Arrange (#0{schema_name}, #1{table_name})
8910-
→Constant (131 rows)
8931+
→Constant (132 rows)
89118932
→Arrange (#0{id})
89128933
→Fused with Child Map/Filter/Project
89138934
Project: #1, #3

test/sqllogictest/information_schema_tables.slt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ mz_optimizer_notices
517517
BASE TABLE
518518
materialize
519519
mz_internal
520+
mz_overridden_system_parameters
521+
MATERIALIZED VIEW
522+
materialize
523+
mz_internal
520524
mz_pending_cluster_replicas
521525
MATERIALIZED VIEW
522526
materialize

0 commit comments

Comments
 (0)