• Tom Lane's avatar
    Revise FDW planning API, again. · b1495393
    Tom Lane authored
    Further reflection shows that a single callback isn't very workable if we
    desire to let FDWs generate multiple Paths, because that forces the FDW to
    do all work necessary to generate a valid Plan node for each Path.  Instead
    split the former PlanForeignScan API into three steps: GetForeignRelSize,
    GetForeignPaths, GetForeignPlan.  We had already bit the bullet of breaking
    the 9.1 FDW API for 9.2, so this shouldn't cause very much additional pain,
    and it's substantially more flexible for complex FDWs.
    
    Add an fdw_private field to RelOptInfo so that the new functions can save
    state there rather than possibly having to recalculate information two or
    three times.
    
    In addition, we'd not thought through what would be needed to allow an FDW
    to set up subexpressions of its choice for runtime execution.  We could
    treat ForeignScan.fdw_private as an executable expression but that seems
    likely to break existing FDWs unnecessarily (in particular, it would
    restrict the set of node types allowable in fdw_private to those supported
    by expression_tree_walker).  Instead, invent a separate field fdw_exprs
    which will receive the postprocessing appropriate for expression trees.
    (One field is enough since it can be a list of expressions; also, we assume
    the corresponding expression state tree(s) will be held within fdw_state,
    so we don't need to add anything to ForeignScanState.)
    
    Per review of Hanada Shigeru's pgsql_fdw patch.  We may need to tweak this
    further as we continue to work on that patch, but to me it feels a lot
    closer to being right now.
    b1495393
file_fdw.c 20.3 KB