pub struct FcInfo<'fcx>(/* private fields */);Implementations§
source§impl<'fcx> FcInfo<'fcx>
impl<'fcx> FcInfo<'fcx>
sourcepub unsafe fn from_ptr(fcinfo: FunctionCallInfo) -> FcInfo<'fcx>
pub unsafe fn from_ptr(fcinfo: FunctionCallInfo) -> FcInfo<'fcx>
Constructor, used to wrap a raw FunctionCallInfo provided by Postgres.
§Safety
This function is unsafe as we cannot ensure the fcinfo argument is a valid
pg_sys::FunctionCallInfo pointer. This is your responsibility.
sourcepub fn raw_args(&self) -> &[NullableDatum]
pub fn raw_args(&self) -> &[NullableDatum]
Retrieve the arguments to this function call as a slice of pgrx_pg_sys::NullableDatum
sourcepub unsafe fn as_mut_ptr(&self) -> FunctionCallInfo
pub unsafe fn as_mut_ptr(&self) -> FunctionCallInfo
Retrieves the internal pg_sys::FunctionCallInfo wrapped by this type.
A FunctionCallInfo is a mutable pointer to a FunctionCallInfoBaseData already, and so
that type is sufficient.
sourcepub unsafe fn set_return_is_null(&mut self) -> &mut bool
pub unsafe fn set_return_is_null(&mut self) -> &mut bool
sourcepub fn return_null(&mut self) -> Datum<'fcx>
pub fn return_null(&mut self) -> Datum<'fcx>
Modifies the function call’s return to be null
Returns a null-pointer Datum for use as the calling function’s return value.
If this flag is set, regardless of what your function actually returns, Postgres will presume it is null and discard it. This means that, if you call this method and then return a value anyway, your extension will leak memory. Please ensure this method is only called for functions which, very definitely, return null.
§Examples
use pgrx::callconv::FcInfo;
use pgrx::datum::Datum;
use pgrx::prelude::*;
fn foo<'a>(mut fcinfo: FcInfo<'a>) -> Datum<'a> {
unsafe { fcinfo.return_null() }
}sourcepub unsafe fn return_raw_datum(&mut self, datum: Datum) -> Datum<'fcx>
pub unsafe fn return_raw_datum(&mut self, datum: Datum) -> Datum<'fcx>
Set the return to be non-null and assign a raw Datum the correct lifetime.
§Safety
- If the function call expects a by-reference return, and the
pg_sys::Datumdoes not point to a valid object of the correct type, this is undefined behavior. - If the function call expects a by-reference return, and the
pg_sys::Datumpoints to an object that will not last for the caller’s lifetime, this is undefined behavior. - If the function call expects a by-value return, and the
pg_sys::Datumis not a valid instance of that type when interpreted as such, this is undefined behavior. - If the return must be the SQL null, then calling this function is undefined behavior.
Functionally, this can be thought of as a convenience for a mem::transmute
from pg_sys::Datum to pgrx::datum::Datum<'fcx>. This gives it similar constraints.
sourcepub fn get_collation(&self) -> Option<Oid>
pub fn get_collation(&self) -> Option<Oid>
Get the collation the function call should use. If the OID is 0 (invalid or no-type) this method will return None, otherwise it will return Some(oid).
sourcepub fn get_arg_type(&self, num: usize) -> Option<Oid>
pub fn get_arg_type(&self, num: usize) -> Option<Oid>
Retrieve the type (as an Oid) of argument number num.
In other words, the type of self.raw_args()[num]
sourcepub fn get_or_init_func_extra<DefaultValue: FnOnce() -> *mut FuncCallContext>(
&self,
default: DefaultValue,
) -> NonNull<FuncCallContext>
pub fn get_or_init_func_extra<DefaultValue: FnOnce() -> *mut FuncCallContext>( &self, default: DefaultValue, ) -> NonNull<FuncCallContext>
Retrieve the .flinfo.fn_extra pointer (as a PgBox’d type) from pg_sys::FunctionCallInfo.
If it was not already initialized, initialize it with default
pub fn srf_is_initialized(&self) -> bool
sourcepub unsafe fn init_multi_func_call(&mut self) -> &'fcx mut FuncCallContext
pub unsafe fn init_multi_func_call(&mut self) -> &'fcx mut FuncCallContext
Thin wrapper around pg_sys::init_MultiFuncCall, made necessary
because this structure’s FunctionCallInfo is a private field.
This should initialize self.0.flinfo.fn_extra
sourcepub unsafe fn srf_return_next(&mut self)
pub unsafe fn srf_return_next(&mut self)
Safety: Assumes self.0.flinfo.fn_extra is non-null
i.e. FcInfo::srf_is_initialized() would be true.
sourcepub unsafe fn srf_return_done(&mut self)
pub unsafe fn srf_return_done(&mut self)
Safety: Assumes self.0.flinfo.fn_extra is non-null
i.e. FcInfo::srf_is_initialized() would be true.
sourcepub unsafe fn get_result_info(&self) -> ReturnSetInfoWrapper<'fcx>
pub unsafe fn get_result_info(&self) -> ReturnSetInfoWrapper<'fcx>
§Safety
Do not corrupt the pg_sys::ReturnSetInfo struct’s data.
pub fn args<'arg>(&'arg self) -> Args<'arg, 'fcx> ⓘ
Trait Implementations§
Auto Trait Implementations§
impl<'fcx> Freeze for FcInfo<'fcx>
impl<'fcx> RefUnwindSafe for FcInfo<'fcx>
impl<'fcx> !Send for FcInfo<'fcx>
impl<'fcx> !Sync for FcInfo<'fcx>
impl<'fcx> Unpin for FcInfo<'fcx>
impl<'fcx> !UnwindSafe for FcInfo<'fcx>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.