• Tom Lane's avatar
    Consider syntactic form when disambiguating function vs column reference. · b97a3465
    Tom Lane authored
    Postgres has traditionally considered the syntactic forms f(x) and x.f
    to be equivalent, allowing tricks such as writing a function and then
    using it as though it were a computed-on-demand column.  However, our
    behavior when both interpretations are feasible left something to be
    desired: we always chose the column interpretation.  This could lead
    to very surprising results, as in a recent bug report from Neil Conway.
    It also created a dump-and-reload hazard, since what was a function
    call in a dumped view could get interpreted as a column reference
    at reload, if a matching column name had been added to the underlying
    table since the view was created.
    
    What seems better, in ambiguous situations, is to prefer the choice
    matching the syntactic form of the reference.  This seems much less
    astonishing in general, and it fixes the dump/reload hazard.
    
    Although this could be called a bug fix, there have been few complaints
    and there's some small risk of breaking applications that depend on the
    old behavior, so no back-patch.  It does seem reasonable to slip it
    into v11, though.
    
    Discussion: https://postgr.es/m/CAOW5sYa3Wp7KozCuzjOdw6PiOYPi6D=VvRybtH2S=2C0SVmRmA@mail.gmail.com
    b97a3465
parse_func.c 73.3 KB