struct CQL::Postgres::ProtocolVersion

Overview

A frontend/backend protocol version, and every rule that depends on it, so the rest of the driver never compares version numbers itself.

3.0 is understood by every server since PostgreSQL 7.4. 3.2 (PostgreSQL 18) enlarges the query-cancel secret key from 4 bytes to 4..256 bytes. 3.1 is reserved and never used.

Included Modules

Defined in:

postgres/protocol_version.cr

Constant Summary

EARLIEST = V3_0
KNOWN = {V3_0, V3_2}
LATEST = V3_2
SECRET_KEY_SIZES_BEFORE_3_2 = 4..4
SECRET_KEY_SIZES_FROM_3_2 = 4..256
V3_0 = new(3, 0)
V3_2 = new(3, 2)

Constructors

Instance Method Summary

Constructor Detail

def self.new(major : Int32, minor : Int32) #

[View source]
def self.parse(text : String) : ProtocolVersion #

"3.0", "3.2" or "latest".


[View source]

Instance Method Detail

def <=>(other : ProtocolVersion) : Int32 #
Description copied from module Comparable(CQL::Postgres::ProtocolVersion)

The comparison operator. Returns 0 if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greater than other, or nil if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]

[View source]
def code : Int32 #

The 32-bit number sent in the StartupMessage.


[View source]
def major : Int32 #

[View source]
def minor : Int32 #

[View source]
def negotiated(offered : Int32) : ProtocolVersion #

The version to use after the server named its newest one in NegotiateProtocolVersion. The protocol says that field holds the newest minor version, but servers before PostgreSQL 18 send the whole version number (3.0 as 196608), so both forms are read.


[View source]
def secret_key_sizes : Range(Int32, Int32) #

The allowed length of the cancel secret key.


[View source]
def to_s(io : IO) : Nil #
Description copied from struct Struct

Same as #inspect(io).


[View source]
def valid_secret_key?(key : Bytes) : Bool #

[View source]