Thread: DOCS - create publication (tweak for generated columns)

DOCS - create publication (tweak for generated columns)

From
Peter Smith
Date:
Hi,

While re-reading documentation about logical replication of generated
columns, I came across this paragraph in the CREATE PUBLICATION ...
FOR TABLE description [1].

----
When a column list is specified, only the named columns are
replicated. The column list can contain stored generated columns as
well. If no column list is specified, all table columns (except
generated columns) are replicated through this publication, including
any columns added later. It has no effect on TRUNCATE commands. See
Section 29.5 for details about column lists.
----

That "except generated columns" part is not strictly correct because
it fails to account for the 'publish_generated_columns' parameter.
I've suggested a more accurate description below.


SUGGESTION
----
When a column list is specified, only the named columns are
replicated. Stored generated columns may be included in the list.
Specifying a column list has no effect on TRUNCATE commands. See
Section 29.5 for details about column lists. If no column list is
specified, all table columns are replicated through this publication,
including any columns added later. Generated columns are included in
this case only if publish_generated_columns is set to stored.
----

I've attached a patch to implement this suggested wording.

Thoughts?

======
[1] https://www.postgresql.org/docs/devel/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-TABLE

Kind Regards,
Peter Smith.
Fujitsu Australia

Attachment

Re: DOCS - create publication (tweak for generated columns)

From
"David G. Johnston"
Date:
On Tuesday, April 22, 2025, Peter Smith <smithpb2250@gmail.com> wrote:
Hi,

While re-reading documentation about logical replication of generated
columns, I came across this paragraph in the CREATE PUBLICATION ...
FOR TABLE description [1].

----
When a column list is specified, only the named columns are
replicated. The column list can contain stored generated columns as
well. If no column list is specified, all table columns (except
generated columns) are replicated through this publication, including
any columns added later. It has no effect on TRUNCATE commands. See
Section 29.5 for details about column lists.
----

That "except generated columns" part is not strictly correct because
it fails to account for the 'publish_generated_columns' parameter.
I've suggested a more accurate description below.


SUGGESTION
----
When a column list is specified, only the named columns are
replicated. Stored generated columns may be included in the list.
Specifying a column list has no effect on TRUNCATE commands. See
Section 29.5 for details about column lists. If no column list is
specified, all table columns are replicated through this publication,
including any columns added later. Generated columns are included in
this case only if publish_generated_columns is set to stored.
----

I've attached a patch to implement this suggested wording.

Thoughts?

======
[1] https://www.postgresql.org/docs/devel/sql-createpublication.html#SQL-CREATEPUBLICATION-PARAMS-FOR-TABLE

In the column list I would stick to mentioning what cannot be specified, since it would be assumed by default that any column on the table is fair game.  I believe that means not mentioning stored generated and instead mentioning virtual generated.  It really seems odds mentioning stored generated being allowed before mentioning when they are optional, default excluded.

Alternative:

The optional column list may include any non-virtual columns of the table.  If omitted, tables publish all (including future) non-generated columns by default, and may publish stored generated columns if the publication option publish_generated_columns is set to stored.  See Section 29.5 for details about column lists.


I don’t get why truncate is mentioned here.  I omitted it intentionally.

David J.