PgLsn
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Represents a position in PostgreSQL’s write-ahead log, as the pg_lsn type holds it.
public readonly struct PgLsn : IComparable<PgLsn>, IComparable, ISpanFormattable, IFormattable, ISpanParsable<PgLsn>, IParsable<PgLsn>, IEquatable<PgLsn>The text form is two hexadecimal numbers, the high and low 32 bits, as in 16/B374D848.
ToString() writes them without padding, as PostgreSQL 13–18, Npgsql and rust-postgres do; PostgreSQL 19
pads the low half to eight digits. Parsing accepts both forms, and so does every supported PostgreSQL version.
Implements: IComparable<PgLsn>, IComparable, ISpanFormattable, IFormattable, ISpanParsable<PgLsn>, IParsable<PgLsn>, IEquatable<PgLsn>
Constructors
Section titled “Constructors”PgLsn(ulong)
Section titled “PgLsn(ulong)”Represents a position in PostgreSQL’s write-ahead log, as the pg_lsn type holds it.
public PgLsn(ulong Value)Parameters:
Value — ulong
The byte position.
The text form is two hexadecimal numbers, the high and low 32 bits, as in 16/B374D848.
ToString() writes them without padding, as PostgreSQL 13–18, Npgsql and rust-postgres do; PostgreSQL 19
pads the low half to eight digits. Parsing accepts both forms, and so does every supported PostgreSQL version.
Methods
Section titled “Methods”CompareTo(PgLsn)
Section titled “CompareTo(PgLsn)”public int CompareTo(PgLsn other)Parameters:
other — PgLsn
Returns: int
CompareTo(object?)
Section titled “CompareTo(object?)”public int CompareTo(object? obj)Parameters:
obj — object
Returns: int
Deconstruct(out ulong)
Section titled “Deconstruct(out ulong)”public void Deconstruct(out ulong Value)Parameters:
Value — ulong
Equals(PgLsn)
Section titled “Equals(PgLsn)”public bool Equals(PgLsn other)Parameters:
other — PgLsn
Returns: bool
Equals(object)
Section titled “Equals(object)”public override bool Equals(object obj)Parameters:
obj — object
Returns: bool
GetHashCode()
Section titled “GetHashCode()”public override int GetHashCode()Returns: int
Parse(ReadOnlySpan<char>)
Section titled “Parse(ReadOnlySpan<char>)”Parses PostgreSQL’s text form, which does not depend on culture.
public static PgLsn Parse(ReadOnlySpan<char> s)Parameters:
The text, such as 16/B374D848.
Returns: PgLsn
The position.
Exceptions:
- FormatException: The text is not a position.
Parse(string)
Section titled “Parse(string)”Parses PostgreSQL’s text form, which does not depend on culture.
public static PgLsn Parse(string s)Parameters:
s — string
The text, such as 16/B374D848.
Returns: PgLsn
The position.
Exceptions:
- FormatException: The text is not a position.
ToString()
Section titled “ToString()”Formats the position as PostgreSQL does, such as 16/B374D848.
public override string ToString()Returns: string
The text form.
ToString(string?, IFormatProvider?)
Section titled “ToString(string?, IFormatProvider?)”public string ToString(string? format, IFormatProvider? formatProvider)Parameters:
format — string
formatProvider — IFormatProvider
Returns: string
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Section titled “TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)”public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)Parameters:
destination — Span<char>
charsWritten — int
format — ReadOnlySpan<char>
provider — IFormatProvider
Returns: bool
TryParse(ReadOnlySpan<char>, out PgLsn)
Section titled “TryParse(ReadOnlySpan<char>, out PgLsn)”Parses PostgreSQL’s text form, which does not depend on culture.
public static bool TryParse(ReadOnlySpan<char> s, out PgLsn result)Parameters:
The text, such as 16/B374D848.
result — PgLsn
The position, or the invalid position when parsing fails.
Returns: bool
Whether the text is a position.
TryParse(string?, out PgLsn)
Section titled “TryParse(string?, out PgLsn)”Parses PostgreSQL’s text form, which does not depend on culture.
public static bool TryParse(string? s, out PgLsn result)Parameters:
s — string
The text, such as 16/B374D848.
result — PgLsn
The position, or the invalid position when parsing fails.
Returns: bool
Whether the text is a position.
Properties
Section titled “Properties”Invalid
Section titled “Invalid”Gets the invalid position, 0/0.
public static PgLsn Invalid { get; }Value: PgLsn
IsValid
Section titled “IsValid”Gets whether the position is valid.
public bool IsValid { get; }Value: bool
The byte position.
public ulong Value { get; init; }Value: ulong
Operators
Section titled “Operators”operator ==(PgLsn, PgLsn)
Section titled “operator ==(PgLsn, PgLsn)”public static bool operator ==(PgLsn left, PgLsn right)Parameters:
left — PgLsn
right — PgLsn
Returns: bool
operator >(PgLsn, PgLsn)
Section titled “operator >(PgLsn, PgLsn)”Compares two positions.
public static bool operator >(PgLsn left, PgLsn right)Parameters:
left — PgLsn
The first position.
right — PgLsn
The second position.
Returns: bool
Whether left comes later.
operator >=(PgLsn, PgLsn)
Section titled “operator >=(PgLsn, PgLsn)”Compares two positions.
public static bool operator >=(PgLsn left, PgLsn right)Parameters:
left — PgLsn
The first position.
right — PgLsn
The second position.
Returns: bool
Whether left does not come first.
operator !=(PgLsn, PgLsn)
Section titled “operator !=(PgLsn, PgLsn)”public static bool operator !=(PgLsn left, PgLsn right)Parameters:
left — PgLsn
right — PgLsn
Returns: bool
operator <(PgLsn, PgLsn)
Section titled “operator <(PgLsn, PgLsn)”Compares two positions.
public static bool operator <(PgLsn left, PgLsn right)Parameters:
left — PgLsn
The first position.
right — PgLsn
The second position.
Returns: bool
Whether left comes first.
operator <=(PgLsn, PgLsn)
Section titled “operator <=(PgLsn, PgLsn)”Compares two positions.
public static bool operator <=(PgLsn left, PgLsn right)Parameters:
left — PgLsn
The first position.
right — PgLsn
The second position.
Returns: bool
Whether left does not come later.