Skip to content

Commit 912db57

Browse files
authored
feat(pg_catalog): stub pg_opclass (#6167)
* stub pg_opclass * fix typo * fix * fix review
1 parent 2499d0d commit 912db57

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
query IITIIIIII
2+
SELECT
3+
oid,
4+
opcmethod,
5+
opcname,
6+
opcnamespace,
7+
opcowner,
8+
opcfamily,
9+
opcintype,
10+
opcdefault,
11+
opckeytype
12+
FROM pg_catalog.pg_opclass;
13+
----

src/frontend/src/catalog/pg_catalog/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub mod pg_class;
1717
pub mod pg_index;
1818
pub mod pg_matviews_info;
1919
pub mod pg_namespace;
20+
pub mod pg_opclass;
2021
pub mod pg_type;
2122
pub mod pg_user;
2223

@@ -40,6 +41,7 @@ use crate::catalog::pg_catalog::pg_class::*;
4041
use crate::catalog::pg_catalog::pg_index::*;
4142
use crate::catalog::pg_catalog::pg_matviews_info::*;
4243
use crate::catalog::pg_catalog::pg_namespace::*;
44+
use crate::catalog::pg_catalog::pg_opclass::*;
4345
use crate::catalog::pg_catalog::pg_type::*;
4446
use crate::catalog::pg_catalog::pg_user::*;
4547
use crate::catalog::system_catalog::SystemCatalog;
@@ -92,6 +94,7 @@ impl SysCatalogReader for SysCatalogReaderImpl {
9294
PG_USER_TABLE_NAME => self.read_user_info(),
9395
PG_CLASS_TABLE_NAME => self.read_class_info(),
9496
PG_INDEX_TABLE_NAME => self.read_index_info(),
97+
PG_OPCLASS_TABLE_NAME => self.read_opclass_info(),
9598
_ => {
9699
Err(ErrorCode::ItemNotFound(format!("Invalid system table: {}", table_name)).into())
97100
}
@@ -209,6 +212,11 @@ impl SysCatalogReaderImpl {
209212
.collect_vec())
210213
}
211214

215+
// FIXME(noel): Tracked by <https://github.com/risingwavelabs/risingwave/issues/3431#issuecomment-1164160988>
216+
fn read_opclass_info(&self) -> Result<Vec<Row>> {
217+
Ok(vec![])
218+
}
219+
212220
fn read_class_info(&self) -> Result<Vec<Row>> {
213221
let reader = self.catalog_reader.read_guard();
214222
let schemas = reader.iter_schemas(&self.auth_context.database)?;
@@ -390,6 +398,7 @@ pub(crate) static PG_CATALOG_MAP: LazyLock<HashMap<String, SystemCatalog>> = Laz
390398
PG_USER_TABLE_NAME.to_string() => def_sys_catalog!(5, PG_USER_TABLE_NAME, PG_USER_COLUMNS),
391399
PG_CLASS_TABLE_NAME.to_string() => def_sys_catalog!(6, PG_CLASS_TABLE_NAME, PG_CLASS_COLUMNS),
392400
PG_INDEX_TABLE_NAME.to_string() => def_sys_catalog!(7, PG_INDEX_TABLE_NAME, PG_INDEX_COLUMNS),
401+
PG_OPCLASS_TABLE_NAME.to_string() => def_sys_catalog!(8, PG_OPCLASS_TABLE_NAME, PG_OPCLASS_COLUMNS),
393402
}
394403
});
395404

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2022 Singularity Data
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use risingwave_common::types::DataType;
16+
17+
use crate::catalog::pg_catalog::PgCatalogColumnsDef;
18+
19+
/// The catalog `pg_opclass` defines index access method operator classes.
20+
/// Reference: [`https://www.postgresql.org/docs/current/catalog-pg-opclass.html`].
21+
pub const PG_OPCLASS_TABLE_NAME: &str = "pg_opclass";
22+
pub const PG_OPCLASS_COLUMNS: &[PgCatalogColumnsDef<'_>] = &[
23+
(DataType::Int32, "oid"),
24+
(DataType::Int32, "opcmethod"),
25+
(DataType::Varchar, "opcname"),
26+
(DataType::Int32, "opcnamespace"),
27+
(DataType::Int32, "opcowner"),
28+
(DataType::Int32, "opcfamily"),
29+
(DataType::Int32, "opcintype"),
30+
(DataType::Int32, "opcdefault"),
31+
(DataType::Int32, "opckeytype"),
32+
];

0 commit comments

Comments
 (0)