Re: GSoC 2017: Foreign Key Arrays

From: Mark Rofail <markm(dot)rofail(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Alexander Korotkov <aekorotkov(at)gmail(dot)com>, David Steele <david(at)pgmasters(dot)net>, Stephen Frost <sfrost(at)snowman(dot)net>, pgsql-hackers-owner(at)postgresql(dot)org, Erik Rijkers <er(at)xs4all(dot)nl>
Subject: Re: GSoC 2017: Foreign Key Arrays
Date: 2017-08-08 10:24:54
Message-ID: CAJvoCuvYD875G6OZMK6nUD5n_O1Yos+V550ypDF-dFoLXrVXkw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Aug 5, 2017 at 10:36 PM, Mark Rofail <markm(dot)rofail(at)gmail(dot)com> wrote:
>
> SELECT 1 WHERE
> (SELECT COUNT(*)
> FROM
> (
> SELECT y
> FROM unnest($1) y
> GROUP BY y
> )
> )
> = (SELECT count(*) (<QUERY>) z)
>
Well, with trial and error the correct query is:

SELECT 1 WHERE
(SELECT COUNT(y) FROM (SELECT y FROM pg_catalog.unnest(%s) y GROUP BY
y) yy)
= (SELECT count(*) (<QUERY>) z)

This passes all the regress tests and elimnates the DISTINCT keyword that
created the limitation.
However a look on the performance change is a must and that's what I plan
to do next.

There is another problem though. When I remove the part of the code setting
the default opclass in tablecmd.c I get this error message afterwards:
CREATE TABLE PKTABLEFORARRAY ( ptest1 float8 PRIMARY KEY, ptest2 text );
CREATE TABLE FKTABLEFORARRAY ( ftest1 int[], FOREIGN KEY (EACH ELEMENT OF
ftest1) REFERENCES PKTABLEFORARRAY, ftest2 int );
- ERROR: foreign key constraint "fktableforarray_ftest1_fkey" cannot be
implemented
- DETAIL: Key column "ftest1" has element type integer which does not have
a default btree operator class that's compatible with class "float8_ops".

Best Regards,
Mark Rofail

Attachment Content-Type Size
Array-ELEMENT-foreign-key-v4.1.0.patch text/x-patch 127.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Piotr Stefaniak 2017-08-08 10:39:25 The error message "sorry, too many clients already" is imprecise
Previous Message Michael Paquier 2017-08-08 10:19:26 Re: FYI: branch for v11 devel is planned for next week