mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Further tweaks to support display of sort keys in EXPLAIN --- initial
implementation didn't work for Sort nodes associated with Append plans.
This commit is contained in:
@ -5,7 +5,7 @@
|
|||||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994-5, Regents of the University of California
|
* 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;
|
outercontext = NULL;
|
||||||
|
|
||||||
context = deparse_context_for_plan(scanrelid, scancontext,
|
context = deparse_context_for_plan(scanrelid, scancontext,
|
||||||
OUTER, outercontext);
|
OUTER, outercontext,
|
||||||
|
NIL);
|
||||||
|
|
||||||
/* Deparse the expression */
|
/* Deparse the expression */
|
||||||
exprstr = deparse_expression(node, context, (outercontext != NULL));
|
exprstr = deparse_expression(node, context, (outercontext != NULL));
|
||||||
@ -726,7 +727,8 @@ show_upper_qual(List *qual, const char *qlabel,
|
|||||||
else
|
else
|
||||||
innercontext = NULL;
|
innercontext = NULL;
|
||||||
context = deparse_context_for_plan(outer_varno, outercontext,
|
context = deparse_context_for_plan(outer_varno, outercontext,
|
||||||
inner_varno, innercontext);
|
inner_varno, innercontext,
|
||||||
|
NIL);
|
||||||
|
|
||||||
/* Deparse the expression */
|
/* Deparse the expression */
|
||||||
node = (Node *) make_ands_explicit(qual);
|
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
|
* 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
|
* processed by set_plan_references(). Normally, any Vars will contain
|
||||||
* varnos referencing the actual rtable.
|
* 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);
|
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;
|
useprefix = length(es->rtable) > 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (keyno = 1; keyno <= nkeys; keyno++)
|
for (keyno = 1; keyno <= nkeys; keyno++)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* back to source text
|
* back to source text
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.107 2002/05/28 22:16:15 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.108 2002/06/13 03:40:49 tgl Exp $
|
||||||
*
|
*
|
||||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||||
*
|
*
|
||||||
@ -685,16 +685,21 @@ deparse_context_for(const char *aliasname, Oid relid)
|
|||||||
* The passed-in Nodes should be made using deparse_context_for_subplan
|
* The passed-in Nodes should be made using deparse_context_for_subplan
|
||||||
* and/or deparse_context_for_relation. The resulting context will work
|
* and/or deparse_context_for_relation. The resulting context will work
|
||||||
* for deparsing quals, tlists, etc of the plan node.
|
* for deparsing quals, tlists, etc of the plan node.
|
||||||
|
*
|
||||||
|
* An rtable list can also be passed in case plain Vars might be seen.
|
||||||
|
* This is not needed for true upper-level expressions, but is helpful for
|
||||||
|
* Sort nodes and similar cases with slightly bogus targetlists.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
deparse_context_for_plan(int outer_varno, Node *outercontext,
|
deparse_context_for_plan(int outer_varno, Node *outercontext,
|
||||||
int inner_varno, Node *innercontext)
|
int inner_varno, Node *innercontext,
|
||||||
|
List *rtable)
|
||||||
{
|
{
|
||||||
deparse_namespace *dpns;
|
deparse_namespace *dpns;
|
||||||
|
|
||||||
dpns = (deparse_namespace *) palloc(sizeof(deparse_namespace));
|
dpns = (deparse_namespace *) palloc(sizeof(deparse_namespace));
|
||||||
|
|
||||||
dpns->rtable = NIL;
|
dpns->rtable = rtable;
|
||||||
dpns->outer_varno = outer_varno;
|
dpns->outer_varno = outer_varno;
|
||||||
dpns->outer_rte = (RangeTblEntry *) outercontext;
|
dpns->outer_rte = (RangeTblEntry *) outercontext;
|
||||||
dpns->inner_varno = inner_varno;
|
dpns->inner_varno = inner_varno;
|
||||||
@ -779,27 +784,6 @@ deparse_context_for_subplan(const char *name, List *tlist,
|
|||||||
return (Node *) rte;
|
return (Node *) rte;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* deparse_context_from_rtable - Build deparse context given a rangetable
|
|
||||||
*
|
|
||||||
* This is suitable for deparsing expressions that refer to only a single
|
|
||||||
* level of variables (no outer-reference Vars).
|
|
||||||
*/
|
|
||||||
List *
|
|
||||||
deparse_context_from_rtable(List *rtable)
|
|
||||||
{
|
|
||||||
deparse_namespace *dpns;
|
|
||||||
|
|
||||||
dpns = (deparse_namespace *) palloc(sizeof(deparse_namespace));
|
|
||||||
|
|
||||||
dpns->rtable = rtable;
|
|
||||||
dpns->outer_varno = dpns->inner_varno = 0;
|
|
||||||
dpns->outer_rte = dpns->inner_rte = NULL;
|
|
||||||
|
|
||||||
/* Return a one-deep namespace stack */
|
|
||||||
return makeList1(dpns);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
* make_ruledef - reconstruct the CREATE RULE command
|
* make_ruledef - reconstruct the CREATE RULE command
|
||||||
* for a given pg_rewrite tuple
|
* for a given pg_rewrite tuple
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: builtins.h,v 1.183 2002/06/11 15:41:38 thomas Exp $
|
* $Id: builtins.h,v 1.184 2002/06/13 03:40:49 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -354,11 +354,11 @@ extern char *deparse_expression(Node *expr, List *dpcontext,
|
|||||||
bool forceprefix);
|
bool forceprefix);
|
||||||
extern List *deparse_context_for(const char *aliasname, Oid relid);
|
extern List *deparse_context_for(const char *aliasname, Oid relid);
|
||||||
extern List *deparse_context_for_plan(int outer_varno, Node *outercontext,
|
extern List *deparse_context_for_plan(int outer_varno, Node *outercontext,
|
||||||
int inner_varno, Node *innercontext);
|
int inner_varno, Node *innercontext,
|
||||||
|
List *rtable);
|
||||||
extern Node *deparse_context_for_rte(RangeTblEntry *rte);
|
extern Node *deparse_context_for_rte(RangeTblEntry *rte);
|
||||||
extern Node *deparse_context_for_subplan(const char *name, List *tlist,
|
extern Node *deparse_context_for_subplan(const char *name, List *tlist,
|
||||||
List *rtable);
|
List *rtable);
|
||||||
extern List *deparse_context_from_rtable(List *rtable);
|
|
||||||
extern const char *quote_identifier(const char *ident);
|
extern const char *quote_identifier(const char *ident);
|
||||||
extern char *quote_qualified_identifier(const char *namespace,
|
extern char *quote_qualified_identifier(const char *namespace,
|
||||||
const char *ident);
|
const char *ident);
|
||||||
|
Reference in New Issue
Block a user