From b0699598c87400604fa91266712fa2b8713bfd76 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 03:54:45 +0000 Subject: [PATCH] feat(catalog): add relpersistence in pg_class (#14400) (#14401) Co-authored-by: Kexiang Wang --- .../planner_test/tests/testdata/output/subquery.yaml | 2 +- .../src/catalog/system_catalog/pg_catalog/pg_class.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/frontend/planner_test/tests/testdata/output/subquery.yaml b/src/frontend/planner_test/tests/testdata/output/subquery.yaml index 076a3ceb8fac..554525b391ef 100644 --- a/src/frontend/planner_test/tests/testdata/output/subquery.yaml +++ b/src/frontend/planner_test/tests/testdata/output/subquery.yaml @@ -238,7 +238,7 @@ ├─LogicalFilter { predicate: In($expr1, 'r':Varchar, 'p':Varchar, 'v':Varchar, 'm':Varchar, 'S':Varchar, 'f':Varchar, '':Varchar) AND (rw_schemas.name <> 'pg_catalog':Varchar) AND Not(RegexpEq(rw_schemas.name, '^pg_toast':Varchar)) AND (rw_schemas.name <> 'information_schema':Varchar) } │ └─LogicalJoin { type: LeftOuter, on: (rw_schemas.id = rw_tables.schema_id), output: all } │ ├─LogicalShare { id: 16 } - │ │ └─LogicalProject { exprs: [rw_tables.id, rw_tables.name, rw_tables.schema_id, rw_tables.owner, Case(('table':Varchar = 'table':Varchar), 'r':Varchar, ('table':Varchar = 'system table':Varchar), 'r':Varchar, ('table':Varchar = 'index':Varchar), 'i':Varchar, ('table':Varchar = 'view':Varchar), 'v':Varchar, ('table':Varchar = 'materialized view':Varchar), 'm':Varchar) as $expr1, 0:Int32, 0:Int32, Array as $expr2] } + │ │ └─LogicalProject { exprs: [rw_tables.id, rw_tables.name, rw_tables.schema_id, rw_tables.owner, 'p':Varchar, Case(('table':Varchar = 'table':Varchar), 'r':Varchar, ('table':Varchar = 'system table':Varchar), 'r':Varchar, ('table':Varchar = 'index':Varchar), 'i':Varchar, ('table':Varchar = 'view':Varchar), 'v':Varchar, ('table':Varchar = 'materialized view':Varchar), 'm':Varchar) as $expr1, 0:Int32, 0:Int32, Array as $expr2] } │ │ └─LogicalShare { id: 14 } │ │ └─LogicalUnion { all: true } │ │ ├─LogicalUnion { all: true } diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_class.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_class.rs index e09543dd81c6..6ff7abac7187 100644 --- a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_class.rs +++ b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_class.rs @@ -25,6 +25,8 @@ pub static PG_CLASS_COLUMNS: LazyLock>> = LazyLo (DataType::Varchar, "relname"), (DataType::Int32, "relnamespace"), (DataType::Int32, "relowner"), + (DataType::Varchar, "relpersistence"), /* p = permanent table, u = unlogged table, t = + * temporary table */ (DataType::Varchar, "relkind"), /* r = ordinary table, i = index, S = sequence, t = * TOAST table, v = view, m = materialized view, c = * composite type, f = foreign table, p = partitioned @@ -38,11 +40,12 @@ pub static PG_CLASS_COLUMNS: LazyLock>> = LazyLo /// The catalog `pg_class` catalogs tables and most everything else that has columns or is otherwise /// similar to a table. Ref: [`https://www.postgresql.org/docs/current/catalog-pg-class.html`] /// todo: should we add internal tables as well? -pub static PG_CLASS: LazyLock = LazyLock::new(|| BuiltinView { +pub static PG_CLASS: LazyLock = LazyLock::new(|| { + BuiltinView { name: "pg_class", schema: PG_CATALOG_SCHEMA_NAME, columns: &PG_CLASS_COLUMNS, - sql: "SELECT id AS oid, name AS relname, schema_id AS relnamespace, owner AS relowner, \ + sql: "SELECT id AS oid, name AS relname, schema_id AS relnamespace, owner AS relowner, 'p' as relpersistence, \ CASE \ WHEN relation_type = 'table' THEN 'r' \ WHEN relation_type = 'system table' THEN 'r' \ @@ -56,4 +59,5 @@ pub static PG_CLASS: LazyLock = LazyLock::new(|| BuiltinView { FROM rw_catalog.rw_relations\ " .to_string(), +} });