Thread

Commits

  1. postgres_fdw: Fix interaction of PHVs with child joins.

  1. PlaceHolderVars in pushed down child-join cause error

    Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> — 2018-02-22T12:41:36Z

    Hi,
    postgres_fdw isn't expected to push down joins with placeholder vars.
    But the check for that in foreign_join_ok() only considers
    joinrel->relids. For a child-join relids contains the child relids but
    PlaceHolderInfo refers to the top parent's relids. Hence postgres_fdw
    tries to push down a child-join with PlaceHolderVars in it and fails
    with error "unsupported expression type for deparse: 198". 198 being
    T_PlaceHolderVar.
    
    The fix is to use joinrel->top_parent_relids for a child-join.
    Attached patch for the same.
    
    -- 
    Best Wishes,
    Ashutosh Bapat
    EnterpriseDB Corporation
    The Postgres Database Company
    
  2. Re: PlaceHolderVars in pushed down child-join cause error

    Robert Haas <robertmhaas@gmail.com> — 2018-02-22T15:06:42Z

    On Thu, Feb 22, 2018 at 7:41 AM, Ashutosh Bapat
    <ashutosh.bapat@enterprisedb.com> wrote:
    > postgres_fdw isn't expected to push down joins with placeholder vars.
    > But the check for that in foreign_join_ok() only considers
    > joinrel->relids. For a child-join relids contains the child relids but
    > PlaceHolderInfo refers to the top parent's relids. Hence postgres_fdw
    > tries to push down a child-join with PlaceHolderVars in it and fails
    > with error "unsupported expression type for deparse: 198". 198 being
    > T_PlaceHolderVar.
    >
    > The fix is to use joinrel->top_parent_relids for a child-join.
    > Attached patch for the same.
    
    Committed, but I changed the formatting, because as you had it,
    pgindent would have mangled it.  While I was at it, I tweaked the
    wording of the comment a bit.
    
    -- 
    Robert Haas
    EnterpriseDB: http://www.enterprisedb.com
    The Enterprise PostgreSQL Company
    
    
    
  3. Re: PlaceHolderVars in pushed down child-join cause error

    Ashutosh Bapat <ashutosh.bapat@enterprisedb.com> — 2018-02-26T04:05:45Z

    On Thu, Feb 22, 2018 at 8:36 PM, Robert Haas <robertmhaas@gmail.com> wrote:
    > On Thu, Feb 22, 2018 at 7:41 AM, Ashutosh Bapat
    > <ashutosh.bapat@enterprisedb.com> wrote:
    >> postgres_fdw isn't expected to push down joins with placeholder vars.
    >> But the check for that in foreign_join_ok() only considers
    >> joinrel->relids. For a child-join relids contains the child relids but
    >> PlaceHolderInfo refers to the top parent's relids. Hence postgres_fdw
    >> tries to push down a child-join with PlaceHolderVars in it and fails
    >> with error "unsupported expression type for deparse: 198". 198 being
    >> T_PlaceHolderVar.
    >>
    >> The fix is to use joinrel->top_parent_relids for a child-join.
    >> Attached patch for the same.
    >
    > Committed, but I changed the formatting, because as you had it,
    > pgindent would have mangled it.  While I was at it, I tweaked the
    > wording of the comment a bit.
    
    Thanks.
    
    
    -- 
    Best Wishes,
    Ashutosh Bapat
    EnterpriseDB Corporation
    The Postgres Database Company