|From:||Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)oss(dot)ntt(dot)co(dot)jp>|
|Subject:||[REVIEW] Generate column names for subquery expressions|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
This is a review for the patch `Generate column names for
Patch format is in context diff format.
This patch applies cleanly on HEAD and make check suceeded.
It seems have no problem to apply.
Documents is needed to modify.
Purpose and function of this patch
This patch intends to name a part of the columns in the outmost
SELECT caluse currently left unnamed - seen as `?column?' - and
fix `unnatural' naming - seen as `int4', `case'.
This patch figures column name after T_SubLink parse nodes
corresponding to EXISTS, ARRAY, and subquery in addition to
currently processed parse node types.
It seems reasonable that (ALL|ANY|ROWCOMPARE|CTE)_SUBLINK is left
Patch application, regression test
The patch applies cleanly onto HEAD. make check yiels no error.
This patch adds no additional test case and it seems ok.
The coding style in this patch seems according to the convention.
The behavior of column naming changes as following.
STATEMENT AFTER BEFORE
select (select 1 as foo) foo ?column?
select (exists (select 1)) exists ?column?
select (array (select 1 as x)) array ?column?
select (select 1 as aaa)::int aaa int4
select case when true then 1 else (select 1 as foo) end;
Aboves are same as described. But the following expression
returns somewhat confising outcome.
> select case when true then (select 2 as bar) else (select 1 as foo) end;
> (1 row)
But this patch is not to blame for the behavior. The following is
seen for unpatched pg.
> # create table foo (a int, b int, c int);
> # insert into foo values (1, 100, -100), (0, 10, -10), (-1, 25, -25);
> # select case when a < 0 then b else c end from foo;
> # select case a when -1 then c when 1 then a else b end from foo;
Nevertheless this behavior seems a bit unnatural, it is not the
issue for this patch.
This patch adds no extra load such as loops, recursive calls or
deep calls. Added code runs for exists(), array() and subquery
appear in the column list of select clause. So I think this patch
can put only negligible impact on performance.
This patch assumes node(subLinkType==EXPR_SUBLINK)->subselect is
not null, and it seems that gram.y(c) says the assumption is
I think this patch needs no documentation, but it is needed to
edit the changed behaviors quoted in document. Maybe only one
change as far as I have seen.
> SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%');
|Next Message||Joachim Wieland||2011-09-14 02:37:56||Re: synchronized snapshots|
|Previous Message||Kyotaro HORIGUCHI||2011-09-14 02:13:20||[v9.2] make_greater_string() does not return a string in some cases|