Re: [HACKERS] GSoC 2017: Foreign Key Arrays

From: Mark Rofail <markm(dot)rofail(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, David Steele <david(at)pgmasters(dot)net>, Erik Rijkers <er(at)xs4all(dot)nl>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hans-Jürgen Schönig <hs(at)cybertec(dot)at>
Subject: Re: [HACKERS] GSoC 2017: Foreign Key Arrays
Date: 2018-01-21 21:36:57
Message-ID: CAJvoCuvOsGya322VhPm-NJb-wx7VOUvWwuiXULtQApszgbzVTQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This new version of the patch compiles well with the HEAD and resolved the
following issues .

> > 2) I think the code in RI_Initial_Check() would be cleaner if you used
> > > "CROSS JOIN LATERAL unnest(col)" rather than having unnest() in the
> target
> > > list. This way you would not need to rename all columns and the code
> paths
> > > for the array case could look more like the code path for the normal
> case.
>
The RI query has been re-factored thanks to Andreas.

== The @>> operator
>
> A previous version of your patch added the "anyelement <<@ anyarray"
> operator to avoid having to build arrays, but that part was reverted due to
> a bug.
>
> I am not expert on the gin code, but as far as I can tell it would be
> relatively simple to fix that bug. Just allocate an array of Datums of
> length one where you put the element you are searching for (or maybe a copy
> of it).
>
The @>> is now restored and functioning correctly, all issues with contrib
libraries has been resolved

> > 1) MATCH FULL does not seem to care about NULLS in arrays. In the
> example
> > > below I expected both inserts into the referring table to fail.
> > >
> > > CREATE TABLE t (x int, y int, PRIMARY KEY (x, y));
> > > CREATE TABLE fk (x int, ys int[], FOREIGN KEY (x, EACH ELEMENT OF ys)
> REFERENCES t MATCH FULL);
> > > INSERT INTO t VALUES (10, 1);
> > > INSERT INTO fk VALUES (10, '{1,NULL}');
> > > INSERT INTO fk VALUES (NULL, '{1}');
>
We agreed that MATCH FULL can wait for a future patch. It's not needed for
now

We really need a review so the patch can pass in this commitfest.

Best Regards,
Mark Rofail

Attachment Content-Type Size
Array-ELEMENT-foreign-key-v6.patch text/x-patch 136.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikolay Shaplov 2018-01-21 21:45:06 [PATCH][PROPOSAL] Add enum releation option type
Previous Message Robert Haas 2018-01-21 21:10:48 Re: [HACKERS] UPDATE of partition key