Re: [HACKERS] GSoC 2017: Foreign Key Arrays - Mailing list pgsql-hackers

From Mark Rofail
Subject Re: [HACKERS] GSoC 2017: Foreign Key Arrays
Date
Msg-id CAJvoCuvi8JREomcteEpy3LQ3m=w0TuPUj4B9vwuJE_+3kSqAPA@mail.gmail.com
Whole thread Raw
In response to Re: [HACKERS] GSoC 2017: Foreign Key Arrays  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: [HACKERS] GSoC 2017: Foreign Key Arrays
List pgsql-hackers
On Mon, Nov 13, 2017 at 2:41 AM, Andreas Karlsson <andreas@proxel.se> wrote:
I think the code would look cleaner if you generate the following query:

SELECT fk.x, fk.ys FROM ONLY t2 fk CROSS JOIN LATERAL pg_catalog.unnest(ys) a2 (v) LEFT OUTER JOIN ONLY t1 pk ON pk.x = fk.x AND pk.y = a2.v WHERE [...]

rather than:

SELECT fk.k1, fk.ak2 FROM (SELECT x k1, pg_catalog.unnest(ys) k2, ys ak2 FROM ONLY t2) fk LEFT OUTER JOIN ONLY t1 pk ON pk.x = fk.k1 AND pk.y = fk.k2 WHERE [...]

Andreas has kindly written the SQL query for us. My problem is generating it with C code

Best Regards,
Mark Rofail

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: [HACKERS] postgres_fdw bug in 9.6
Next
From: Peter Eisentraut
Date:
Subject: Re: WIP: a way forward on bootstrap data