• Tom Lane's avatar
    Get rid of multiple applications of transformExpr() to the same tree. · 6a75562e
    Tom Lane authored
    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.
    6a75562e
copyfuncs.c 95.8 KB