Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-10-18 Thread Robert Haas
On Sun, Oct 16, 2011 at 7:46 PM, Kerem Kat kerem...@gmail.com wrote: CORRESPONDING clause take 2 You should probably read this: http://wiki.postgresql.org/wiki/Submitting_a_Patch And add your patch here: https://commitfest.postgresql.org/action/commitfest_view/open -- Robert Haas

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-10-16 Thread Kerem Kat
CORRESPONDING clause take 2 After realizing that modifying prepunion.c to include a custom subquery is not easy(incomprehensible to me) as it sounds and turning into a hassle after making several uninformed changes, I decided to go with modifying analyze.c. The incomprehensible part is

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-26 Thread Tom Lane
Kerem Kat kerem...@gmail.com writes: In the parser while analyzing SetOperationStmt, larg and rarg needs to be transformed as subqueries. SetOperationStmt can have two fields representing larg and rarg with projected columns according to corresponding: larg_corresponding, rarg_corresponding.

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-25 Thread Tom Lane
Kerem Kat kerem...@gmail.com writes: On Sat, Sep 24, 2011 at 19:51, Tom Lane t...@sss.pgh.pa.us wrote: Why? CORRESPONDING at a given set-operation level doesn't affect either sub-query, so I don't see why you'd need a different representation for the sub-queries. In the planner to construct

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-24 Thread Kerem Kat
I am looking into perpunion.c and analyze.c There is a catch inserting subqueries for corresponding in the planner. Parser expects to see equal number of columns in both sides of the UNION query. If there is corresponding however we cannot guarantee that. Target columns, collations and types for

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-24 Thread Tom Lane
Kerem Kat kerem...@gmail.com writes: There is a catch inserting subqueries for corresponding in the planner. Parser expects to see equal number of columns in both sides of the UNION query. If there is corresponding however we cannot guarantee that. Well, you certainly need the parse analysis

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-24 Thread Kerem Kat
On Sat, Sep 24, 2011 at 18:49, Tom Lane t...@sss.pgh.pa.us wrote: Kerem Kat kerem...@gmail.com writes: There is a catch inserting subqueries for corresponding in the planner. Parser expects to see equal number of columns in both sides of the UNION query. If there is corresponding however

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-24 Thread Kerem Kat
On Sat, Sep 24, 2011 at 19:51, Tom Lane t...@sss.pgh.pa.us wrote: Kerem Kat kerem...@gmail.com writes: In the parser while analyzing SetOperationStmt, larg and rarg needs to be transformed as subqueries. SetOperationStmt can have two fields representing larg and rarg with projected columns

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-22 Thread Robert Haas
On Sun, Sep 18, 2011 at 5:39 AM, Kerem Kat kerem...@gmail.com wrote: I am new to postgresql code, I would like to start implementing easyish TODO items. I have read most of the development guidelines, faqs, articles by Greg Smith (Hacking Postgres with UDFs, Adding WHEN to triggers). The item

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-22 Thread Kerem Kat
I delved into the code without waiting for comments from the list just to learn something about postgresql internals. And I have finished the CORRESPONDING, now CORRESPONDING BY is being tested. I will also write documentation and regression tests. Yes Robert, you are correct. Having used SQL

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-22 Thread Kerem Kat
While testing I noticed that ordering is incorrect in my implementation. At first I thought that removing mismatched entries from ltargetlist and rtargetlist would be enough, it didn't seem enough so I added rtargetlist sorting. SELECT 1 a, 2 b, 3 c UNION CORRESPONDING 4 b, 5 a, 6 c; returns

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-22 Thread Tom Lane
Kerem Kat kerem...@gmail.com writes: While testing I noticed that ordering is incorrect in my implementation. At first I thought that removing mismatched entries from ltargetlist and rtargetlist would be enough, it didn't seem enough so I added rtargetlist sorting. I don't think you can get

Re: [HACKERS] Adding CORRESPONDING to Set Operations

2011-09-19 Thread Kerem Kat
Is it feasible to implement the CORRESPONDING [BY (expr_list)] statement in set operations by the following changes: i) In analyze.c:transformSetOperationStmt after parsing left and right queries as subnodes to a set operation tree, a) CORRESPONDING: Find matching column targets from both

[HACKERS] Adding CORRESPONDING to Set Operations

2011-09-18 Thread Kerem Kat
Hello, I am new to postgresql code, I would like to start implementing easyish TODO items. I have read most of the development guidelines, faqs, articles by Greg Smith (Hacking Postgres with UDFs, Adding WHEN to triggers). The item I would like to implement is adding CORRESPONDING [BY