Skip to content

Commit

Permalink
feat(pg_catalog): stub pg_opclass (#6167)
Browse files Browse the repository at this point in the history
* stub pg_opclass

* fix typo

* fix

* fix review
  • Loading branch information
kwannoel authored Nov 2, 2022
1 parent 2499d0d commit 912db57
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
13 changes: 13 additions & 0 deletions e2e_test/batch/catalog/pg_opclass.slt.part
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query IITIIIIII
SELECT
oid,
opcmethod,
opcname,
opcnamespace,
opcowner,
opcfamily,
opcintype,
opcdefault,
opckeytype
FROM pg_catalog.pg_opclass;
----
9 changes: 9 additions & 0 deletions src/frontend/src/catalog/pg_catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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())
}
Expand Down Expand Up @@ -209,6 +212,11 @@ impl SysCatalogReaderImpl {
.collect_vec())
}

// FIXME(noel): Tracked by <https://github.com/risingwavelabs/risingwave/issues/3431#issuecomment-1164160988>
fn read_opclass_info(&self) -> Result<Vec<Row>> {
Ok(vec![])
}

fn read_class_info(&self) -> Result<Vec<Row>> {
let reader = self.catalog_reader.read_guard();
let schemas = reader.iter_schemas(&self.auth_context.database)?;
Expand Down Expand Up @@ -390,6 +398,7 @@ pub(crate) static PG_CATALOG_MAP: LazyLock<HashMap<String, SystemCatalog>> = 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),
}
});

Expand Down
32 changes: 32 additions & 0 deletions src/frontend/src/catalog/pg_catalog/pg_opclass.rs
Original file line number Diff line number Diff line change
@@ -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"),
];

0 comments on commit 912db57

Please sign in to comment.