Skip to content

PgTextView

Namespace: Ankus

Assembly: Ankus.Runtime.dll

Borrows a strictly validated UTF-8 representation of PostgreSQL text.

public sealed class PgTextView : IDisposable

UTF-8 databases retain flat or short native bytes. Other database encodings require conversion into a private child context; the original server representation remains available through Datum. The source owner must remain alive and direct scalar inputs expire at callback exit. Copied byte length and type metadata remain readable after disposal. Dispose explicitly created views while their backend is active.

Inheritance: object

Implements: IDisposable

Borrows a strictly validated UTF-8 representation of PostgreSQL text.

public PgTextView(PgDatum value)

Parameters:

value — PgDatum

Present text, varchar or bpchar, optionally wrapped in a domain.

UTF-8 databases retain flat or short native bytes. Other database encodings require conversion into a private child context; the original server representation remains available through Datum. The source owner must remain alive and direct scalar inputs expire at callback exit. Copied byte length and type metadata remain readable after disposal. Dispose explicitly created views while their backend is active.

Copies the entire UTF-8 representation after validating its lifetime and destination capacity.

public void CopyUtf8To(Span<byte> destination)

Parameters:

destination — Span<byte>

Storage large enough for Utf8Length bytes.

Checks the lifetime once and exposes the UTF-8 bytes without a managed copy.

public ReadOnlySpan<byte> DangerousGetUtf8Span()

Returns: ReadOnlySpan<byte>

A span whose validity is the caller’s responsibility after this method returns.

Never reset or delete the source owner, dispose this view, or exit its callback while using the span. Keep it on the originating backend thread and do not retain it across backend calls. The span cannot check subsequent native lifetime changes; prefer checked reads or copies.

Releases private detoast and encoding allocations and invalidates native access.

public void Dispose()

Reads one UTF-8 byte after checking the native lifetime and zero-based byte index.

public byte GetUtf8Byte(int index)

Parameters:

index — int

A byte offset, independent of Unicode character boundaries.

Returns: byte

The byte at the requested position.

Decodes the checked UTF-8 bytes into an independent managed string without lossy replacement.

public override string ToString()

Returns: string

The exact text, including trailing bpchar spaces when present.

Gets the checked original server-encoded datum, valid until this view or its source expires.

public PgDatum Datum { get; }

Value: PgDatum

Gets the original PostgreSQL type OID, preserving varchar, bpchar and domain identities.

public uint TypeOid { get; }

Value: uint

Gets the UTF-8 byte length, which may differ from the character count or server byte length.

public int Utf8Length { get; }

Value: int