Re: [HACKERS] pg_get_viewdef 7.4 et al

From: Andreas Pflug <Andreas(dot)Pflug(at)web(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgadmin-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] pg_get_viewdef 7.4 et al
Date: 2003-04-09 10:57:36
Message-ID: 3E93FCA0.1020402@web.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers pgsql-hackers

Tom,

I believe we have to discuss this a little more in-depth.
Parenthese-usage needs theroretical proof, since not all cases can be
tested. So I list the assumptions I made.

- JOINS:
A JOIN can only have RangeTblRef or JoinExpr as left and right argument.
RangeTblRef is trivial, no parentheses needed. JoinExpr on the left dont
need them either because that represents the standard evaluation order.
JoinExpr on the right needs parentheses (at least for clarification). ON
clause won't need them.

A is left of B, left of join root, (C JOIN D) is right of join root
A JOIN B ON xxx
JOIN (C JOIN D ON xxx) ON xxx

- general:
T_Var, T_Const, T_Param, T_Aggref, T_ArrayRef, T_FuncExpr,
T_DistinctExpr, T_SubLink, T_SubPlan, T_FieldSelect, T_NullIfExpr,
T_NullTest, T_BooleanTest, T_CoerceToDomainValue can be handled as a
simple argument.

- T_CoerceToDomain and T_RelabelType:
Both only take simple arguments, no complex expressions and thus don't
need parentheses. The typecast will stick correctly to its argument on
the left (rtfm 1.1.6 Table 1.1).

- T_BoolExpr:
Arguments will have precedence over AND/OR/NOT, unless they are
T_BoolExpr themselves. (according rtfm 1.1.6 Table 1.1)

- T_OperExpr:
Arguments only need parentheses if they are of type T_OperExpr or
T_BoolExpr. The second is presently disregarded in my code (didn't think
of bool operators), needs addition in get_rule_expr_paren().

- T_NullTest, T_BooleanTest
Could be optimized (handled like T_OperExpr) without loosing their
"simple argument" status for T_BoolExpr

Regards,
Andreas

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Tom Lane 2003-04-09 14:20:25 Re: pg_get_viewdef 7.4 et al
Previous Message Andreas Pflug 2003-04-09 09:17:47 Re: pg_get_viewdef 7.4 et al

Browse pgsql-hackers by date

  From Date Subject
Next Message Jan Wieck 2003-04-09 14:13:45 Re: Anyone know why PostgreSQL doesn't support 2 phase
Previous Message Andreas Pflug 2003-04-09 09:17:47 Re: pg_get_viewdef 7.4 et al