← All compilation units

Flyology.Postgres.Replication.Logical

Description

PostgreSQL pgoutput logical-replication messages for protocol versions 1 through 4, including streaming and two-phase transaction extensions.

Abort_LSN

function Abort_LSN (Item : Message) return LSN

Return the version-4 stream abort record's LSN.

Parameters
Item

Version-4 Stream_Abort_Message.

Return value

Abort record LSN.

Raised exceptions
Protocol

.Protocol_Error Item lacks version-4 abort metadata.

Binary_Column

function Binary_Column (Value : Byte_Array) return Tuple_Value

Construct a logical binary tuple value.

Parameters
Value

Exact binary representation bytes.

Return value

Owned binary tuple value.

Byte

subtype Byte is Ada.Streams.Stream_Element;

One pgoutput wire octet.

Byte_Array

subtype Byte_Array is Ada.Streams.Stream_Element_Array;

Contiguous pgoutput wire octets.

Cascade

function Cascade (Item : Message) return Boolean

Test whether a Truncate message used CASCADE.

Parameters
Item

Truncate_Message.

Return value

True when TRUNCATE CASCADE was used.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Column

function Column
  (Item : Tuple_Data; Index : Positive) return Tuple_Value

Return one logical tuple value by position.

Parameters
Item

Tuple to inspect.

Index

One-based column index.

Return value

Selected column value.

Raised exceptions
Constraint_Error

Index exceeds Column_Count.

Column_Count

function Column_Count (Item : Tuple_Data) return Natural

Return the number of values in a logical tuple.

Parameters
Item

Tuple to inspect.

Return value

Number of column values.

Commit_LSN

function Commit_LSN (Item : Message) return LSN

Return a transaction commit record's LSN.

Parameters
Item

Commit, Stream Commit, or Commit Prepared message.

Return value

Commit record LSN.

Raised exceptions
Protocol

.Protocol_Error Item has no commit LSN.

Configuration_Is_Valid

function Configuration_Is_Valid
  (Version : Protocol_Version; Streaming : Streaming_Mode) return Boolean

Check whether a protocol version supports a streaming mode.

Parameters
Version

Negotiated pgoutput protocol version.

Streaming

Requested streaming behavior.

Return value

True when the combination can be encoded and decoded.

Configure

procedure Configure
  (Item      : out Decoder;
   Version   : Protocol_Version;
   Streaming : Streaming_Mode := Disabled)

Initialize or reconfigure a decoder outside any stream segment.

Parameters
Item

Decoder to initialize.

Version

Negotiated protocol version.

Streaming

Negotiated streaming mode.

Raised exceptions
Protocol

.Protocol_Error Configuration is not valid.

Content

function Content (Item : Message) return Byte_Array

Copy a user logical message's application payload.

Parameters
Item

Logical_Decoding_Message.

Return value

Copy of application-defined payload bytes.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Decode

function Decode
  (Data      : Byte_Array;
   Version   : Protocol_Version;
   Streamed  : Boolean := False;
   Streaming : Streaming_Mode := Disabled) return Message

Strictly decode one complete pgoutput message with an explicitly stated stream context.

Streamed is a precondition, not a hint: it must equal the message's true on-wire stream context -- True exactly when Data occurs between a decoded Stream Start ('S') and Stream Stop ('E'). It selects whether the data-bearing messages (Insert, Update, Delete, Relation, Type, Truncate, and Logical_Decoding_Message) carry a leading streamed transaction id. Supplying a value inconsistent with the bytes maps those four id bytes onto the following field and yields an undefined -- though always memory-safe and Protocol_Error-bounded -- decode; Decode cannot detect the mismatch, because the prefix is not self-describing.

Consumers that do not themselves track Stream Start/Stop boundaries MUST decode through the stateful Decoder below, which derives Streamed from its own In_Stream state and additionally rejects malformed stream sequencing. Reserve this stateless form for callers that already know the exact stream context of Data (for example, non-streamed version-1 output).

Parameters
Data

Exact bytes for one logical message.

Version

Negotiated protocol version.

Streamed

True exactly when Data lies inside a stream segment; it must match the on-wire context (see the warning above).

Streaming

Negotiated streaming mode.

Return value

Validated owned logical message.

Raised exceptions
Protocol

.Protocol_Error Data or configuration is invalid.

