PgHeapTuple
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Owns the cells of a PostgreSQL composite or anonymous record independently of backend memory contexts. Ordinals include dropped physical slots. Nested tuples, arrays, and binary buffers are ordinary shared references.
public sealed class PgHeapTupleInheritance: object
Methods
Section titled “Methods”Clone()
Section titled “Clone()”Copies the cell slots while sharing immutable metadata and nested reference values. Replacing a cell in either tuple leaves the other tuple’s slots unchanged.
public PgHeapTuple Clone()Returns: PgHeapTuple
A shallow detached copy.
Create(params (string Name, SpiParameter Value)[])
Section titled “Create(params (string Name, SpiParameter Value)[])”Creates and registers an anonymous PostgreSQL record from named typed fields in the active backend. New field names must contain at most sixty-three UTF-8 bytes and cannot contain a zero character. Relation fields copy their OIDs without retaining the supplied reference’s close obligation.
public static PgHeapTuple Create(params (string Name, SpiParameter Value)[] fields)Parameters:
fields — (string Name, SpiParameter Value)[]
The field names and typed values in physical order.
Returns: PgHeapTuple
An owned record with a canonical registered type modifier.
DangerousCopy(nint, nint)
Section titled “DangerousCopy(nint, nint)”Copies a native heap tuple and its descriptor, such as a row a hook or custom scan receives, as pgrx’s
PgHeapTuple::from_heap_tuple does. Cells whose types have no managed conversion are copied exactly.
[NativeUnsafeAccess]public static PgHeapTuple DangerousCopy(nint heapTuple, nint tupleDescriptor)Parameters:
heapTuple — nint
The native HeapTuple address.
tupleDescriptor — nint
The native TupleDesc address describing the tuple.
Returns: PgHeapTuple
An owned tuple.
The caller must supply live addresses in this backend, and the descriptor must describe the tuple; any other address is undefined behavior.
DangerousToNative(PgMemoryContext)
Section titled “DangerousToNative(PgMemoryContext)”Forms a native heap tuple from this composite in a memory context, as pgrx’s PgHeapTuple::into_pg does.
Current domain and type-modifier constraints apply, as they do when PostgreSQL receives the composite.
[NativeUnsafeAccess]public nint DangerousToNative(PgMemoryContext context)Parameters:
context — PgMemoryContext
The destination context whose reset or deletion frees the heap tuple.
Returns: nint
The native HeapTuple address.
The returned address is valid until the context is reset or deleted.
Get<T>(int)
Section titled “Get<T>(int)”Reads a cell with the same strict type and SQL NULL rules as an SPI row. A PgDatumTypeAttribute type, or an array of one, uses its reader when the attribute has exactly the mapped PostgreSQL type. PgDatum rebuilds the cell, including SQL NULL, as a datum of its type owned by the current callback. Reading PgRelation or its arrays opens fresh references that the caller must dispose.
public T Get<T>(int ordinal)Type parameters:
T
The requested managed type.
Parameters:
ordinal — int
The zero-based physical ordinal.
Returns: T
The converted cell.
Get<T>(string)
Section titled “Get<T>(string)”Reads the first live attribute with the exact name using strict managed conversion.
public T Get<T>(string name)Type parameters:
T
The requested managed type.
Parameters:
name — string
The exact attribute name.
Returns: T
The converted cell.
Set(int, SpiParameter)
Section titled “Set(int, SpiParameter)”Replaces a cell using an explicit parameter identity, including a typed NULL composite or array. Raw datums are copied into independent managed values before assignment.
public void Set(int ordinal, SpiParameter value)Parameters:
ordinal — int
The zero-based physical ordinal.
value — SpiParameter
The typed replacement.
Set(string, SpiParameter)
Section titled “Set(string, SpiParameter)”Replaces a named cell using an explicit parameter identity.
public void Set(string name, SpiParameter value)Parameters:
name — string
The exact attribute name.
value — SpiParameter
The typed replacement.
Set<T>(int, T)
Section titled “Set<T>(int, T)”Replaces a cell while preserving declared type, domain, collation, and type-modifier metadata. Native output applies current catalog and domain constraints before exposing the tuple to PostgreSQL. Raw datums and PgDatumTypeAttribute values are copied into independent managed storage before assignment; relations retain only their OIDs.
public void Set<T>(int ordinal, T value)Type parameters:
T
The replacement’s declared managed type, including its type when null.
Parameters:
ordinal — int
The zero-based physical ordinal.
value — T
The replacement cell.
Set<T>(string, T)
Section titled “Set<T>(string, T)”Replaces the first live attribute with an exact matching name.
public void Set<T>(string name, T value)Type parameters:
T
The replacement’s managed type.
Parameters:
name — string
The exact attribute name.
value — T
The replacement value.
Properties
Section titled “Properties”Gets the number of physical cells, including dropped attributes.
public int Count { get; }Value: int
Descriptor
Section titled “Descriptor”Gets the immutable physical tuple description, including its type identity.
public PgTupleDescriptor Descriptor { get; }Value: PgTupleDescriptor
this[int]
Section titled “this[int]”Gets an owned cell by zero-based physical ordinal. SQL NULL and dropped attributes return null; unavailable fields throw. A cell whose type has no managed conversion throws; read it with its PgDatumTypeAttribute type.
public object? this[int ordinal] { get; }Parameters:
ordinal — int
The physical ordinal.
Value: object
The managed cell.
this[string]
Section titled “this[string]”Gets the first live cell with the exact case-sensitive name.
public object? this[string name] { get; }Parameters:
name — string
The exact attribute name.
Value: object
The managed cell.