Type Alias pgrx_pg_sys::regproc

source ·
pub type regproc = Oid;

Aliased Type§

struct regproc(/* private fields */);

Implementations§

source§

impl Oid

source

pub const INVALID: Oid = _

source

pub const unsafe fn from_u32_unchecked(id: u32) -> Oid

Generate an Oid from an arbitrary u32.

Safety

This allows you to create an Oid that Postgres won’t recognize and throw it into Postgres. Don’t.

You should know what kind of object the identifier would imply before creating it. Postgres may sometimes call very different internal functions based on an Oid input. The extension programming interface of Postgres can reach deep, calling functions that assume the caller should be trusted like Postgres would trust itself. Because it is. Postgres tables can also change at runtime, so if an Oid is not a BuiltinOid, what Postgres does based on an Oid can change dynamically.

The existence of this unsafe requirement to create arbitrary Oids does not, itself, constitute a promise any Oid from Postgres or PGRX is guaranteed to be valid or sensical. There are many existing problems in the way of this, for example:

  • Oid includes the guaranteed-wrong values Oid::INVALID
  • Postgres may return arbitrary-seeming Oids, like BuiltinOid::UNKNOWNOID
  • an Oid can arrive in Rust from a table a non-superuser can write
  • PGRX mostly relies on Rust’s type system instead of the dynamic typing of Postgres, thus often deliberately does not bother to remember what OID something had.

So this function is merely a reminder. Even for extensions that work with many Oids, it is not typical to need to create one from an arbitrary u32. Prefer to use a constant, or a BuiltinOid, or to obtain one from querying Postgres, or simply use Oid::INVALID. Marking it as an unsafe fn is an invitation to get an Oid from more trustworthy sources. This includes Oid::INVALID, or BuiltinOid, or by directly calling into Postgres. An unsafe fn is not an officer of the law empowered to indict C programs for felonies, nor cite SQL statements for misdemeanors, nor even truly stop you from foolishness. Even “trustworthy” is meant here in a similar sense to how raw pointers can be “trustworthy”. Often, you should still check if it’s null.

source

pub const fn from_builtin(id: u32) -> Result<Oid, NotBuiltinOid>

Gets an Oid from a u32 if it is a valid builtin declared by Postgres

source

pub const fn as_u32(self) -> u32

Trait Implementations§

source§

impl Clone for Oid

source§

fn clone(&self) -> Oid

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Oid

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Oid

source§

fn default() -> Oid

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Oid

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Oid

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<BuiltinOid> for Oid

source§

fn from(builtin: BuiltinOid) -> Oid

Converts to this type from the input type.
source§

impl Hash for Oid

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Oid> for Oid

source§

fn eq(&self, other: &Oid) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Oid

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl SqlTranslatable for Oid

source§

impl Copy for Oid

source§

impl Eq for Oid

source§

impl StructuralEq for Oid

source§

impl StructuralPartialEq for Oid