Decode

function Decode
  (Item : in out Decoder; Data : Byte_Array) return Message

Decode one message and update Stream Start/Stop state atomically.

Parameters
Item

Configured stateful decoder.

Data

Exact bytes for one logical message.

Return value

Validated message annotated with stream state.

Raised exceptions
Protocol

.Protocol_Error Data violates message or stream sequencing rules; Item retains its previous stream state.

Decoder

type Decoder is private;

Stateful decoder that tracks Stream Start/Stop boundaries.

Empty_Tuple

Empty_Tuple : constant Tuple_Data;

Tuple with zero columns, used when no old tuple is present.

Encode

function Encode
  (Item      : Message;
   Version   : Protocol_Version;
   Streaming : Streaming_Mode := Disabled) return Byte_Array

Encode Item according to the negotiated pgoutput configuration.

Parameters
Item

Logical message to serialize.

Version

Negotiated protocol version.

Streaming

Negotiated streaming mode.

Return value

Exact pgoutput payload bytes.

Raised exceptions
Protocol

.Protocol_Error Item is unavailable or inconsistent with the selected configuration.

End_LSN

function End_LSN (Item : Message) return LSN

Return the LSN immediately after a transaction record.

Parameters
Item

Commit, prepare, or prepared-completion message.

Return value

LSN immediately after the transaction record.

Raised exceptions
Protocol

.Protocol_Error Item has no end LSN.

Event_Timestamp

function Event_Timestamp
  (Item : Message) return Replication_Timestamp

Return the primary timestamp carried by transaction-control Item.

Parameters
Item

Begin, commit, prepare, or abort message.

Return value

Commit, prepare, or abort timestamp as applicable.

Raised exceptions
Protocol

.Protocol_Error Item has no event timestamp.

Final_LSN

function Final_LSN (Item : Message) return LSN

Return the final LSN announced by Begin.

Parameters
Item

Begin_Message.

Return value

Transaction final LSN.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

GID

function GID (Item : Message) return String

Return a two-phase transaction's global identifier.

Parameters
Item

Two-phase transaction message.

Return value

Global transaction identifier.

Raised exceptions
Protocol

.Protocol_Error Item has no GID.

Identity

function Identity (Item : Message) return Replica_Identity

Return a relation's replica-identity policy.

Parameters
Item

Relation_Message.

Return value

Replica-identity policy.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Inside_Stream

function Inside_Stream (Item : Decoder) return Boolean

Test whether a stateful decoder is inside a stream segment.

Parameters
Item

Stateful decoder.

Return value

True between successfully decoded Stream Start and Stream Stop.

Int32

subtype Int32 is Interfaces.Integer_32;

Signed 32-bit pgoutput integer.

Is_First_Stream_Segment

function Is_First_Stream_Segment (Item : Message) return Boolean

Test whether Stream Start begins a transaction's first segment.

Parameters
Item

Stream_Start_Message.

Return value

True for a transaction's first streamed segment.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Is_Key

function Is_Key (Item : Relation_Column) return Boolean

Test whether a relation column belongs to replica identity.

Parameters
Item

Relation column metadata.

Return value

True when it participates in replica identity.

Is_Streamed

function Is_Streamed (Item : Message) return Boolean

Test whether a message belongs to a streamed transaction.

Parameters
Item

Logical message.

Return value

True when Item belongs to a streamed transaction segment.

Is_Transactional

function Is_Transactional (Item : Message) return Boolean

Test whether a logical decoding message is transactional.

Parameters
Item

Logical_Decoding_Message.

Return value

True when delivery is tied to transaction commit.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Kind

function Kind (Item : Message) return Message_Kind

Return a logical message's variant.

Parameters
Item

Logical message.

Return value

Its message variant.

Kind

function Kind (Item : Tuple_Value) return Tuple_Value_Kind

Return a logical tuple value's variant.

Parameters
Item

Tuple value to inspect.

Return value

Its null/TOAST/text/binary variant.

Level

function Level (Item : Message) return Message_Level

Return a logical message's consumer processing level.

Parameters
Item

Logical message.

Return value

Consumer processing level for Item.

LSN

subtype LSN is Replication.LSN;

PostgreSQL log sequence number.

Make_Begin

