use crate::list::PgList;
use crate::pg_sys;
use pgx_pg_sys::AsPgCStr;
pub struct PgQualifiedNameBuilder {
#[cfg(feature = "pg15")]
list: PgList<pg_sys::String>,
#[cfg(not(feature = "pg15"))]
list: PgList<pg_sys::Value>,
}
impl Default for PgQualifiedNameBuilder {
fn default() -> Self {
Self::new()
}
}
impl PgQualifiedNameBuilder {
pub fn new() -> PgQualifiedNameBuilder {
PgQualifiedNameBuilder {
#[cfg(feature = "pg15")]
list: PgList::<pg_sys::String>::new(),
#[cfg(not(feature = "pg15"))]
list: PgList::<pg_sys::Value>::new(),
}
}
pub fn push(mut self, value: &str) -> PgQualifiedNameBuilder {
unsafe {
self.list.push(pg_sys::makeString(value.as_pg_cstr()));
}
self
}
pub fn get_operator_oid(self, lhs_type: pg_sys::Oid, rhs_type: pg_sys::Oid) -> pg_sys::Oid {
unsafe { pg_sys::OpernameGetOprid(self.list.into_pg(), lhs_type, rhs_type) }
}
}