aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/explain.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-05-06 00:20:33 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-05-06 00:20:33 +0000
commit2cf57c8f8d060711c1ad7e1dd6cc1115a2839b47 (patch)
treeb3b2a9616d425072d26cfc57efcbe676c56b399e /src/backend/commands/explain.c
parent94a3c60324465f98850b60f548c1ea481ab4e52f (diff)
downloadpostgresql-2cf57c8f8d060711c1ad7e1dd6cc1115a2839b47.tar.gz
postgresql-2cf57c8f8d060711c1ad7e1dd6cc1115a2839b47.zip
Implement feature of new FE/BE protocol whereby RowDescription identifies
the column by table OID and column number, if it's a simple column reference. Along the way, get rid of reskey/reskeyop fields in Resdoms. Turns out that representation was not convenient for either the planner or the executor; we can make the planner deliver exactly what the executor wants with no more effort. initdb forced due to change in stored rule representation.
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r--src/backend/commands/explain.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index d117d2e9a23..2504d69fd06 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994-5, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.106 2003/04/24 21:16:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.107 2003/05/06 00:20:31 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -57,8 +57,9 @@ static void show_upper_qual(List *qual, const char *qlabel,
const char *outer_name, int outer_varno, Plan *outer_plan,
const char *inner_name, int inner_varno, Plan *inner_plan,
StringInfo str, int indent, ExplainState *es);
-static void show_sort_keys(List *tlist, int nkeys, const char *qlabel,
- StringInfo str, int indent, ExplainState *es);
+static void show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols,
+ const char *qlabel,
+ StringInfo str, int indent, ExplainState *es);
static Node *make_ors_ands_explicit(List *orclauses);
/*
@@ -193,18 +194,10 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt,
ExplainState *es;
StringInfo str;
- /*
- * If we are not going to execute, suppress any SELECT INTO marker.
- * Without this, ExecutorStart will create the INTO target table,
- * which we don't want.
- */
- if (!stmt->analyze)
- queryDesc->parsetree->into = NULL;
-
gettimeofday(&starttime, NULL);
/* call ExecutorStart to prepare the plan for execution */
- ExecutorStart(queryDesc);
+ ExecutorStart(queryDesc, !stmt->analyze);
/* Execute the plan for statistics if asked for */
if (stmt->analyze)
@@ -672,7 +665,9 @@ explain_outNode(StringInfo str,
str, indent, es);
break;
case T_Sort:
- show_sort_keys(plan->targetlist, ((Sort *) plan)->keycount,
+ show_sort_keys(plan->targetlist,
+ ((Sort *) plan)->numCols,
+ ((Sort *) plan)->sortColIdx,
"Sort Key",
str, indent, es);
break;
@@ -937,7 +932,8 @@ show_upper_qual(List *qual, const char *qlabel,
* Show the sort keys for a Sort node.
*/
static void
-show_sort_keys(List *tlist, int nkeys, const char *qlabel,
+show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols,
+ const char *qlabel,
StringInfo str, int indent, ExplainState *es)
{
List *context;
@@ -985,27 +981,30 @@ show_sort_keys(List *tlist, int nkeys, const char *qlabel,
}
bms_free(varnos);
- for (keyno = 1; keyno <= nkeys; keyno++)
+ for (keyno = 0; keyno < nkeys; keyno++)
{
/* find key expression in tlist */
+ AttrNumber keyresno = keycols[keyno];
+
foreach(tl, tlist)
{
TargetEntry *target = (TargetEntry *) lfirst(tl);
- if (target->resdom->reskey == keyno)
+ if (target->resdom->resno == keyresno)
{
/* Deparse the expression, showing any top-level cast */
exprstr = deparse_expression((Node *) target->expr, context,
useprefix, true);
/* And add to str */
- if (keyno > 1)
+ if (keyno > 0)
appendStringInfo(str, ", ");
appendStringInfo(str, "%s", exprstr);
break;
}
}
if (tl == NIL)
- elog(ERROR, "show_sort_keys: no tlist entry for key %d", keyno);
+ elog(ERROR, "show_sort_keys: no tlist entry for key %d",
+ keyresno);
}
appendStringInfo(str, "\n");