aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/print.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-02-22 22:00:26 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-02-22 22:00:26 +0000
commiteab6b8b27eba54b8fd0ad3f64989d12200979c96 (patch)
treeca4fad45c65c60b7900df6e373bd5999993ea2b1 /src/backend/nodes/print.c
parent849000c7823d604270094aea76fc530b6cfe9466 (diff)
downloadpostgresql-eab6b8b27eba54b8fd0ad3f64989d12200979c96.tar.gz
postgresql-eab6b8b27eba54b8fd0ad3f64989d12200979c96.zip
Turn the rangetable used by the executor into a flat list, and avoid storing
useless substructure for its RangeTblEntry nodes. (I chose to keep using the same struct node type and just zero out the link fields for unneeded info, rather than making a separate ExecRangeTblEntry type --- it seemed too fragile to have two different rangetable representations.) Along the way, put subplans into a list in the toplevel PlannedStmt node, and have SubPlan nodes refer to them by list index instead of direct pointers. Vadim wanted to do that years ago, but I never understood what he was on about until now. It makes things a *whole* lot more robust, because we can stop worrying about duplicate processing of subplans during expression tree traversals. That's been a constant source of bugs, and it's finally gone. There are some consequent simplifications yet to be made, like not using a separate EState for subplans in the executor, but I'll tackle that later.
Diffstat (limited to 'src/backend/nodes/print.c')
-rw-r--r--src/backend/nodes/print.c171
1 files changed, 1 insertions, 170 deletions
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c
index 06d28b56b21..c6edfbed8a0 100644
--- a/src/backend/nodes/print.c
+++ b/src/backend/nodes/print.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.84 2007/02/10 14:58:54 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.85 2007/02/22 22:00:23 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -25,7 +25,6 @@
#include "parser/parsetree.h"
#include "utils/lsyscache.h"
-static char *plannode_type(Plan *p);
/*
* print
@@ -488,171 +487,3 @@ print_slot(TupleTableSlot *slot)
debugtup(slot, NULL);
}
-
-static char *
-plannode_type(Plan *p)
-{
- switch (nodeTag(p))
- {
- case T_Plan:
- return "PLAN";
- case T_Result:
- return "RESULT";
- case T_Append:
- return "APPEND";
- case T_BitmapAnd:
- return "BITMAPAND";
- case T_BitmapOr:
- return "BITMAPOR";
- case T_Scan:
- return "SCAN";
- case T_SeqScan:
- return "SEQSCAN";
- case T_IndexScan:
- return "INDEXSCAN";
- case T_BitmapIndexScan:
- return "BITMAPINDEXSCAN";
- case T_BitmapHeapScan:
- return "BITMAPHEAPSCAN";
- case T_TidScan:
- return "TIDSCAN";
- case T_SubqueryScan:
- return "SUBQUERYSCAN";
- case T_FunctionScan:
- return "FUNCTIONSCAN";
- case T_ValuesScan:
- return "VALUESSCAN";
- case T_Join:
- return "JOIN";
- case T_NestLoop:
- return "NESTLOOP";
- case T_MergeJoin:
- return "MERGEJOIN";
- case T_HashJoin:
- return "HASHJOIN";
- case T_Material:
- return "MATERIAL";
- case T_Sort:
- return "SORT";
- case T_Agg:
- return "AGG";
- case T_Unique:
- return "UNIQUE";
- case T_SetOp:
- return "SETOP";
- case T_Limit:
- return "LIMIT";
- case T_Hash:
- return "HASH";
- case T_Group:
- return "GROUP";
- default:
- return "UNKNOWN";
- }
-}
-
-/*
- * Recursively prints a simple text description of the plan tree
- */
-void
-print_plan_recursive(Plan *p, Query *parsetree, int indentLevel, char *label)
-{
- int i;
- char extraInfo[NAMEDATALEN + 100];
-
- if (!p)
- return;
- for (i = 0; i < indentLevel; i++)
- printf(" ");
- printf("%s%s :c=%.2f..%.2f :r=%.0f :w=%d ", label, plannode_type(p),
- p->startup_cost, p->total_cost,
- p->plan_rows, p->plan_width);
- if (IsA(p, Scan) ||
- IsA(p, SeqScan) ||
- IsA(p, BitmapHeapScan))
- {
- RangeTblEntry *rte;
-
- rte = rt_fetch(((Scan *) p)->scanrelid, parsetree->rtable);
- strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
- }
- else if (IsA(p, IndexScan))
- {
- RangeTblEntry *rte;
-
- rte = rt_fetch(((IndexScan *) p)->scan.scanrelid, parsetree->rtable);
- strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
- }
- else if (IsA(p, FunctionScan))
- {
- RangeTblEntry *rte;
-
- rte = rt_fetch(((FunctionScan *) p)->scan.scanrelid, parsetree->rtable);
- strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
- }
- else if (IsA(p, ValuesScan))
- {
- RangeTblEntry *rte;
-
- rte = rt_fetch(((ValuesScan *) p)->scan.scanrelid, parsetree->rtable);
- strlcpy(extraInfo, rte->eref->aliasname, NAMEDATALEN);
- }
- else
- extraInfo[0] = '\0';
- if (extraInfo[0] != '\0')
- printf(" ( %s )\n", extraInfo);
- else
- printf("\n");
- print_plan_recursive(p->lefttree, parsetree, indentLevel + 3, "l: ");
- print_plan_recursive(p->righttree, parsetree, indentLevel + 3, "r: ");
-
- if (IsA(p, Append))
- {
- ListCell *l;
- Append *appendplan = (Append *) p;
-
- foreach(l, appendplan->appendplans)
- {
- Plan *subnode = (Plan *) lfirst(l);
-
- print_plan_recursive(subnode, parsetree, indentLevel + 3, "a: ");
- }
- }
-
- if (IsA(p, BitmapAnd))
- {
- ListCell *l;
- BitmapAnd *bitmapandplan = (BitmapAnd *) p;
-
- foreach(l, bitmapandplan->bitmapplans)
- {
- Plan *subnode = (Plan *) lfirst(l);
-
- print_plan_recursive(subnode, parsetree, indentLevel + 3, "a: ");
- }
- }
-
- if (IsA(p, BitmapOr))
- {
- ListCell *l;
- BitmapOr *bitmaporplan = (BitmapOr *) p;
-
- foreach(l, bitmaporplan->bitmapplans)
- {
- Plan *subnode = (Plan *) lfirst(l);
-
- print_plan_recursive(subnode, parsetree, indentLevel + 3, "a: ");
- }
- }
-}
-
-/*
- * print_plan
- *
- * prints just the plan node types
- */
-void
-print_plan(Plan *p, Query *parsetree)
-{
- print_plan_recursive(p, parsetree, 0, "");
-}