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

From Peter Smith
Subject Re: Pgoutput not capturing the generated columns
Date
Msg-id CAHut+PuykmXF57T9AcBnsVqQEddmpBeHZvnGdJt=byYozXAcSg@mail.gmail.com
Whole thread Raw
In response to Re: Pgoutput not capturing the generated columns  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: Pgoutput not capturing the generated columns
List pgsql-hackers
Hi Vignesh.

Some review comments for v52-0001.

======
Commit message

1.
I guess the root cause is that in PG18 we decided to put the
"Generated columns" column to the left of the "Via Root" column
instead of to the right, and in doing so introduced a mistake ordering
the code.

The commit message can say that a bit more plainly -- e.g. you can
name those columns 'pubgencols' and 'pubviaroot' explicitly instead of
just referring to "the newly added column".

======
src/bin/psql/describe.c

describePublications:

2.
  if (has_pubgencols)
- printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
- if (has_pubviaroot)
  printTableAddCell(&cont, PQgetvalue(res, i, 9), false, false);
+ if (has_pubviaroot)
+ printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);

It seems a bit tricky for the code to just have the PQgetvalue
hardwired indexes (8,9) reversed like that. I think at least this
reversal needs a comment to explain why it is done that way, so nobody
in future is tempted to change it and accidentally re-break this.

Maybe also, consider adding variables for those PQgetvalue indexes.
Maybe, something like this can work?

pubviaroot_idx = ncols;
pubgencols_idx = ncols + 1;

======
Kind Regards,
Peter Smith.
Fujitsu Australia



pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: An improvement of ProcessTwoPhaseBuffer logic
Next
From: Peter Smith
Date:
Subject: Re: Pgoutput not capturing the generated columns