diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-06-13 03:40:49 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-06-13 03:40:49 +0000 |
commit | ecb5269404bcb489aaa46d433f9d564e47d2a490 (patch) | |
tree | 36eaf0c16ef67a1b741fc150feb088fead877e28 /src/backend/commands/explain.c | |
parent | 59c325bb7363aed9115e9f3ccb77feca05b00ec4 (diff) | |
download | postgresql-ecb5269404bcb489aaa46d433f9d564e47d2a490.tar.gz postgresql-ecb5269404bcb489aaa46d433f9d564e47d2a490.zip |
Further tweaks to support display of sort keys in EXPLAIN --- initial
implementation didn't work for Sort nodes associated with Append plans.
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index a7412b0e720..f9bc64953d1 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994-5, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.78 2002/05/18 21:38:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.79 2002/06/13 03:40:49 tgl Exp $ * */ @@ -681,7 +681,8 @@ show_scan_qual(List *qual, bool is_or_qual, const char *qlabel, outercontext = NULL; context = deparse_context_for_plan(scanrelid, scancontext, - OUTER, outercontext); + OUTER, outercontext, + NIL); /* Deparse the expression */ exprstr = deparse_expression(node, context, (outercontext != NULL)); @@ -726,7 +727,8 @@ show_upper_qual(List *qual, const char *qlabel, else innercontext = NULL; context = deparse_context_for_plan(outer_varno, outercontext, - inner_varno, innercontext); + inner_varno, innercontext, + NIL); /* Deparse the expression */ node = (Node *) make_ands_explicit(qual); @@ -761,11 +763,30 @@ show_sort_keys(List *tlist, int nkeys, const char *qlabel, /* * In this routine we expect that the plan node's tlist has not been - * processed by set_plan_references(), so any Vars will contain valid - * varnos referencing the actual rtable. + * processed by set_plan_references(). Normally, any Vars will contain + * valid varnos referencing the actual rtable. But we might instead be + * looking at a dummy tlist generated by prepunion.c; if there are + * Vars with zero varno, use the tlist itself to determine their names. */ - context = deparse_context_from_rtable(es->rtable); - useprefix = length(es->rtable) > 1; + if (intMember(0, pull_varnos((Node *) tlist))) + { + Node *outercontext; + + outercontext = deparse_context_for_subplan("sort", + tlist, + es->rtable); + context = deparse_context_for_plan(0, outercontext, + 0, NULL, + NIL); + useprefix = false; + } + else + { + context = deparse_context_for_plan(0, NULL, + 0, NULL, + es->rtable); + useprefix = length(es->rtable) > 1; + } for (keyno = 1; keyno <= nkeys; keyno++) { |