On Tue, Oct 14, 2025 at 01:13:38PM +0200, Matěj Klonfar wrote:
> I can imagine this limitation is likely a holdover from the system's
> evolution from physical replication where comments make no sense. However,
> in logical replication walsender mode both SQL and replication statements
> can be issued [1], so the current state brings the necessity to distinguish
> when to inject the comment and when not to. What do you feel, are there any
> unexpected impacts of extending the replication grammar with comments?
>
> I attached a simple patch extending the `replication/repl_scanner.l` with
> following test:
>
> What do you feel, is that a good idea and/or are there any downsides I am
> missing? Thank you all for the feedback.
A downside here is the extra maintenance that this creates. I cannot
get much excited about the support of comments in the context of
replication commands, TBH. That's just one opinion, of course, others
may have a different view. Note that even if one uses
"replication=database", the code falls back to the main query parser,
where comments work.
FWIW, this is a bit like a past proposal with making the replication
commands case-insensitive, back in 2017:
https://www.postgresql.org/message-id/CAB7nPqSg2ZECE+ctGXieiCpVFibLyWgwAGaoEP3-zwYqJwaP-g@mail.gmail.com
The argument for rejection back then is that these commands are not
for manual consumption, so we should keep the replication grammar file
simpler. Perhaps there could be an argument with allowing commands
when it comes to the logging of replication commands in the server
logs, where comments can be used as a reference. That's a very narrow
case, so I'd still argue that this is not enough to balance in favor
of this proposal. Just my 2c.
--
Michael