作者
digoal
日期
2021-04-06
标签
PostgreSQL , decode , logical , 消息 , 定制消息
背景
pg_logical_emit_message 可以往WAL写的定制消息 ! 例如一些控制消息, 不需要写到table里再通过wal decode解析出来, 直接写到wal, 不依赖pgcatalog元数据结构, 非常好用.
```
pg_logical_emit_message ( transactional boolean, prefix text, content text ) → pg_lsn
pg_logical_emit_message ( transactional boolean, prefix text, content bytea ) → pg_lsn
```
Emits a logical decoding message. This can be used to pass generic messages to logical decoding plugins through WAL. The transactional parameter specifies if the message should be part of the current transaction, or if it should be written immediately and decoded as soon as the logical decoder reads the record. The prefix parameter is a textual prefix that can be used by logical decoding plugins to easily recognize messages that are interesting for them. The content parameter is the content of the message, given either in text or binary form.
PostgreSQL 14 pgoutput 内置plugin可以decode这个消息了.
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=ac4645c0157fc5fcef0af8ff571512aa284a2cec
```
Allow pgoutput to send logical decoding messages. master github/master
author Amit Kapila akapila@postgresql.org
Tue, 6 Apr 2021 03:10:47 +0000 (08:40 +0530)
committer Amit Kapila akapila@postgresql.org
Tue, 6 Apr 2021 03:10:47 +0000 (08:40 +0530)
commit ac4645c0157fc5fcef0af8ff571512aa284a2cec
tree a414a4b21e4a79ac04cd67b8ed4ac907d9856f76 tree
parent 531737ddad214cb8a675953208e2f3a6b1be122b commit | diff
Allow pgoutput to send logical decoding messages.
The output plugin accepts a new parameter (messages) that controls if
logical decoding messages are written into the replication stream. It is
useful for those clients that use pgoutput as an output plugin and needs
to process messages that were written by pg_logical_emit_message().
Although logical streaming replication protocol supports logical
decoding messages now, logical replication does not use this feature yet.
Author: David Pirotte, Euler Taveira
Reviewed-by: Euler Taveira, Andres Freund, Ashutosh Bapat, Amit Kapila
Discussion: https://postgr.es/m/CADK3HHJ-+9SO7KuRLH=9Wa1rAo60Yreq1GFNkH_kd0=CdaWM+A@mail.gmail.com
```
postgres=# \df pg_logical_emit_message
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+-------------------------+------------------+----------------------+------
pg_catalog | pg_logical_emit_message | pg_lsn | boolean, text, bytea | func
pg_catalog | pg_logical_emit_message | pg_lsn | boolean, text, text | func
(2 rows)
PostgreSQL 许愿链接
您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.
9.9元购买3个月阿里云RDS PostgreSQL实例
PostgreSQL 解决方案集合
德哥 / digoal's github - 公益是一辈子的事.