function Make_Begin
  (Final_LSN : LSN;
   Commit_At : Replication_Timestamp;
   Xid       : Transaction_Id) return Message

Construct a non-streamed transaction Begin message.

Parameters
Final_LSN

Transaction's final LSN.

Commit_At

Commit timestamp announced at begin.

Xid

Transaction identifier.

Return value

Begin message.

Make_Begin_Prepare

function Make_Begin_Prepare
  (Prepare_LSN : LSN;
   End_LSN     : LSN;
   Prepare_At  : Replication_Timestamp;
   Xid         : Transaction_Id;
   GID         : String) return Message

Construct the begin marker for a prepared transaction.

Parameters
Prepare_LSN

LSN of the prepare record.

End_LSN

LSN immediately after the prepare record.

Prepare_At

Prepare timestamp.

Xid

Transaction identifier.

GID

Global transaction identifier.

Return value

Begin Prepare message.

Make_Commit

function Make_Commit
  (Commit_LSN : LSN;
   End_LSN    : LSN;
   Commit_At  : Replication_Timestamp) return Message

Construct a non-streamed transaction Commit message.

Parameters
Commit_LSN

LSN of the commit record.

End_LSN

LSN immediately after the commit record.

Commit_At

Commit timestamp.

Return value

Commit message.

Make_Commit_Prepared

function Make_Commit_Prepared
  (Commit_LSN : LSN;
   End_LSN    : LSN;
   Commit_At  : Replication_Timestamp;
   Xid        : Transaction_Id;
   GID        : String) return Message

Construct a prepared transaction commit.

Parameters
Commit_LSN

LSN of the commit-prepared record.

End_LSN

LSN immediately after the record.

Commit_At

Commit timestamp.

Xid

Transaction identifier.

GID

Global transaction identifier.

Return value

Commit Prepared message.

Make_Delete

function Make_Delete
  (Relation_Id : UInt32;
   Old_Kind    : Old_Tuple_Kind;
   Old_Tuple   : Tuple_Data;
   Xid         : Transaction_Id := 0) return Message

Construct a deleted row change.

Parameters
Relation_Id

Target relation OID.

Old_Kind

Key-only or full old tuple marker.

Old_Tuple

Deleted row identity or full tuple.

Xid

Transaction identifier required for streamed encoding.

Return value

Delete message.

Raised exceptions
Protocol

.Protocol_Error Old_Kind is No_Old_Tuple.

Make_Insert

function Make_Insert
  (Relation_Id : UInt32;
   New_Tuple   : Tuple_Data;
   Xid         : Transaction_Id := 0) return Message

Construct an inserted row change.

Parameters
Relation_Id

Target relation OID.

New_Tuple

Complete inserted tuple.

Xid

Transaction identifier required for streamed encoding.

Return value

Insert message.

Make_Logical_Decoding_Message

function Make_Logical_Decoding_Message
  (Message_LSN   : LSN;
   Prefix        : String;
   Content       : Byte_Array;
   Transactional : Boolean := False;
   Xid           : Transaction_Id := 0) return Message

Construct a user logical-decoding message.

Parameters
Message_LSN

LSN associated with the message.

Prefix

Application-defined message prefix.

Content

Arbitrary application payload bytes.

Transactional

Whether delivery is tied to transaction commit.

Xid

Transaction identifier required for streamed encoding.

Return value

Logical decoding message.

Make_Origin

function Make_Origin
  (Commit_LSN : LSN; Name : String) return Message

Construct replication-origin metadata.

Parameters
Commit_LSN

Commit LSN on the origin server.

Name

Replication origin name.

Return value

Origin message.

Make_Prepare

function Make_Prepare
  (Prepare_LSN : LSN;
   End_LSN     : LSN;
   Prepare_At  : Replication_Timestamp;
   Xid         : Transaction_Id;
   GID         : String) return Message

Construct completion of transaction preparation.

Parameters
Prepare_LSN

LSN of the prepare record.

End_LSN

LSN immediately after the prepare record.

Prepare_At

Prepare timestamp.

Xid

Transaction identifier.

GID

Global transaction identifier.

Return value

Prepare message.

Make_Relation

function Make_Relation
  (Relation_Id : UInt32;
   Namespace   : String;
   Name        : String;
   Identity    : Replica_Identity;
   Columns     : Relation_Column_Array;
   Xid         : Transaction_Id := 0) return Message

