PgTextView
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Borrows a strictly validated UTF-8 representation of PostgreSQL text.
public sealed class PgTextView : IDisposableUTF-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
Constructors
Section titled “Constructors”PgTextView(PgDatum)
Section titled “PgTextView(PgDatum)”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.
Methods
Section titled “Methods”CopyUtf8To(Span<byte>)
Section titled “CopyUtf8To(Span<byte>)”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.
DangerousGetUtf8Span()
Section titled “DangerousGetUtf8Span()”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.
Dispose()
Section titled “Dispose()”Releases private detoast and encoding allocations and invalidates native access.
public void Dispose()GetUtf8Byte(int)
Section titled “GetUtf8Byte(int)”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.
ToString()
Section titled “ToString()”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.
Properties
Section titled “Properties”Gets the checked original server-encoded datum, valid until this view or its source expires.
public PgDatum Datum { get; }Value: PgDatum
TypeOid
Section titled “TypeOid”Gets the original PostgreSQL type OID, preserving varchar, bpchar and domain identities.
public uint TypeOid { get; }Value: uint
Utf8Length
Section titled “Utf8Length”Gets the UTF-8 byte length, which may differ from the character count or server byte length.
public int Utf8Length { get; }Value: int