1998-12-14 09:11:17 +01:00
|
|
|
/*
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* outfuncs.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* routines to convert a node to ascii representation
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-12-03 21:45:40 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.135 2000/12/03 20:45:33 tgl Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
1997-09-07 07:04:48 +02:00
|
|
|
* Every (plan) node in POSTGRES has an associated "out" routine which
|
|
|
|
* knows how to create its ascii representation. These functions are
|
|
|
|
* useful for debugging as well as for storing plans in the system
|
|
|
|
* catalogs (eg. indexes). This is also the plan string sent out in
|
|
|
|
* Mariposa.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* These functions update the in/out argument of type StringInfo
|
|
|
|
* passed to them. This argument contains the string holding the ASCII
|
|
|
|
* representation plus some other information (string length, etc.)
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*/
|
1999-07-17 22:18:55 +02:00
|
|
|
#include "postgres.h"
|
2000-01-14 01:53:21 +01:00
|
|
|
|
2000-10-31 11:22:13 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "access/heapam.h"
|
|
|
|
#include "access/htup.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "catalog/pg_type.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "fmgr.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "lib/stringinfo.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "nodes/execnodes.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "nodes/nodes.h"
|
|
|
|
#include "nodes/parsenodes.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "nodes/pg_list.h"
|
|
|
|
#include "nodes/plannodes.h"
|
|
|
|
#include "nodes/primnodes.h"
|
|
|
|
#include "nodes/relation.h"
|
2000-05-29 07:45:56 +02:00
|
|
|
#include "parser/parse.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "utils/datum.h"
|
|
|
|
#include "utils/lsyscache.h"
|
|
|
|
#include "utils/syscache.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-05-10 01:46:35 +02:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
static void _outDatum(StringInfo str, Datum value, Oid type);
|
|
|
|
static void _outNode(StringInfo str, void *obj);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2000-01-14 01:53:21 +01:00
|
|
|
/*
|
|
|
|
* _outToken
|
|
|
|
* Convert an ordinary string (eg, an identifier) into a form that
|
|
|
|
* will be decoded back to a plain token by read.c's functions.
|
|
|
|
*
|
|
|
|
* If a null or empty string is given, it is encoded as "<>".
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outToken(StringInfo str, char *s)
|
|
|
|
{
|
|
|
|
if (s == NULL || *s == '\0')
|
|
|
|
{
|
|
|
|
appendStringInfo(str, "<>");
|
|
|
|
return;
|
|
|
|
}
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2000-01-14 01:53:21 +01:00
|
|
|
/*
|
|
|
|
* Look for characters or patterns that are treated specially by
|
2000-04-12 19:17:23 +02:00
|
|
|
* read.c (either in lsptok() or in nodeRead()), and therefore need a
|
|
|
|
* protective backslash.
|
2000-01-14 01:53:21 +01:00
|
|
|
*/
|
|
|
|
/* These characters only need to be quoted at the start of the string */
|
|
|
|
if (*s == '<' ||
|
|
|
|
*s == '\"' ||
|
|
|
|
*s == '@' ||
|
2000-12-03 21:45:40 +01:00
|
|
|
isdigit((unsigned char) *s) ||
|
|
|
|
(*s == '-' && isdigit((unsigned char) s[1])))
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfoChar(str, '\\');
|
|
|
|
while (*s)
|
|
|
|
{
|
|
|
|
/* These chars must be backslashed anywhere in the string */
|
|
|
|
if (*s == ' ' || *s == '\n' || *s == '\t' ||
|
|
|
|
*s == '(' || *s == ')' || *s == '{' || *s == '}' ||
|
|
|
|
*s == '\\')
|
|
|
|
appendStringInfoChar(str, '\\');
|
|
|
|
appendStringInfoChar(str, *s++);
|
|
|
|
}
|
|
|
|
}
|
1999-08-31 03:28:37 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
|
|
|
* _outIntList -
|
1997-09-07 07:04:48 +02:00
|
|
|
* converts a List of integers
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1996-11-10 04:06:38 +01:00
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outIntList(StringInfo str, List *list)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
List *l;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfoChar(str, '(');
|
1997-09-07 07:04:48 +02:00
|
|
|
foreach(l, list)
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " %d", lfirsti(l));
|
|
|
|
appendStringInfoChar(str, ')');
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-12-05 00:20:32 +01:00
|
|
|
static void
|
|
|
|
_outCreateStmt(StringInfo str, CreateStmt *node)
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " CREATE :relname ");
|
|
|
|
_outToken(str, node->relname);
|
1999-02-02 04:45:56 +01:00
|
|
|
|
|
|
|
appendStringInfo(str, " :istemp %s ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->istemp ? "true" : "false");
|
1999-02-02 04:45:56 +01:00
|
|
|
|
|
|
|
appendStringInfo(str, " :columns ");
|
1997-12-05 00:20:32 +01:00
|
|
|
_outNode(str, node->tableElts);
|
1998-12-20 08:13:36 +01:00
|
|
|
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " :inhRelnames ");
|
1998-01-06 19:53:02 +01:00
|
|
|
_outNode(str, node->inhRelnames);
|
1998-12-20 08:13:36 +01:00
|
|
|
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " :constraints ");
|
1998-01-06 19:53:02 +01:00
|
|
|
_outNode(str, node->constraints);
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
1997-12-05 00:20:32 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
_outIndexStmt(StringInfo str, IndexStmt *node)
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " INDEX :idxname ");
|
|
|
|
_outToken(str, node->idxname);
|
|
|
|
appendStringInfo(str, " :relname ");
|
|
|
|
_outToken(str, node->relname);
|
|
|
|
appendStringInfo(str, " :accessMethod ");
|
|
|
|
_outToken(str, node->accessMethod);
|
|
|
|
appendStringInfo(str, " :indexParams ");
|
1997-12-05 00:20:32 +01:00
|
|
|
_outNode(str, node->indexParams);
|
1998-12-20 08:13:36 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :withClause ");
|
|
|
|
_outNode(str, node->withClause);
|
1998-12-20 08:13:36 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :whereClause ");
|
|
|
|
_outNode(str, node->whereClause);
|
1998-12-20 08:13:36 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :rangetable ");
|
|
|
|
_outNode(str, node->rangetable);
|
1998-12-14 09:11:17 +01:00
|
|
|
|
2000-07-15 02:01:41 +02:00
|
|
|
appendStringInfo(str, " :unique %s :primary %s ",
|
|
|
|
node->unique ? "true" : "false",
|
|
|
|
node->primary ? "true" : "false");
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
1997-12-05 00:20:32 +01:00
|
|
|
|
1998-05-10 01:46:35 +02:00
|
|
|
static void
|
|
|
|
_outSelectStmt(StringInfo str, SelectStmt *node)
|
|
|
|
{
|
2000-10-05 21:11:39 +02:00
|
|
|
/* XXX this is pretty durn incomplete */
|
1998-12-14 09:11:17 +01:00
|
|
|
appendStringInfo(str, "SELECT :where ");
|
1998-05-10 01:46:35 +02:00
|
|
|
_outNode(str, node->whereClause);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_outFuncCall(StringInfo str, FuncCall *node)
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "FUNCTION ");
|
|
|
|
_outToken(str, node->funcname);
|
|
|
|
appendStringInfo(str, " :args ");
|
1998-05-10 01:46:35 +02:00
|
|
|
_outNode(str, node->args);
|
1999-12-10 08:37:35 +01:00
|
|
|
appendStringInfo(str, " :agg_star %s :agg_distinct %s ",
|
|
|
|
node->agg_star ? "true" : "false",
|
|
|
|
node->agg_distinct ? "true" : "false");
|
1998-05-10 01:46:35 +02:00
|
|
|
}
|
1998-09-01 06:40:42 +02:00
|
|
|
|
1997-12-05 00:20:32 +01:00
|
|
|
static void
|
|
|
|
_outColumnDef(StringInfo str, ColumnDef *node)
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " COLUMNDEF :colname ");
|
|
|
|
_outToken(str, node->colname);
|
|
|
|
appendStringInfo(str, " :typename ");
|
1997-12-05 00:20:32 +01:00
|
|
|
_outNode(str, node->typename);
|
1999-10-04 01:55:40 +02:00
|
|
|
appendStringInfo(str, " :is_not_null %s :is_sequence %s :raw_default ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->is_not_null ? "true" : "false",
|
1999-10-04 01:55:40 +02:00
|
|
|
node->is_sequence ? "true" : "false");
|
|
|
|
_outNode(str, node->raw_default);
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :cooked_default ");
|
|
|
|
_outToken(str, node->cooked_default);
|
|
|
|
appendStringInfo(str, " :constraints ");
|
1998-01-06 19:53:02 +01:00
|
|
|
_outNode(str, node->constraints);
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_outTypeName(StringInfo str, TypeName *node)
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " TYPENAME :name ");
|
|
|
|
_outToken(str, node->name);
|
|
|
|
appendStringInfo(str, " :timezone %s :setof %s typmod %d :arrayBounds ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->timezone ? "true" : "false",
|
|
|
|
node->setof ? "true" : "false",
|
|
|
|
node->typmod);
|
1998-01-07 00:19:49 +01:00
|
|
|
_outNode(str, node->arrayBounds);
|
|
|
|
}
|
1997-12-05 00:20:32 +01:00
|
|
|
|
2000-01-17 01:14:49 +01:00
|
|
|
static void
|
|
|
|
_outTypeCast(StringInfo str, TypeCast *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " TYPECAST :arg ");
|
|
|
|
_outNode(str, node->arg);
|
|
|
|
appendStringInfo(str, " :typename ");
|
|
|
|
_outNode(str, node->typename);
|
|
|
|
}
|
|
|
|
|
1997-12-05 00:20:32 +01:00
|
|
|
static void
|
|
|
|
_outIndexElem(StringInfo str, IndexElem *node)
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " INDEXELEM :name ");
|
|
|
|
_outToken(str, node->name);
|
|
|
|
appendStringInfo(str, " :args ");
|
1998-01-06 19:53:02 +01:00
|
|
|
_outNode(str, node->args);
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :class ");
|
|
|
|
_outToken(str, node->class);
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
1997-12-05 00:20:32 +01:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outQuery(StringInfo str, Query *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-01-21 17:08:55 +01:00
|
|
|
|
1998-12-15 03:24:15 +01:00
|
|
|
appendStringInfo(str, " QUERY :command %d ", node->commandType);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1997-12-05 00:20:32 +01:00
|
|
|
if (node->utilityStmt)
|
|
|
|
{
|
2000-09-29 20:21:41 +02:00
|
|
|
/*
|
|
|
|
* Hack to make up for lack of outfuncs for utility-stmt nodes
|
|
|
|
*/
|
1997-12-05 00:20:32 +01:00
|
|
|
switch (nodeTag(node->utilityStmt))
|
|
|
|
{
|
|
|
|
case T_CreateStmt:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :create ");
|
|
|
|
_outToken(str, ((CreateStmt *) (node->utilityStmt))->relname);
|
|
|
|
appendStringInfo(str, " ");
|
1997-12-05 00:20:32 +01:00
|
|
|
_outNode(str, node->utilityStmt);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_IndexStmt:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :index ");
|
|
|
|
_outToken(str, ((IndexStmt *) (node->utilityStmt))->idxname);
|
|
|
|
appendStringInfo(str, " on ");
|
|
|
|
_outToken(str, ((IndexStmt *) (node->utilityStmt))->relname);
|
|
|
|
appendStringInfo(str, " ");
|
1997-12-05 00:20:32 +01:00
|
|
|
_outNode(str, node->utilityStmt);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_NotifyStmt:
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :notify ");
|
2000-01-14 01:53:21 +01:00
|
|
|
_outToken(str, ((NotifyStmt *) (node->utilityStmt))->relname);
|
1997-12-05 00:20:32 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :utility ? ");
|
1997-12-05 00:20:32 +01:00
|
|
|
}
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
1998-12-18 15:45:09 +01:00
|
|
|
appendStringInfo(str, " :utility <>");
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :resultRelation %d :into ",
|
2000-01-14 01:53:21 +01:00
|
|
|
node->resultRelation);
|
|
|
|
_outToken(str, node->into);
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :isPortal %s :isBinary %s :isTemp %s"
|
2000-10-05 21:11:39 +02:00
|
|
|
" :hasAggs %s :hasSubLinks %s :rtable ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->isPortal ? "true" : "false",
|
|
|
|
node->isBinary ? "true" : "false",
|
|
|
|
node->isTemp ? "true" : "false",
|
2000-09-29 20:21:41 +02:00
|
|
|
node->hasAggs ? "true" : "false",
|
|
|
|
node->hasSubLinks ? "true" : "false");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->rtable);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :jointree ");
|
|
|
|
_outNode(str, node->jointree);
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :rowMarks ");
|
|
|
|
_outIntList(str, node->rowMarks);
|
|
|
|
|
2000-10-05 21:11:39 +02:00
|
|
|
appendStringInfo(str, " :targetList ");
|
|
|
|
_outNode(str, node->targetList);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :groupClause ");
|
|
|
|
_outNode(str, node->groupClause);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :havingQual ");
|
1998-02-26 05:46:47 +01:00
|
|
|
_outNode(str, node->havingQual);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
2000-10-05 21:11:39 +02:00
|
|
|
appendStringInfo(str, " :distinctClause ");
|
|
|
|
_outNode(str, node->distinctClause);
|
Hi!
INTERSECT and EXCEPT is available for postgresql-v6.4!
The patch against v6.4 is included at the end of the current text
(in uuencoded form!)
I also included the text of my Master's Thesis. (a postscript
version). I hope that you find something of it useful and would be
happy if parts of it find their way into the PostgreSQL documentation
project (If so, tell me, then I send the sources of the document!)
The contents of the document are:
-) The first chapter might be of less interest as it gives only an
overview on SQL.
-) The second chapter gives a description on much of PostgreSQL's
features (like user defined types etc. and how to use these features)
-) The third chapter starts with an overview of PostgreSQL's internal
structure with focus on the stages a query has to pass (i.e. parser,
planner/optimizer, executor). Then a detailed description of the
implementation of the Having clause and the Intersect/Except logic is
given.
Originally I worked on v6.3.2 but never found time enough to prepare
and post a patch. Now I applied the changes to v6.4 to get Intersect
and Except working with the new version. Chapter 3 of my documentation
deals with the changes against v6.3.2, so keep that in mind when
comparing the parts of the code printed there with the patched sources
of v6.4.
Here are some remarks on the patch. There are some things that have
still to be done but at the moment I don't have time to do them
myself. (I'm doing my military service at the moment) Sorry for that
:-(
-) I used a rewrite technique for the implementation of the Except/Intersect
logic which rewrites the query to a semantically equivalent query before
it is handed to the rewrite system (for views, rules etc.), planner,
executor etc.
-) In v6.3.2 the types of the attributes of two select statements
connected by the UNION keyword had to match 100%. In v6.4 the types
only need to be familiar (i.e. int and float can be mixed). Since this
feature did not exist when I worked on Intersect/Except it
does not work correctly for Except/Intersect queries WHEN USED IN
COMBINATION WITH UNIONS! (i.e. sometimes the wrong type is used for the
resulting table. This is because until now the types of the attributes of
the first select statement have been used for the resulting table.
When Intersects and/or Excepts are used in combination with Unions it
might happen, that the first select statement of the original query
appears at another position in the query which will be executed. The reason
for this is the technique used for the implementation of
Except/Intersect which does a query rewrite!)
NOTE: It is NOT broken for pure UNION queries and pure INTERSECT/EXCEPT
queries!!!
-) I had to add the field intersect_clause to some data structures
but did not find time to implement printfuncs for the new field.
This does NOT break the debug modes but when an Except/Intersect
is used the query debug output will be the already rewritten query.
-) Massive changes to the grammar rules for SELECT and INSERT statements
have been necessary (see comments in gram.y and documentation for
deatails) in order to be able to use mixed queries like
(SELECT ... UNION (SELECT ... EXCEPT SELECT)) INTERSECT SELECT...;
-) When using UNION/EXCEPT/INTERSECT you will get:
NOTICE: equal: "Don't know if nodes of type xxx are equal".
I did not have time to add comparsion support for all the needed nodes,
but the default behaviour of the function equal met my requirements.
I did not dare to supress this message!
That's the reason why the regression test for union will fail: These
messages are also included in the union.out file!
-) Somebody of you changed the union_planner() function for v6.4
(I copied the targetlist to new_tlist and that was removed and
replaced by a cleanup of the original targetlist). These chnages
violated some having queries executed against views so I changed
it back again. I did not have time to examine the differences between the
two versions but now it works :-)
If you want to find out, try the file queries/view_having.sql on
both versions and compare the results . Two queries won't produce a
correct result with your version.
regards
Stefan
1999-01-18 01:10:17 +01:00
|
|
|
|
2000-10-05 21:11:39 +02:00
|
|
|
appendStringInfo(str, " :sortClause ");
|
|
|
|
_outNode(str, node->sortClause);
|
2000-09-29 20:21:41 +02:00
|
|
|
|
1998-10-22 15:52:24 +02:00
|
|
|
appendStringInfo(str, " :limitOffset ");
|
|
|
|
_outNode(str, node->limitOffset);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-10-22 15:52:24 +02:00
|
|
|
appendStringInfo(str, " :limitCount ");
|
|
|
|
_outNode(str, node->limitCount);
|
2000-10-05 21:11:39 +02:00
|
|
|
|
|
|
|
appendStringInfo(str, " :setOperations ");
|
|
|
|
_outNode(str, node->setOperations);
|
2000-11-12 01:37:02 +01:00
|
|
|
|
|
|
|
appendStringInfo(str, " :resultRelations ");
|
|
|
|
_outIntList(str, node->resultRelations);
|
1998-01-06 19:53:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-01-07 00:19:49 +01:00
|
|
|
_outSortClause(StringInfo str, SortClause *node)
|
1998-01-06 19:53:02 +01:00
|
|
|
{
|
1999-08-21 05:49:17 +02:00
|
|
|
appendStringInfo(str, " SORTCLAUSE :tleSortGroupRef %d :sortop %u ",
|
|
|
|
node->tleSortGroupRef, node->sortop);
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_outGroupClause(StringInfo str, GroupClause *node)
|
|
|
|
{
|
1999-08-21 05:49:17 +02:00
|
|
|
appendStringInfo(str, " GROUPCLAUSE :tleSortGroupRef %d :sortop %u ",
|
|
|
|
node->tleSortGroupRef, node->sortop);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-10-05 21:11:39 +02:00
|
|
|
static void
|
|
|
|
_outSetOperationStmt(StringInfo str, SetOperationStmt *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " SETOPERATIONSTMT :op %d :all %s :larg ",
|
|
|
|
(int) node->op,
|
|
|
|
node->all ? "true" : "false");
|
|
|
|
_outNode(str, node->larg);
|
|
|
|
appendStringInfo(str, " :rarg ");
|
|
|
|
_outNode(str, node->rarg);
|
|
|
|
appendStringInfo(str, " :colTypes ");
|
|
|
|
_outIntList(str, node->colTypes);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
|
|
|
* print the basic stuff of all nodes that inherit from Plan
|
2000-11-12 01:37:02 +01:00
|
|
|
*
|
|
|
|
* NOTE: we deliberately omit the execution state (EState)
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outPlanInfo(StringInfo str, Plan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
2000-11-12 01:37:02 +01:00
|
|
|
":startup_cost %.2f :total_cost %.2f :rows %.0f :width %d :qptargetlist ",
|
2000-02-15 21:49:31 +01:00
|
|
|
node->startup_cost,
|
|
|
|
node->total_cost,
|
2000-01-09 01:26:47 +01:00
|
|
|
node->plan_rows,
|
2000-11-12 01:37:02 +01:00
|
|
|
node->plan_width);
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->targetlist);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :qpqual ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->qual);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :lefttree ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->lefttree);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :righttree ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->righttree);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-02-13 04:27:47 +01:00
|
|
|
appendStringInfo(str, " :extprm ");
|
|
|
|
_outIntList(str, node->extParam);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-02-13 04:27:47 +01:00
|
|
|
appendStringInfo(str, " :locprm ");
|
|
|
|
_outIntList(str, node->locParam);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-02-13 04:27:47 +01:00
|
|
|
appendStringInfo(str, " :initplan ");
|
|
|
|
_outNode(str, node->initPlan);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-12-15 03:32:57 +01:00
|
|
|
appendStringInfo(str, " :nprm %d ", node->nParamExec);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Stuff from plannodes.h
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outPlan(StringInfo str, Plan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " PLAN ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outResult(StringInfo str, Result *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " RESULT ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :resconstantqual ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->resconstantqual);
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Append is a subclass of Plan.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 22:59:27 +02:00
|
|
|
_outAppend(StringInfo str, Append *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " APPEND ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
1998-07-15 16:54:39 +02:00
|
|
|
appendStringInfo(str, " :appendplans ");
|
|
|
|
_outNode(str, node->appendplans);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-11-12 01:37:02 +01:00
|
|
|
appendStringInfo(str, " :isTarget %s ",
|
|
|
|
node->isTarget ? "true" : "false");
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Join is a subclass of Plan
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outJoin(StringInfo str, Join *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " JOIN ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :jointype %d :joinqual ",
|
|
|
|
(int) node->jointype);
|
|
|
|
_outNode(str, node->joinqual);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* NestLoop is a subclass of Join
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outNestLoop(StringInfo str, NestLoop *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " NESTLOOP ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :jointype %d :joinqual ",
|
|
|
|
(int) node->join.jointype);
|
|
|
|
_outNode(str, node->join.joinqual);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* MergeJoin is a subclass of Join
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outMergeJoin(StringInfo str, MergeJoin *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " MERGEJOIN ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :jointype %d :joinqual ",
|
|
|
|
(int) node->join.jointype);
|
|
|
|
_outNode(str, node->join.joinqual);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :mergeclauses ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->mergeclauses);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* HashJoin is a subclass of Join.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outHashJoin(StringInfo str, HashJoin *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " HASHJOIN ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :jointype %d :joinqual ",
|
|
|
|
(int) node->join.jointype);
|
|
|
|
_outNode(str, node->join.joinqual);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :hashclauses ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->hashclauses);
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :hashjoinop %u ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->hashjoinop);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-02-13 04:27:47 +01:00
|
|
|
static void
|
|
|
|
_outSubPlan(StringInfo str, SubPlan *node)
|
|
|
|
{
|
1998-12-15 03:24:15 +01:00
|
|
|
appendStringInfo(str, " SUBPLAN :plan ");
|
1998-02-13 04:27:47 +01:00
|
|
|
_outNode(str, node->plan);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
|
|
|
appendStringInfo(str, " :planid %u :rtable ", node->plan_id);
|
1998-02-13 04:27:47 +01:00
|
|
|
_outNode(str, node->rtable);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-02-13 04:27:47 +01:00
|
|
|
appendStringInfo(str, " :setprm ");
|
1998-02-26 05:46:47 +01:00
|
|
|
_outIntList(str, node->setParam);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-02-13 04:27:47 +01:00
|
|
|
appendStringInfo(str, " :parprm ");
|
1998-02-26 05:46:47 +01:00
|
|
|
_outIntList(str, node->parParam);
|
1998-12-15 03:24:15 +01:00
|
|
|
|
1998-02-13 04:27:47 +01:00
|
|
|
appendStringInfo(str, " :slink ");
|
|
|
|
_outNode(str, node->sublink);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Scan is a subclass of Node
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outScan(StringInfo str, Scan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " SCAN ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
1999-05-10 02:46:32 +02:00
|
|
|
appendStringInfo(str, " :scanrelid %u ", node->scanrelid);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* SeqScan is a subclass of Scan
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outSeqScan(StringInfo str, SeqScan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " SEQSCAN ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
1999-05-10 02:46:32 +02:00
|
|
|
appendStringInfo(str, " :scanrelid %u ", node->scanrelid);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* IndexScan is a subclass of Scan
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outIndexScan(StringInfo str, IndexScan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " INDEXSCAN ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
1999-05-10 02:46:32 +02:00
|
|
|
appendStringInfo(str, " :scanrelid %u :indxid ", node->scan.scanrelid);
|
1997-09-07 07:04:48 +02:00
|
|
|
_outIntList(str, node->indxid);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :indxqual ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->indxqual);
|
|
|
|
|
1998-11-22 11:48:45 +01:00
|
|
|
appendStringInfo(str, " :indxqualorig ");
|
|
|
|
_outNode(str, node->indxqualorig);
|
|
|
|
|
1999-08-09 08:20:27 +02:00
|
|
|
appendStringInfo(str, " :indxorderdir %d ", node->indxorderdir);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1999-11-23 21:07:06 +01:00
|
|
|
/*
|
|
|
|
* TidScan is a subclass of Scan
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outTidScan(StringInfo str, TidScan *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " TIDSCAN ");
|
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :scanrelid %u ", node->scan.scanrelid);
|
|
|
|
appendStringInfo(str, " :needrescan %d ", node->needRescan);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :tideval ");
|
|
|
|
_outNode(str, node->tideval);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
/*
|
|
|
|
* SubqueryScan is a subclass of Scan
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outSubqueryScan(StringInfo str, SubqueryScan *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " SUBQUERYSCAN ");
|
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :scanrelid %u :subplan ", node->scan.scanrelid);
|
|
|
|
_outNode(str, node->subplan);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
2000-06-19 00:44:35 +02:00
|
|
|
* Material is a subclass of Plan
|
2000-03-24 03:58:25 +01:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outMaterial(StringInfo str, Material *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " MATERIAL ");
|
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
2000-06-19 00:44:35 +02:00
|
|
|
* Sort is a subclass of Plan
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outSort(StringInfo str, Sort *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " SORT ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
2000-06-19 00:44:35 +02:00
|
|
|
appendStringInfo(str, " :keycount %d ", node->keycount);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-09-08 22:59:27 +02:00
|
|
|
_outAgg(StringInfo str, Agg *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " AGG ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outGroup(StringInfo str, Group *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " GRP ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
|
|
|
/* the actual Group fields */
|
1998-12-15 03:32:57 +01:00
|
|
|
appendStringInfo(str, " :numCols %d :tuplePerGroup %s ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->numCols,
|
|
|
|
node->tuplePerGroup ? "true" : "false");
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outUnique(StringInfo str, Unique *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-04-27 01:39:10 +02:00
|
|
|
int i;
|
|
|
|
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " UNIQUE ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
2000-06-19 00:44:35 +02:00
|
|
|
appendStringInfo(str, " :numCols %d :uniqColIdx ",
|
2000-01-27 19:11:50 +01:00
|
|
|
node->numCols);
|
2000-04-27 01:39:10 +02:00
|
|
|
for (i = 0; i < node->numCols; i++)
|
|
|
|
appendStringInfo(str, "%d ", (int) node->uniqColIdx[i]);
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2000-10-05 21:11:39 +02:00
|
|
|
static void
|
|
|
|
_outSetOp(StringInfo str, SetOp *node)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
appendStringInfo(str, " SETOP ");
|
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :cmd %d :numCols %d :dupColIdx ",
|
|
|
|
(int) node->cmd, node->numCols);
|
|
|
|
for (i = 0; i < node->numCols; i++)
|
|
|
|
appendStringInfo(str, "%d ", (int) node->dupColIdx[i]);
|
|
|
|
appendStringInfo(str, " :flagColIdx %d ",
|
|
|
|
(int) node->flagColIdx);
|
|
|
|
}
|
|
|
|
|
2000-10-26 23:38:24 +02:00
|
|
|
static void
|
|
|
|
_outLimit(StringInfo str, Limit *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " LIMIT ");
|
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :limitOffset ");
|
|
|
|
_outNode(str, node->limitOffset);
|
|
|
|
appendStringInfo(str, " :limitCount ");
|
|
|
|
_outNode(str, node->limitCount);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
2000-06-19 00:44:35 +02:00
|
|
|
* Hash is a subclass of Plan
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outHash(StringInfo str, Hash *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-04-27 04:58:07 +02:00
|
|
|
appendStringInfo(str, " HASH ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :hashkey ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->hashkey);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Stuff from primnodes.h.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Resdom is a subclass of Node
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outResdom(StringInfo str, Resdom *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str,
|
2000-04-12 19:17:23 +02:00
|
|
|
" RESDOM :resno %d :restype %u :restypmod %d :resname ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->resno,
|
|
|
|
node->restype,
|
|
|
|
node->restypmod);
|
2000-01-14 01:53:21 +01:00
|
|
|
_outToken(str, node->resname);
|
|
|
|
appendStringInfo(str, " :reskey %d :reskeyop %u :ressortgroupref %d :resjunk %s ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->reskey,
|
2000-01-14 01:53:21 +01:00
|
|
|
node->reskeyop,
|
1999-08-21 05:49:17 +02:00
|
|
|
node->ressortgroupref,
|
1999-05-25 18:15:34 +02:00
|
|
|
node->resjunk ? "true" : "false");
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outFjoin(StringInfo str, Fjoin *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-12-15 03:24:15 +01:00
|
|
|
appendStringInfo(str, " FJOIN :initialized %s :nNodes %d ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->fj_initialized ? "true" : "false",
|
|
|
|
node->fj_nNodes);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
appendStringInfo(str, " :innerNode ");
|
|
|
|
_outNode(str, node->fj_innerNode);
|
|
|
|
|
2000-11-16 06:51:07 +01:00
|
|
|
appendStringInfo(str, " :results @ 0x%p :alwaysdone",
|
|
|
|
node->fj_results);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
for (i = 0; i < node->fj_nNodes; i++)
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, (node->fj_alwaysDone[i]) ? "true" : "false");
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Expr is a subclass of Node
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outExpr(StringInfo str, Expr *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *opstr = NULL;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-12-15 05:00:46 +01:00
|
|
|
appendStringInfo(str, " EXPR :typeOid %u ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->typeOid);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
switch (node->opType)
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
case OP_EXPR:
|
|
|
|
opstr = "op";
|
|
|
|
break;
|
|
|
|
case FUNC_EXPR:
|
|
|
|
opstr = "func";
|
|
|
|
break;
|
|
|
|
case OR_EXPR:
|
|
|
|
opstr = "or";
|
|
|
|
break;
|
|
|
|
case AND_EXPR:
|
|
|
|
opstr = "and";
|
|
|
|
break;
|
|
|
|
case NOT_EXPR:
|
|
|
|
opstr = "not";
|
|
|
|
break;
|
1998-02-13 04:27:47 +01:00
|
|
|
case SUBPLAN_EXPR:
|
|
|
|
opstr = "subp";
|
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :opType ");
|
|
|
|
_outToken(str, opstr);
|
|
|
|
appendStringInfo(str, " :oper ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->oper);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :args ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->args);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Var is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outVar(StringInfo str, Var *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
|
|
|
" VAR :varno %d :varattno %d :vartype %u :vartypmod %d ",
|
|
|
|
node->varno,
|
|
|
|
node->varattno,
|
|
|
|
node->vartype,
|
|
|
|
node->vartypmod);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str, " :varlevelsup %u :varnoold %d :varoattno %d",
|
|
|
|
node->varlevelsup,
|
|
|
|
node->varnoold,
|
|
|
|
node->varoattno);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Const is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outConst(StringInfo str, Const *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
|
|
|
" CONST :consttype %u :constlen %d :constisnull %s :constvalue ",
|
|
|
|
node->consttype,
|
|
|
|
node->constlen,
|
|
|
|
node->constisnull ? "true" : "false");
|
1998-12-15 05:00:46 +01:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
if (node->constisnull)
|
1998-01-07 16:32:47 +01:00
|
|
|
appendStringInfo(str, "<>");
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
|
|
|
_outDatum(str, node->constvalue, node->consttype);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str, " :constbyval %s ",
|
|
|
|
node->constbyval ? "true" : "false");
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-01-24 01:28:37 +01:00
|
|
|
* Aggref
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1999-05-26 00:43:53 +02:00
|
|
|
_outAggref(StringInfo str, Aggref *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " AGGREG :aggname ");
|
|
|
|
_outToken(str, node->aggname);
|
|
|
|
appendStringInfo(str, " :basetype %u :aggtype %u :target ",
|
2000-07-17 05:05:41 +02:00
|
|
|
node->basetype, node->aggtype);
|
1998-01-06 19:53:02 +01:00
|
|
|
_outNode(str, node->target);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
2000-07-17 05:05:41 +02:00
|
|
|
appendStringInfo(str, " :aggstar %s :aggdistinct %s ",
|
1999-12-13 02:27:21 +01:00
|
|
|
node->aggstar ? "true" : "false",
|
|
|
|
node->aggdistinct ? "true" : "false");
|
|
|
|
/* aggno is not dumped */
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-01-17 05:53:46 +01:00
|
|
|
/*
|
|
|
|
* SubLink
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outSubLink(StringInfo str, SubLink *node)
|
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
|
|
|
" SUBLINK :subLinkType %d :useor %s :lefthand ",
|
|
|
|
node->subLinkType,
|
|
|
|
node->useor ? "true" : "false");
|
1998-01-17 05:53:46 +01:00
|
|
|
_outNode(str, node->lefthand);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
1998-01-17 05:53:46 +01:00
|
|
|
appendStringInfo(str, " :oper ");
|
1998-01-20 06:05:08 +01:00
|
|
|
_outNode(str, node->oper);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
1998-01-17 05:53:46 +01:00
|
|
|
appendStringInfo(str, " :subselect ");
|
|
|
|
_outNode(str, node->subselect);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* ArrayRef is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 22:59:27 +02:00
|
|
|
_outArrayRef(StringInfo str, ArrayRef *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
1999-07-18 21:02:49 +02:00
|
|
|
" ARRAYREF :refelemtype %u :refattrlength %d :refelemlength %d ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->refelemtype,
|
|
|
|
node->refattrlength,
|
|
|
|
node->refelemlength);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str, " :refelembyval %c :refupperindex ",
|
|
|
|
node->refelembyval ? 't' : 'f');
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->refupperindexpr);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :reflowerindex ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->reflowerindexpr);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :refexpr ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->refexpr);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :refassgnexpr ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->refassgnexpr);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Func is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outFunc(StringInfo str, Func *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-08-08 17:43:12 +02:00
|
|
|
appendStringInfo(str, " FUNC :funcid %u :functype %u ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->funcid,
|
2000-08-08 17:43:12 +02:00
|
|
|
node->functype);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Oper is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outOper(StringInfo str, Oper *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
|
|
|
" OPER :opno %u :opid %u :opresulttype %u ",
|
|
|
|
node->opno,
|
|
|
|
node->opid,
|
|
|
|
node->opresulttype);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Param is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outParam(StringInfo str, Param *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " PARAM :paramkind %d :paramid %d :paramname ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->paramkind,
|
2000-01-14 01:53:21 +01:00
|
|
|
node->paramid);
|
|
|
|
_outToken(str, node->paramname);
|
2000-08-08 17:43:12 +02:00
|
|
|
appendStringInfo(str, " :paramtype %u ", node->paramtype);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-09-12 23:07:18 +02:00
|
|
|
/*
|
|
|
|
* FieldSelect
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outFieldSelect(StringInfo str, FieldSelect *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " FIELDSELECT :arg ");
|
|
|
|
_outNode(str, node->arg);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :fieldnum %d :resulttype %u :resulttypmod %d ",
|
|
|
|
node->fieldnum, node->resulttype, node->resulttypmod);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RelabelType
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outRelabelType(StringInfo str, RelabelType *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " RELABELTYPE :arg ");
|
|
|
|
_outNode(str, node->arg);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :resulttype %u :resulttypmod %d ",
|
|
|
|
node->resulttype, node->resulttypmod);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RangeTblRef
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outRangeTblRef(StringInfo str, RangeTblRef *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " RANGETBLREF %d ",
|
|
|
|
node->rtindex);
|
|
|
|
}
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
/*
|
|
|
|
* FromExpr
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outFromExpr(StringInfo str, FromExpr *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " FROMEXPR :fromlist ");
|
|
|
|
_outNode(str, node->fromlist);
|
|
|
|
appendStringInfo(str, " :quals ");
|
|
|
|
_outNode(str, node->quals);
|
|
|
|
}
|
|
|
|
|
2000-09-12 23:07:18 +02:00
|
|
|
/*
|
|
|
|
* JoinExpr
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outJoinExpr(StringInfo str, JoinExpr *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " JOINEXPR :jointype %d :isNatural %s :larg ",
|
|
|
|
(int) node->jointype,
|
|
|
|
node->isNatural ? "true" : "false");
|
|
|
|
_outNode(str, node->larg);
|
|
|
|
appendStringInfo(str, " :rarg ");
|
|
|
|
_outNode(str, node->rarg);
|
|
|
|
appendStringInfo(str, " :using ");
|
|
|
|
_outNode(str, node->using);
|
|
|
|
appendStringInfo(str, " :quals ");
|
|
|
|
_outNode(str, node->quals);
|
|
|
|
appendStringInfo(str, " :alias ");
|
|
|
|
_outNode(str, node->alias);
|
|
|
|
appendStringInfo(str, " :colnames ");
|
|
|
|
_outNode(str, node->colnames);
|
|
|
|
appendStringInfo(str, " :colvars ");
|
|
|
|
_outNode(str, node->colvars);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Stuff from relation.h
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2000-01-09 01:26:47 +01:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
static void
|
1999-05-26 00:43:53 +02:00
|
|
|
_outRelOptInfo(StringInfo str, RelOptInfo *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-12-15 05:00:46 +01:00
|
|
|
appendStringInfo(str, " RELOPTINFO :relids ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outIntList(str, node->relids);
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :rows %.0f :width %d :targetlist ",
|
2000-01-09 01:26:47 +01:00
|
|
|
node->rows,
|
2000-09-29 20:21:41 +02:00
|
|
|
node->width);
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->targetlist);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :pathlist ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->pathlist);
|
2000-02-15 21:49:31 +01:00
|
|
|
appendStringInfo(str, " :cheapest_startup_path ");
|
|
|
|
_outNode(str, node->cheapest_startup_path);
|
|
|
|
appendStringInfo(str, " :cheapest_total_path ");
|
|
|
|
_outNode(str, node->cheapest_total_path);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :pruneable %s :issubquery %s :indexed %s :pages %ld :tuples %.0f :subplan ",
|
|
|
|
node->pruneable ? "true" : "false",
|
|
|
|
node->issubquery ? "true" : "false",
|
|
|
|
node->indexed ? "true" : "false",
|
|
|
|
node->pages,
|
|
|
|
node->tuples);
|
|
|
|
_outNode(str, node->subplan);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :baserestrictinfo ");
|
|
|
|
_outNode(str, node->baserestrictinfo);
|
|
|
|
appendStringInfo(str, " :baserestrictcost %.2f :outerjoinset ",
|
2000-09-12 23:07:18 +02:00
|
|
|
node->baserestrictcost);
|
|
|
|
_outIntList(str, node->outerjoinset);
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :joininfo ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->joininfo);
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :innerjoin ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->innerjoin);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-01-09 01:26:47 +01:00
|
|
|
static void
|
|
|
|
_outIndexOptInfo(StringInfo str, IndexOptInfo *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " INDEXOPTINFO :indexoid %u :pages %ld :tuples %g ",
|
|
|
|
node->indexoid,
|
|
|
|
node->pages,
|
|
|
|
node->tuples);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* TargetEntry is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outTargetEntry(StringInfo str, TargetEntry *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-12-15 05:00:46 +01:00
|
|
|
appendStringInfo(str, " TARGETENTRY :resdom ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->resdom);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :expr ");
|
|
|
|
_outNode(str, node->expr);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outRangeTblEntry(StringInfo str, RangeTblEntry *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " RTE :relname ");
|
|
|
|
_outToken(str, node->relname);
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :relid %u ",
|
2000-09-12 23:07:18 +02:00
|
|
|
node->relid);
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :subquery ");
|
|
|
|
_outNode(str, node->subquery);
|
|
|
|
appendStringInfo(str, " :alias ");
|
2000-09-12 23:07:18 +02:00
|
|
|
_outNode(str, node->alias);
|
|
|
|
appendStringInfo(str, " :eref ");
|
|
|
|
_outNode(str, node->eref);
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :inh %s :inFromCl %s :checkForRead %s"
|
|
|
|
" :checkForWrite %s :checkAsUser %u",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->inh ? "true" : "false",
|
|
|
|
node->inFromCl ? "true" : "false",
|
2000-09-29 20:21:41 +02:00
|
|
|
node->checkForRead ? "true" : "false",
|
|
|
|
node->checkForWrite ? "true" : "false",
|
|
|
|
node->checkAsUser);
|
1999-01-21 17:08:55 +01:00
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Path is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outPath(StringInfo str, Path *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-02-15 21:49:31 +01:00
|
|
|
appendStringInfo(str,
|
2000-04-12 19:17:23 +02:00
|
|
|
" PATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->pathtype,
|
2000-02-15 21:49:31 +01:00
|
|
|
node->startup_cost,
|
|
|
|
node->total_cost);
|
1999-02-10 04:52:54 +01:00
|
|
|
_outNode(str, node->pathkeys);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* IndexPath is a subclass of Path.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outIndexPath(StringInfo str, IndexPath *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
2000-02-15 21:49:31 +01:00
|
|
|
" INDEXPATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->path.pathtype,
|
2000-02-15 21:49:31 +01:00
|
|
|
node->path.startup_cost,
|
|
|
|
node->path.total_cost);
|
1999-02-10 04:52:54 +01:00
|
|
|
_outNode(str, node->path.pathkeys);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :indexid ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outIntList(str, node->indexid);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :indexqual ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->indexqual);
|
1999-08-16 04:17:58 +02:00
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
appendStringInfo(str, " :indexscandir %d :joinrelids ",
|
|
|
|
(int) node->indexscandir);
|
1999-08-16 04:17:58 +02:00
|
|
|
_outIntList(str, node->joinrelids);
|
2000-03-22 23:08:35 +01:00
|
|
|
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :alljoinquals %s :rows %.2f ",
|
|
|
|
node->alljoinquals ? "true" : "false",
|
2000-03-22 23:08:35 +01:00
|
|
|
node->rows);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1999-11-23 21:07:06 +01:00
|
|
|
/*
|
|
|
|
* TidPath is a subclass of Path.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outTidPath(StringInfo str, TidPath *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str,
|
2000-02-15 21:49:31 +01:00
|
|
|
" TIDPATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
|
1999-11-23 21:07:06 +01:00
|
|
|
node->path.pathtype,
|
2000-02-15 21:49:31 +01:00
|
|
|
node->path.startup_cost,
|
|
|
|
node->path.total_cost);
|
1999-11-23 21:07:06 +01:00
|
|
|
_outNode(str, node->path.pathkeys);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :tideval ");
|
|
|
|
_outNode(str, node->tideval);
|
|
|
|
|
2000-11-12 01:37:02 +01:00
|
|
|
appendStringInfo(str, " :unjoined_relids ");
|
1999-11-23 21:07:06 +01:00
|
|
|
_outIntList(str, node->unjoined_relids);
|
|
|
|
}
|
|
|
|
|
2000-11-12 01:37:02 +01:00
|
|
|
/*
|
|
|
|
* AppendPath is a subclass of Path.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outAppendPath(StringInfo str, AppendPath *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str,
|
|
|
|
" APPENDPATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
|
|
|
|
node->path.pathtype,
|
|
|
|
node->path.startup_cost,
|
|
|
|
node->path.total_cost);
|
|
|
|
_outNode(str, node->path.pathkeys);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :subpaths ");
|
|
|
|
_outNode(str, node->subpaths);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1999-02-12 07:43:53 +01:00
|
|
|
* NestPath is a subclass of Path
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1999-05-26 00:43:53 +02:00
|
|
|
_outNestPath(StringInfo str, NestPath *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
2000-02-15 21:49:31 +01:00
|
|
|
" NESTPATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->path.pathtype,
|
2000-02-15 21:49:31 +01:00
|
|
|
node->path.startup_cost,
|
|
|
|
node->path.total_cost);
|
1999-02-10 04:52:54 +01:00
|
|
|
_outNode(str, node->path.pathkeys);
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :jointype %d :outerjoinpath ",
|
|
|
|
(int) node->jointype);
|
2000-02-07 05:41:04 +01:00
|
|
|
_outNode(str, node->outerjoinpath);
|
|
|
|
appendStringInfo(str, " :innerjoinpath ");
|
|
|
|
_outNode(str, node->innerjoinpath);
|
|
|
|
appendStringInfo(str, " :joinrestrictinfo ");
|
|
|
|
_outNode(str, node->joinrestrictinfo);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-02-12 07:43:53 +01:00
|
|
|
* MergePath is a subclass of NestPath.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outMergePath(StringInfo str, MergePath *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
2000-02-15 21:49:31 +01:00
|
|
|
" MERGEPATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->jpath.path.pathtype,
|
2000-02-15 21:49:31 +01:00
|
|
|
node->jpath.path.startup_cost,
|
|
|
|
node->jpath.path.total_cost);
|
1999-02-10 04:52:54 +01:00
|
|
|
_outNode(str, node->jpath.path.pathkeys);
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :jointype %d :outerjoinpath ",
|
|
|
|
(int) node->jpath.jointype);
|
2000-02-07 05:41:04 +01:00
|
|
|
_outNode(str, node->jpath.outerjoinpath);
|
|
|
|
appendStringInfo(str, " :innerjoinpath ");
|
|
|
|
_outNode(str, node->jpath.innerjoinpath);
|
|
|
|
appendStringInfo(str, " :joinrestrictinfo ");
|
|
|
|
_outNode(str, node->jpath.joinrestrictinfo);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :path_mergeclauses ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->path_mergeclauses);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :outersortkeys ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->outersortkeys);
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :innersortkeys ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->innersortkeys);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-02-12 07:43:53 +01:00
|
|
|
* HashPath is a subclass of NestPath.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outHashPath(StringInfo str, HashPath *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
2000-02-15 21:49:31 +01:00
|
|
|
" HASHPATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->jpath.path.pathtype,
|
2000-02-15 21:49:31 +01:00
|
|
|
node->jpath.path.startup_cost,
|
|
|
|
node->jpath.path.total_cost);
|
1999-02-10 04:52:54 +01:00
|
|
|
_outNode(str, node->jpath.path.pathkeys);
|
2000-09-12 23:07:18 +02:00
|
|
|
appendStringInfo(str, " :jointype %d :outerjoinpath ",
|
|
|
|
(int) node->jpath.jointype);
|
2000-02-07 05:41:04 +01:00
|
|
|
_outNode(str, node->jpath.outerjoinpath);
|
|
|
|
appendStringInfo(str, " :innerjoinpath ");
|
|
|
|
_outNode(str, node->jpath.innerjoinpath);
|
|
|
|
appendStringInfo(str, " :joinrestrictinfo ");
|
|
|
|
_outNode(str, node->jpath.joinrestrictinfo);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :path_hashclauses ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->path_hashclauses);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-08-16 04:17:58 +02:00
|
|
|
* PathKeyItem is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1999-08-16 04:17:58 +02:00
|
|
|
_outPathKeyItem(StringInfo str, PathKeyItem *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-08-16 04:17:58 +02:00
|
|
|
appendStringInfo(str, " PATHKEYITEM :sortop %u :key ",
|
|
|
|
node->sortop);
|
|
|
|
_outNode(str, node->key);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-02-03 21:15:53 +01:00
|
|
|
* RestrictInfo is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1999-05-26 00:43:53 +02:00
|
|
|
_outRestrictInfo(StringInfo str, RestrictInfo *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-02-05 20:59:31 +01:00
|
|
|
appendStringInfo(str, " RESTRICTINFO :clause ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->clause);
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :ispusheddown %s :subclauseindices ",
|
|
|
|
node->ispusheddown ? "true" : "false");
|
1999-08-16 04:17:58 +02:00
|
|
|
_outNode(str, node->subclauseindices);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-08-16 04:17:58 +02:00
|
|
|
appendStringInfo(str, " :mergejoinoperator %u ", node->mergejoinoperator);
|
|
|
|
appendStringInfo(str, " :left_sortop %u ", node->left_sortop);
|
|
|
|
appendStringInfo(str, " :right_sortop %u ", node->right_sortop);
|
1998-12-20 08:13:36 +01:00
|
|
|
appendStringInfo(str, " :hashjoinoperator %u ", node->hashjoinoperator);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1998-09-01 05:29:17 +02:00
|
|
|
* JoinInfo is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1999-05-26 00:43:53 +02:00
|
|
|
_outJoinInfo(StringInfo str, JoinInfo *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-02-18 01:49:48 +01:00
|
|
|
appendStringInfo(str, " JINFO :unjoined_relids ");
|
|
|
|
_outIntList(str, node->unjoined_relids);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-02-03 21:15:53 +01:00
|
|
|
appendStringInfo(str, " :jinfo_restrictinfo ");
|
|
|
|
_outNode(str, node->jinfo_restrictinfo);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print the value of a Datum given its type.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outDatum(StringInfo str, Datum value, Oid type)
|
|
|
|
{
|
2000-11-16 23:30:52 +01:00
|
|
|
int16 typeLength;
|
1997-09-08 04:41:22 +02:00
|
|
|
bool byValue;
|
2000-07-12 04:37:39 +02:00
|
|
|
Size length;
|
|
|
|
char *s;
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* find some information about the type and the "real" length of the
|
|
|
|
* datum.
|
|
|
|
*/
|
2000-11-16 23:30:52 +01:00
|
|
|
get_typlenbyval(type, &typeLength, &byValue);
|
2000-07-12 04:37:39 +02:00
|
|
|
length = datumGetSize(value, byValue, typeLength);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
if (byValue)
|
|
|
|
{
|
|
|
|
s = (char *) (&value);
|
2000-07-12 04:37:39 +02:00
|
|
|
appendStringInfo(str, " %u [ ", (unsigned int) length);
|
2000-03-17 03:36:41 +01:00
|
|
|
for (i = 0; i < (int) sizeof(Datum); i++)
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "%d ", (int) (s[i]));
|
1998-12-20 08:13:36 +01:00
|
|
|
appendStringInfo(str, "] ");
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
|
|
|
{ /* !byValue */
|
|
|
|
s = (char *) DatumGetPointer(value);
|
|
|
|
if (!PointerIsValid(s))
|
1998-12-20 08:13:36 +01:00
|
|
|
appendStringInfo(str, " 0 [ ] ");
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
|
|
|
{
|
2000-07-12 04:37:39 +02:00
|
|
|
appendStringInfo(str, " %u [ ", (unsigned int) length);
|
2000-03-17 03:36:41 +01:00
|
|
|
for (i = 0; i < (int) length; i++)
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "%d ", (int) (s[i]));
|
1998-12-20 08:13:36 +01:00
|
|
|
appendStringInfo(str, "] ");
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outIter(StringInfo str, Iter *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-12-20 08:13:36 +01:00
|
|
|
appendStringInfo(str, " ITER :iterexpr ");
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->iterexpr);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outStream(StringInfo str, Stream *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
2000-11-16 06:51:07 +01:00
|
|
|
" STREAM :pathptr @ %p :cinfo @ %p :clausetype %p :upstream @ %p ",
|
|
|
|
node->pathptr,
|
|
|
|
node->cinfo,
|
|
|
|
node->clausetype,
|
|
|
|
node->upstream);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-05-25 18:15:34 +02:00
|
|
|
appendStringInfo(str,
|
2000-11-16 06:51:07 +01:00
|
|
|
" :downstream @ %p :groupup %d :groupcost %f :groupsel %f ",
|
|
|
|
node->downstream,
|
1999-05-25 18:15:34 +02:00
|
|
|
node->groupup,
|
|
|
|
node->groupcost,
|
|
|
|
node->groupsel);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-12-23 20:50:54 +01:00
|
|
|
static void
|
|
|
|
_outAExpr(StringInfo str, A_Expr *node)
|
|
|
|
{
|
2000-05-26 00:43:12 +02:00
|
|
|
appendStringInfo(str, " AEXPR ");
|
1998-05-10 01:46:35 +02:00
|
|
|
switch (node->oper)
|
|
|
|
{
|
|
|
|
case AND:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "AND ");
|
1998-05-10 01:46:35 +02:00
|
|
|
break;
|
|
|
|
case OR:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "OR ");
|
1998-05-10 01:46:35 +02:00
|
|
|
break;
|
|
|
|
case NOT:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "NOT ");
|
1998-05-10 01:46:35 +02:00
|
|
|
break;
|
|
|
|
case ISNULL:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "ISNULL ");
|
1998-05-10 01:46:35 +02:00
|
|
|
break;
|
|
|
|
case NOTNULL:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "NOTNULL ");
|
1998-05-10 01:46:35 +02:00
|
|
|
break;
|
2000-05-26 00:43:12 +02:00
|
|
|
case OP:
|
2000-01-14 01:53:21 +01:00
|
|
|
_outToken(str, node->opname);
|
|
|
|
appendStringInfo(str, " ");
|
1998-05-10 01:46:35 +02:00
|
|
|
break;
|
2000-05-26 00:43:12 +02:00
|
|
|
default:
|
|
|
|
appendStringInfo(str, "?? ");
|
|
|
|
break;
|
1998-05-10 01:46:35 +02:00
|
|
|
}
|
1997-12-23 20:50:54 +01:00
|
|
|
_outNode(str, node->lexpr);
|
2000-05-26 00:43:12 +02:00
|
|
|
appendStringInfo(str, " ");
|
1997-12-23 20:50:54 +01:00
|
|
|
_outNode(str, node->rexpr);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_outValue(StringInfo str, Value *value)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
switch (value->type)
|
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
case T_Integer:
|
1998-12-18 15:45:09 +01:00
|
|
|
appendStringInfo(str, " %ld ", value->val.ival);
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
|
|
|
case T_Float:
|
2000-04-12 19:17:23 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We assume the value is a valid numeric literal and so does
|
|
|
|
* not need quoting.
|
2000-02-21 19:47:12 +01:00
|
|
|
*/
|
|
|
|
appendStringInfo(str, " %s ", value->val.str);
|
|
|
|
break;
|
|
|
|
case T_String:
|
|
|
|
appendStringInfo(str, " \"");
|
|
|
|
_outToken(str, value->val.str);
|
|
|
|
appendStringInfo(str, "\" ");
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
2000-10-31 11:22:13 +01:00
|
|
|
case T_BitString:
|
2000-10-31 14:59:53 +01:00
|
|
|
/* internal representation already has leading 'b' */
|
|
|
|
appendStringInfo(str, " %s ", value->val.str);
|
2000-10-31 11:22:13 +01:00
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
default:
|
2000-01-14 01:53:21 +01:00
|
|
|
elog(NOTICE, "_outValue: don't know how to print type %d ",
|
|
|
|
value->type);
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-12-23 20:50:54 +01:00
|
|
|
static void
|
|
|
|
_outIdent(StringInfo str, Ident *node)
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " IDENT ");
|
|
|
|
_outToken(str, node->name);
|
1997-12-23 20:50:54 +01:00
|
|
|
}
|
|
|
|
|
1999-02-23 09:01:47 +01:00
|
|
|
static void
|
|
|
|
_outAttr(StringInfo str, Attr *node)
|
|
|
|
{
|
2000-02-15 04:38:29 +01:00
|
|
|
appendStringInfo(str, " ATTR :relname ");
|
2000-01-14 01:53:21 +01:00
|
|
|
_outToken(str, node->relname);
|
2000-02-15 04:38:29 +01:00
|
|
|
appendStringInfo(str, " :attrs ");
|
|
|
|
_outNode(str, node->attrs);
|
1999-02-23 09:01:47 +01:00
|
|
|
}
|
|
|
|
|
1997-12-23 20:50:54 +01:00
|
|
|
static void
|
|
|
|
_outAConst(StringInfo str, A_Const *node)
|
|
|
|
{
|
1998-12-18 15:45:09 +01:00
|
|
|
appendStringInfo(str, "CONST ");
|
1997-12-23 20:50:54 +01:00
|
|
|
_outValue(str, &(node->val));
|
2000-01-17 01:14:49 +01:00
|
|
|
appendStringInfo(str, " :typename ");
|
|
|
|
_outNode(str, node->typename);
|
1997-12-23 20:50:54 +01:00
|
|
|
}
|
|
|
|
|
1998-12-04 16:34:49 +01:00
|
|
|
static void
|
|
|
|
_outConstraint(StringInfo str, Constraint *node)
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " ");
|
|
|
|
_outToken(str, node->name);
|
|
|
|
appendStringInfo(str, " :type ");
|
1998-12-04 16:34:49 +01:00
|
|
|
|
|
|
|
switch (node->contype)
|
|
|
|
{
|
|
|
|
case CONSTR_PRIMARY:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "PRIMARY KEY ");
|
1998-12-04 16:34:49 +01:00
|
|
|
_outNode(str, node->keys);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CONSTR_CHECK:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "CHECK :raw ");
|
1999-10-04 01:55:40 +02:00
|
|
|
_outNode(str, node->raw_expr);
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :cooked ");
|
|
|
|
_outToken(str, node->cooked_expr);
|
1998-12-04 16:34:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CONSTR_DEFAULT:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "DEFAULT :raw ");
|
1999-10-04 01:55:40 +02:00
|
|
|
_outNode(str, node->raw_expr);
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :cooked ");
|
|
|
|
_outToken(str, node->cooked_expr);
|
1998-12-04 16:34:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CONSTR_NOTNULL:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "NOT NULL");
|
1998-12-04 16:34:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CONSTR_UNIQUE:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "UNIQUE ");
|
1998-12-04 16:34:49 +01:00
|
|
|
_outNode(str, node->keys);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, "<unrecognized_constraint>");
|
1998-12-04 16:34:49 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-05-26 00:43:53 +02:00
|
|
|
_outCaseExpr(StringInfo str, CaseExpr *node)
|
1998-12-04 16:34:49 +01:00
|
|
|
{
|
2000-06-16 07:27:03 +02:00
|
|
|
appendStringInfo(str, " CASE :casetype %u :arg ",
|
|
|
|
node->casetype);
|
|
|
|
_outNode(str, node->arg);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :args ");
|
1998-12-04 16:34:49 +01:00
|
|
|
_outNode(str, node->args);
|
1998-12-20 08:13:36 +01:00
|
|
|
|
2000-06-16 07:27:03 +02:00
|
|
|
appendStringInfo(str, " :defresult ");
|
1998-12-04 16:34:49 +01:00
|
|
|
_outNode(str, node->defresult);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-05-26 00:43:53 +02:00
|
|
|
_outCaseWhen(StringInfo str, CaseWhen *node)
|
1998-12-04 16:34:49 +01:00
|
|
|
{
|
1998-12-18 15:45:09 +01:00
|
|
|
appendStringInfo(str, " WHEN ");
|
1998-12-04 16:34:49 +01:00
|
|
|
_outNode(str, node->expr);
|
1998-12-20 08:13:36 +01:00
|
|
|
|
1998-12-18 15:45:09 +01:00
|
|
|
appendStringInfo(str, " :then ");
|
1998-12-04 16:34:49 +01:00
|
|
|
_outNode(str, node->result);
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
|
|
|
* _outNode -
|
1997-09-07 07:04:48 +02:00
|
|
|
* converts a Node into ascii string and append it to 'str'
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outNode(StringInfo str, void *obj)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
if (obj == NULL)
|
|
|
|
{
|
1998-01-07 16:32:47 +01:00
|
|
|
appendStringInfo(str, "<>");
|
1997-09-07 07:04:48 +02:00
|
|
|
return;
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
if (IsA(obj, List))
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
List *l;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfoChar(str, '(');
|
1997-09-07 07:04:48 +02:00
|
|
|
foreach(l, (List *) obj)
|
|
|
|
{
|
|
|
|
_outNode(str, lfirst(l));
|
|
|
|
if (lnext(l))
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfoChar(str, ' ');
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfoChar(str, ')');
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
2000-02-15 21:49:31 +01:00
|
|
|
else if (IsA_Value(obj))
|
|
|
|
{
|
|
|
|
/* nodeRead does not want to see { } around these! */
|
|
|
|
_outValue(str, obj);
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
|
|
|
{
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfoChar(str, '{');
|
1997-09-07 07:04:48 +02:00
|
|
|
switch (nodeTag(obj))
|
|
|
|
{
|
1997-12-05 00:20:32 +01:00
|
|
|
case T_CreateStmt:
|
|
|
|
_outCreateStmt(str, obj);
|
|
|
|
break;
|
|
|
|
case T_IndexStmt:
|
|
|
|
_outIndexStmt(str, obj);
|
|
|
|
break;
|
|
|
|
case T_ColumnDef:
|
|
|
|
_outColumnDef(str, obj);
|
|
|
|
break;
|
1998-01-07 00:19:49 +01:00
|
|
|
case T_TypeName:
|
|
|
|
_outTypeName(str, obj);
|
|
|
|
break;
|
2000-01-17 01:14:49 +01:00
|
|
|
case T_TypeCast:
|
|
|
|
_outTypeCast(str, obj);
|
|
|
|
break;
|
1997-12-05 00:20:32 +01:00
|
|
|
case T_IndexElem:
|
|
|
|
_outIndexElem(str, obj);
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_Query:
|
|
|
|
_outQuery(str, obj);
|
|
|
|
break;
|
1998-01-07 00:19:49 +01:00
|
|
|
case T_SortClause:
|
|
|
|
_outSortClause(str, obj);
|
|
|
|
break;
|
|
|
|
case T_GroupClause:
|
|
|
|
_outGroupClause(str, obj);
|
1998-01-06 19:53:02 +01:00
|
|
|
break;
|
2000-10-05 21:11:39 +02:00
|
|
|
case T_SetOperationStmt:
|
|
|
|
_outSetOperationStmt(str, obj);
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_Plan:
|
|
|
|
_outPlan(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Result:
|
|
|
|
_outResult(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Append:
|
|
|
|
_outAppend(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Join:
|
|
|
|
_outJoin(str, obj);
|
|
|
|
break;
|
|
|
|
case T_NestLoop:
|
|
|
|
_outNestLoop(str, obj);
|
|
|
|
break;
|
|
|
|
case T_MergeJoin:
|
|
|
|
_outMergeJoin(str, obj);
|
|
|
|
break;
|
|
|
|
case T_HashJoin:
|
|
|
|
_outHashJoin(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Scan:
|
|
|
|
_outScan(str, obj);
|
|
|
|
break;
|
|
|
|
case T_SeqScan:
|
|
|
|
_outSeqScan(str, obj);
|
|
|
|
break;
|
|
|
|
case T_IndexScan:
|
|
|
|
_outIndexScan(str, obj);
|
|
|
|
break;
|
1999-11-23 21:07:06 +01:00
|
|
|
case T_TidScan:
|
|
|
|
_outTidScan(str, obj);
|
|
|
|
break;
|
2000-09-29 20:21:41 +02:00
|
|
|
case T_SubqueryScan:
|
|
|
|
_outSubqueryScan(str, obj);
|
|
|
|
break;
|
2000-03-24 03:58:25 +01:00
|
|
|
case T_Material:
|
|
|
|
_outMaterial(str, obj);
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_Sort:
|
|
|
|
_outSort(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Agg:
|
|
|
|
_outAgg(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Group:
|
|
|
|
_outGroup(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Unique:
|
|
|
|
_outUnique(str, obj);
|
|
|
|
break;
|
2000-10-05 21:11:39 +02:00
|
|
|
case T_SetOp:
|
|
|
|
_outSetOp(str, obj);
|
|
|
|
break;
|
2000-10-26 23:38:24 +02:00
|
|
|
case T_Limit:
|
|
|
|
_outLimit(str, obj);
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_Hash:
|
|
|
|
_outHash(str, obj);
|
|
|
|
break;
|
1998-02-13 04:27:47 +01:00
|
|
|
case T_SubPlan:
|
|
|
|
_outSubPlan(str, obj);
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_Resdom:
|
|
|
|
_outResdom(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Fjoin:
|
|
|
|
_outFjoin(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Expr:
|
|
|
|
_outExpr(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Var:
|
|
|
|
_outVar(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Const:
|
|
|
|
_outConst(str, obj);
|
|
|
|
break;
|
1999-01-24 01:28:37 +01:00
|
|
|
case T_Aggref:
|
|
|
|
_outAggref(str, obj);
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
1998-01-17 05:53:46 +01:00
|
|
|
case T_SubLink:
|
|
|
|
_outSubLink(str, obj);
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_ArrayRef:
|
|
|
|
_outArrayRef(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Func:
|
|
|
|
_outFunc(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Oper:
|
|
|
|
_outOper(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Param:
|
|
|
|
_outParam(str, obj);
|
|
|
|
break;
|
2000-09-12 23:07:18 +02:00
|
|
|
case T_FieldSelect:
|
|
|
|
_outFieldSelect(str, obj);
|
|
|
|
break;
|
|
|
|
case T_RelabelType:
|
|
|
|
_outRelabelType(str, obj);
|
|
|
|
break;
|
|
|
|
case T_RangeTblRef:
|
|
|
|
_outRangeTblRef(str, obj);
|
|
|
|
break;
|
2000-09-29 20:21:41 +02:00
|
|
|
case T_FromExpr:
|
|
|
|
_outFromExpr(str, obj);
|
|
|
|
break;
|
2000-09-12 23:07:18 +02:00
|
|
|
case T_JoinExpr:
|
|
|
|
_outJoinExpr(str, obj);
|
|
|
|
break;
|
1998-07-18 06:22:52 +02:00
|
|
|
case T_RelOptInfo:
|
1998-08-02 00:12:13 +02:00
|
|
|
_outRelOptInfo(str, obj);
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
2000-01-09 01:26:47 +01:00
|
|
|
case T_IndexOptInfo:
|
|
|
|
_outIndexOptInfo(str, obj);
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_TargetEntry:
|
|
|
|
_outTargetEntry(str, obj);
|
|
|
|
break;
|
|
|
|
case T_RangeTblEntry:
|
|
|
|
_outRangeTblEntry(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Path:
|
|
|
|
_outPath(str, obj);
|
|
|
|
break;
|
|
|
|
case T_IndexPath:
|
|
|
|
_outIndexPath(str, obj);
|
|
|
|
break;
|
1999-11-23 21:07:06 +01:00
|
|
|
case T_TidPath:
|
|
|
|
_outTidPath(str, obj);
|
|
|
|
break;
|
2000-11-12 01:37:02 +01:00
|
|
|
case T_AppendPath:
|
|
|
|
_outAppendPath(str, obj);
|
|
|
|
break;
|
1999-02-12 07:43:53 +01:00
|
|
|
case T_NestPath:
|
|
|
|
_outNestPath(str, obj);
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
|
|
|
case T_MergePath:
|
|
|
|
_outMergePath(str, obj);
|
|
|
|
break;
|
|
|
|
case T_HashPath:
|
|
|
|
_outHashPath(str, obj);
|
|
|
|
break;
|
1999-08-16 04:17:58 +02:00
|
|
|
case T_PathKeyItem:
|
|
|
|
_outPathKeyItem(str, obj);
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
1999-02-03 21:15:53 +01:00
|
|
|
case T_RestrictInfo:
|
|
|
|
_outRestrictInfo(str, obj);
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
1998-09-01 05:29:17 +02:00
|
|
|
case T_JoinInfo:
|
|
|
|
_outJoinInfo(str, obj);
|
1997-09-08 04:41:22 +02:00
|
|
|
break;
|
|
|
|
case T_Iter:
|
|
|
|
_outIter(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Stream:
|
|
|
|
_outStream(str, obj);
|
|
|
|
break;
|
1997-12-23 20:50:54 +01:00
|
|
|
case T_A_Expr:
|
|
|
|
_outAExpr(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Ident:
|
|
|
|
_outIdent(str, obj);
|
|
|
|
break;
|
|
|
|
case T_A_Const:
|
|
|
|
_outAConst(str, obj);
|
|
|
|
break;
|
1998-12-04 16:34:49 +01:00
|
|
|
case T_Constraint:
|
|
|
|
_outConstraint(str, obj);
|
|
|
|
break;
|
|
|
|
case T_CaseExpr:
|
|
|
|
_outCaseExpr(str, obj);
|
|
|
|
break;
|
|
|
|
case T_CaseWhen:
|
|
|
|
_outCaseWhen(str, obj);
|
|
|
|
break;
|
1999-02-23 09:01:47 +01:00
|
|
|
|
|
|
|
case T_VariableSetStmt:
|
|
|
|
break;
|
|
|
|
case T_SelectStmt:
|
|
|
|
_outSelectStmt(str, obj);
|
|
|
|
break;
|
|
|
|
case T_FuncCall:
|
|
|
|
_outFuncCall(str, obj);
|
|
|
|
break;
|
|
|
|
case T_Attr:
|
|
|
|
_outAttr(str, obj);
|
|
|
|
break;
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
default:
|
1998-01-07 06:42:47 +01:00
|
|
|
elog(NOTICE, "_outNode: don't know how to print type %d ",
|
1997-09-08 04:41:22 +02:00
|
|
|
nodeTag(obj));
|
|
|
|
break;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfoChar(str, '}');
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* nodeToString -
|
1999-04-25 05:19:27 +02:00
|
|
|
* returns the ascii representation of the Node as a palloc'd string
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1998-02-26 05:46:47 +01:00
|
|
|
char *
|
1996-07-09 08:22:35 +02:00
|
|
|
nodeToString(void *obj)
|
|
|
|
{
|
1999-05-25 18:15:34 +02:00
|
|
|
StringInfoData str;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-04-25 05:19:27 +02:00
|
|
|
/* see stringinfo.h for an explanation of this maneuver */
|
|
|
|
initStringInfo(&str);
|
|
|
|
_outNode(&str, obj);
|
|
|
|
return str.data;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|