Skip to main content

uqa_sql/catalog/
access_methods.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! The access methods of `pg_am`: `PostgreSQL` 18's own table and index methods, and the vector index methods the engine adds.
8
9/// The type of an access method (`pg_am.amtype`).
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
11pub enum AccessMethodKind {
12    Table,
13    Index,
14}
15
16/// Every access method by name, in `pg_am` order.
17const ACCESS_METHODS: &[(&str, AccessMethodKind)] = &[
18    ("heap", AccessMethodKind::Table),
19    ("btree", AccessMethodKind::Index),
20    ("hash", AccessMethodKind::Index),
21    ("gist", AccessMethodKind::Index),
22    ("gin", AccessMethodKind::Index),
23    ("brin", AccessMethodKind::Index),
24    ("spgist", AccessMethodKind::Index),
25    ("ivf", AccessMethodKind::Index),
26    ("hnsw", AccessMethodKind::Index),
27    ("diskann", AccessMethodKind::Index),
28];
29
30/// The type of the access method `name`, which names one exactly, or `None` when no access method has that name.
31pub fn access_method_kind(name: &str) -> Option<AccessMethodKind> {
32    ACCESS_METHODS
33        .iter()
34        .find(|(method, _)| *method == name)
35        .map(|(_, kind)| *kind)
36}