Re: [HACKERS] pg_get_viewdef 7.4 et al - Mailing list pgadmin-hackers

From Andreas Pflug
Subject Re: [HACKERS] pg_get_viewdef 7.4 et al
Date
Msg-id 3E93FCA0.1020402@web.de
Whole thread Raw
List pgadmin-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


pgadmin-hackers by date:

Previous
From: Andreas Pflug
Date:
Subject: Re: pgadmin3 GTK
Next
From: "Dave Page"
Date:
Subject: CVS Server