Skip to content

Commit

Permalink
feat(catalog): add relpersistence in pg_class (#14400) (#14401)
Browse files Browse the repository at this point in the history
Co-authored-by: Kexiang Wang <[email protected]>
  • Loading branch information
github-actions[bot] and KeXiangWang authored Jan 8, 2024
1 parent f10f7b5 commit b069959
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub static PG_CLASS_COLUMNS: LazyLock<Vec<SystemCatalogColumnsDef<'_>>> = 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
Expand All @@ -38,11 +40,12 @@ pub static PG_CLASS_COLUMNS: LazyLock<Vec<SystemCatalogColumnsDef<'_>>> = 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<BuiltinView> = LazyLock::new(|| BuiltinView {
pub static PG_CLASS: LazyLock<BuiltinView> = 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' \
Expand All @@ -56,4 +59,5 @@ pub static PG_CLASS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
FROM rw_catalog.rw_relations\
"
.to_string(),
}
});

0 comments on commit b069959

Please sign in to comment.