From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Peter Smith <smithpb2250(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18558: ALTER PUBLICATION fails with unhelpful error on attempt to use system column |
Date: | 2024-08-12 07:44:58 |
Message-ID: | CAApHDvp=K+f8jH=WJ_-epXFW4FMnocY+-BrYQYbEBpLd02-H2w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Mon, 5 Aug 2024 at 19:43, Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> On Sat, Aug 3, 2024 at 12:14 AM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> > Looking at this, I only just noticed that fixing the bug is quite
> > simple. We could just do something like:
> >
> > - newcolumns =
> > bms_add_member(newcolumns, attnum);
> > + if (attnum >= 0)
> > + newcolumns =
> > bms_add_member(newcolumns, attnum);
> >
> > as later in AlterPublicationTables() the PublicationAddTables()
> > function is called and the column list is validated anyway. So if
> > there are system attributes in the columns list, they'll still be
> > found and rejected.
> >
>
> ... which sounds good. But did you try it?
Seemingly not well enough. What I was trying to get around was the
double validation when modifying the column list or WHERE clause of an
existing table within a publication. I had assumed that because
PublicationAddTables() is still called that the validation is done
there. What actually happens is PublicationAddTables() is called with
"if_not_exists" == true and we short-circuit out (without validating
the columns) when we see that the table already exists in the
publication.
Maybe it's not worth going to the trouble of rearranging the code so
the validation is only done once. It is fairly cheap. get_attnum() is
a hash table lookup and the algorithm is just O(n) for the number of
attributes. It's probably not going to be a big deal on the
performance front.
Here's the patch updated to do the validation inside AlterPublicationTables().
David
Attachment | Content-Type | Size |
---|---|---|
v2-0001-Improve-ALTER-PUBLICATION-validation-and-error-me.patch | application/octet-stream | 11.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2024-08-12 08:44:27 | Re: BUG #18569: Memory leak in Postgres Enterprise server |
Previous Message | Sahu, Abhisek Kumar | 2024-08-12 05:37:50 | RE: BUG #18569: Memory leak in Postgres Enterprise server |