Re: partitioned tables referenced by FKs

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: partitioned tables referenced by FKs
Date: 2019-03-28 04:30:31
Message-ID: 0057bbc0-b099-701f-9f92-ef1c7a68e7d6@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2019/03/27 8:27, Alvaro Herrera wrote:
> On 2019-Mar-26, Alvaro Herrera wrote:
>
>> Thanks for the thorough testing and bug analysis! It was spot-on. I've
>> applied your two proposed fixes, as well as added a new test setup that
>> covers both these bugs. The attached set is rebased on 7c366ac969ce.
>
> Attached is rebased on 126d63122232. No further changes.

Noticed something -- I was expecting that your earlier commit 1af25ca0c2d9
would've taken care of this, but apparently it didn't.

-- pk
create table p (a int primary key) partition by list (a);
create table p1 partition of p for values in (1) partition by list (a);
create table p11 partition of p1 for values in (1);

-- fk (partitioned)
create table q (a int references p) partition by list (a);
create table q1 partition of q for values in (1) partition by list (a);
create table q11 partition of q1 for values in (1);

-- prints only the top-level constraint as expected
\d q
Partitioned table "public.q"
Column │ Type │ Collation │ Nullable │ Default
────────┼─────────┼───────────┼──────────┼─────────
a │ integer │ │ │
Partition key: LIST (a)
Foreign-key constraints:
"q_a_fkey" FOREIGN KEY (a) REFERENCES p(a)
Number of partitions: 1 (Use \d+ to list them.)

-- fk (regular table)
create table r (a int references p);

-- this prints all, which seems unintentional
\d r
Table "public.r"
Column │ Type │ Collation │ Nullable │ Default
────────┼─────────┼───────────┼──────────┼─────────
a │ integer │ │ │
Foreign-key constraints:
"r_a_fkey" FOREIGN KEY (a) REFERENCES p(a)
"r_a_fkey1" FOREIGN KEY (a) REFERENCES p1(a)
"r_a_fkey2" FOREIGN KEY (a) REFERENCES p11(a)

So, 0002 needs to include some psql tweaks.

Thanks,
Amit

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2019-03-28 04:34:52 Re: pgsql: Compute XID horizon for page level index vacuum on primary.
Previous Message Nagaura, Ryohei 2019-03-28 03:01:15 RE: Timeout parameters