While implementing a function for making view definitions look prettier  
in pgadmin3, I had a look at ruleutils.c to examine why there are tons 
of parentheses coming out of pg_get_viewdef. I believe that some are 
really not needed.

These are:
- get_rule_expr, for CASES T_RelabelType and T_CoerceToDomain. The cast 
is always bound to the near left variable, so it can be left out.
- get_from_clauses for ON. Operators will deliver what is needed.

for get_rule_expr and get_from_clauses(JOIN part), parentheses could be 
omitted if the top-level expression is evaluated.

Do you agree?

Regards,
Andreas
 


Mon, 07 Apr 2003 18:48:55 +0200
Andreas Pflug <Andreas.Pflug@web.de>
pg_get_viewdef 7.4 parentheses
Andreas Pflug <Andreas.Pflug@web.de> writes:
> While implementing a function for making view definitions look prettier  
> in pgadmin3, I had a look at ruleutils.c to examine why there are tons 
> of parentheses coming out of pg_get_viewdef. I believe that some are 
> really not needed.

The difficulty is to know which ones *are* needed in complex
expressions.  If you think that any of them are always unnecessary,
you haven't thought hard enough.  For example:

> - get_rule_expr, for CASES T_RelabelType and T_CoerceToDomain. The cast 
> is always bound to the near left variable, so it can be left out.

What if the argument isn't just a variable?

			regards, tom lane


Tue, 08 Apr 2003 19:27:14 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: pg_get_viewdef 7.4 parentheses 