Skip to main content

uqa_sql/catalog/system_relations/
columns.rs

1//
2// Unified Query Algebra
3//
4// Copyright (c) 2023-2026 Cognica, Inc.
5//
6
7//! Public attribute order for built-in relation authorization.
8
9use super::SystemRelation;
10
11impl SystemRelation {
12    pub fn column_names(self) -> Vec<String> {
13        self.column_names_with_control(&uqa_core::memory::ProductionControl::uncontrolled())
14            .expect("ordinary system column production")
15            .into_uncontrolled()
16            .expect("ordinary columns")
17    }
18
19    pub fn column_names_with_control(
20        self,
21        control: &uqa_core::memory::ProductionControl<'_>,
22    ) -> Result<uqa_core::memory::Produced<Vec<String>>, crate::SQLError> {
23        control.check()?;
24        let names: &[&str] = match self {
25            Self::Projected(relation) => return relation.column_names_with_control(control),
26            Self::PgDbRoleSetting => &["setdatabase", "setrole", "setconfig"],
27            Self::PgShadow => &[
28                "usename",
29                "usesysid",
30                "usecreatedb",
31                "usesuper",
32                "userepl",
33                "usebypassrls",
34                "passwd",
35                "valuntil",
36                "useconfig",
37            ],
38            Self::PgTablespace => &["oid", "spcname", "spcowner", "spcacl", "spcoptions"],
39            Self::PgCollation => &[
40                "oid",
41                "collname",
42                "collnamespace",
43                "collowner",
44                "collprovider",
45                "collisdeterministic",
46                "collencoding",
47                "collcollate",
48                "collctype",
49                "colllocale",
50                "collicurules",
51                "collversion",
52            ],
53            Self::PgSequence => &[
54                "seqrelid",
55                "seqtypid",
56                "seqstart",
57                "seqincrement",
58                "seqmax",
59                "seqmin",
60                "seqcache",
61                "seqcycle",
62            ],
63            Self::InformationEnabledRoles => &["role_name"],
64        };
65        let mut output = uqa_core::memory::ProductionVec::new(*control);
66        for name in names {
67            output.push_produced(control.copy_text(name)?)?;
68        }
69        Ok(output.finish()?)
70    }
71}