Construct relation metadata.

Parameters
Relation_Id

Relation OID referenced by subsequent row changes.

Namespace

Schema name.

Name

Relation name.

Identity

Replica-identity policy.

Columns

Columns in tuple order.

Xid

Transaction identifier required for streamed encoding.

Return value

Relation message.

Make_Relation_Column

function Make_Relation_Column
  (Name          : String;
   Type_Oid      : UInt32;
   Type_Modifier : Int32 := -1;
   Is_Key        : Boolean := False) return Relation_Column

Construct one relation column description.

Parameters
Name

PostgreSQL attribute name.

Type_Oid

PostgreSQL data type OID.

Type_Modifier

Type-specific modifier, or -1.

Is_Key

Whether the column belongs to replica identity.

Return value

Owned relation column metadata.

Make_Rollback_Prepared

function Make_Rollback_Prepared
  (Prepare_End_LSN  : LSN;
   Rollback_End_LSN : LSN;
   Prepare_At       : Replication_Timestamp;
   Rollback_At      : Replication_Timestamp;
   Xid              : Transaction_Id;
   GID              : String) return Message

Construct a prepared transaction rollback.

Parameters
Prepare_End_LSN

End LSN recorded when transaction was prepared.

Rollback_End_LSN

LSN immediately after rollback.

Prepare_At

Original prepare timestamp.

Rollback_At

Rollback timestamp.

Xid

Transaction identifier.

GID

Global transaction identifier.

Return value

Rollback Prepared message.

Make_Stream_Abort

function Make_Stream_Abort
  (Xid        : Transaction_Id;
   Subxid     : Transaction_Id;
   Abort_LSN  : LSN := 0;
   Aborted_At : Replication_Timestamp := 0) return Message

Construct a streamed transaction or subtransaction abort.

Parameters
Xid

Top-level streamed transaction identifier.

Subxid

Aborted transaction or subtransaction identifier.

Abort_LSN

Version-4 abort record LSN, otherwise zero.

Aborted_At

Version-4 abort timestamp, otherwise zero.

Return value

Stream Abort message.

Make_Stream_Commit

function Make_Stream_Commit
  (Xid        : Transaction_Id;
   Commit_LSN : LSN;
   End_LSN    : LSN;
   Commit_At  : Replication_Timestamp) return Message

Construct a streamed transaction commit.

Parameters
Xid

Streamed transaction identifier.

Commit_LSN

LSN of the commit record.

End_LSN

LSN immediately after the commit record.

Commit_At

Commit timestamp.

Return value

Stream Commit message.

Make_Stream_Prepare

function Make_Stream_Prepare
  (Prepare_LSN : LSN;
   End_LSN     : LSN;
   Prepare_At  : Replication_Timestamp;
   Xid         : Transaction_Id;
   GID         : String) return Message

Construct preparation of a streamed transaction.

Parameters
Prepare_LSN

LSN of the prepare record.

End_LSN

LSN immediately after the prepare record.

Prepare_At

Prepare timestamp.

Xid

Streamed transaction identifier.

GID

Global transaction identifier.

Return value

Stream Prepare message.

Make_Stream_Start

function Make_Stream_Start
  (Xid : Transaction_Id; First_Segment : Boolean) return Message

Construct a Stream Start transaction boundary.

Parameters
Xid

Streamed transaction identifier.

First_Segment

True for the transaction's first segment.

Return value

Stream Start message.

Make_Stream_Stop

function Make_Stream_Stop return Message

Construct a Stream Stop segment boundary.

Return value

Stream Stop marker for the current segment.

Make_Truncate

function Make_Truncate
  (Relations        : Relation_Id_Array;
   Cascade          : Boolean := False;
   Restart_Identity : Boolean := False;
   Xid              : Transaction_Id := 0) return Message

Construct a truncate row change.

Parameters
Relations

Relation OIDs truncated together.

Cascade

Whether TRUNCATE CASCADE was specified.

Restart_Identity

Whether sequences were restarted.

Xid

Transaction identifier required for streamed encoding.

Return value

Truncate message.

Make_Tuple

function Make_Tuple (Columns : Tuple_Value_Array) return Tuple_Data

Construct an owned logical tuple.

Parameters
Columns

Values in relation column order.

Return value

Tuple owning copies of Columns.

