mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-19 04:46:59 +08:00
Keep track of what RTIs a Result node is scanning.
Result nodes now include an RTI set, which is only non-NULL when they have no subplan, and is taken from the relid set of the RelOptInfo that the Result is generating. ExplainPreScanNode now takes notice of these RTIs, which means that a few things get schema-qualified in the regression tests that previously did not. This makes the output more consistent between cases where some part of the plan tree is replaced by a Result node and those where this does not happen. Likewise, pg_overexplain's EXPLAIN (RANGE_TABLE) now displays the RTIs stored in a Result node just as it already does for other RTI-bearing node types. Result nodes also now include a result_reason, which tells us something about why the Result node was inserted. Using that information, EXPLAIN now emits, where relevant, a "Replaces" line describing the origin of a Result node. The purpose of these changes is to allow code that inspects a Plan tree to understand the origin of Result nodes that appear therein. Discussion: http://postgr.es/m/CA+TgmoYeUZePZWLsSO+1FAN7UPePT_RMEZBKkqYBJVCF1s60=w@mail.gmail.com Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com> Reviewed-by: Richard Guo <guofenglinux@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
This commit is contained in:
@ -252,6 +252,20 @@ typedef struct Plan
|
||||
#define outerPlan(node) (((Plan *)(node))->lefttree)
|
||||
|
||||
|
||||
/* ----------------
|
||||
* ResultType -
|
||||
* Classification of Result nodes
|
||||
* ----------------
|
||||
*/
|
||||
typedef enum ResultType
|
||||
{
|
||||
RESULT_TYPE_GATING, /* project or one-time-filter outer plan */
|
||||
RESULT_TYPE_SCAN, /* replace empty scan */
|
||||
RESULT_TYPE_JOIN, /* replace empty join */
|
||||
RESULT_TYPE_UPPER, /* replace degenerate upper rel */
|
||||
RESULT_TYPE_MINMAX /* implement minmax aggregate */
|
||||
} ResultType;
|
||||
|
||||
/* ----------------
|
||||
* Result node -
|
||||
* If no outer plan, evaluate a variable-free targetlist.
|
||||
@ -261,12 +275,20 @@ typedef struct Plan
|
||||
* If resconstantqual isn't NULL, it represents a one-time qualification
|
||||
* test (i.e., one that doesn't depend on any variables from the outer plan,
|
||||
* so needs to be evaluated only once).
|
||||
*
|
||||
* relids identifies the relation for which this Result node is generating the
|
||||
* tuples. When subplan is not NULL, it should be empty: this node is not
|
||||
* generating anything in that case, just acting on tuples generated by the
|
||||
* subplan. Otherwise, it contains the relids of the planner relation that
|
||||
* the Result represents.
|
||||
* ----------------
|
||||
*/
|
||||
typedef struct Result
|
||||
{
|
||||
Plan plan;
|
||||
ResultType result_type;
|
||||
Node *resconstantqual;
|
||||
Bitmapset *relids;
|
||||
} Result;
|
||||
|
||||
/* ----------------
|
||||
|
||||
Reference in New Issue
Block a user