Re: Pgoutput not capturing the generated columns

vignesh C <vignesh21@gmail.com>

From: vignesh C <vignesh21@gmail.com>
To: Shlok Kyal <shlok.kyal.oss@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Peter Smith <smithpb2250@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-16T08:49:31Z
Lists: pgsql-hackers
On Wed, 15 Jan 2025 at 14:41, Shlok Kyal <shlok.kyal.oss@gmail.com> wrote:
>
> I have reviewed the patch and have following comments:
>
> In file: create_publication.sgml
>
> 1.
> +         <para>
> +          If set to <literal>stored</literal>, the generated columns present in
> +          the tables associated with publication will be replicated.
>           </para>
>
> Instead of 'generated columns' we should use 'stored generated columns'

Modified

> ======
> In file: pg_publication.c
>
> 2. I feel this condition can be more specific. Since a new macro will
> be introduced for upcoming Virtual Generated columns.
>
> - if (att->attisdropped || (att->attgenerated && !include_gencols))
> + if (att->attisdropped ||
> + (att->attgenerated && (gencols_type == PUBLISH_GENCOL_NONE)))
>   continue;
>
> Something like:
>     if (att->attisdropped)
>         continue;
>     if (att->attgenerated == ATTRIBUTE_GENERATED_STORED &&
> gencols_type != PUBLISH_GENCOL_STORED)
>         continue;
>
> Thoughs?

Modified

> 3. Similarly this can be updated here as well:
>
> - if (att->attisdropped || (att->attgenerated && !pub->pubgencols))
> + if (att->attisdropped ||
> + (att->attgenerated && pub->pubgencols_type == PUBLISH_GENCOL_NONE))
>   continue;

Modified

> =======
> In file proto.c
>
> 4. I feel this condition should also be more specific:
>
>   /* All non-generated columns are always published. */
> - return att->attgenerated ? include_gencols : true;
> + return att->attgenerated ? (gencols_type == PUBLISH_GENCOL_STORED) : true;
>
> We should return 'true' for 'gencols_type == PUBLISH_GENCOL_STORED'
> only if 'att->attgenerated = ATTRIBUTE_GENERATED_STORED'

Modified

> =======
> In file publicationcmds.c
>
> 5.
>   /*
>   * As we don't allow a column list with REPLICA IDENTITY FULL, the
> - * publish_generated_columns option must be set to true if the table
> - * has any stored generated columns.
> + * publish_generated_columns option must be set to 's'(stored) if the
> + * table has any stored generated columns.
>   */
> - if (!pubgencols &&
> + if (gencols_type == PUBLISH_GENCOL_NONE &&
>   relation->rd_att->constr &&
>
> To be consistent with the comment, I think we should check if
> 'gencols_type != PUBLISH_GENCOL_STORED' instead of 'gencols_type ==
> PUBLISH_GENCOL_NONE'.
> Thoughts?

Modified

The v52 version patch attached at [1] has the changes for the same.
[1] - https://www.postgresql.org/message-id/CALDaNm3OcXdY0EzDEKAfaK9gq2B67Mfsgxu93%2B_249ohyts%3D0g%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.