Avoid generating excess (and illegal) parentheses around an aliased JOIN
authorTom Lane <[email protected]>
Mon, 13 Dec 2004 00:33:18 +0000 (00:33 +0000)
committerTom Lane <[email protected]>
Mon, 13 Dec 2004 00:33:18 +0000 (00:33 +0000)
in prettyprint mode.  Andreas Pflug

src/backend/utils/adt/ruleutils.c

index 48407038c57dfd0d7fcd617a8855c0479c27875b..78375a9f98c77eb68d9a9068ab669faf9a27f909 100644 (file)
@@ -3816,7 +3816,8 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
                bool            need_paren_on_right;
 
                need_paren_on_right = PRETTY_PAREN(context) &&
-                       !IsA(j->rarg, RangeTblRef);
+                 !IsA(j->rarg, RangeTblRef) && 
+                 !(IsA(j->rarg, JoinExpr) && ((JoinExpr*)j->rarg)->alias != NULL);
 
                if (!PRETTY_PAREN(context) || j->alias != NULL)
                        appendStringInfoChar(buf, '(');