aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_clause.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-02-22 13:59:09 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2015-02-22 13:59:09 -0500
commit6a75562ed16b5fa52cfd8830e4546972e647db26 (patch)
tree3592cc8b39f8827404aa8732829b3699c990394a /src/backend/parser/parse_clause.c
parent34af082f95aa6adb8af5fbd4da46bd4c3c176856 (diff)
downloadpostgresql-6a75562ed16b5fa52cfd8830e4546972e647db26.tar.gz
postgresql-6a75562ed16b5fa52cfd8830e4546972e647db26.zip
Get rid of multiple applications of transformExpr() to the same tree.
transformExpr() has for many years had provisions to do nothing when applied to an already-transformed expression tree. However, this was always ugly and of dubious reliability, so we'd be much better off without it. The primary historical reason for it was that gram.y sometimes returned multiple links to the same subexpression, which is no longer true as of my BETWEEN fixes. We'd also grown some lazy hacks in CREATE TABLE LIKE (failing to distinguish between raw and already-transformed index specifications) and one or two other places. This patch removes the need for and support for re-transforming already transformed expressions. The index case is dealt with by adding a flag to struct IndexStmt to indicate that it's already been transformed; which has some benefit anyway in that tablecmds.c can now Assert that transformation has happened rather than just assuming. The other main reason was some rather sloppy code for array type coercion, which can be fixed (and its performance improved too) by refactoring. I did leave transformJoinUsingClause() still constructing expressions containing untransformed operator nodes being applied to Vars, so that transformExpr() still has to allow Var inputs. But that's a much narrower, and safer, special case than before, since Vars will never appear in a raw parse tree, and they don't have any substructure to worry about. In passing fix some oversights in the patch that added CREATE INDEX IF NOT EXISTS (missing processing of IndexStmt.if_not_exists). These appear relatively harmless, but still sloppy coding practice.
Diffstat (limited to 'src/backend/parser/parse_clause.c')
-rw-r--r--src/backend/parser/parse_clause.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 654dce6755e..8d90b5098a1 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -339,10 +339,11 @@ transformJoinUsingClause(ParseState *pstate,
/*
* We cheat a little bit here by building an untransformed operator tree
- * whose leaves are the already-transformed Vars. This is OK because
- * transformExpr() won't complain about already-transformed subnodes.
- * However, this does mean that we have to mark the columns as requiring
- * SELECT privilege for ourselves; transformExpr() won't do it.
+ * whose leaves are the already-transformed Vars. This requires collusion
+ * from transformExpr(), which normally could be expected to complain
+ * about already-transformed subnodes. However, this does mean that we
+ * have to mark the columns as requiring SELECT privilege for ourselves;
+ * transformExpr() won't do it.
*/
forboth(lvars, leftVars, rvars, rightVars)
{