Re: doc: Make logical replication examples executable in bulk and legal sgml. - Mailing list pgsql-hackers

From Peter Smith
Subject Re: doc: Make logical replication examples executable in bulk and legal sgml.
Date
Msg-id CAHut+PuT1rUNEgCONXvGm4hmC4YDGc8taf=eijD9T=ebPx0dDA@mail.gmail.com
Whole thread Raw
In response to doc: Make logical replication examples executable in bulk and legal sgml.  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: doc: Make logical replication examples executable in bulk and legal sgml.
List pgsql-hackers
On Sun, May 4, 2025 at 2:03 AM David G. Johnston
<david.g.johnston@gmail.com> wrote:
>
> While responding to a "our documentation is buggy" complaint I got annoyed in my attempt to reproduce the behavior by
havingto surgically copy line-by-line the DDL and DML code involved.  Let's strive for a more copy-paste friendly
examplesetup.  No prompts and no interspersed command tags (they are ok if the script is one block and the output is
another).
>

Hi David,

I think I was the author of most of these examples, so I feel obliged
to post my 2c.

For the logical replication examples it is really important to be
aware if the psql is executing at the publisher or subscriber side;
that is the main reason why I had kept prompts in the examples (e.g.
it avoided having to say "On the publisher:" or "On the subscriber:"
for every example).

OTOH, I understand your issue that those prompts made it difficult to
simply cut/paste slabs of psql directly from the examples -- I've
heard this complaint a few times before from other people.

So, your patch which still keeps my prompts albeit as "comments", but
that now allows the execution of the bulk copy/paste, seems like a
reasonable compromise to me.

~~

BTW, I can understand the commented prompt for the bulk fragments like:
/* sub # */ CREATE SUBSCRIPTION sub1
/* sub - */ CONNECTION 'host=localhost dbname=test_pub application_name=sub1'
/* sub - */ PUBLICATION pub1;
/* sub # */ CREATE SUBSCRIPTION sub2
/* sub - */ CONNECTION 'host=localhost dbname=test_pub application_name=sub2'
/* sub - */ PUBLICATION pub2;
/* sub # */ CREATE SUBSCRIPTION sub3
/* sub - */ CONNECTION 'host=localhost dbname=test_pub application_name=sub3'
/* sub - */ PUBLICATION pub3a, pub3b;

~

But, for the SELECT statements, commenting the prompt like:
/* sub # */ SELECT * FROM t1;
 a |   b
---+-------
 1 | one
 2 | two
 3 | three
(3 rows)

doesn't help bulk execution at all because the result gets in the way
so you'll still end up surgically copying each SELECT. Since it fixes
nothing I assumed you just commented the SELECT prompts for
consistency with the other ones, right?

======
Kind Regards,
Peter Smith.
Fujitsu Australia



pgsql-hackers by date:

Previous
From: Peter Smith
Date:
Subject: Re: Proposal: Filter irrelevant change before reassemble transactions during logical decoding
Next
From: "David G. Johnston"
Date:
Subject: Re: doc: Make logical replication examples executable in bulk and legal sgml.