1use crate::list::PgList;
13use crate::pg_sys;
14use pgx_pg_sys::AsPgCStr;
15
16pub struct PgQualifiedNameBuilder {
18 #[cfg(feature = "pg15")]
19 list: PgList<pg_sys::String>,
20 #[cfg(not(feature = "pg15"))]
21 list: PgList<pg_sys::Value>,
22}
23
24impl Default for PgQualifiedNameBuilder {
25 fn default() -> Self {
26 Self::new()
27 }
28}
29
30impl PgQualifiedNameBuilder {
31 pub fn new() -> PgQualifiedNameBuilder {
32 PgQualifiedNameBuilder {
33 #[cfg(feature = "pg15")]
34 list: PgList::<pg_sys::String>::new(),
35 #[cfg(not(feature = "pg15"))]
36 list: PgList::<pg_sys::Value>::new(),
37 }
38 }
39
40 pub fn push(mut self, value: &str) -> PgQualifiedNameBuilder {
41 unsafe {
42 self.list.push(pg_sys::makeString(value.as_pg_cstr()));
44 }
45 self
46 }
47
48 pub fn get_operator_oid(self, lhs_type: pg_sys::Oid, rhs_type: pg_sys::Oid) -> pg_sys::Oid {
49 unsafe { pg_sys::OpernameGetOprid(self.list.into_pg(), lhs_type, rhs_type) }
50 }
51}