Skip to content

PgTupleDescriptor

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Owns immutable PostgreSQL tuple metadata independently of native memory contexts and catalog cache entries.

public sealed class PgTupleDescriptor

Inheritance: object

Gets the immutable physical attribute list, including dropped slots.

public IReadOnlyList<PgTupleAttributeInfo> Attributes { get; }

Value: IReadOnlyList<PgTupleAttributeInfo>

Gets the underlying composite identity when the declared type is a domain, otherwise the declared type OID.

public uint BaseTypeOid { get; }

Value: uint

Gets the anonymous record’s registered type modifier, or minus one when no modifier is registered.

public int TypeModifier { get; }

Value: int

Gets the composite or explicitly loaded domain OID, or PostgreSQL’s record OID for an anonymous tuple. Tuples read from PostgreSQL datums carry the physical base composite identity. Physical relation metadata can have zero when PostgreSQL supplies no row type, such as indexes on PostgreSQL 13.

public uint TypeOid { get; }

Value: uint

Creates a vector with this descriptor’s explicit type identity, including empty and all-null arrays.

public PgArray<PgHeapTuple?> CreateArray(ReadOnlySpan<PgHeapTuple?> values)

Parameters:

values — ReadOnlySpan<PgHeapTuple>

The tuple values, copied into the array; nested tuples remain shared references.

Returns: PgArray<PgHeapTuple>

A detached array with lower bound one, or rank zero when empty.

Exceptions:

CreateArray(ReadOnlySpan<PgHeapTuple?>, ReadOnlySpan<int>, ReadOnlySpan<int>)

Section titled “CreateArray(ReadOnlySpan<PgHeapTuple?>, ReadOnlySpan<int>, ReadOnlySpan<int>)”

Copies tuple elements and PostgreSQL shape while retaining an explicit element type for every array state. Nonnull elements must share this descriptor’s underlying composite identity.

public PgArray<PgHeapTuple?> CreateArray(ReadOnlySpan<PgHeapTuple?> values, ReadOnlySpan<int> lengths, ReadOnlySpan<int> lowerBounds = default)

Parameters:

values — ReadOnlySpan<PgHeapTuple>

The row-major tuple elements, including SQL NULLs.

lengths — ReadOnlySpan<int>

The dimension lengths.

lowerBounds — ReadOnlySpan<int>

The lower bounds, or an empty span to use one.

Returns: PgArray<PgHeapTuple>

An array whose element OID is this descriptor’s type OID.

Exceptions:

Creates a nonnull tuple whose physical fields are all SQL NULL. It may be populated before native validation.

public PgHeapTuple CreateTuple()

Returns: PgHeapTuple

A detached mutable tuple.

Exceptions:

Copies a native tuple descriptor, such as one a hook or custom scan receives, as pgrx’s PgTupleDesc::from_pg_copy does.

[NativeUnsafeAccess]
public static PgTupleDescriptor DangerousCopy(nint tupleDescriptor)

Parameters:

tupleDescriptor — nint

The native TupleDesc address.

Returns: PgTupleDescriptor

An owned descriptor.

The caller must supply the address of a live descriptor with a row type in this backend; any other address is undefined behavior.

Resolves the first live attribute with the exact case-sensitive name.

public int GetOrdinal(string name)

Parameters:

name — string

The exact attribute name.

Returns: int

The zero-based physical ordinal.

Loads a current composite descriptor using PostgreSQL’s identifier and search-path rules.

public static PgTupleDescriptor Load(string name)

Parameters:

name — string

The optionally schema-qualified PostgreSQL type name.

Returns: PgTupleDescriptor

An owned descriptor.

Loads a current named composite descriptor by its catalog identity.

public static PgTupleDescriptor Load(uint typeOid)

Parameters:

typeOid — uint

The PostgreSQL composite type OID.

Returns: PgTupleDescriptor

An owned descriptor.