Skip to content

SpiCursor

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Owns a PostgreSQL cursor and fetches independent managed or raw result batches. Cursors opened through SPI live until closed or their transaction ends.

public sealed class SpiCursor : IDisposable

Inheritance: object

Implements: IDisposable

Relinquishes ownership without closing the portal and returns its name for a later Spi.FindCursor call. This managed cursor can no longer fetch rows after detaching.

public string Detach()

Returns: string

The PostgreSQL portal name.

Closes the portal through the native guard. Repeated disposal and disposal after transaction end are harmless. Disposal requires the owning backend thread; no PostgreSQL calls run on the finalizer thread.

public void Dispose()

Fetches up to the requested number of rows in the forward direction. Zero uses PostgreSQL’s current-row fetch semantics and may require a scrollable cursor. Fetching past the end returns an empty result.

public SpiResult Fetch(int count)

Parameters:

count — int

The nonnegative fetch count.

Returns: SpiResult

A materialized batch independent of the cursor’s lifetime.

Fetches a batch in the requested direction. Backward fetching requires a scrollable PostgreSQL cursor.

public SpiResult Fetch(int count, bool forward)

Parameters:

count — int

The nonnegative number of rows, or zero to fetch the current row.

forward — bool

Whether to move forward rather than backward.

Returns: SpiResult

An independently owned managed batch.

Fetches raw native values without requiring a managed mapping for their PostgreSQL types.

public SpiRawResult FetchRaw(int count)

Parameters:

count — int

The nonnegative fetch count, or zero to fetch the current row.

Returns: SpiRawResult

A disposable batch that survives cursor disposal and expires on disposal or callback-context cleanup.

Fetches raw native values in the requested direction. Backward fetching requires a scrollable cursor.

public SpiRawResult FetchRaw(int count, bool forward)

Parameters:

count — int

The nonnegative fetch count, or zero to fetch the current row.

forward — bool

Whether to move forward rather than backward.

Returns: SpiRawResult

A raw batch to dispose before leaving the backend callback.

Gets the PostgreSQL portal name, which can be used to find a detached cursor in the same transaction.

public string Name { get; }

Value: string