From ea45c3575f5da917d921c37b6381038589891b0d Mon Sep 17 00:00:00 2001 From: August Date: Mon, 22 Apr 2024 17:54:06 +0800 Subject: [PATCH] chore: populate pg_attribute.attgenerated and pg_type.typdelim (#16436) --- .../planner_test/tests/testdata/output/pg_catalog.yaml | 6 +++--- .../src/catalog/system_catalog/pg_catalog/pg_attribute.rs | 5 ++++- .../src/catalog/system_catalog/pg_catalog/pg_type.rs | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/frontend/planner_test/tests/testdata/output/pg_catalog.yaml b/src/frontend/planner_test/tests/testdata/output/pg_catalog.yaml index f00576765236..eadaba6305ee 100644 --- a/src/frontend/planner_test/tests/testdata/output/pg_catalog.yaml +++ b/src/frontend/planner_test/tests/testdata/output/pg_catalog.yaml @@ -2,9 +2,9 @@ - sql: | select * from pg_catalog.pg_type logical_plan: |- - LogicalProject { exprs: [pg_type.oid, pg_type.typname, pg_type.typelem, pg_type.typarray, pg_type.typinput, pg_type.typnotnull, pg_type.typbasetype, pg_type.typtypmod, pg_type.typcollation, pg_type.typlen, pg_type.typnamespace, pg_type.typtype, pg_type.typrelid, pg_type.typdefault, pg_type.typcategory, pg_type.typreceive] } - └─LogicalSysScan { table: pg_type, columns: [pg_type.oid, pg_type.typname, pg_type.typelem, pg_type.typarray, pg_type.typinput, pg_type.typnotnull, pg_type.typbasetype, pg_type.typtypmod, pg_type.typcollation, pg_type.typlen, pg_type.typnamespace, pg_type.typtype, pg_type.typrelid, pg_type.typdefault, pg_type.typcategory, pg_type.typreceive] } - batch_plan: 'BatchScan { table: pg_type, columns: [pg_type.oid, pg_type.typname, pg_type.typelem, pg_type.typarray, pg_type.typinput, pg_type.typnotnull, pg_type.typbasetype, pg_type.typtypmod, pg_type.typcollation, pg_type.typlen, pg_type.typnamespace, pg_type.typtype, pg_type.typrelid, pg_type.typdefault, pg_type.typcategory, pg_type.typreceive], distribution: Single }' + LogicalProject { exprs: [pg_type.oid, pg_type.typname, pg_type.typelem, pg_type.typarray, pg_type.typinput, pg_type.typnotnull, pg_type.typbasetype, pg_type.typtypmod, pg_type.typcollation, pg_type.typlen, pg_type.typnamespace, pg_type.typtype, pg_type.typdelim, pg_type.typrelid, pg_type.typdefault, pg_type.typcategory, pg_type.typreceive] } + └─LogicalSysScan { table: pg_type, columns: [pg_type.oid, pg_type.typname, pg_type.typelem, pg_type.typarray, pg_type.typinput, pg_type.typnotnull, pg_type.typbasetype, pg_type.typtypmod, pg_type.typcollation, pg_type.typlen, pg_type.typnamespace, pg_type.typtype, pg_type.typdelim, pg_type.typrelid, pg_type.typdefault, pg_type.typcategory, pg_type.typreceive] } + batch_plan: 'BatchScan { table: pg_type, columns: [pg_type.oid, pg_type.typname, pg_type.typelem, pg_type.typarray, pg_type.typinput, pg_type.typnotnull, pg_type.typbasetype, pg_type.typtypmod, pg_type.typcollation, pg_type.typlen, pg_type.typnamespace, pg_type.typtype, pg_type.typdelim, pg_type.typrelid, pg_type.typdefault, pg_type.typcategory, pg_type.typreceive], distribution: Single }' - sql: | select * from pg_catalog.pg_namespace logical_plan: |- diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_attribute.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_attribute.rs index 8ff8bbe47e00..a0bf9190df2c 100644 --- a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_attribute.rs +++ b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_attribute.rs @@ -34,7 +34,10 @@ use risingwave_frontend_macro::system_catalog; false AS atthasdef, false AS attisdropped, ''::varchar AS attidentity, - ''::varchar AS attgenerated, + CASE + WHEN c.is_generated THEN 's'::varchar + ELSE ''::varchar + END AS attgenerated, -1 AS atttypmod, 0 AS attcollation FROM rw_catalog.rw_columns c diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_type.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_type.rs index 3e2fff85e461..d1d399451da4 100644 --- a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_type.rs +++ b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_type.rs @@ -41,6 +41,7 @@ use crate::error::Result; // 0 AS typlen, // s.id AS typnamespace, // 'b' AS typtype, +// ',' AS typdelim, // 0 AS typrelid, // NULL AS typdefault, // NULL AS typcategory, @@ -64,6 +65,7 @@ struct PgType { typlen: i32, typnamespace: i32, typtype: char, + typdelim: char, typrelid: i32, typdefault: Option, typcategory: Option, @@ -94,6 +96,7 @@ fn read_pg_type(reader: &SysCatalogReaderImpl) -> Result> { typlen: 0, typnamespace: pg_catalog_id, typtype: 'b', + typdelim: ',', typrelid: 0, typdefault: None, typcategory: None,