Skip to content

Support PostgreSQL LISTEN, NOTIFY, UNLISTEN, and pg_notify #3236

Description

@off-axis

Please add PostgreSQL-compatible asynchronous notification support through LISTEN, NOTIFY, UNLISTEN, and pg_notify(text, text).

Doltgres currently rejects all four operations, which leaves applications without a transaction-coupled way to wake another process after committed work becomes visible.

Repro

Reproduced with dolthub/doltgresql:1.3.0:

LISTEN test_dispatch;
ERROR:  at or near "listen": syntax error
NOTIFY test_dispatch, '1';
ERROR:  at or near "notify": syntax error
SELECT pg_notify('test_dispatch', '1');
ERROR:  function: 'pg_notify' not found
UNLISTEN test_dispatch;
ERROR:  at or near "unlisten": syntax error

Use case

The application we are working on stores durable work records in Doltgres. A transaction inserts or updates a pending row, then a separate dispatcher must process it.

The process can terminate after Doltgres commits the row but before the callback, Redis publication, HTTP request, or other wakeup executes.

Required behavior

The requested behavior is the standard PostgreSQL contract:

  • LISTEN channel registers the current session for that channel.
  • UNLISTEN channel and UNLISTEN * remove registrations.
  • NOTIFY channel and NOTIFY channel, payload send asynchronous notification messages to listening sessions.
  • pg_notify(channel, payload) provides the equivalent function form, including use from SQL functions and triggers.
  • A notification issued inside a transaction is delivered only after that transaction commits successfully.
  • A rolled-back transaction produces no notification.
  • The notification includes the channel and payload through the PostgreSQL wire protocol.
  • Listener registrations last until UNLISTEN or session termination.
  • Notifications are scoped to the Doltgres database, not to the currently checked-out Dolt branch.
  • A transaction emits its notifications only after the complete Doltgres commit succeeds.
  • If the Doltgres commit fails because of a conflict or another error, no notification is delivered.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions