Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitecb5269

Browse files
committed
Further tweaks to support display of sort keys in EXPLAIN --- initial
implementation didn't work for Sort nodes associated with Append plans.
1 parent59c325b commitecb5269

File tree

3 files changed

+39
-34
lines changed

3 files changed

+39
-34
lines changed

‎src/backend/commands/explain.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994-5, Regents of the University of California
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.78 2002/05/18 21:38:40 tgl Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.79 2002/06/13 03:40:49 tgl Exp $
99
*
1010
*/
1111

@@ -681,7 +681,8 @@ show_scan_qual(List *qual, bool is_or_qual, const char *qlabel,
681681
outercontext=NULL;
682682

683683
context=deparse_context_for_plan(scanrelid,scancontext,
684-
OUTER,outercontext);
684+
OUTER,outercontext,
685+
NIL);
685686

686687
/* Deparse the expression */
687688
exprstr=deparse_expression(node,context, (outercontext!=NULL));
@@ -726,7 +727,8 @@ show_upper_qual(List *qual, const char *qlabel,
726727
else
727728
innercontext=NULL;
728729
context=deparse_context_for_plan(outer_varno,outercontext,
729-
inner_varno,innercontext);
730+
inner_varno,innercontext,
731+
NIL);
730732

731733
/* Deparse the expression */
732734
node= (Node*)make_ands_explicit(qual);
@@ -761,11 +763,30 @@ show_sort_keys(List *tlist, int nkeys, const char *qlabel,
761763

762764
/*
763765
* In this routine we expect that the plan node's tlist has not been
764-
* processed by set_plan_references(), so any Vars will contain valid
765-
* varnos referencing the actual rtable.
766+
* processed by set_plan_references(). Normally, any Vars will contain
767+
* valid varnos referencing the actual rtable. But we might instead be
768+
* looking at a dummy tlist generated by prepunion.c; if there are
769+
* Vars with zero varno, use the tlist itself to determine their names.
766770
*/
767-
context=deparse_context_from_rtable(es->rtable);
768-
useprefix=length(es->rtable)>1;
771+
if (intMember(0,pull_varnos((Node*)tlist)))
772+
{
773+
Node*outercontext;
774+
775+
outercontext=deparse_context_for_subplan("sort",
776+
tlist,
777+
es->rtable);
778+
context=deparse_context_for_plan(0,outercontext,
779+
0,NULL,
780+
NIL);
781+
useprefix= false;
782+
}
783+
else
784+
{
785+
context=deparse_context_for_plan(0,NULL,
786+
0,NULL,
787+
es->rtable);
788+
useprefix=length(es->rtable)>1;
789+
}
769790

770791
for (keyno=1;keyno <=nkeys;keyno++)
771792
{

‎src/backend/utils/adt/ruleutils.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*back to source text
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.107 2002/05/28 22:16:15 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.108 2002/06/13 03:40:49 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -685,16 +685,21 @@ deparse_context_for(const char *aliasname, Oid relid)
685685
* The passed-in Nodes should be made using deparse_context_for_subplan
686686
* and/or deparse_context_for_relation. The resulting context will work
687687
* for deparsing quals, tlists, etc of the plan node.
688+
*
689+
* An rtable list can also be passed in case plain Vars might be seen.
690+
* This is not needed for true upper-level expressions, but is helpful for
691+
* Sort nodes and similar cases with slightly bogus targetlists.
688692
*/
689693
List*
690694
deparse_context_for_plan(intouter_varno,Node*outercontext,
691-
intinner_varno,Node*innercontext)
695+
intinner_varno,Node*innercontext,
696+
List*rtable)
692697
{
693698
deparse_namespace*dpns;
694699

695700
dpns= (deparse_namespace*)palloc(sizeof(deparse_namespace));
696701

697-
dpns->rtable=NIL;
702+
dpns->rtable=rtable;
698703
dpns->outer_varno=outer_varno;
699704
dpns->outer_rte= (RangeTblEntry*)outercontext;
700705
dpns->inner_varno=inner_varno;
@@ -779,27 +784,6 @@ deparse_context_for_subplan(const char *name, List *tlist,
779784
return (Node*)rte;
780785
}
781786

782-
/*
783-
* deparse_context_from_rtable- Build deparse context given a rangetable
784-
*
785-
* This is suitable for deparsing expressions that refer to only a single
786-
* level of variables (no outer-reference Vars).
787-
*/
788-
List*
789-
deparse_context_from_rtable(List*rtable)
790-
{
791-
deparse_namespace*dpns;
792-
793-
dpns= (deparse_namespace*)palloc(sizeof(deparse_namespace));
794-
795-
dpns->rtable=rtable;
796-
dpns->outer_varno=dpns->inner_varno=0;
797-
dpns->outer_rte=dpns->inner_rte=NULL;
798-
799-
/* Return a one-deep namespace stack */
800-
returnmakeList1(dpns);
801-
}
802-
803787
/* ----------
804788
* make_ruledef- reconstruct the CREATE RULE command
805789
* for a given pg_rewrite tuple

‎src/include/utils/builtins.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: builtins.h,v 1.183 2002/06/11 15:41:38 thomas Exp $
10+
* $Id: builtins.h,v 1.184 2002/06/13 03:40:49 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -354,11 +354,11 @@ extern char *deparse_expression(Node *expr, List *dpcontext,
354354
boolforceprefix);
355355
externList*deparse_context_for(constchar*aliasname,Oidrelid);
356356
externList*deparse_context_for_plan(intouter_varno,Node*outercontext,
357-
intinner_varno,Node*innercontext);
357+
intinner_varno,Node*innercontext,
358+
List*rtable);
358359
externNode*deparse_context_for_rte(RangeTblEntry*rte);
359360
externNode*deparse_context_for_subplan(constchar*name,List*tlist,
360361
List*rtable);
361-
externList*deparse_context_from_rtable(List*rtable);
362362
externconstchar*quote_identifier(constchar*ident);
363363
externchar*quote_qualified_identifier(constchar*namespace,
364364
constchar*ident);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp