Skip to content

PgList

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Creates typed PostgreSQL lists and explicitly borrows existing native containers.

public static class PgList

Inheritance: object

Creates an empty list bound to the selected context’s current lifetime.

public static PgList<T> Create<T>(PgMemoryContext? context = null) where T : unmanaged

Type parameters:

T

Exactly int, uint (OID), PgTransactionId, or nint (opaque pointer).

Parameters:

context — PgMemoryContext

The native owner, or null for the current context.

Returns: PgList<T>

An owned NIL list; transaction-ID lists require PostgreSQL 16 or later.

Create<T>(ReadOnlySpan<T>, PgMemoryContext?)

Section titled “Create<T>(ReadOnlySpan<T>, PgMemoryContext?)”

Creates a native list containing an independent copy of the supplied cell values.

public static PgList<T> Create<T>(ReadOnlySpan<T> values, PgMemoryContext? context = null) where T : unmanaged

Type parameters:

T

Exactly int, uint (OID), PgTransactionId, or nint (opaque pointer).

Parameters:

values — ReadOnlySpan<T>

The initial values, including zero and all raw bit patterns.

context — PgMemoryContext

The native owner, or null for the current context.

Returns: PgList<T>

An owned container; pointer elements remain owned by their original owners.

DangerousBorrow<T>(void*, PgMemoryContext)

Section titled “DangerousBorrow<T>(void*, PgMemoryContext)”

Borrows an exclusively accessible palloc-compatible list after validating its native cell tag.

public static PgList<T> DangerousBorrow<T>(void* address, PgMemoryContext owner) where T : unmanaged

Type parameters:

T

The expected cell type.

Parameters:

address — void*

The native List pointer; null represents a valid empty list.

owner — PgMemoryContext

The exact allocator context for both the header and any separate cell buffer.

Returns: PgList<T>

A borrowed list whose disposal leaves native storage intact.

Exceptions:

The caller proves valid storage and exclusive access until disposal or detach. An owner anchor cannot detect external frees. Mutations may free or replace the native container; obtain its current pointer after structural changes. Pointer elements are never freed.

DangerousTryBorrow<T>(void*, PgMemoryContext, out PgList<T>?)

Section titled “DangerousTryBorrow<T>(void*, PgMemoryContext, out PgList<T>?)”

Attempts an exclusive typed borrow, returning false only for a mismatched native tag.

public static bool DangerousTryBorrow<T>(void* address, PgMemoryContext owner, out PgList<T>? list) where T : unmanaged

Type parameters:

T

The expected cell type.

Parameters:

address — void*

The native List pointer, including null for NIL.

owner — PgMemoryContext

The exact native allocator context and reset-sensitive lifetime anchor.

list — PgList<T>

The borrowed wrapper on success, otherwise null.

Returns: bool

Whether the native tag matches; NIL matches every supported cell type.

The same allocator, exclusive-access and lifetime requirements as DangerousBorrow apply. Unsupported server versions, invalid metadata and dead contexts still throw.