Make_Type

function Make_Type
  (Type_Oid  : UInt32;
   Namespace : String;
   Name      : String;
   Xid       : Transaction_Id := 0) return Message

Construct data type metadata.

Parameters
Type_Oid

PostgreSQL type OID.

Namespace

Schema name.

Name

Type name.

Xid

Transaction identifier required for streamed encoding.

Return value

Type message.

Make_Update

function Make_Update
  (Relation_Id : UInt32;
   New_Tuple   : Tuple_Data;
   Old_Kind    : Old_Tuple_Kind := No_Old_Tuple;
   Old_Tuple   : Tuple_Data := Empty_Tuple;
   Xid         : Transaction_Id := 0) return Message

Construct an updated row change.

Parameters
Relation_Id

Target relation OID.

New_Tuple

Complete post-update tuple.

Old_Kind

Whether Old_Tuple is absent, key-only, or full.

Old_Tuple

Optional pre-update identity or full tuple.

Xid

Transaction identifier required for streamed encoding.

Return value

Update message.

Message

type Message is private;

Owned pgoutput message with validated variant-specific fields.

Message_Kind

type Message_Kind is
  (Begin_Message,
   Commit_Message,
   Origin_Message,
   Logical_Decoding_Message,
   Relation_Message,
   Type_Message,
   Insert_Message,
   Update_Message,
   …,
   Stream_Prepare_Message);

Supported pgoutput message classification.

Enumeration literals
Begin_Message

Begin a non-streamed transaction.

Commit_Message

Commit a non-streamed transaction.

Origin_Message

Replication-origin metadata.

Logical_Decoding_Message

User logical decoding message.

Relation_Message

Relation metadata.

Type_Message

Data type metadata.

Insert_Message

Inserted tuple.

Update_Message

Updated tuple with optional old tuple.

Delete_Message

Deleted tuple identity.

Truncate_Message

One or more truncated relations.

Stream_Start_Message

Begin or continue a streamed transaction.

Stream_Stop_Message

End the current stream segment.

Stream_Commit_Message

Commit a streamed transaction.

Stream_Abort_Message

Abort a streamed transaction/subtransaction.

Begin_Prepare_Message

Begin decoding a prepared transaction.

Prepare_Message

Complete transaction preparation.

Commit_Prepared_Message

Commit a prepared transaction.

Rollback_Prepared_Message

Roll back a prepared transaction.

Stream_Prepare_Message

Prepare a streamed transaction.

Message_Level

type Message_Level is
  (Transaction_Control, Transaction_Metadata, Row_Change);

Consumer-facing processing level of a pgoutput message.

Enumeration literals
Transaction_Control

Defines transaction lifecycle boundaries.

Transaction_Metadata

Adds metadata within a transaction.

Row_Change

Describes relation contents or row changes.

Message_LSN

function Message_LSN (Item : Message) return LSN

Return a user logical message's associated LSN.

Parameters
Item

Logical_Decoding_Message.

Return value

LSN associated with the user message.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Minimum_Server_Major

function Minimum_Server_Major (Version : Protocol_Version) return Positive

Return the first PostgreSQL release supporting a protocol version.

Parameters
Version

pgoutput protocol version.

Return value

First PostgreSQL major supporting Version.

Name

function Name (Item : Relation_Column) return String

Return a logical relation column's name.

Parameters
Item

Relation column metadata.

Return value

Attribute name.

Namespace_Name

function Namespace_Name (Item : Message) return String

Return the schema name carried by Relation or Type.

Parameters
Item

Relation_Message or Type_Message.

Return value

Schema name.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

New_Tuple

function New_Tuple (Item : Message) return Tuple_Data

Return the new tuple carried by Insert or Update.

Parameters
Item

Insert_Message or Update_Message.

Return value

Inserted or post-update tuple.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

No_Relation_Ids

No_Relation_Ids : constant Relation_Id_Array (1 .. 0) :=
  (others => 0);

Empty relation OID list.

Null_Column

function Null_Column return Tuple_Value

Construct a logical tuple SQL NULL marker.

Return value

Tuple value representing SQL NULL.

Object_Name

function Object_Name (Item : Message) return String

Return the relation or type name carried by metadata.

Parameters
Item

Relation_Message or Type_Message.

Return value

Relation or type name.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Old_Kind

