Re: Pgoutput not capturing the generated columns - Mailing list pgsql-hackers

From vignesh C
Subject Re: Pgoutput not capturing the generated columns
Date
Msg-id CALDaNm1GoBqrCNyhvJ9Kf5oCTNvGC2s=PejcbxNidd9JvM1qBw@mail.gmail.com
Whole thread Raw
In response to Re: Pgoutput not capturing the generated columns  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-hackers
On Mon, 4 Nov 2024 at 16:25, Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Wed, Oct 30, 2024 at 9:46 PM vignesh C <vignesh21@gmail.com> wrote:
> >
> ...
> + /*
> + * For non-column list publications—such as TABLE (without a column
> + * list), ALL TABLES, or ALL TABLES IN SCHEMA publications consider
> + * all columns of the table, including generated columns, based on the
> + * pubgencols option.
> + */
> + if (!cols)
> + {
> + Assert(pub->pubgencols == entry->pubgencols);
> +
> + /*
> + * Retrieve the columns if they haven't been prepared yet, or if
> + * there are multiple publications.
> + */
> + if (!relcols && (list_length(publications) > 1))
> + {
> + pgoutput_ensure_entry_cxt(data, entry);
> + relcols = pub_getallcol_bitmapset(relation, entry->pubgencols,
> +   entry->entry_cxt);
> + }
> +
> + cols = relcols;
>
> Don't we need this only when generated column(s) are present, if so,
> we can get that as an input to pgoutput_column_list_init()?

We will use this in all cases i.e. irrespective of generated columns present:
ex:
CREATE TABLE t1(c1 int, c2 int);
create publication pub1 for table t1(c1);
create publication pub2 for table t1;

Create subscription ... publication pub1,pub2;

Even in this case we will have to identify that column list is not
matching and throw:
2024-11-04 20:35:58.199 IST [492190] 492190 sub1 ERROR:  cannot use
different column lists for table "public.t1" in different publications

Regards,
Vignesh



pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: New function normal_rand_array function to contrib/tablefunc.
Next
From: Matthias van de Meent
Date:
Subject: Re: pg_dump --no-comments confusion