aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-07-20 11:29:36 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-07-20 11:29:36 -0400
commiteb145fdfea91ee5dc6d7aad0309527f810f7c90a (patch)
tree5ac1a2a8855e73568a4daca9355a1f5366552214 /src/backend/utils/adt/ruleutils.c
parent3cb29c42f990522131535eea75c691fb23191685 (diff)
downloadpostgresql-eb145fdfea91ee5dc6d7aad0309527f810f7c90a.tar.gz
postgresql-eb145fdfea91ee5dc6d7aad0309527f810f7c90a.zip
Fix dumping of outer joins with empty qual lists.
Normally, a JoinExpr would have empty "quals" only if it came from CROSS JOIN syntax. However, it's possible to get to this state by specifying NATURAL JOIN between two tables with no common column names, and there might be other ways too. The code previously printed no ON clause if "quals" was empty; that's right for CROSS JOIN but syntactically invalid if it's some type of outer join. Fix by printing ON TRUE in that case. This got broken by commit 2ffa740be, which stopped using NATURAL JOIN syntax in ruleutils output due to its brittleness in the face of column renamings. Back-patch to 9.3 where that commit appeared. Per report from Tushar Ahuja. Discussion: https://postgr.es/m/98b283cd-6dda-5d3f-f8ac-87db8c76a3da@enterprisedb.com
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index d2fb20d5649..23000281bbe 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -10082,6 +10082,11 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
if (!PRETTY_PAREN(context))
appendStringInfoChar(buf, ')');
}
+ else if (j->jointype != JOIN_INNER)
+ {
+ /* If we didn't say CROSS JOIN above, we must provide an ON */
+ appendStringInfoString(buf, " ON TRUE");
+ }
if (!PRETTY_PAREN(context) || j->alias != NULL)
appendStringInfoChar(buf, ')');