function Old_Kind (Item : Message) return Old_Tuple_Kind

Return the old-tuple marker carried by Update or Delete.

Parameters
Item

Update_Message or Delete_Message.

Return value

Presence and scope of old tuple data.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Old_Tuple

function Old_Tuple (Item : Message) return Tuple_Data

Return the old tuple carried by Update or Delete.

Parameters
Item

Update or Delete with Old_Kind other than No_Old_Tuple.

Return value

Pre-change identity or full tuple.

Raised exceptions
Protocol

.Protocol_Error No old tuple is present.

Old_Tuple_Kind

type Old_Tuple_Kind is
  (No_Old_Tuple, Key_Old_Tuple, Full_Old_Tuple);

Presence and scope of old tuple data on update/delete.

Enumeration literals
No_Old_Tuple

No old tuple is included.

Key_Old_Tuple

Only replica-identity columns are included.

Full_Old_Tuple

Full old row is included.

Origin_Commit_LSN

function Origin_Commit_LSN (Item : Message) return LSN

Return the commit LSN recorded by a replication origin.

Parameters
Item

Origin_Message.

Return value

Commit LSN on the origin server.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Origin_Name

function Origin_Name (Item : Message) return String

Return replication-origin metadata's name.

Parameters
Item

Origin_Message.

Return value

Replication origin name.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Prefix

function Prefix (Item : Message) return String

Return a user logical message's application prefix.

Parameters
Item

Logical_Decoding_Message.

Return value

Application-defined prefix.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Prepare_End_LSN

function Prepare_End_LSN (Item : Message) return LSN

Return the original prepare end LSN from Rollback Prepared.

Parameters
Item

Rollback_Prepared_Message.

Return value

End LSN captured at original prepare time.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Prepare_LSN

function Prepare_LSN (Item : Message) return LSN

Return a prepared transaction's prepare-record LSN.

Parameters
Item

Begin Prepare, Prepare, or Stream Prepare message.

Return value

Prepare record LSN.

Raised exceptions
Protocol

.Protocol_Error Item has no prepare LSN.

Protocol_Version

type Protocol_Version is range 1 .. 4;

Supported pgoutput protocol version.

Relation_Column

type Relation_Column is private;

Relation-message metadata for one logical column.

Relation_Column_Array

type Relation_Column_Array is
  array (Positive range <>) of Relation_Column;

Logical relation columns in tuple order.

Relation_Column_At

function Relation_Column_At
  (Item : Message; Index : Positive) return Relation_Column

Return one Relation metadata column by position.

Parameters
Item

Relation_Message.

Index

One-based relation column index.

Return value

Selected column metadata.

Raised exceptions
Constraint_Error

Index exceeds Relation_Column_Count.

Relation_Column_Count

function Relation_Column_Count (Item : Message) return Natural

Return the number of columns carried by Relation.

Parameters
Item

Relation_Message.

Return value

Number of relation columns.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Relation_Id

function Relation_Id (Item : Message) return UInt32

Return the relation OID named by relation or row-change data.

Parameters
Item

Relation or row-change message.

Return value

Referenced relation OID.

Raised exceptions
Protocol

.Protocol_Error Item has no single relation OID.

Relation_Id_Array

type Relation_Id_Array is array (Positive range <>) of UInt32;

Ordered relation OIDs in a Truncate message.

Replica_Identity

type Replica_Identity is
  (Default_Identity,
   Nothing_Identity,
   Full_Identity,
   Index_Identity);

Relation replica identity sent by pgoutput.

Enumeration literals
Default_Identity

Primary key identifies old rows.

Nothing_Identity

No old-row identity is logged.

Full_Identity

Entire old row is logged.

Index_Identity

Configured replica-identity index is logged.

Replication_Timestamp

subtype Replication_Timestamp is Replication.Replication_Timestamp;

Microseconds since PostgreSQL's 2000-01-01 epoch.

Reset

procedure Reset (Item : in out Decoder)

Leave any active stream while preserving configured version and mode.

Parameters
Item

Decoder whose stream state is cleared.

Restart_Identity

function Restart_Identity (Item : Message) return Boolean

Test whether a Truncate message restarted sequences.

Parameters
Item

Truncate_Message.

Return value

True when sequences were restarted.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Rollback_Timestamp

