Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cf/5128~1
Choose a base ref
...
head repository: postgresql-cfbot/postgresql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf/5128
Choose a head ref
  • 7 commits
  • 19 files changed
  • 3 contributors

Commits on Feb 1, 2025

  1. Allow partition-wise join when reltarget contains whole row vars

    This partially revert 7cfdc77,
    restoring setrefs logic to handle converted whole row reference.
    Alexander Pyhalov authored and Commitfest Bot committed Feb 1, 2025
    Configuration menu
    Copy the full SHA
    a9a174c View commit details
    Browse the repository at this point in the history
  2. Handle ConvertRowtypeExprs in pull_vars_clause().

    This is a preparatory patch to fix the unresolved ConvertRowtypeExpr
    references in the targetlists. The patch allows pull_vars_clause() to
    return ConvertRowtypeExprs without recursing into those. Because of
    the recent work to support indexes and triggers on partitioned table,
    every caller of pull_var_clause() can encounter a ConvertRowtype
    embedding a whole-row reference. Current behavior is unchanged.
    Callers which don't need to recurse to ConvertRowtypeExprs
    should explicitly pass PVC_INCLUDE_CONVERTROWTYPES.
    
    The patch is taken from https://www.postgresql.org/message-id/CAFjFpRc8ZoDm0%2Bzhx%2BMckwGyEqkOzWcpVqbvjaxwdGarZSNrmA%40mail.gmail.com
    ashutosh-bapat authored and Commitfest Bot committed Feb 1, 2025
    Configuration menu
    Copy the full SHA
    fa400cc View commit details
    Browse the repository at this point in the history
  3. Handle child relation's ConvertRowtypeExpr in find_computable_ec_memb…

    …er()
    ashutosh-bapat authored and Commitfest Bot committed Feb 1, 2025
    Configuration menu
    Copy the full SHA
    80f0e3b View commit details
    Browse the repository at this point in the history
  4. Compare converted whole row vars in search_indexed_tlist_for_non_var(…

    …) correctly and fix test results
    Alexander Pyhalov authored and Commitfest Bot committed Feb 1, 2025
    Configuration menu
    Copy the full SHA
    ab48128 View commit details
    Browse the repository at this point in the history
  5. postgres_fdw: child-join with ConvertRowtypeExprs causes expression r…

    …eference errors.
    
    Whole row reference of the parent is translated into
    ConvertRowtypeExpr with whole row of child as an argument. When
    partition-wise join is used, targetlist of a child-join contains
    ConvertRowtypeExpr/s when the parent-join's targetlist has whole-row
    reference/s of joining partitioned tables.
    
    The targetlist to be deparsed for a child-join is built using
    build_tlist_to_deparse(). The same targetlist is then saved as
    fdw_scan_tlist in ForeignScanPlan. build_tlist_to_deparse() pulls only
    Var nodes from the join's targetlist.  So it pulls Var reprensenting a
    whole-row reference of a child from a ConvertRowtypeExpr. Thus the
    child-join's projected target list contains ConvertRowtypeExpr but the
    SELECT clause and fdw_scan_tlist contains a whole-row reference.
    
    This causes two problems:
    1.  When a relation (participating in the child-join being pushed
    down) is deparsed as a subquery, subquery's targetlist (and SELECT
    clause) contains expressions from foreignrel->reltarget->exprs. A Var
    from such a relation is deparsed as column reference of subquery using
    get_relation_column_alias_ids().  That function uses foreignrel's
    targetlist to locate given node to be deparsed.  If the joining
    relation corresponding to ConvertRowtypeExpr is deparsed as a
    subquery, this function is called with whole-row reference node (Var
    node with varattno = 0).  The relation's foreignrel->reltarget->exprs
    doesn't contain its whole-row reference directly but has it embedded
    in ConvertRowtypeExpr. So, the function doesn't find the given node
    and throws error.
    
    2. When there is possibility of EvalPlanQual being called, we
    construct local join plan matching the pushed down foreign join. In
    postgresGetForeignPlan() after we have built the local join plan, the
    topmost plan node's targetlist is changed to fdw_scan_tlist to match
    the output of the ForeignScan node. As explained above, this
    fdw_scan_tlist contains a bare reference to the whole-row reference from a
    child relation if the child-join's targetlist contains a
    ConvertRowtypeExpr. When changing the topmost plan node's targetlist,
    we do not modify the targetlists of its left and right tree nodes. The
    left/right plan involving corresponding child relation will have
    ConvertRowtypeExpr expression in its targetlist, but not whole-row
    reference directly. When the topmost local join plan node's targetlist
    is processed by set_plan_ref(), it throws error "variable not found in
    subplan target lists" since it doesn't find bare whole-row reference
    of the child relation in subplan's targetlists.
    
    Solution
    This requires two parts
    a. In build_tlist_to_deparse(), instead of pulling Var node from
    ConvertRowtypeExpr, we pull whole ConvertRowtypeExpr and include it in
    the targetlist being deparsed which is also used to set
    fdw_scan_tlist.
    
    b. deparse ConvertRowtypeExpr.  For this we need to get the conversion
    map between the parent and child. We then deparse ConvertRowtypeExpr
    as a ROW() with the attributes of child rearranged per the conversion
    map. A multi-level partitioned table will have nested
    ConvertRowtypeExpr. To deparse such expressions, we need to find the
    conversion map between the topmost parent and the child, by ignoring
    any intermediate parents.
    
    The patch is taken from https://www.postgresql.org/message-id/CAFjFpRc8ZoDm0%2Bzhx%2BMckwGyEqkOzWcpVqbvjaxwdGarZSNrmA%40mail.gmail.com
    ashutosh-bapat authored and Commitfest Bot committed Feb 1, 2025
    Configuration menu
    Copy the full SHA
    52ab882 View commit details
    Browse the repository at this point in the history
  6. postgres_fdw: fix partition-wise DML

    Alexander Pyhalov authored and Commitfest Bot committed Feb 1, 2025
    Configuration menu
    Copy the full SHA
    4b565fe View commit details
    Browse the repository at this point in the history
  7. [CF 51/5128] Allow partition-wise join when whole row var is needed

    This commit was automatically generated by a robot at cfbot.cputube.org.
    It is based on patches submitted to the PostgreSQL mailing lists and
    registered in the PostgreSQL Commitfest application.
    
    This branch will be overwritten each time a new patch version is posted to
    the email thread, and also periodically to check for bitrot caused by changes
    on the master branch.
    
    Commitfest entry: https://commitfest.postgresql.org/51/5128
    Patch(es): https://www.postgresql.org/message-id/[email protected]
    Author(s): Ashutosh Bapat, Alexander Pyhalov
    Commitfest Bot committed Feb 1, 2025
    Configuration menu
    Copy the full SHA
    3e641ab View commit details
    Browse the repository at this point in the history
Loading