← All compilation units

Flyology.Postgres.Server_Sessions

Description

Stateful backend-side I/O helpers for one PostgreSQL connection.

Accept_TLS

procedure Accept_TLS
  (Item : in out Session; Timeout : Duration)

Reply S to an SSLRequest before the transport is upgraded.

Parameters
Item

Session awaiting the negotiation response.

Timeout

Maximum time allowed for the one-byte response.

Cancellation_Requested

function Cancellation_Requested (Item : Session) return Boolean

Report whether the current handler operation was cancelled by a matching CancelRequest or forced structured-server shutdown.

Parameters
Item

Session whose operation token is queried.

Return value

True after cancellation has been requested.

Password_Text

function Password_Text (Command : Protocol.Message) return String

Decode the credential in a cleartext PasswordMessage.

Parameters
Command

PasswordMessage to inspect.

Return value

Exact password octets represented as a String.

Query_Text

function Query_Text (Command : Protocol.Message) return String

Decode the SQL string in a Query frontend message.

Parameters
Command

Query message to inspect.

Return value

SQL text without its terminating zero byte.

Read_Command

function Read_Command
  (Item : in out Session; Timeout : Duration) return Protocol.Message

Read one complete typed frontend message after startup.

Parameters
Item

Authenticated server session to read.

Timeout

Maximum time allowed for the complete message.

Return value

Raw frontend protocol message.

Read_Copy_Command

function Read_Copy_Command
  (Item : in out Session; Timeout : Duration)
   return Protocol.Frontend_Copy_Message

Read the next frontend COPY event, ignoring Flush and Sync messages.

Parameters
Item

Server session in COPY mode.

Timeout

Maximum time allowed for the complete message.

Return value

CopyData, CopyDone, or CopyFail event.

Raised exceptions
Protocol_Error

The next non-ignored message is not a COPY event or is malformed.

Read_Initial

function Read_Initial
  (Item : in out Session;
   Timeout : Duration) return Protocol.Initial_Request

Read a startup, SSL, GSS, or cancellation request before authentication.

Parameters
Item

New server session to read.

Timeout

Maximum time allowed for the complete packet.

Return value

Decoded initial request.

Refuse_GSS

procedure Refuse_GSS
  (Item : in out Session; Timeout : Duration)

Reply N to a GSSENCRequest because GSS encryption is unsupported.

Parameters
Item

Session awaiting the negotiation response.

Timeout

Maximum time allowed for the one-byte response.

Refuse_TLS

procedure Refuse_TLS
  (Item : in out Session; Timeout : Duration)

Reply N to an SSLRequest.

Parameters
Item

Session awaiting the negotiation response.

Timeout

Maximum time allowed for the one-byte response.

SASL_Initial_Response

function SASL_Initial_Response
  (Command : Protocol.Message) return String

Decode the response bytes in a SASLInitialResponse message.

Parameters
Command

Initial SASL response to inspect.

Return value

Exact SCRAM client-first message.

SASL_Response

function SASL_Response (Command : Protocol.Message) return String

Decode the bytes in a subsequent SASLResponse message.

Parameters
Command

SASL response to inspect.

Return value

Exact SCRAM client-final message.

Send

procedure Send
  (Item    : in out Session;
   Value   : Protocol.Message;
   Timeout : Duration)

Send one complete backend protocol message.

Parameters
Item

Session to write.

Value

Backend message to encode and transmit.

Timeout

Maximum time allowed for the complete write.

Send_Authentication_Cleartext_Password

procedure Send_Authentication_Cleartext_Password
  (Item : in out Session; Timeout : Duration)

Request a cleartext PasswordMessage from the client.

Parameters
Item

Starting session to write.

Timeout

Maximum time allowed for the response.

Send_Authentication_Ok

procedure Send_Authentication_Ok
  (Item : in out Session; Timeout : Duration)

Confirm successful authentication.

Parameters
Item

Starting session to write.

Timeout

Maximum time allowed for the response.

Send_Authentication_SASL

procedure Send_Authentication_SASL
  (Item : in out Session; Timeout : Duration)

Advertise SCRAM-SHA-256 as the supported SASL mechanism.

Parameters
Item

Starting session to write.

Timeout

Maximum time allowed for the response.