function Rollback_Timestamp
  (Item : Message) return Replication_Timestamp

Return the rollback time carried by Rollback Prepared.

Parameters
Item

Rollback_Prepared_Message.

Return value

Rollback timestamp.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Streaming_Mode

type Streaming_Mode is (Disabled, In_Progress, Parallel);

Negotiated streaming option.

Enumeration literals
Disabled

Decode only complete, non-streamed transactions.

In_Progress

Decode interleaved in-progress transactions.

Parallel

Decode version-4 parallel-streaming messages.

Subtransaction

function Subtransaction (Item : Message) return Transaction_Id

Return the subtransaction named by Stream Abort.

Parameters
Item

Stream_Abort_Message.

Return value

Aborted transaction or subtransaction ID.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Text

function Text (Item : Tuple_Value) return String

Interpret a text value's bytes as character codes without transcoding.

Parameters
Item

Text_Value to inspect.

Return value

String with identical byte values.

Raised exceptions
Protocol

.Protocol_Error Item is not Text_Value.

Text_Column

function Text_Column (Value : String) return Tuple_Value

Construct a logical text tuple value.

Parameters
Value

Exact text representation bytes.

Return value

Owned text tuple value.

Transaction

function Transaction (Item : Message) return Transaction_Id

Return a message's top-level transaction identifier.

Parameters
Item

Message carrying a transaction identifier.

Return value

Top-level transaction ID, or zero when not encoded.

Transaction_Id

subtype Transaction_Id is Replication.Transaction_Id;

PostgreSQL 32-bit transaction identifier.

Truncated_Relation

function Truncated_Relation
  (Item : Message; Index : Positive) return UInt32

Return one truncated relation OID by position.

Parameters
Item

Truncate_Message.

Index

One-based relation index.

Return value

Selected truncated relation OID.

Raised exceptions
Constraint_Error

Index exceeds Truncated_Relation_Count.

Truncated_Relation_Count

function Truncated_Relation_Count (Item : Message) return Natural

Return the number of relation OIDs carried by Truncate.

Parameters
Item

Truncate_Message.

Return value

Number of truncated relation OIDs.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Tuple_Data

type Tuple_Data is private;

Owned ordered logical tuple.

Tuple_Value

type Tuple_Value is private;

One owned TupleData column value.

Tuple_Value_Array

type Tuple_Value_Array is array (Positive range <>) of Tuple_Value;

Tuple columns in relation order.

Tuple_Value_Kind

type Tuple_Value_Kind is
  (Null_Value, Unchanged_Toast_Value, Text_Value, Binary_Value);

TupleData column marker and representation.

Enumeration literals
Null_Value

SQL NULL.

Unchanged_Toast_Value

External value unchanged and not included.

Text_Value

Text-format bytes.

Binary_Value

Binary-format bytes.

Type_Id

function Type_Id (Item : Message) return UInt32

Return the data type OID named by Type.

Parameters
Item

Type_Message.

Return value

PostgreSQL data type OID.

Raised exceptions
Protocol

.Protocol_Error Item is another variant.

Type_Modifier

function Type_Modifier (Item : Relation_Column) return Int32

Return a logical relation column's type modifier.

Parameters
Item

Relation column metadata.

Return value

Type-specific modifier, or -1.

Type_Oid

function Type_Oid (Item : Relation_Column) return UInt32

Return a logical relation column's PostgreSQL type OID.

Parameters
Item

Relation column metadata.

Return value

PostgreSQL data type OID.

UInt32

subtype UInt32 is Interfaces.Unsigned_32;

Unsigned 32-bit pgoutput integer.

Unchanged_Toast_Column

function Unchanged_Toast_Column return Tuple_Value

Construct an unchanged external TOAST marker.

Return value

Tuple marker for an unchanged external TOAST value.

Value

function Value (Item : Tuple_Value) return Byte_Array

Copy the bytes carried by a text or binary tuple value.

Parameters
Item

Text_Value or Binary_Value.

Return value

Copy of its exact bytes.

Raised exceptions
Protocol

.Protocol_Error Item carries no bytes.

Version

function Version (Item : Message) return Protocol_Version

Return the pgoutput version attached to a message.

Parameters
Item

Decoded or constructed logical message.

Return value

Protocol version used during decode, or version 1 for a message created by a Make_* constructor.