Re: (PATCH) Adding CORRESPONDING to Set Operations

From: "Erik Rijkers" <er(at)xs4all(dot)nl>
To: "Kerem Kat" <keremkat(at)gmail(dot)com>
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: (PATCH) Adding CORRESPONDING to Set Operations
Date: 2011-10-24 17:52:31
Message-ID: cd505d419919eaab83d943fc2d242c9a.squirrel@webmail.xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, October 19, 2011 15:01, Kerem Kat wrote:
> Adding CORRESPONDING to Set Operations
> Initial patch, filename: corresponding_clause_v2.patch

I had a quick look at the behaviour of this patch.

Btw, the examples in your email were typoed (one select is missing):

> SELECT 1 a, 2 b, 3 c UNION CORRESPONDING 4 b, 5 d, 6 c, 7 f;
should be:
SELECT 1 a, 2 b, 3 c UNION CORRESPONDING select 4 b, 5 d, 6 c, 7 f;

and

> SELECT 1 a, 2 b, 3 c UNION CORRESPONDING BY(b) 4 b, 5 d, 6 c, 7 f;
should be:
SELECT 1 a, 2 b, 3 c UNION CORRESPONDING BY(b) select 4 b, 5 d, 6 c, 7 f;
>

But there is also a small bug, I think: the order in the CORRESPONDING BY list should be followed,
according to the standard (foundation, p. 408):

"2) If <corresponding column list> is specified, then let SL be a <select list> of those <column
name>s explicitly appearing in the <corresponding column list> in the order that these
<column name>s appear in the <corresponding column list>. Every <column name> in the
<corresponding column list> shall be a <column name> of both T1 and T2."

That would make this wrong, I think:

SELECT 1 a, 2 b, 3 c UNION CORRESPONDING BY(c,b) select 5 d, 6 c, 7 f, 4 b ;

b | c
---+---
2 | 3
4 | 6
(2 rows)

i.e., I think it should show columns in the order c, b (and not b, c); the order of the
CORRESPONDING BY phrase.

(but maybe I'm misreading the text of the standard; I find it often difficult to follow)

Thanks,

Erik Rijkers

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2011-10-24 18:15:06 Re: So, is COUNT(*) fast now?
Previous Message Tom Lane 2011-10-24 17:51:59 Re: So, is COUNT(*) fast now?