Send_Authentication_SASL_Continue

procedure Send_Authentication_SASL_Continue
  (Item : in out Session; Data : String; Timeout : Duration)

Send a SCRAM server-first challenge.

Parameters
Item

Session in SASL authentication.

Data

Exact SCRAM challenge text.

Timeout

Maximum time allowed for the response.

Send_Authentication_SASL_Final

procedure Send_Authentication_SASL_Final
  (Item : in out Session; Data : String; Timeout : Duration)

Send the final SCRAM server signature or error text.

Parameters
Item

Session in SASL authentication.

Data

Exact SCRAM server-final text.

Timeout

Maximum time allowed for the response.

Send_Backend_Key_Data

procedure Send_Backend_Key_Data
  (Item       : in out Session;
   Process_Id : Protocol.UInt32;
   Secret_Key : Protocol.Byte_Array;
   Timeout    : Duration)

Provide credentials used by a later CancelRequest.

Parameters
Item

Authenticated session to write.

Process_Id

Server-assigned cancellation process identifier.

Secret_Key

Unpredictable cancellation secret bytes.

Timeout

Maximum time allowed for the response.

Send_Bind_Complete

procedure Send_Bind_Complete
  (Item : in out Session; Timeout : Duration)

Acknowledge successful Bind processing.

Parameters
Item

Session to write.

Timeout

Maximum time allowed for the response.

Send_Close_Complete

procedure Send_Close_Complete
  (Item : in out Session; Timeout : Duration)

Acknowledge successful Close processing.

Parameters
Item

Session to write.

Timeout

Maximum time allowed for the response.

Send_Command_Complete

procedure Send_Command_Complete
  (Item : in out Session; Tag : String; Timeout : Duration)

Report successful completion of one SQL command.

Parameters
Item

Session to write.

Tag

PostgreSQL command tag, including any row count.

Timeout

Maximum time allowed for the response.

Send_Copy_Both_Response

procedure Send_Copy_Both_Response
  (Item           : in out Session;
   Overall_Format : Protocol.Field_Format;
   Column_Formats : Protocol.Field_Format_Array;
   Timeout        : Duration)

Enter bidirectional COPY and describe both directions' formats.

Parameters
Item

Session to write.

Overall_Format

Overall text or binary COPY format.

Column_Formats

Per-column formats in order.

Timeout

Maximum time allowed for the response.

Send_Copy_Data

procedure Send_Copy_Data
  (Item : in out Session;
   Data : Protocol.Byte_Array;
   Timeout : Duration)

Send one CopyData payload.

Parameters
Item

Session in COPY OUT or COPY BOTH.

Data

Raw COPY payload bytes.

Timeout

Maximum time allowed for the response.

Send_Copy_Done

procedure Send_Copy_Done
  (Item : in out Session; Timeout : Duration)

Close the backend-to-frontend COPY direction.

Parameters
Item

Session in COPY OUT or COPY BOTH.

Timeout

Maximum time allowed for the response.

Send_Copy_In_Response

procedure Send_Copy_In_Response
  (Item           : in out Session;
   Overall_Format : Protocol.Field_Format;
   Column_Formats : Protocol.Field_Format_Array;
   Timeout        : Duration)

Enter COPY IN and describe expected input formats.

Parameters
Item

Session to write.

Overall_Format

Overall text or binary COPY format.

Column_Formats

Per-column formats in order.

Timeout

Maximum time allowed for the response.

Send_Copy_Out_Response

procedure Send_Copy_Out_Response
  (Item           : in out Session;
   Overall_Format : Protocol.Field_Format;
   Column_Formats : Protocol.Field_Format_Array;
   Timeout        : Duration)

Enter COPY OUT and describe emitted formats.

Parameters
Item

Session to write.

Overall_Format

Overall text or binary COPY format.

Column_Formats

Per-column formats in order.

Timeout

Maximum time allowed for the response.

Send_Data_Row

procedure Send_Data_Row
  (Item    : in out Session;
   Values  : Protocol.Column_Value_Array;
   Timeout : Duration)

Send one result row with explicit null and byte values.

Parameters
Item

Session to write.

Values

Column values in row-description order.

Timeout

Maximum time allowed for the response.

Send_Data_Row

