Wrong table in "conflicting or redundant WHERE clauses / column lists" publicaiton error

Started by vignesh C4 days ago3 messageshackers

Thread notes

1 note#bug
hackorum-bot#bug
hackorum-bot
2 days ago

@global #bug

#bug
Jump to latest
#1vignesh C
vignesh21@gmail.com

Hi,

When a table is listed explicitly and also reached through its
inheritance parent, CREATE PUBLICATION reports an error for the wrong
table. For example:
CREATE TABLE par (a int);
CREATE TABLE c1 () INHERITS (par);
CREATE TABLE c2 () INHERITS (par);

--- The table listed is c2, but the error reports c1.
CREATE PUBLICATION pub FOR TABLE c2, par WHERE (a > 0);
ERROR: conflicting or redundant WHERE clauses for table "c1"

The same problem occurs with column lists:
CREATE PUBLICATION pub FOR TABLE c2, par (a);
ERROR: conflicting or redundant column lists for table "c1"

While looping over a table's children, OpenTableList() uses rel =
table_open(childrelid, NoLock), overwriting rel, which holds the
explicitly named table. Both error messages use
RelationGetRelationName(rel), so they report the last child opened
rather than the conflicting table. In this example, c1 is not yet in
the list, so it is opened into rel. When c2 is found to be a
duplicate, rel still points to c1.

The attached patch opens each child into a separate local variable,
childrel, leaving rel unchanged. It also uses get_rel_name(childrelid)
to report the conflicting child in both error messages. The child is
already locked by find_all_inheritors(), so its name is available.

Regards,
Vignesh

Attachments:

t259787_1
v1-0001-Report-the-correct-table-in-publication-duplicate.patchapplication/octet-stream; name=v1-0001-Report-the-correct-table-in-publication-duplicate.patchDownload+23-5
#2Heikki Linnakangas
hlinnaka@iki.fi
In reply to: vignesh C (#1)
Re: Wrong table in "conflicting or redundant WHERE clauses / column lists" publicaiton error

On 25/11/2026 14:01, vignesh C wrote:

When a table is listed explicitly and also reached through its
inheritance parent, CREATE PUBLICATION reports an error for the wrong
table. For example:
CREATE TABLE par (a int);
CREATE TABLE c1 () INHERITS (par);
CREATE TABLE c2 () INHERITS (par);

--- The table listed is c2, but the error reports c1.
CREATE PUBLICATION pub FOR TABLE c2, par WHERE (a > 0);
ERROR: conflicting or redundant WHERE clauses for table "c1"

The same problem occurs with column lists:
CREATE PUBLICATION pub FOR TABLE c2, par (a);
ERROR: conflicting or redundant column lists for table "c1"

While looping over a table's children, OpenTableList() uses rel =
table_open(childrelid, NoLock), overwriting rel, which holds the
explicitly named table. Both error messages use
RelationGetRelationName(rel), so they report the last child opened
rather than the conflicting table. In this example, c1 is not yet in
the list, so it is opened into rel. When c2 is found to be a
duplicate, rel still points to c1.

The attached patch opens each child into a separate local variable,
childrel, leaving rel unchanged. It also uses get_rel_name(childrelid)
to report the conflicting child in both error messages. The child is
already locked by find_all_inheritors(), so its name is available.

Applied, thanks!

- Heikki

#3vignesh C
vignesh21@gmail.com
In reply to: Heikki Linnakangas (#2)
Re: Wrong table in "conflicting or redundant WHERE clauses / column lists" publicaiton error

On Wed, 25 Nov 2026 at 20:14, Heikki Linnakangas <hlinnaka@iki.fi> wrote:

Applied, thanks!

Thanks for pushing this patch.

Regards,
Vignesh