Re: Adding CORRESPONDING to Set Operations - Mailing list pgsql-hackers

From Kerem Kat
Subject Re: Adding CORRESPONDING to Set Operations
Date
Msg-id CAJZSWkVGTLr8ScxJbCLCc_NALN9qZn469u4_v6JNyz2G7ohCWA@mail.gmail.com
Whole thread Raw
In response to Re: Adding CORRESPONDING to Set Operations  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Adding CORRESPONDING to Set Operations
List pgsql-hackers
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 constructing a custom subquery as a
SubqueryScan.

Anyway I managed to implement the clause as a Subquery in analyze.c.

In the method transformSetOperationTree, if the node is a setoperation and
contains a corresponding clause, i.e. CORRESPONDING, or CORRESPONDING
BY(columns...),
we determine the common column names. Column ordering in select statements
are not important to the CORRESPONDING. With the common column names
in hand, we create a RangeSubselect node accordingly and replace the original
statement op->larg with the new RangeSubselect. RangeSubselect in turn has the
original op->larg as a from clause. We do the same to op->rarg too.

There were no changes done in prepunion.c

There are documentation changes and one regression test in the patch.


Best Regards,

Kerem KAT

Attachment

pgsql-hackers by date:

Previous
From: Hitoshi Harada
Date:
Subject: Re: Underspecified window queries in regression tests
Next
From: Hitoshi Harada
Date:
Subject: Re: Underspecified window queries in regression tests