(PATCH) Adding CORRESPONDING to Set Operations
Kerem Kat <keremkat@gmail.com>
From: Kerem Kat <keremkat@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@postgresql.org
Date: 2011-10-19T13:01:09Z
Lists: pgsql-hackers
Attachments
- corresponding_clause_v2.patch (text/x-patch) patch v2
Adding CORRESPONDING to Set Operations Initial patch, filename: corresponding_clause_v2.patch This patch adds CORRESPONDING clause to set operations according to SQL20nn standard draft as Feature F301, "CORRESPONDING in query expressions" Corresponding clause either contains a BY(...) clause or not. If it doesn't have a BY(...) clause the usage is as follows. SELECT 1 a, 2 b, 3 c UNION CORRESPONDING 4 b, 5 d, 6 c, 7 f; with output: b c ----- 2 3 4 6 i.e. matching column names are filtered and are only output from the whole set operation clause. If we introduce a BY(...) clause, then column names are further intersected with that BY clause: SELECT 1 a, 2 b, 3 c UNION CORRESPONDING BY(b) 4 b, 5 d, 6 c, 7 f; with output: b -- 2 4 This patch compiles and tests successfully with master branch. It has been tested only on Pardus Linux i686 ( Kernel 2.6.37.6 #1 SMP i686 i686 i386 GNU/Linux) This patch includes documentation and add one regression file. This patch addresses the following TODO item: SQL Commands: Add CORRESPONDING BY to UNION/INTERSECT/EXCEPT Best Regards, Kerem KAT