Re: Fix foreign key constraint check for partitioned tables

From: Hadi Moshayedi <hadi(at)moshayedi(dot)net>
To: Edmund Horner <ejrh00(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix foreign key constraint check for partitioned tables
Date: 2019-03-25 18:57:48
Message-ID: CAK=1=WonwcuN_0KiZwQO3SQxse41jZ5hOJRpFCvZ3qa8n9cssw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Edmund,

Thanks for the review.

> I was a bit curious about the need for "set role" in the reproduction,
> but I see that it's because RI_Initial_Check does some checks to see
> if a simple SELECT can be used, and one of the checks is for basic
> table permissions.
>

I think to reproduce this the current user shouldn't be able to SELECT on
both tables, so RI_Initial_Check fails. Setting the owner of one of the
tables isn't always enough as the current user can be a super user.

> I wonder if the macro RELKIND_HAS_STORAGE should be used instead of
> checking for each relkind? This would apply to the check on line 4405
> too.
>

done.

This patch also changed the output of some of tests, i.e. previously
foreign key constraint failures errored on the partitioned table itself,
but now it shows the child table's name in the error message. I hope it is
ok.

I also added a regression test which would fail without this patch.

Thanks,
Hadi

Attachment Content-Type Size
fix-foreign-key-check.patch application/octet-stream 5.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Erik Rijkers 2019-03-25 19:40:15 Re: [HACKERS] proposal: schema variables
Previous Message Tom Lane 2019-03-25 18:19:56 Re: warning to publication created and wal_level is not set to logical