Struct NpgsqlLogSequenceNumber
Wraps a PostgreSQL Write-Ahead Log Sequence Number (see: https://www.postgresql.org/docs/current/datatype-pg-lsn.html)
Inherited Members
Namespace: NpgsqlTypes
Assembly: Npgsql.dll
Syntax
public readonly struct NpgsqlLogSequenceNumber : IEquatable<NpgsqlLogSequenceNumber>, IComparable<NpgsqlLogSequenceNumber>
Remarks
Log Sequence Numbers are a fundamental concept of the PostgreSQL Write-Ahead Log and by that of PostgreSQL replication. See https://www.postgresql.org/docs/current/wal-internals.html for what they represent.
This struct provides conversions from/to String and UInt64 and beyond that tries to port the methods and operators in https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/adt/pg_lsn.c but nothing more.
Constructors
NpgsqlLogSequenceNumber(UInt64)
Initializes a new instance of NpgsqlLogSequenceNumber.
Declaration
public NpgsqlLogSequenceNumber(ulong value)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | value | The value to wrap. |
Fields
Invalid
Zero is used indicate an invalid Log Sequence Number. No XLOG record can begin at zero.
Declaration
public static readonly NpgsqlLogSequenceNumber Invalid
Field Value
Type | Description |
---|---|
NpgsqlLogSequenceNumber |
Methods
CompareTo(NpgsqlLogSequenceNumber)
Compares this instance to a specified NpgsqlLogSequenceNumber and returns an indication of their relative values.
Declaration
public readonly int CompareTo(NpgsqlLogSequenceNumber value)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value | A NpgsqlLogSequenceNumber instance to compare to this instance. |
Returns
Type | Description |
---|---|
Int32 | A signed number indicating the relative values of this instance and |
Equals(NpgsqlLogSequenceNumber)
Returns a value indicating whether this instance is equal to a specified NpgsqlLogSequenceNumber instance.
Declaration
public readonly bool Equals(NpgsqlLogSequenceNumber other)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | other | A NpgsqlLogSequenceNumber instance to compare to this instance. |
Returns
Type | Description |
---|---|
Boolean | true if the current instance is equal to the value parameter; otherwise, false. |
Equals(Object)
Returns a value indicating whether this instance is equal to a specified object.
Declaration
public override readonly bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | An object to compare to this instance |
Returns
Type | Description |
---|---|
Boolean | true if the current instance is equal to the value parameter; otherwise, false. |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer hash code. |
Overrides
Larger(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Returns the larger of two NpgsqlLogSequenceNumber values.
Declaration
public static NpgsqlLogSequenceNumber Larger(NpgsqlLogSequenceNumber value1, NpgsqlLogSequenceNumber value2)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value1 | The first value to compare. |
NpgsqlLogSequenceNumber | value2 | The second value to compare. |
Returns
Type | Description |
---|---|
NpgsqlLogSequenceNumber | The larger of the two NpgsqlLogSequenceNumber values. |
Parse(ReadOnlySpan<Char>)
Converts the span representation of a Log Sequence Number to a NpgsqlLogSequenceNumber instance.
Declaration
public static NpgsqlLogSequenceNumber Parse(ReadOnlySpan<char> s)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Char> | s | A span containing the characters that represent the Log Sequence Number to convert. |
Returns
Type | Description |
---|---|
NpgsqlLogSequenceNumber | A NpgsqlLogSequenceNumber equivalent to the Log Sequence Number specified in |
Exceptions
Type | Condition |
---|---|
OverflowException | The |
FormatException | The |
Parse(String)
Converts the string representation of a Log Sequence Number to a NpgsqlLogSequenceNumber instance.
Declaration
public static NpgsqlLogSequenceNumber Parse(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s | A string that represents the Log Sequence Number to convert. |
Returns
Type | Description |
---|---|
NpgsqlLogSequenceNumber | A NpgsqlLogSequenceNumber equivalent to the Log Sequence Number specified in |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | The |
OverflowException | The |
FormatException | The |
Smaller(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Returns the smaller of two NpgsqlLogSequenceNumber values.
Declaration
public static NpgsqlLogSequenceNumber Smaller(NpgsqlLogSequenceNumber value1, NpgsqlLogSequenceNumber value2)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value1 | The first value to compare. |
NpgsqlLogSequenceNumber | value2 | The second value to compare. |
Returns
Type | Description |
---|---|
NpgsqlLogSequenceNumber | The smaller of the two NpgsqlLogSequenceNumber values. |
ToString()
Converts the numeric value of this instance to its equivalent string representation.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
String | The string representation of the value of this instance, consisting of two hexadecimal numbers of up to 8 digits each, separated by a slash |
Overrides
TryParse(ReadOnlySpan<Char>, out NpgsqlLogSequenceNumber)
Tries to convert the span representation of a Log Sequence Number to an NpgsqlLogSequenceNumber instance. A return value indicates whether the conversion succeeded or failed.
Declaration
public static bool TryParse(ReadOnlySpan<char> s, out NpgsqlLogSequenceNumber result)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<Char> | s | A span containing the characters that represent the Log Sequence Number to convert. |
NpgsqlLogSequenceNumber | result | When this method returns, contains a NpgsqlLogSequenceNumber instance equivalent to the Log Sequence
Number contained in |
Returns
Type | Description |
---|---|
Boolean | true if |
TryParse(String, out NpgsqlLogSequenceNumber)
Tries to convert the string representation of a Log Sequence Number to an NpgsqlLogSequenceNumber instance. A return value indicates whether the conversion succeeded or failed.
Declaration
public static bool TryParse(string s, out NpgsqlLogSequenceNumber result)
Parameters
Type | Name | Description |
---|---|---|
String | s | A string that represents the Log Sequence Number to convert. |
NpgsqlLogSequenceNumber | result | When this method returns, contains a NpgsqlLogSequenceNumber instance equivalent to the Log Sequence
Number contained in |
Returns
Type | Description |
---|---|
Boolean | true if |
Operators
Addition(NpgsqlLogSequenceNumber, Double)
Add the number of bytes to a NpgsqlLogSequenceNumber instance, giving a new NpgsqlLogSequenceNumber instance. Handles both positive and negative numbers of bytes.
Declaration
public static NpgsqlLogSequenceNumber operator +(NpgsqlLogSequenceNumber lsn, double nbytes)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | lsn | The NpgsqlLogSequenceNumber instance representing a write-ahead log location. |
Double | nbytes | The number of bytes to add. |
Returns
Type | Description |
---|---|
NpgsqlLogSequenceNumber | A new NpgsqlLogSequenceNumber instance. |
Exceptions
Type | Condition |
---|---|
OverflowException | The resulting NpgsqlLogSequenceNumber instance would represent a number greater than MaxValue. |
Equality(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Returns a value that indicates whether two specified instances of NpgsqlLogSequenceNumber are equal.
Declaration
public static bool operator ==(NpgsqlLogSequenceNumber value1, NpgsqlLogSequenceNumber value2)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value1 | The first Log Sequence Number to compare. |
NpgsqlLogSequenceNumber | value2 | The second Log Sequence Number to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
Explicit(NpgsqlLogSequenceNumber to UInt64)
Converts the value of a NpgsqlLogSequenceNumber instance to a 64-bit unsigned integer value.
Declaration
public static explicit operator ulong (NpgsqlLogSequenceNumber value)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value | A NpgsqlLogSequenceNumber instance |
Returns
Type | Description |
---|---|
UInt64 | The contents of |
Explicit(UInt64 to NpgsqlLogSequenceNumber)
Converts the value of a 64-bit unsigned integer to a NpgsqlLogSequenceNumber instance.
Declaration
public static explicit operator NpgsqlLogSequenceNumber(ulong value)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | value | A 64-bit unsigned integer. |
Returns
Type | Description |
---|---|
NpgsqlLogSequenceNumber | A new instance of NpgsqlLogSequenceNumber initialized to |
GreaterThan(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Returns a value indicating whether a specified NpgsqlLogSequenceNumber instance is greater than another specified NpgsqlLogSequenceNumber instance.
Declaration
public static bool operator>(NpgsqlLogSequenceNumber value1, NpgsqlLogSequenceNumber value2)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value1 | The first value to compare. |
NpgsqlLogSequenceNumber | value2 | The second value to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
GreaterThanOrEqual(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Returns a value indicating whether a specified NpgsqlLogSequenceNumber instance is greater than or equal to another specified NpgsqlLogSequenceNumber instance.
Declaration
public static bool operator >=(NpgsqlLogSequenceNumber value1, NpgsqlLogSequenceNumber value2)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value1 | The first value to compare. |
NpgsqlLogSequenceNumber | value2 | The second value to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
Inequality(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Returns a value that indicates whether two specified instances of NpgsqlLogSequenceNumber are not equal.
Declaration
public static bool operator !=(NpgsqlLogSequenceNumber value1, NpgsqlLogSequenceNumber value2)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value1 | The first Log Sequence Number to compare. |
NpgsqlLogSequenceNumber | value2 | The second Log Sequence Number to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
LessThan(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Returns a value indicating whether a specified NpgsqlLogSequenceNumber instance is less than another specified NpgsqlLogSequenceNumber instance.
Declaration
public static bool operator <(NpgsqlLogSequenceNumber value1, NpgsqlLogSequenceNumber value2)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value1 | The first value to compare. |
NpgsqlLogSequenceNumber | value2 | The second value to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
LessThanOrEqual(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Returns a value indicating whether a specified NpgsqlLogSequenceNumber instance is less than or equal to another specified NpgsqlLogSequenceNumber instance.
Declaration
public static bool operator <=(NpgsqlLogSequenceNumber value1, NpgsqlLogSequenceNumber value2)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | value1 | The first value to compare. |
NpgsqlLogSequenceNumber | value2 | The second value to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
Subtraction(NpgsqlLogSequenceNumber, NpgsqlLogSequenceNumber)
Subtracts two specified NpgsqlLogSequenceNumber values.
Declaration
public static ulong operator -(NpgsqlLogSequenceNumber first, NpgsqlLogSequenceNumber second)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | first | The first NpgsqlLogSequenceNumber value. |
NpgsqlLogSequenceNumber | second | The second NpgsqlLogSequenceNumber value. |
Returns
Type | Description |
---|---|
UInt64 | The number of bytes separating those write-ahead log locations. |
Subtraction(NpgsqlLogSequenceNumber, Double)
Subtract the number of bytes from a NpgsqlLogSequenceNumber instance, giving a new NpgsqlLogSequenceNumber instance. Handles both positive and negative numbers of bytes.
Declaration
public static NpgsqlLogSequenceNumber operator -(NpgsqlLogSequenceNumber lsn, double nbytes)
Parameters
Type | Name | Description |
---|---|---|
NpgsqlLogSequenceNumber | lsn | The NpgsqlLogSequenceNumber instance representing a write-ahead log location. |
Double | nbytes | The number of bytes to subtract. |
Returns
Type | Description |
---|---|
NpgsqlLogSequenceNumber | A new NpgsqlLogSequenceNumber instance. |
Exceptions
Type | Condition |
---|---|
OverflowException | The resulting NpgsqlLogSequenceNumber instance would represent a number less than MinValue. |