Skip to content

Commit

Permalink
feat(frontend): introduce system catalog table pg_enum (risingwavelab…
Browse files Browse the repository at this point in the history
…s#7706)

Introduce system catalog table `pg_enum`.

Approved-By: neverchanje
  • Loading branch information
yezizp2012 authored Feb 6, 2023
1 parent 7e565a7 commit 77b4607
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions e2e_test/batch/catalog/pg_enum.slt.part
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
query IIIT
SELECT * FROM pg_catalog.pg_enum;
----
1 change: 1 addition & 0 deletions src/frontend/src/catalog/system_catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ prepare_sys_catalog! {
{ PG_CATALOG, PG_SHDESCRIPTION, vec![0], read_shdescription_info },
{ PG_CATALOG, PG_TABLESPACE, vec![0], read_tablespace_info },
{ PG_CATALOG, PG_STAT_ACTIVITY, vec![0], read_stat_activity },
{ PG_CATALOG, PG_ENUM, vec![0], read_enum_info },
{ INFORMATION_SCHEMA, COLUMNS, vec![], read_columns_info },
{ INFORMATION_SCHEMA, TABLES, vec![], read_tables_info },
{ RW_CATALOG, RW_META_SNAPSHOT, vec![], read_meta_snapshot await },
Expand Down
6 changes: 6 additions & 0 deletions src/frontend/src/catalog/system_catalog/pg_catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod pg_class;
pub mod pg_collation;
pub mod pg_database;
pub mod pg_description;
pub mod pg_enum;
pub mod pg_index;
pub mod pg_keywords;
pub mod pg_matviews;
Expand All @@ -46,6 +47,7 @@ pub use pg_class::*;
pub use pg_collation::*;
pub use pg_database::*;
pub use pg_description::*;
pub use pg_enum::*;
pub use pg_index::*;
pub use pg_keywords::*;
pub use pg_matviews::*;
Expand Down Expand Up @@ -250,6 +252,10 @@ impl SysCatalogReaderImpl {
Ok(vec![])
}

pub(crate) fn read_enum_info(&self) -> Result<Vec<OwnedRow>> {
Ok(vec![])
}

pub(super) fn read_roles_info(&self) -> Result<Vec<OwnedRow>> {
let reader = self.user_info_reader.read_guard();
let users = reader.get_all_users();
Expand Down
28 changes: 28 additions & 0 deletions src/frontend/src/catalog/system_catalog/pg_catalog/pg_enum.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2023 RisingWave Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use risingwave_common::types::DataType;

use crate::catalog::system_catalog::SystemCatalogColumnsDef;

/// The `pg_enum` catalog contains entries showing the values and labels for each enum type.
/// The internal representation of a given enum value is actually the OID of its associated row in
/// `pg_enum`. Reference: [`https://www.postgresql.org/docs/current/catalog-pg-enum.html`]
pub const PG_ENUM_TABLE_NAME: &str = "pg_enum";
pub const PG_ENUM_COLUMNS: &[SystemCatalogColumnsDef<'_>] = &[
(DataType::Int32, "oid"),
(DataType::Int32, "enumtypid"),
(DataType::Float32, "enumsortorder"),
(DataType::Varchar, "enumlabel"),
];

0 comments on commit 77b4607

Please sign in to comment.