[−][src]Struct pgx::rel::PgRelation
Implementations
impl PgRelation
[src]
pub unsafe fn from_pg(ptr: Relation) -> Self
[src]
Wrap a Postgres-provided pg_sys::Relation
.
It is assumed that Postgres will later RelationClose()
the provided relation pointer.
As such, it is not closed when this instance is dropped
Safety
This method is unsafe as we cannot ensure that this relation will later be closed by Postgres
pub fn from_pg_owned(ptr: Relation) -> Self
[src]
Wrap a Postgres-provided pg_sys::Relation
.
The provided Relation
will be closed via pg_sys::RelationClose
when this instance is dropped
pub unsafe fn open(oid: Oid) -> Self
[src]
Given a relation oid, use pg_sys::RelationIdGetRelation()
to open the relation
If the specified relation oid was recently deleted, this function will panic.
Additionally, the relation is closed via pg_sys::RelationClose()
when this instance is
dropped.
Safety
The caller should already have at least AccessShareLock on the relation ID, else there are nasty race conditions.
As such, this function is unsafe as we cannot guarantee that this requirement is true.
pub fn with_lock(oid: Oid, lockmode: LOCKMODE) -> Self
[src]
relation_open - open any relation by relation OID
If lockmode is not "NoLock", the specified kind of lock is obtained on the relation. (Generally, NoLock should only be used if the caller knows it has some appropriate lock on the relation already.)
An error is raised if the relation does not exist.
NB: a "relation" is anything with a pg_class entry. The caller is expected to check whether the relkind is something it can handle.
The opened relation is automatically closed via pg_sys::relation_close()
when this instance is dropped
pub unsafe fn open_with_name(relname: &str) -> Result<Self, &'static str>
[src]
Given a relation name, use pg_sys::to_regclass
to look up its oid, and then
pg_sys::RelationIdGetRelation()
to open the relation.
If the specified relation name is not found, we return an Err(&str)
.
If the specified relation was recently deleted, this function will panic.
Additionally, the relation is closed via pg_sys::RelationClose()
when this instance is
dropped.
Safety
The caller should already have at least AccessShareLock on the relation ID, else there are nasty race conditions.
As such, this function is unsafe as we cannot guarantee that this requirement is true.
pub fn open_with_name_and_share_lock(
relname: &str
) -> Result<Self, &'static str>
[src]
relname: &str
) -> Result<Self, &'static str>
Given a relation name, use pg_sys::to_regclass
to look up its oid, and then
open it with an AccessShareLock
If the specified relation name is not found, we return an Err(&str)
.
If the specified relation was recently deleted, this function will panic.
Additionally, the relation is closed via pg_sys::RelationClose()
when this instance is
dropped.
pub fn name(&self) -> &str
[src]
RelationGetRelationName Returns the rel's name.
Note that the name is only unique within the containing namespace.
pub fn oid(&self) -> Oid
[src]
RelationGetRelid Returns the OID of the relation
pub fn namespace_oid(&self) -> Oid
[src]
RelationGetNamespace Returns the rel's namespace OID.
pub fn namespace(&self) -> &str
[src]
What is the name of the namespace in which this relation is located?
pub fn heap_relation(&self) -> Option<PgRelation>
[src]
If this PgRelation
represents an index, return the PgRelation
for the heap
relation to which it is attached
pub fn indicies(&self, lockmode: LOCKMODE) -> impl Iterator<Item = PgRelation>
[src]
Return an iterator of indices, as PgRelation
s, attached to this relation
pub fn tuple_desc(&self) -> PgTupleDesc<'_>
[src]
Returned a wrapped PgTupleDesc
The returned PgTupleDesc
is tied to the lifetime of this PgRelation
instance.
use pgx::{PgRelation, pg_sys}; let oid = 42; // a valid pg_class "oid" value let relation = unsafe { PgRelation::from_pg(pg_sys::RelationIdGetRelation(oid) ) }; let tupdesc = relation.tuple_desc(); // assert that the tuple descriptor has 12 attributes assert_eq!(tupdesc.len(), 12);
pub fn reltuples(&self) -> Option<f32>
[src]
Number of tuples in this relation (not always up-to-date)
pub fn is_table(&self) -> bool
[src]
pub fn is_matview(&self) -> bool
[src]
pub fn is_index(&self) -> bool
[src]
pub fn is_view(&self) -> bool
[src]
pub fn is_sequence(&self) -> bool
[src]
pub fn is_composite_type(&self) -> bool
[src]
pub fn is_foreign_table(&self) -> bool
[src]
pub fn is_partitioned_table(&self) -> bool
[src]
pub fn is_toast_value(&self) -> bool
[src]
pub fn to_owned(mut self: Self) -> Self
[src]
ensures that the returned PgRelation
is closed by Rust when it is dropped
Methods from Deref<Target = PgBox<RelationData>>
pub fn is_null(&self) -> bool
[src]
Are we boxing a NULL?
pub fn as_ptr(&self) -> *mut T
[src]
Return the boxed pointer, so that it can be passed back into a Postgres function
Trait Implementations
impl Clone for PgRelation
[src]
pub fn clone(&self) -> Self
[src]
Same as calling PgRelation::with_lock(AccessShareLock)
on the underlying relation id
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Deref for PgRelation
[src]
type Target = PgBox<RelationData>
The resulting type after dereferencing.
pub fn deref(&self) -> &Self::Target
[src]
impl Drop for PgRelation
[src]
impl FromDatum for PgRelation
[src]
pub unsafe fn from_datum(
datum: Datum,
is_null: bool,
_typoid: u32
) -> Option<PgRelation>
[src]
datum: Datum,
is_null: bool,
_typoid: u32
) -> Option<PgRelation>
pub unsafe fn from_datum_in_memory_context(
mut memory_context: PgMemoryContexts,
datum: Datum,
is_null: bool,
typoid: Oid
) -> Option<Self> where
Self: Sized,
[src]
mut memory_context: PgMemoryContexts,
datum: Datum,
is_null: bool,
typoid: Oid
) -> Option<Self> where
Self: Sized,
impl IntoDatum for PgRelation
[src]
pub fn into_datum(self) -> Option<Datum>
[src]
pub fn type_oid() -> u32
[src]
pub fn array_type_oid() -> Oid
[src]
Auto Trait Implementations
impl RefUnwindSafe for PgRelation
[src]
impl !Send for PgRelation
[src]
impl !Sync for PgRelation
[src]
impl Unpin for PgRelation
[src]
impl UnwindSafe for PgRelation
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,