• Tom Lane's avatar
    Change plpgsql from using textual substitution to insert variable references · 0772f1e5
    Tom Lane authored
    into SQL expressions, to using the newly added parser callback hooks.
    
    This allows us to do the substitutions in a more semantically-aware way:
    a variable reference will only be recognized where it can validly go,
    ie, a place where a column value or parameter would be legal, instead of
    the former behavior that would replace any textual match including
    table names and column aliases (leading to syntax errors later on).
    A release-note-worthy fine point is that plpgsql variable names that match
    fully-reserved words will now need to be quoted.
    
    This commit preserves the former behavior that variable references take
    precedence over any possible match to a column name.  The infrastructure
    is in place to support the reverse precedence or throwing an error on
    ambiguity, but those behaviors aren't accessible yet.
    
    Most of the code changes here are associated with making the namespace
    data structure persist so that it can be consulted at runtime, instead
    of throwing it away at the end of initial function parsing.
    
    The plpgsql scanner is still doing name lookups, but that behavior is
    now irrelevant for SQL expressions.  A future commit will deal with
    removing unnecessary lookups.
    0772f1e5
plpgsql.out 119 KB