diff --git a/e2e_test/batch/catalog/pg_opclass.slt.part b/e2e_test/batch/catalog/pg_opclass.slt.part new file mode 100644 index 0000000000000..a7f2d6041c9b6 --- /dev/null +++ b/e2e_test/batch/catalog/pg_opclass.slt.part @@ -0,0 +1,13 @@ +query IITIIIIII +SELECT + oid, + opcmethod, + opcname, + opcnamespace, + opcowner, + opcfamily, + opcintype, + opcdefault, + opckeytype +FROM pg_catalog.pg_opclass; +---- \ No newline at end of file diff --git a/src/frontend/src/catalog/pg_catalog/mod.rs b/src/frontend/src/catalog/pg_catalog/mod.rs index 0da27a00fa1e0..47510f03aa7df 100644 --- a/src/frontend/src/catalog/pg_catalog/mod.rs +++ b/src/frontend/src/catalog/pg_catalog/mod.rs @@ -17,6 +17,7 @@ pub mod pg_class; pub mod pg_index; pub mod pg_matviews_info; pub mod pg_namespace; +pub mod pg_opclass; pub mod pg_type; pub mod pg_user; @@ -40,6 +41,7 @@ use crate::catalog::pg_catalog::pg_class::*; use crate::catalog::pg_catalog::pg_index::*; use crate::catalog::pg_catalog::pg_matviews_info::*; use crate::catalog::pg_catalog::pg_namespace::*; +use crate::catalog::pg_catalog::pg_opclass::*; use crate::catalog::pg_catalog::pg_type::*; use crate::catalog::pg_catalog::pg_user::*; use crate::catalog::system_catalog::SystemCatalog; @@ -92,6 +94,7 @@ impl SysCatalogReader for SysCatalogReaderImpl { PG_USER_TABLE_NAME => self.read_user_info(), PG_CLASS_TABLE_NAME => self.read_class_info(), PG_INDEX_TABLE_NAME => self.read_index_info(), + PG_OPCLASS_TABLE_NAME => self.read_opclass_info(), _ => { Err(ErrorCode::ItemNotFound(format!("Invalid system table: {}", table_name)).into()) } @@ -209,6 +212,11 @@ impl SysCatalogReaderImpl { .collect_vec()) } + // FIXME(noel): Tracked by + fn read_opclass_info(&self) -> Result> { + Ok(vec![]) + } + fn read_class_info(&self) -> Result> { let reader = self.catalog_reader.read_guard(); let schemas = reader.iter_schemas(&self.auth_context.database)?; @@ -390,6 +398,7 @@ pub(crate) static PG_CATALOG_MAP: LazyLock> = Laz PG_USER_TABLE_NAME.to_string() => def_sys_catalog!(5, PG_USER_TABLE_NAME, PG_USER_COLUMNS), PG_CLASS_TABLE_NAME.to_string() => def_sys_catalog!(6, PG_CLASS_TABLE_NAME, PG_CLASS_COLUMNS), PG_INDEX_TABLE_NAME.to_string() => def_sys_catalog!(7, PG_INDEX_TABLE_NAME, PG_INDEX_COLUMNS), + PG_OPCLASS_TABLE_NAME.to_string() => def_sys_catalog!(8, PG_OPCLASS_TABLE_NAME, PG_OPCLASS_COLUMNS), } }); diff --git a/src/frontend/src/catalog/pg_catalog/pg_opclass.rs b/src/frontend/src/catalog/pg_catalog/pg_opclass.rs new file mode 100644 index 0000000000000..571e807b2d62f --- /dev/null +++ b/src/frontend/src/catalog/pg_catalog/pg_opclass.rs @@ -0,0 +1,32 @@ +// Copyright 2022 Singularity Data +// +// 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::pg_catalog::PgCatalogColumnsDef; + +/// The catalog `pg_opclass` defines index access method operator classes. +/// Reference: [`https://www.postgresql.org/docs/current/catalog-pg-opclass.html`]. +pub const PG_OPCLASS_TABLE_NAME: &str = "pg_opclass"; +pub const PG_OPCLASS_COLUMNS: &[PgCatalogColumnsDef<'_>] = &[ + (DataType::Int32, "oid"), + (DataType::Int32, "opcmethod"), + (DataType::Varchar, "opcname"), + (DataType::Int32, "opcnamespace"), + (DataType::Int32, "opcowner"), + (DataType::Int32, "opcfamily"), + (DataType::Int32, "opcintype"), + (DataType::Int32, "opcdefault"), + (DataType::Int32, "opckeytype"), +];