procedure Send_Data_Row
  (Item : in out Session; Value : String; Timeout : Duration)

Send one text result column in a one-column row.

Parameters
Item

Session to write.

Value

Text column contents.

Timeout

Maximum time allowed for the response.

Send_Empty_Query_Response

procedure Send_Empty_Query_Response
  (Item : in out Session; Timeout : Duration)

Report an empty simple-query string.

Parameters
Item

Session to write.

Timeout

Maximum time allowed for the response.

Send_Error

procedure Send_Error
  (Item      : in out Session;
   Message   : String;
   SQL_State : String := "XX000";
   Severity  : String := "ERROR";
   Timeout   : Duration)

Send an ErrorResponse with required severity, SQLSTATE, and message.

Parameters
Item

Session to write.

Message

Human-readable primary diagnostic text.

SQL_State

Five-character SQLSTATE code.

Severity

Localized or nonlocalized severity label.

Timeout

Maximum time allowed for the response.

Send_Negotiate_Protocol

procedure Send_Negotiate_Protocol
  (Item           : in out Session;
   Latest_Version : Protocol.UInt32;
   Timeout        : Duration)

Report the newest supported protocol version.

Parameters
Item

Starting session to write.

Latest_Version

Packed version word, major << 16 or minor.

Timeout

Maximum time allowed for the response.

Send_No_Data

procedure Send_No_Data
  (Item : in out Session; Timeout : Duration)

Report that Describe has no row description.

Parameters
Item

Session to write.

Timeout

Maximum time allowed for the response.

Send_Notice

procedure Send_Notice
  (Item      : in out Session;
   Message   : String;
   SQL_State : String := "00000";
   Severity  : String := "NOTICE";
   Timeout   : Duration)

Send an asynchronous NoticeResponse.

Parameters
Item

Session to write.

Message

Human-readable primary diagnostic text.

SQL_State

Five-character SQLSTATE code.

Severity

Notice severity label.

Timeout

Maximum time allowed for the response.

Send_Null_Data_Row

procedure Send_Null_Data_Row
  (Item : in out Session; Timeout : Duration)

Send a one-column row whose value is SQL NULL.

Parameters
Item

Session to write.

Timeout

Maximum time allowed for the response.

Send_Parameter_Status

procedure Send_Parameter_Status
  (Item    : in out Session;
   Name    : String;
   Value   : String;
   Timeout : Duration)

Send one run-time parameter name/value pair.

Parameters
Item

Authenticated session to write.

Name

PostgreSQL parameter name.

Value

Current textual parameter value.

Timeout

Maximum time allowed for the response.

Send_Parse_Complete

procedure Send_Parse_Complete
  (Item : in out Session; Timeout : Duration)

Acknowledge successful Parse processing.

Parameters
Item

Session to write.

Timeout

Maximum time allowed for the response.

Send_Ready

procedure Send_Ready
  (Item               : in out Session;
   Transaction_Status : Character := 'I';
   Timeout            : Duration)

Send ReadyForQuery and its transaction-status byte.

Parameters
Item

Session completing startup or a query cycle.

Transaction_Status

I, T, or E per PostgreSQL semantics.

Timeout

Maximum time allowed for the response.

Send_Row_Description

procedure Send_Row_Description
  (Item    : in out Session;
   Columns : Protocol.Field_Description_Array;
   Timeout : Duration)

Send metadata for all result columns.

Parameters
Item

Session to write.

Columns

Field metadata in result order.

Timeout

Maximum time allowed for the response.

Send_Row_Description

procedure Send_Row_Description
  (Item      : in out Session;
   Name      : String;
   Type_Oid  : Protocol.UInt32 := 25;
   Type_Size : Protocol.UInt16 := 16#FFFF#;
   Timeout   : Duration)

Send metadata for one text-format result column.

Parameters
Item

Session to write.

Name

Result-column label.

Type_Oid

PostgreSQL data type OID; defaults to text.

Type_Size

Type width, or 16#FFFF# for variable width.

Timeout

Maximum time allowed for the response.

Session

type Session
  (Channel : not null access Transports.Transport'Class) is limited private;

Server view of a caller-owned transport and its cancellation state.

Record fields
Channel

Open transport whose lifetime exceeds the session.