New CORRESPONDING clause design

From: Surafel Temsgen <surafel3000(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: New CORRESPONDING clause design
Date: 2017-01-17 06:37:43
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-hackers

I am new here and I really want to contribute, I have read same resource
that help understanding database system and postgresql. I would like to
start implementing sql syntax corresponding by clause because I believe
implementing sql syntax gives an opportunity to familiarize many part of
postgresql source code. Previous implementation is here
have an issue on explain query and break cases on unlabeled NULLs
To repeat what a corresponding by clause means
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 SELECT 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) SELECT 4 b, 5 d, 6 c, 7 f;

with output:

My design is
*In parsing stage*
1. Check at least one common column name appear in queries
2. If corresponding column list is not specified, then make corresponding
list from common column name in queries target lists in the order
that those column names appear in first query
3. If corresponding column list is specified, then check that every column
in The corresponding column list appears in column names of both queries
*In planner*
1. Take projection columen name from corresponding list
2. Reorder left and right queries target lists according to corresponding
3. For each query, project columens as many as number of corresponding
Continue with normal set operation process


Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2017-01-17 06:38:50 Re: Supporting huge pages on Windows
Previous Message Michael Paquier 2017-01-17 06:24:21 Re: pg_hba_file_settings view patch