PS_NITPICKS_20240618_commit_msg.txt.txt

text/plain

Filename: PS_NITPICKS_20240618_commit_msg.txt.txt
Type: text/plain
Part: 0
Message: Re: Pgoutput not capturing the generated columns
CURRENT (v7-0002)
During initial sync the data is replicated from publisher to subscriber
using COPY command. But normally COPY of generated column is not
supported. So instead, we can use the syntax
'COPY (SELECT column_name FROM table_name) TO STDOUT' for COPY.

With this patch, if 'include_generated_columns' and 'copy_data' options
are 'true' during 'CREATE SUBSCRIPTION', then the generated columns data
is replicated from publisher to the subscriber during inital sync.

While making column list for COPY command we donot include a column if it
is a generated column on the subscriber side. And the data corresponding
to that column will not be replicated instead, that column will be filled
as normal with the subscriber-side computed or default data


SUGGESTION
When 'copy_data' is true, during the initial sync, the data is replicated from
the publisher to the subscriber using the COPY command. The normal COPY
command does not copy generated columns, so when 'include_generated_columns'
is true, we need to copy using the syntax:
'COPY (SELECT column_name FROM table_name) TO STDOUT'.

Note that we don't copy columns when the subscriber-side column is also
generated. Those will be filled as normal with the subscriber-side computed or
default data.