Top
Enterprise Postgres 17 SP1 Userlog Operation Guide

Chapter 5 How to Insert a Userlog (pgx_emit_userlog Function)

The following functions can be used to insert a userlog into WAL:

pgx_emit_userlog (content text) Return types: pg_lsn

pgx_emit_userlog (content bytea) Return types: pg_lsn

Arguments

Specify the userlog you want to insert in content. Except for the userlog.limit_size_per_xact parameter, which limits the total size of the data in a transaction, there is no special limit on the length of the data you specify.

Note that if text data is supplied as an argument to pgx_emit_userlog(), it is limited by the length after conversion to the database character encoding.

Privilege

Like the pg_logical_emit_message function, which also inserts a log into WAL, this function can be run by any user once introduced. Use the GRANT/REVOKE statement to adjust the privileges to suit your policy.

Schema

The userlog extension can relocate the schema in which it is registered.

Examples

select pgx_emit_userlog('some userlog')

Return value

Returns the WAL log location where the specified userlog was inserted.

Error

In addition to errors returned by PostgreSQL's pg_logical_emit_message function, this error is returned:

  • If one of these functions is used within a subtransaction, it returns SQLSTATE: 0A000 and the transaction is ROLLBACK.

  • function causes the total size of userlog inserts in the transaction to exceed userlog.limit_size_per_xact, return SQLSTATE: 54000 and internally ABORT the transaction, preventing further SQL execution, and explicitly terminate the transaction with a ROLLBACK statement.