5
5
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
6
6
* Portions Copyright (c) 1994-5, Regents of the University of California
7
7
*
8
- * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.75 2002/03/24 17:11:36 tgl Exp $
8
+ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.76 2002/05/03 15:56:45 tgl Exp $
9
9
*
10
10
*/
11
11
12
12
#include "postgres.h"
13
13
14
+ #include "access/genam.h"
14
15
#include "access/heapam.h"
15
16
#include "catalog/pg_type.h"
16
17
#include "commands/explain.h"
26
27
#include "utils/builtins.h"
27
28
#include "utils/guc.h"
28
29
#include "utils/lsyscache.h"
29
- #include "utils/relcache.h"
30
30
31
31
32
32
typedef struct ExplainState
@@ -62,9 +62,6 @@ static void do_text_output(TextOutputState *tstate, char *aline);
62
62
static void do_text_output_multiline (TextOutputState * tstate ,char * text );
63
63
static void end_text_output (TextOutputState * tstate );
64
64
65
- /* Convert a null string pointer into "<>" */
66
- #define stringStringInfo (s ) (((s) == NULL) ? "<>" : (s))
67
-
68
65
69
66
/*
70
67
* ExplainQuery -
@@ -227,7 +224,6 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
227
224
int indent ,ExplainState * es )
228
225
{
229
226
List * l ;
230
- Relation relation ;
231
227
char * pname ;
232
228
int i ;
233
229
@@ -322,13 +318,13 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
322
318
i = 0 ;
323
319
foreach (l , ((IndexScan * )plan )-> indxid )
324
320
{
325
- relation = RelationIdGetRelation (lfirsti (l ));
326
- Assert (relation );
321
+ Relation relation ;
322
+
323
+ relation = index_open (lfirsti (l ));
327
324
appendStringInfo (str ,"%s%s" ,
328
325
(++ i > 1 ) ?", " :"" ,
329
- stringStringInfo (RelationGetRelationName (relation )));
330
- /* drop relcache refcount from RelationIdGetRelation */
331
- RelationDecrementReferenceCount (relation );
326
+ quote_identifier (RelationGetRelationName (relation )));
327
+ index_close (relation );
332
328
}
333
329
/* FALL THRU */
334
330
case T_SeqScan :
@@ -346,10 +342,10 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
346
342
relname = get_rel_name (rte -> relid );
347
343
348
344
appendStringInfo (str ," on %s" ,
349
- stringStringInfo (relname ));
345
+ quote_identifier (relname ));
350
346
if (strcmp (rte -> eref -> aliasname ,relname )!= 0 )
351
347
appendStringInfo (str ," %s" ,
352
- stringStringInfo (rte -> eref -> aliasname ));
348
+ quote_identifier (rte -> eref -> aliasname ));
353
349
}
354
350
break ;
355
351
case T_SubqueryScan :
@@ -359,7 +355,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
359
355
es -> rtable );
360
356
361
357
appendStringInfo (str ," %s" ,
362
- stringStringInfo (rte -> eref -> aliasname ));
358
+ quote_identifier (rte -> eref -> aliasname ));
363
359
}
364
360
break ;
365
361
default :