]> granicus.if.org Git - postgresql/commitdiff
show the index used in an explain
authorMarc G. Fournier <scrappy@hub.org>
Mon, 27 Apr 1998 16:57:09 +0000 (16:57 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Mon, 27 Apr 1998 16:57:09 +0000 (16:57 +0000)
From: Zeugswetter Andreas SARZ <Andreas.Zeugswetter@telecom.at>

src/backend/commands/explain.c

index a8b32e2e0a165de6aa1f59d40fd6ca6082e1250c..82ef0a2939e4a81c2bcb23d522ba416ed0b5ee63 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.18 1998/02/26 04:30:58 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.19 1998/04/27 16:57:09 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -23,6 +23,7 @@
 #include <parser/parse_node.h>
 #include <optimizer/planner.h>
 #include <access/xact.h>
+#include <utils/relcache.h>
 
 typedef struct ExplainState
 {
@@ -117,6 +118,8 @@ ExplainQuery(Query *query, bool verbose, CommandDest dest)
 static void
 explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
 {
+       List            *l;
+       Relation        relation;
        char       *pname;
        char            buf[1000];
        int                     i;
@@ -184,8 +187,12 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
        appendStringInfo(str, pname);
        switch (nodeTag(plan))
        {
-               case T_SeqScan:
                case T_IndexScan:
+                       appendStringInfo(str, " using ");
+                       l = ((IndexScan *) plan)->indxid;
+                       relation = RelationIdCacheGetRelation((int) lfirst(l));
+                       appendStringInfo(str, (RelationGetRelationName(relation))->data);
+               case T_SeqScan:
                        if (((Scan *) plan)->scanrelid > 0)
                        {
                                RangeTblEntry *rte = nth(((Scan *) plan)->scanrelid - 1, es->rtable);