pgsql: Get rid of multiple applications of transformExpr() to the same - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Get rid of multiple applications of transformExpr() to the same
Date
Msg-id E1YPbkd-0002f8-IH@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/6a75562ed16b5fa52cfd8830e4546972e647db26

Modified Files
--------------
src/backend/bootstrap/bootparse.y  |    4 +
src/backend/commands/tablecmds.c   |    5 +-
src/backend/nodes/copyfuncs.c      |    1 +
src/backend/nodes/equalfuncs.c     |    1 +
src/backend/nodes/outfuncs.c       |    2 +
src/backend/parser/gram.y          |    2 +
src/backend/parser/parse_clause.c  |    9 +-
src/backend/parser/parse_expr.c    |  163 ++++++++++++------------------------
src/backend/parser/parse_utilcmd.c |   11 +++
src/include/nodes/parsenodes.h     |    1 +
10 files changed, 83 insertions(+), 116 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Represent BETWEEN as a special node type in raw parse trees.
Next
From: Tom Lane
Date:
Subject: pgsql: Add parse location fields to NullTest and BooleanTest structs.