PgFunctions
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Calls PostgreSQL functions through native lookup, expression evaluation, and guarded error transport.
public static class PgFunctionsCatalog calls support PgAnyElement and PgAnyArray results owned by the current callback or iterator. PgArrayView and PgArrayView<T> expose checked cells over callback-owned result snapshots. Typed array results validate their declared element identity before catalog execution, including for SQL NULL. Ordinary managed results are independent copies. Use CallRaw to select an explicit native owner. Registered datum readers use an exact declared result OID check before invoking a catalog function and return independent managed values before temporary native storage is released. Native-address calls use the selected mapping as the caller’s asserted result type without catalog declaration proof.
Inheritance: object
Methods
Section titled “Methods”Call(string, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)
Section titled “Call(string, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)”Calls a named void-returning function with explicit collation or variadic options.
public static void Call(string name, PgFunctionCallOptions options, params ReadOnlySpan<PgFunctionArgument> arguments)Parameters:
name — string
The SQL function identifier.
options — PgFunctionCallOptions
The call options.
arguments — ReadOnlySpan<PgFunctionArgument>
The typed arguments.
Call(string, params ReadOnlySpan<PgFunctionArgument>)
Section titled “Call(string, params ReadOnlySpan<PgFunctionArgument>)”Calls a named function returning void.
public static void Call(string name, params ReadOnlySpan<PgFunctionArgument> arguments)Parameters:
name — string
The SQL function identifier.
arguments — ReadOnlySpan<PgFunctionArgument>
The typed arguments.
Call(uint, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)
Section titled “Call(uint, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)”Calls a void-returning function by OID with explicit collation options.
public static void Call(uint functionOid, PgFunctionCallOptions options, params ReadOnlySpan<PgFunctionArgument> arguments)Parameters:
functionOid — uint
The nonzero function OID.
options — PgFunctionCallOptions
The call options.
arguments — ReadOnlySpan<PgFunctionArgument>
The declared argument list.
Call(uint, params ReadOnlySpan<PgFunctionArgument>)
Section titled “Call(uint, params ReadOnlySpan<PgFunctionArgument>)”Calls a function returning void by catalog OID.
public static void Call(uint functionOid, params ReadOnlySpan<PgFunctionArgument> arguments)Parameters:
functionOid — uint
The nonzero function OID.
arguments — ReadOnlySpan<PgFunctionArgument>
The declared argument list.
CallRaw(string, PgMemoryContext, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)
Section titled “CallRaw(string, PgMemoryContext, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)”Calls a named scalar function with options and copies its exact native result into a selected context.
public static PgDatum CallRaw(string name, PgMemoryContext context, PgFunctionCallOptions options, params ReadOnlySpan<PgFunctionArgument> arguments)Parameters:
name — string
The SQL function identifier.
context — PgMemoryContext
The result owner.
options — PgFunctionCallOptions
The call options.
arguments — ReadOnlySpan<PgFunctionArgument>
The typed arguments.
Returns: PgDatum
The context-owned result.
CallRaw(string, PgMemoryContext, params ReadOnlySpan<PgFunctionArgument>)
Section titled “CallRaw(string, PgMemoryContext, params ReadOnlySpan<PgFunctionArgument>)”Calls a named scalar function and copies its exact native result into a selected memory context.
public static PgDatum CallRaw(string name, PgMemoryContext context, params ReadOnlySpan<PgFunctionArgument> arguments)Parameters:
name — string
The SQL function identifier.
context — PgMemoryContext
The owner of the returned native value.
arguments — ReadOnlySpan<PgFunctionArgument>
The typed arguments.
Returns: PgDatum
A checked datum preserving the actual result type and SQL NULL.
CallRaw(uint, PgMemoryContext, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)
Section titled “CallRaw(uint, PgMemoryContext, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)”Calls a scalar function by catalog OID with options and copies its result into a selected context.
public static PgDatum CallRaw(uint functionOid, PgMemoryContext context, PgFunctionCallOptions options, params ReadOnlySpan<PgFunctionArgument> arguments)Parameters:
functionOid — uint
The nonzero function OID.
context — PgMemoryContext
The result owner.
options — PgFunctionCallOptions
The call options.
arguments — ReadOnlySpan<PgFunctionArgument>
The declared argument list.
Returns: PgDatum
The context-owned result with exact type identity.
CallRaw(uint, PgMemoryContext, params ReadOnlySpan<PgFunctionArgument>)
Section titled “CallRaw(uint, PgMemoryContext, params ReadOnlySpan<PgFunctionArgument>)”Calls a scalar function by catalog OID and copies its result into a selected memory context.
public static PgDatum CallRaw(uint functionOid, PgMemoryContext context, params ReadOnlySpan<PgFunctionArgument> arguments)Parameters:
functionOid — uint
The nonzero function OID.
context — PgMemoryContext
The result owner.
arguments — ReadOnlySpan<PgFunctionArgument>
The declared argument list.
Returns: PgDatum
The context-owned result with exact type identity.
Call<T>(string, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)
Section titled “Call<T>(string, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)”Calls a named scalar function with explicit collation or variadic binding options.
public static T Call<T>(string name, PgFunctionCallOptions options, params ReadOnlySpan<PgFunctionArgument> arguments)Type parameters:
T
The exact managed result type.
Parameters:
name — string
The SQL function identifier.
options — PgFunctionCallOptions
The call options.
arguments — ReadOnlySpan<PgFunctionArgument>
The typed arguments.
Returns: T
An independent managed copy or callback-owned polymorphic result.
Call<T>(string, params ReadOnlySpan<PgFunctionArgument>)
Section titled “Call<T>(string, params ReadOnlySpan<PgFunctionArgument>)”Calls a scalar function by its optionally schema-qualified SQL name.
public static T Call<T>(string name, params ReadOnlySpan<PgFunctionArgument> arguments)Type parameters:
T
The exact managed result type; use a nullable type when SQL NULL is possible.
Parameters:
name — string
The SQL identifier, with ordinary PostgreSQL quoting and search-path rules.
arguments — ReadOnlySpan<PgFunctionArgument>
Typed values, NULLs, and defaults. Trailing default arguments may be omitted.
Returns: T
An independent managed copy or callback-owned polymorphic result.
Call<T>(uint, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)
Section titled “Call<T>(uint, PgFunctionCallOptions, params ReadOnlySpan<PgFunctionArgument>)”Calls a scalar function by catalog OID with explicit collation options.
public static T Call<T>(uint functionOid, PgFunctionCallOptions options, params ReadOnlySpan<PgFunctionArgument> arguments)Type parameters:
T
The exact managed result type.
Parameters:
functionOid — uint
The nonzero function OID.
options — PgFunctionCallOptions
The call options.
arguments — ReadOnlySpan<PgFunctionArgument>
The declared argument list, including any variadic array.
Returns: T
An independent managed copy or callback-owned polymorphic result.
Call<T>(uint, params ReadOnlySpan<PgFunctionArgument>)
Section titled “Call<T>(uint, params ReadOnlySpan<PgFunctionArgument>)”Calls a scalar function by catalog OID using its declared argument list.
public static T Call<T>(uint functionOid, params ReadOnlySpan<PgFunctionArgument> arguments)Type parameters:
T
The exact managed result type.
Parameters:
functionOid — uint
The nonzero function OID.
arguments — ReadOnlySpan<PgFunctionArgument>
Typed arguments; supply a variadic parameter as an array.
Returns: T
An independent managed copy or callback-owned polymorphic result.
DangerousCallRaw(nint, uint, PgMemoryContext, uint, params ReadOnlySpan<PgDatum>)
Section titled “DangerousCallRaw(nint, uint, PgMemoryContext, uint, params ReadOnlySpan<PgDatum>)”Calls a native PostgreSQL version-1 entry point and copies its raw result to a selected owner.
[NativeUnsafeAccess]public static PgDatum DangerousCallRaw(nint function, uint resultTypeOid, PgMemoryContext context, uint collationOid, params ReadOnlySpan<PgDatum> arguments)Parameters:
function — nint
The valid native entry-point address.
resultTypeOid — uint
The actual PostgreSQL return type.
context — PgMemoryContext
The returned datum’s owner.
collationOid — uint
The input collation, or zero for none.
arguments — ReadOnlySpan<PgDatum>
The exact raw arguments and SQL NULL flags.
Returns: PgDatum
A checked copy of the returned datum.
The caller owns ABI correctness and pointer validity. FmgrInfo, context, and resultinfo are null. Pointer-bearing types such as internal retain their bits; copying them does not clone their pointees.
DangerousCall<T>(nint, uint, params ReadOnlySpan<PgDatum>)
Section titled “DangerousCall<T>(nint, uint, params ReadOnlySpan<PgDatum>)”Calls a native PostgreSQL version-1 entry point and copies a supported result or invokes its registered reader.
[NativeUnsafeAccess]public static T DangerousCall<T>(nint function, uint collationOid, params ReadOnlySpan<PgDatum> arguments)Type parameters:
T
The entry point’s actual result type.
Parameters:
function — nint
The valid native function address.
collationOid — uint
The input collation, or zero for none.
arguments — ReadOnlySpan<PgDatum>
Live raw arguments matching the entry point’s ABI and NULL contract.
Returns: T
The copied managed result, including SQL NULL for nullable types.
The caller must prove the address and argument/result representations are correct. The native call has no FmgrInfo, context, or resultinfo; use catalog calls for functions needing those fields. Registered scalar and array readers return independent managed data before temporary result storage is released. Their current mapped type is the caller’s result contract; the address supplies no catalog return declaration. A PgArrayView<T> result uses the array type of T as that asserted contract and retains callback-owned storage. PostgreSQL errors remain guarded, but invalid pointers or ABI contracts can crash the backend.
GetInfo(uint)
Section titled “GetInfo(uint)”Copies the metadata of a function, procedure, aggregate or window function from pg_proc.
public static PgFunctionInfo? GetInfo(uint functionOid)Parameters:
functionOid — uint
The exact catalog identity, including zero for a missing entry.
Returns: PgFunctionInfo
An immutable detached snapshot, or null when the OID has no pg_proc row.