Avoid generating excess (and illegal) parentheses around an aliased JOIN
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 13 Dec 2004 00:33:18 +0000 (00:33 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 13 Dec 2004 00:33:18 +0000 (00:33 +0000)
in prettyprint mode.  Andreas Pflug

src/backend/utils/adt/ruleutils.c

index aceb02699c7d0b50c5815369696971451e466f28..08b25a8447a17fda81b7c174fc2f8be65439c6d1 100644 (file)
@@ -3903,7 +3903,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, '(');