PgNodes
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Creates checked node views over generated PostgreSQL representations and explicit native lifetimes.
public static class PgNodesInheritance: object
Methods
Section titled “Methods”Borrow<T>(PgNativeReference<T>)
Section titled “Borrow<T>(PgNativeReference<T>)”Borrows a node view while retaining the reference’s original storage bounds and lifetime anchor.
public static PgNodeReference<T> Borrow<T>(PgNativeReference<T> reference) where T : unmanaged, IPgNativeNodeType parameters:
T
The generated native node representation.
Parameters:
reference — PgNativeReference<T>
The initialized complete native value to view.
Returns: PgNodeReference<T>
A node view without allocation or release rights.
The representation’s complete size, alignment and selected-header ABI are checked. The caller remains responsible for the validity and lifetime of native pointer members. A tag does not prove that those members refer to valid objects.
DangerousAllocate<T>(PgMemoryContext?)
Section titled “DangerousAllocate<T>(PgMemoryContext?)”Allocates a zeroed native node with its type’s own tag, as C’s makeNode(Query) and pgrx’s makeNode! do.
public static PgNativeBox<T> DangerousAllocate<T>(PgMemoryContext? context = null) where T : unmanaged, IPgNativeTaggedNodeType parameters:
T
The generated node type, whose tag the node gets.
Parameters:
context — PgMemoryContext
The allocation owner, or null for the current context.
Returns: PgNativeBox<T>
An individually owned box, which can transfer ownership to its context.
Exceptions:
- InvalidOperationException: No backend callback is active, or the type’s ABI doesn’t match the server.
The caller must initialize all fields required by subsequent native operations. Pointer fields retain native lifetime obligations. Native allocator restrictions apply to individual disposal and ownership transfer.
DangerousAllocate<T>(uint, PgMemoryContext?)
Section titled “DangerousAllocate<T>(uint, PgMemoryContext?)”Allocates a zeroed native node and writes its caller-supplied tag without invoking a constructor.
public static PgNativeBox<T> DangerousAllocate<T>(uint tag, PgMemoryContext? context = null) where T : unmanaged, IPgNativeNodeType parameters:
T
The complete generated native representation.
Parameters:
tag — uint
The exact tag appropriate for this complete representation.
context — PgMemoryContext
The allocation owner, or null for the current context.
Returns: PgNativeBox<T>
An individually owned box, which can transfer ownership to its context.
The caller must choose a tag whose complete native representation fits T and initialize all fields required by subsequent native operations. A base node’s accepted cast tags do not make it large enough to allocate its descendants. Pointer fields retain native lifetime obligations. Native allocator restrictions apply to individual disposal and ownership transfer.
DangerousIsA(void*, uint)
Section titled “DangerousIsA(void*, uint)”Tests a raw node pointer’s exact tag, treating NULL as no match, as pgrx’s PgNode::is_a_ptr does.
public static bool DangerousIsA(void* node, uint tag)Parameters:
node — void*
A node pointer such as a list element or plan field, or NULL.
tag — uint
The native NodeTag value to compare.
Returns: bool
Whether the pointer is non-NULL and its tag is exactly equal.
The caller must guarantee that a non-NULL pointer addresses a live node, whose first field is its tag.
DangerousIsA<T>(void*)
Section titled “DangerousIsA<T>(void*)”Tests a raw node pointer for the tag of a node type, treating NULL as no match, as C’s IsA(node, Query) and
pgrx’s IsA! do.
public static bool DangerousIsA<T>(void* node) where T : unmanaged, IPgNativeTaggedNodeType parameters:
T
The generated node type whose own tag to compare, such as Query for T_Query.
Parameters:
node — void*
A node pointer such as a list element or plan field, or NULL.
Returns: bool
Whether the pointer is non-NULL and its tag is exactly the type’s.
The caller must guarantee that a non-NULL pointer addresses a live node, whose first field is its tag. A node of a
type C derives from T has another tag, so it doesn’t match; use
DangerousTryCast<TTarget>(void*) to accept those too.
DangerousTryCast<TTarget>(void*)
Section titled “DangerousTryCast<TTarget>(void*)”Casts a raw node pointer when the target’s generated cast rules accept its tag, as pgrx’s
PgNode::try_cast_ptr does, and returns NULL for NULL or a rejected tag.
public static TTarget* DangerousTryCast<TTarget>(void* node) where TTarget : unmanaged, IPgNativeNodeType parameters:
TTarget
The generated target node representation.
Parameters:
node — void*
A node pointer such as a list element or plan field, or NULL.
Returns: TTarget*
The original pointer as the target type, or NULL.
Exceptions:
- InvalidOperationException: No backend callback is active, or the target’s ABI doesn’t match the server.
The result is the same address, so it keeps whatever right to write the input had. The caller must guarantee that a non-NULL pointer addresses a live node whose complete storage fits the target. Use Borrow<T>(PgNativeReference<T>) for a view that checks storage bounds and lifetime.