Re: Pgoutput not capturing the generated columns

vignesh C <vignesh21@gmail.com>

From: vignesh C <vignesh21@gmail.com>
To: Peter Smith <smithpb2250@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Michael Paquier <michael@paquier.xyz>, "Shinoda, Noriyoshi (SXD Japan FSIP)" <noriyoshi.shinoda@hpe.com>, Shubham Khanna <khannashubham1197@gmail.com>, Masahiko Sawada <sawada.mshk@gmail.com>, Rajendra Kumar Dangwal <dangwalrajendra888@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "euler@eulerto.com" <euler@eulerto.com>
Date: 2025-01-19T12:16:49Z
Lists: pgsql-hackers

Attachments

On Fri, 17 Jan 2025 at 11:23, Peter Smith <smithpb2250@gmail.com> wrote:
>
> Hi Vignesh.
>
> Some review comments for patch v52-0003
>
> ======
>
> 1. GENERAL - change to use enum.
>
> On Thu, Jan 16, 2025 at 7:47 PM vignesh C <vignesh21@gmail.com> wrote:
> >
> > On Wed, 15 Jan 2025 at 11:17, Peter Smith <smithpb2250@gmail.com> wrote:
> > > 2.
> > > As suggested in more detail below, I think it would be better if you
> > > can define a C code enum type for these potential values instead of
> > > just using #define macros and char. I guess that will impact a lot of
> > > the APIs.
> >
> > If we change it to enum, we will not be able to access
> > PUBLISH_GENCOLS_NONE and PUBLISH_GENCOLS_STORED from describe.c files.
> > Maybe that is the reason the macros were used in the case of
> > pg_subscription.h also.
>
> Hm. I am not sure. Can't you just define the enum inside the #ifdef
> EXPOSE_TO_CLIENT_CODE? I saw some examples of this already (see
> src/include/catalog/pg_cast.h)
>
> e.g. I tried following, which compiles for me:
>
> #ifdef EXPOSE_TO_CLIENT_CODE
>
> typedef enum PublishGencolsType
> {
>   /* Generated columns present should not be replicated. */
>   PUBLISH_GENCOLS_NONE = 'n',
>
>   /* Generated columns present should be replicated. */
>   PUBLISH_GENCOLS_STORED = 's',
>
> } PublishGencolsType;
>
> #endif  /* EXPOSE_TO_CLIENT_CODE */
>
> typedef struct Publication
> {
>   Oid    oid;
>   char   *name;
>   bool   alltables;
>   bool   pubviaroot;
>   PublishGencolsType pubgencols_type;
>   PublicationActions pubactions;
> } Publication;

Yes, the compilation seems fine but listPublications which uses
CppAsString2(PUBLISH_GENCOLS_NONE) does not get 'n' but gets it as
publish_gencols_none like below:
postgres=# \dRp
ERROR:  column "publish_gencols_none" does not exist
LINE 9:     WHEN PUBLISH_GENCOLS_NONE THEN 'non

The rest of the comments are handled and also the comments from [1]
are fixed in the v53 version patch attached.

[1] - https://www.postgresql.org/message-id/CAHut%2BPuykmXF57T9AcBnsVqQEddmpBeHZvnGdJt%3DbyYozXAcSg%40mail.gmail.com

Regards,
Vignesh

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Doc: Generated column replication.

  2. Rename pubgencols_type to pubgencols in pg_publication.

  3. Doc: Fix column name in pg_publication catalog.

  4. Fix buildfarm failure introduced by commit e65dbc9927.

  5. Change publication's publish_generated_columns option type to enum.

  6. Fix \dRp+ output when describing publications with a lower server version.

  7. Replicate generated columns when 'publish_generated_columns' is set.

  8. Doc: Update the behavior of generated columns in Logical Replication.

  9. Replicate generated columns when specified in the column list.

  10. Doc: Generated columns are skipped for logical replication.