• Tom Lane's avatar
    Code review for NextValueExpr expression node type. · decb08eb
    Tom Lane authored
    Add missing infrastructure for this node type, notably in ruleutils.c where
    its lack could demonstrably cause EXPLAIN to fail.  Add outfuncs/readfuncs
    support.  (outfuncs support is useful today for debugging purposes.  The
    readfuncs support may never be needed, since at present it would only
    matter for parallel query and NextValueExpr should never appear in a
    parallelizable query; but it seems like a bad idea to have a primnode type
    that isn't fully supported here.)  Teach planner infrastructure that
    NextValueExpr is a volatile, parallel-unsafe, non-leaky expression node
    with cost cpu_operator_cost.  Given its limited scope of usage, there
    *might* be no live bug today from the lack of that knowledge, but it's
    certainly going to bite us on the rear someday.  Teach pg_stat_statements
    about the new node type, too.
    
    While at it, also teach cost_qual_eval() that MinMaxExpr, SQLValueFunction,
    XmlExpr, and CoerceToDomain should be charged as cpu_operator_cost.
    Failing to do this for SQLValueFunction was an oversight in my commit
    0bb51aa9.  The others are longer-standing oversights, but no time like the
    present to fix them.  (In principle, CoerceToDomain could have cost much
    higher than this, but it doesn't presently seem worth trying to examine the
    domain's constraints here.)
    
    Modify execExprInterp.c to execute NextValueExpr as an out-of-line
    function; it seems quite unlikely to me that it's worth insisting that
    it be inlined in all expression eval methods.  Besides, providing the
    out-of-line function doesn't stop anyone from inlining if they want to.
    
    Adjust some places where NextValueExpr support had been inserted with the
    aid of a dartboard rather than keeping it in the same order as elsewhere.
    
    Discussion: https://postgr.es/m/23862.1499981661@sss.pgh.pa.us
    decb08eb
outfuncs.c 98.4 KB