• Robert Haas's avatar
    postgres_fdw: Check PlaceHolderVars before pushing down a join. · 131c7e70
    Robert Haas authored
    As discovered by Andreas Seltenreich via sqlsmith, it's possible for a
    remote join to need to generate a target list which contains a
    PlaceHolderVar which would need to be evaluated on the remote server.
    This happens when we try to push down a join tree which contains outer
    joins and the nullable side of the join contains a subquery which
    evauates some expression which can go to NULL above the level of the
    join.  Since the deparsing logic can't build a remote query that
    involves subqueries, it fails while trying to produce an SQL query
    that can be sent to the remote side.  Detect such cases and don't try
    to push down the join at all.
    
    It's actually fine to push down the join if the PlaceHolderVar needs
    to be evaluated at the current join level.  This patch makes a small
    change to build_tlist_to_deparse so that this case will work.
    
    Amit Langote, Ashutosh Bapat, and me.
    131c7e70
postgres_fdw.c 138 KB