1998-12-14 09:11:17 +01: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
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2002-11-24 22:52:15 +01:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.181 2002/11/24 21:52:13 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
|
2001-01-07 02:08:48 +01:00
|
|
|
* catalogs (eg. views).
|
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>
|
|
|
|
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "lib/stringinfo.h"
|
|
|
|
#include "nodes/nodes.h"
|
|
|
|
#include "nodes/parsenodes.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#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"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-05-10 01:46:35 +02:00
|
|
|
|
2001-01-08 01:31:43 +01:00
|
|
|
#define booltostr(x) ((x) ? "true" : "false")
|
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
static void _outDatum(StringInfo str, Datum value, int typlen, bool typbyval);
|
1997-09-08 04:41:22 +02:00
|
|
|
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
|
2001-01-07 02:08:48 +01:00
|
|
|
* read.c (either in pg_strtok() 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) ||
|
2001-01-08 01:31:43 +01:00
|
|
|
((*s == '+' || *s == '-') &&
|
|
|
|
(isdigit((unsigned char) s[1]) || 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
|
|
|
}
|
|
|
|
|
2001-01-08 01:31:43 +01:00
|
|
|
/*
|
|
|
|
* _outOidList -
|
|
|
|
* converts a List of OIDs
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outOidList(StringInfo str, List *list)
|
|
|
|
{
|
|
|
|
List *l;
|
|
|
|
|
|
|
|
appendStringInfoChar(str, '(');
|
|
|
|
foreach(l, list)
|
|
|
|
appendStringInfo(str, " %u", (Oid) lfirsti(l));
|
|
|
|
appendStringInfoChar(str, ')');
|
|
|
|
}
|
|
|
|
|
1997-12-05 00:20:32 +01:00
|
|
|
static void
|
|
|
|
_outCreateStmt(StringInfo str, CreateStmt *node)
|
|
|
|
{
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " CREATE :relation ");
|
|
|
|
_outNode(str, node->relation);
|
1999-02-02 04:45:56 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " :tableElts ");
|
1997-12-05 00:20:32 +01:00
|
|
|
_outNode(str, node->tableElts);
|
1998-12-20 08:13:36 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " :inhRelations ");
|
|
|
|
_outNode(str, node->inhRelations);
|
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);
|
2001-08-10 20:57:42 +02:00
|
|
|
|
2002-11-11 23:19:25 +01:00
|
|
|
appendStringInfo(str, " :hasoids %s :oncommit %d ",
|
|
|
|
booltostr(node->hasoids),
|
|
|
|
(int) node->oncommit);
|
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);
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " :relation ");
|
|
|
|
_outNode(str, node->relation);
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :accessMethod ");
|
|
|
|
_outToken(str, node->accessMethod);
|
|
|
|
appendStringInfo(str, " :indexParams ");
|
1997-12-05 00:20:32 +01:00
|
|
|
_outNode(str, node->indexParams);
|
1998-01-06 19:53:02 +01:00
|
|
|
appendStringInfo(str, " :whereClause ");
|
|
|
|
_outNode(str, node->whereClause);
|
|
|
|
appendStringInfo(str, " :rangetable ");
|
|
|
|
_outNode(str, node->rangetable);
|
2002-07-12 20:43:19 +02:00
|
|
|
appendStringInfo(str, " :unique %s :primary %s :isconstraint %s ",
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->unique),
|
2002-07-12 20:43:19 +02:00
|
|
|
booltostr(node->primary),
|
|
|
|
booltostr(node->isconstraint));
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
1997-12-05 00:20:32 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
static void
|
|
|
|
_outNotifyStmt(StringInfo str, NotifyStmt *node)
|
|
|
|
{
|
2002-08-29 02:17:06 +02:00
|
|
|
appendStringInfo(str, " NOTIFY :relation ");
|
2002-03-21 17:02:16 +01:00
|
|
|
_outNode(str, node->relation);
|
|
|
|
}
|
|
|
|
|
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 */
|
2002-08-29 02:17:06 +02:00
|
|
|
appendStringInfo(str, " SELECT :where ");
|
1998-05-10 01:46:35 +02:00
|
|
|
_outNode(str, node->whereClause);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_outFuncCall(StringInfo str, FuncCall *node)
|
|
|
|
{
|
2002-08-29 02:17:06 +02:00
|
|
|
appendStringInfo(str, " FUNCCALL ");
|
2002-04-09 22:35:55 +02:00
|
|
|
_outNode(str, node->funcname);
|
2000-01-14 01:53:21 +01:00
|
|
|
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 ",
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->agg_star),
|
|
|
|
booltostr(node->agg_distinct));
|
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);
|
2002-09-22 21:42:52 +02:00
|
|
|
appendStringInfo(str, " :inhcount %d :is_local %s :is_not_null %s :raw_default ",
|
|
|
|
node->inhcount,
|
|
|
|
booltostr(node->is_local),
|
2001-08-16 22:38:56 +02:00
|
|
|
booltostr(node->is_not_null));
|
1999-10-04 01:55:40 +02:00
|
|
|
_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);
|
2002-07-17 00:12:20 +02:00
|
|
|
appendStringInfo(str, " :support ");
|
|
|
|
_outNode(str, node->support);
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_outTypeName(StringInfo str, TypeName *node)
|
|
|
|
{
|
2002-03-29 20:06:29 +01:00
|
|
|
appendStringInfo(str, " TYPENAME :names ");
|
|
|
|
_outNode(str, node->names);
|
|
|
|
appendStringInfo(str, " :typeid %u :timezone %s :setof %s"
|
2002-08-10 22:44:48 +02:00
|
|
|
" :pct_type %s :typmod %d :arrayBounds ",
|
2002-03-29 20:06:29 +01:00
|
|
|
node->typeid,
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->timezone),
|
|
|
|
booltostr(node->setof),
|
2002-03-29 20:06:29 +01:00
|
|
|
booltostr(node->pct_type),
|
1999-05-25 18:15:34 +02:00
|
|
|
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);
|
2002-04-09 22:35:55 +02:00
|
|
|
appendStringInfo(str, " :funcname ");
|
|
|
|
_outNode(str, node->funcname);
|
2000-01-14 01:53:21 +01:00
|
|
|
appendStringInfo(str, " :args ");
|
1998-01-06 19:53:02 +01:00
|
|
|
_outNode(str, node->args);
|
2002-04-17 22:57:57 +02:00
|
|
|
appendStringInfo(str, " :opclass ");
|
|
|
|
_outNode(str, node->opclass);
|
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
|
|
|
{
|
2002-10-15 00:14:35 +02:00
|
|
|
appendStringInfo(str, " QUERY :command %d :source %d :utility ",
|
|
|
|
(int) node->commandType, (int) node->querySource);
|
1999-01-21 17:08:55 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
/*
|
|
|
|
* Hack to work around missing outfuncs routines for a lot of the
|
2002-09-04 22:31:48 +02:00
|
|
|
* utility-statement node types. (The only one we actually *need* for
|
|
|
|
* rules support is NotifyStmt.) Someday we ought to support 'em all,
|
|
|
|
* but for the meantime do this to avoid getting lots of warnings when
|
|
|
|
* running with debug_print_parse on.
|
2002-03-21 17:02:16 +01:00
|
|
|
*/
|
1997-12-05 00:20:32 +01:00
|
|
|
if (node->utilityStmt)
|
|
|
|
{
|
|
|
|
switch (nodeTag(node->utilityStmt))
|
|
|
|
{
|
|
|
|
case T_CreateStmt:
|
|
|
|
case T_IndexStmt:
|
|
|
|
case T_NotifyStmt:
|
2002-03-21 17:02:16 +01:00
|
|
|
_outNode(str, node->utilityStmt);
|
1997-12-05 00:20:32 +01:00
|
|
|
break;
|
|
|
|
default:
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, "?");
|
|
|
|
break;
|
1997-12-05 00:20:32 +01:00
|
|
|
}
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, "<>");
|
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);
|
2002-03-21 17:02:16 +01:00
|
|
|
_outNode(str, node->into);
|
2000-01-14 01:53:21 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " :isPortal %s :isBinary %s"
|
2000-10-05 21:11:39 +02:00
|
|
|
" :hasAggs %s :hasSubLinks %s :rtable ",
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->isPortal),
|
|
|
|
booltostr(node->isBinary),
|
|
|
|
booltostr(node->hasAggs),
|
|
|
|
booltostr(node->hasSubLinks));
|
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);
|
2002-10-15 00:14:35 +02:00
|
|
|
|
|
|
|
/* planner-internal fields are not written out */
|
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
|
|
|
{
|
2001-01-08 01:31:43 +01:00
|
|
|
appendStringInfo(str, " SORTCLAUSE :tleSortGroupRef %u :sortop %u ",
|
1999-08-21 05:49:17 +02:00
|
|
|
node->tleSortGroupRef, node->sortop);
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_outGroupClause(StringInfo str, GroupClause *node)
|
|
|
|
{
|
2001-01-08 01:31:43 +01:00
|
|
|
appendStringInfo(str, " GROUPCLAUSE :tleSortGroupRef %u :sortop %u ",
|
1999-08-21 05:49:17 +02:00
|
|
|
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,
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->all));
|
2000-10-05 21:11:39 +02:00
|
|
|
_outNode(str, node->larg);
|
|
|
|
appendStringInfo(str, " :rarg ");
|
|
|
|
_outNode(str, node->rarg);
|
|
|
|
appendStringInfo(str, " :colTypes ");
|
2001-01-08 01:31:43 +01:00
|
|
|
_outOidList(str, node->colTypes);
|
2000-10-05 21:11:39 +02:00
|
|
|
}
|
|
|
|
|
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 ",
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->isTarget));
|
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
|
|
|
|
2001-01-08 01:31:43 +01:00
|
|
|
appendStringInfo(str, " :planid %d :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);
|
2001-01-08 01:31:43 +01:00
|
|
|
_outOidList(str, node->indxid);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2002-05-12 22:10:05 +02:00
|
|
|
/*
|
|
|
|
* FunctionScan is a subclass of Scan
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outFunctionScan(StringInfo str, FunctionScan *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " FUNCTIONSCAN ");
|
|
|
|
_outPlanInfo(str, (Plan *) node);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :scanrelid %u ", node->scan.scanrelid);
|
|
|
|
}
|
|
|
|
|
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);
|
2002-11-06 23:31:24 +01:00
|
|
|
appendStringInfo(str, " :aggstrategy %d :numCols %d :numGroups %ld ",
|
|
|
|
(int) node->aggstrategy, node->numCols, node->numGroups);
|
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);
|
2002-11-06 01:00:45 +01:00
|
|
|
appendStringInfo(str, " :numCols %d ", node->numCols);
|
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
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int i;
|
2000-04-27 01:39:10 +02:00
|
|
|
|
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)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
int i;
|
2000-10-05 21:11:39 +02:00
|
|
|
|
|
|
|
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);
|
2001-01-08 01:31:43 +01:00
|
|
|
appendStringInfo(str, " :reskey %u :reskeyop %u :ressortgroupref %u :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,
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->resjunk));
|
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 ",
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->fj_initialized),
|
1999-05-25 18:15:34 +02:00
|
|
|
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++)
|
2001-01-08 01:31:43 +01:00
|
|
|
appendStringInfo(str,
|
|
|
|
booltostr(node->fj_alwaysDone[i]));
|
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;
|
2002-07-04 17:24:11 +02:00
|
|
|
case DISTINCT_EXPR:
|
|
|
|
opstr = "distinct";
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
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,
|
2001-01-08 01:31:43 +01:00
|
|
|
" VAR :varno %u :varattno %d :vartype %u :vartypmod %d ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->varno,
|
|
|
|
node->varattno,
|
|
|
|
node->vartype,
|
|
|
|
node->vartypmod);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
2001-01-08 01:31:43 +01:00
|
|
|
appendStringInfo(str, " :varlevelsup %u :varnoold %u :varoattno %d",
|
1999-05-25 18:15:34 +02:00
|
|
|
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,
|
2001-01-07 02:08:48 +01:00
|
|
|
" CONST :consttype %u :constlen %d :constbyval %s"
|
|
|
|
" :constisnull %s :constvalue ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->consttype,
|
|
|
|
node->constlen,
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->constbyval),
|
|
|
|
booltostr(node->constisnull));
|
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
|
2001-01-07 02:08:48 +01:00
|
|
|
_outDatum(str, node->constvalue, node->constlen, node->constbyval);
|
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
|
|
|
{
|
2002-04-11 22:00:18 +02:00
|
|
|
appendStringInfo(str, " AGGREG :aggfnoid %u :aggtype %u :target ",
|
|
|
|
node->aggfnoid, 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 ",
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->aggstar),
|
|
|
|
booltostr(node->aggdistinct));
|
1999-12-13 02:27:21 +01:00
|
|
|
/* 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,
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->useor));
|
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,
|
2002-09-04 22:31:48 +02:00
|
|
|
" ARRAYREF :refrestype %u :refattrlength %d :refelemlength %d ",
|
2002-08-26 19:54:02 +02:00
|
|
|
node->refrestype,
|
1999-05-25 18:15:34 +02:00
|
|
|
node->refattrlength,
|
|
|
|
node->refelemlength);
|
1998-12-15 05:00:46 +01:00
|
|
|
|
2002-08-26 19:54:02 +02:00
|
|
|
appendStringInfo(str,
|
2002-09-04 22:31:48 +02:00
|
|
|
":refelembyval %s :refelemalign %c :refupperindexpr ",
|
2002-08-26 19:54:02 +02:00
|
|
|
booltostr(node->refelembyval),
|
|
|
|
node->refelemalign);
|
1997-09-07 07:04:48 +02:00
|
|
|
_outNode(str, node->refupperindexpr);
|
|
|
|
|
2002-08-26 19:54:02 +02:00
|
|
|
appendStringInfo(str, " :reflowerindexpr ");
|
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
|
|
|
{
|
2002-05-13 01:43:04 +02:00
|
|
|
appendStringInfo(str,
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 23:35:25 +02:00
|
|
|
" FUNC :funcid %u :funcresulttype %u :funcretset %s :funcformat %d ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->funcid,
|
2002-05-13 01:43:04 +02:00
|
|
|
node->funcresulttype,
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 23:35:25 +02:00
|
|
|
booltostr(node->funcretset),
|
|
|
|
(int) node->funcformat);
|
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,
|
2002-09-04 22:31:48 +02:00
|
|
|
" OPER :opno %u :opid %u :opresulttype %u :opretset %s ",
|
1999-05-25 18:15:34 +02:00
|
|
|
node->opno,
|
|
|
|
node->opid,
|
2002-05-13 01:43:04 +02:00
|
|
|
node->opresulttype,
|
|
|
|
booltostr(node->opretset));
|
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 ",
|
2001-03-22 05:01:46 +01:00
|
|
|
node->fieldnum, node->resulttype, node->resulttypmod);
|
2000-09-12 23:07:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RelabelType
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outRelabelType(StringInfo str, RelabelType *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " RELABELTYPE :arg ");
|
|
|
|
_outNode(str, node->arg);
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 23:35:25 +02:00
|
|
|
appendStringInfo(str,
|
|
|
|
" :resulttype %u :resulttypmod %d :relabelformat %d ",
|
|
|
|
node->resulttype,
|
|
|
|
node->resulttypmod,
|
|
|
|
(int) node->relabelformat);
|
2000-09-12 23:07:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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,
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->isNatural));
|
2000-09-12 23:07:18 +02:00
|
|
|
_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);
|
2002-03-12 01:52:10 +01:00
|
|
|
appendStringInfo(str, " :rtindex %d ", node->rtindex);
|
2000-09-12 23:07:18 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
static void
|
|
|
|
_outAlias(StringInfo str, Alias *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " ALIAS :aliasname ");
|
|
|
|
_outToken(str, node->aliasname);
|
|
|
|
appendStringInfo(str, " :colnames ");
|
|
|
|
_outNode(str, node->colnames);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2002-03-22 03:56:37 +01:00
|
|
|
/* put alias + eref first to make dump more legible */
|
|
|
|
appendStringInfo(str, " RTE :alias ");
|
2000-09-12 23:07:18 +02:00
|
|
|
_outNode(str, node->alias);
|
|
|
|
appendStringInfo(str, " :eref ");
|
|
|
|
_outNode(str, node->eref);
|
2002-03-22 03:56:37 +01:00
|
|
|
appendStringInfo(str, " :rtekind %d ",
|
|
|
|
(int) node->rtekind);
|
|
|
|
switch (node->rtekind)
|
|
|
|
{
|
|
|
|
case RTE_RELATION:
|
|
|
|
case RTE_SPECIAL:
|
2002-04-28 21:54:29 +02:00
|
|
|
appendStringInfo(str, ":relid %u", node->relid);
|
2002-03-22 03:56:37 +01:00
|
|
|
break;
|
|
|
|
case RTE_SUBQUERY:
|
|
|
|
appendStringInfo(str, ":subquery ");
|
|
|
|
_outNode(str, node->subquery);
|
|
|
|
break;
|
2002-05-12 22:10:05 +02:00
|
|
|
case RTE_FUNCTION:
|
|
|
|
appendStringInfo(str, ":funcexpr ");
|
|
|
|
_outNode(str, node->funcexpr);
|
2002-08-29 02:17:06 +02:00
|
|
|
appendStringInfo(str, " :coldeflist ");
|
Attached are two patches to implement and document anonymous composite
types for Table Functions, as previously proposed on HACKERS. Here is a
brief explanation:
1. Creates a new pg_type typtype: 'p' for pseudo type (currently either
'b' for base or 'c' for catalog, i.e. a class).
2. Creates new builtin type of typtype='p' named RECORD. This is the
first of potentially several pseudo types.
3. Modify FROM clause grammer to accept:
SELECT * FROM my_func() AS m(colname1 type1, colname2 type1, ...)
where m is the table alias, colname1, etc are the column names, and
type1, etc are the column types.
4. When typtype == 'p' and the function return type is RECORD, a list
of column defs is required, and when typtype != 'p', it is
disallowed.
5. A check was added to ensure that the tupdesc provide via the parser
and the actual return tupdesc match in number and type of
attributes.
When creating a function you can do:
CREATE FUNCTION foo(text) RETURNS setof RECORD ...
When using it you can do:
SELECT * from foo(sqlstmt) AS (f1 int, f2 text, f3 timestamp)
or
SELECT * from foo(sqlstmt) AS f(f1 int, f2 text, f3 timestamp)
or
SELECT * from foo(sqlstmt) f(f1 int, f2 text, f3 timestamp)
Included in the patches are adjustments to the regression test sql and
expected files, and documentation.
p.s.
This potentially solves (or at least improves) the issue of builtin
Table Functions. They can be bootstrapped as returning RECORD, and
we can wrap system views around them with properly specified column
defs. For example:
CREATE VIEW pg_settings AS
SELECT s.name, s.setting
FROM show_all_settings()AS s(name text, setting text);
Then we can also add the UPDATE RULE that I previously posted to
pg_settings, and have pg_settings act like a virtual table, allowing
settings to be queried and set.
Joe Conway
2002-08-04 21:48:11 +02:00
|
|
|
_outNode(str, node->coldeflist);
|
2002-05-12 22:10:05 +02:00
|
|
|
break;
|
2002-03-22 03:56:37 +01:00
|
|
|
case RTE_JOIN:
|
2002-04-28 21:54:29 +02:00
|
|
|
appendStringInfo(str, ":jointype %d :joinaliasvars ",
|
2002-03-22 03:56:37 +01:00
|
|
|
(int) node->jointype);
|
2002-04-28 21:54:29 +02:00
|
|
|
_outNode(str, node->joinaliasvars);
|
2002-03-22 03:56:37 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
elog(ERROR, "bogus rte kind %d", (int) node->rtekind);
|
|
|
|
break;
|
|
|
|
}
|
2000-09-29 20:21:41 +02:00
|
|
|
appendStringInfo(str, " :inh %s :inFromCl %s :checkForRead %s"
|
|
|
|
" :checkForWrite %s :checkAsUser %u",
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->inh),
|
|
|
|
booltostr(node->inFromCl),
|
|
|
|
booltostr(node->checkForRead),
|
|
|
|
booltostr(node->checkForWrite),
|
2000-09-29 20:21:41 +02:00
|
|
|
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
|
|
|
|
2001-05-20 22:28:20 +02:00
|
|
|
appendStringInfo(str, " :indexinfo ");
|
|
|
|
_outNode(str, node->indexinfo);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
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
|
|
|
|
2002-11-24 22:52:15 +01:00
|
|
|
appendStringInfo(str, " :indexscandir %d :rows %.2f ",
|
|
|
|
(int) node->indexscandir,
|
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);
|
|
|
|
}
|
|
|
|
|
2002-11-06 01:00:45 +01:00
|
|
|
/*
|
|
|
|
* ResultPath is a subclass of Path.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outResultPath(StringInfo str, ResultPath *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str,
|
|
|
|
" RESULTPATH :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, " :subpath ");
|
|
|
|
_outNode(str, node->subpath);
|
|
|
|
|
|
|
|
appendStringInfo(str, " :constantqual ");
|
|
|
|
_outNode(str, node->constantqual);
|
|
|
|
}
|
|
|
|
|
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 ",
|
2001-01-08 01:31:43 +01:00
|
|
|
booltostr(node->ispusheddown));
|
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
|
2001-01-07 02:08:48 +01:00
|
|
|
_outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2001-01-07 02:08:48 +01:00
|
|
|
Size length,
|
|
|
|
i;
|
2000-07-12 04:37:39 +02:00
|
|
|
char *s;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
length = datumGetSize(value, typbyval, typlen);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
if (typbyval)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
|
|
|
s = (char *) (&value);
|
2000-07-12 04:37:39 +02:00
|
|
|
appendStringInfo(str, " %u [ ", (unsigned int) length);
|
2001-01-07 02:08:48 +01:00
|
|
|
for (i = 0; i < (Size) 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
|
2001-01-07 02:08:48 +01:00
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
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);
|
2001-01-07 02:08:48 +01:00
|
|
|
for (i = 0; i < 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2000-05-26 00:43:12 +02:00
|
|
|
case OP:
|
2002-04-17 01:08:12 +02:00
|
|
|
_outNode(str, node->name);
|
2000-01-14 01:53:21 +01:00
|
|
|
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)
|
|
|
|
{
|
2001-10-25 07:50:21 +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:
|
2002-03-06 07:10:59 +01:00
|
|
|
elog(WARNING, "_outValue: don't know how to print type %d ",
|
2000-01-14 01:53:21 +01:00
|
|
|
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
|
2002-03-21 17:02:16 +01:00
|
|
|
_outRangeVar(StringInfo str, RangeVar *node)
|
1997-12-23 20:50:54 +01:00
|
|
|
{
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " RANGEVAR :relation ");
|
2002-09-04 22:31:48 +02:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
/*
|
|
|
|
* we deliberately ignore catalogname here, since it is presently not
|
|
|
|
* semantically meaningful
|
|
|
|
*/
|
|
|
|
_outToken(str, node->schemaname);
|
|
|
|
appendStringInfo(str, " . ");
|
|
|
|
_outToken(str, node->relname);
|
|
|
|
appendStringInfo(str, " :inhopt %d :istemp %s",
|
2002-09-04 22:31:48 +02:00
|
|
|
(int) node->inhOpt,
|
|
|
|
booltostr(node->istemp));
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " :alias ");
|
|
|
|
_outNode(str, node->alias);
|
1997-12-23 20:50:54 +01:00
|
|
|
}
|
|
|
|
|
1999-02-23 09:01:47 +01:00
|
|
|
static void
|
2002-03-21 17:02:16 +01:00
|
|
|
_outColumnRef(StringInfo str, ColumnRef *node)
|
1999-02-23 09:01:47 +01:00
|
|
|
{
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " COLUMNREF :fields ");
|
|
|
|
_outNode(str, node->fields);
|
|
|
|
appendStringInfo(str, " :indirection ");
|
|
|
|
_outNode(str, node->indirection);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_outParamRef(StringInfo str, ParamRef *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " PARAMREF :number %d :fields ", node->number);
|
|
|
|
_outNode(str, node->fields);
|
|
|
|
appendStringInfo(str, " :indirection ");
|
|
|
|
_outNode(str, node->indirection);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
static void
|
|
|
|
_outExprFieldSelect(StringInfo str, ExprFieldSelect *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " EXPRFIELDSELECT :arg ");
|
|
|
|
_outNode(str, node->arg);
|
|
|
|
appendStringInfo(str, " :fields ");
|
|
|
|
_outNode(str, node->fields);
|
|
|
|
appendStringInfo(str, " :indirection ");
|
|
|
|
_outNode(str, node->indirection);
|
|
|
|
}
|
|
|
|
|
1998-12-04 16:34:49 +01:00
|
|
|
static void
|
|
|
|
_outConstraint(StringInfo str, Constraint *node)
|
|
|
|
{
|
2001-10-25 16:08:11 +02:00
|
|
|
appendStringInfo(str, " CONSTRAINT :name ");
|
2000-01-14 01:53:21 +01:00
|
|
|
_outToken(str, node->name);
|
|
|
|
appendStringInfo(str, " :type ");
|
1998-12-04 16:34:49 +01:00
|
|
|
|
|
|
|
switch (node->contype)
|
|
|
|
{
|
|
|
|
case CONSTR_PRIMARY:
|
2001-10-25 16:08:11 +02:00
|
|
|
appendStringInfo(str, "PRIMARY_KEY :keys ");
|
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:
|
2001-10-25 16:08:11 +02:00
|
|
|
appendStringInfo(str, "NOT_NULL");
|
1998-12-04 16:34:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CONSTR_UNIQUE:
|
2001-10-25 16:08:11 +02:00
|
|
|
appendStringInfo(str, "UNIQUE :keys ");
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-25 16:08:11 +02:00
|
|
|
static void
|
|
|
|
_outFkConstraint(StringInfo str, FkConstraint *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " FKCONSTRAINT :constr_name ");
|
|
|
|
_outToken(str, node->constr_name);
|
2002-03-21 17:02:16 +01:00
|
|
|
appendStringInfo(str, " :pktable ");
|
|
|
|
_outNode(str, node->pktable);
|
2001-10-25 16:08:11 +02:00
|
|
|
appendStringInfo(str, " :fk_attrs ");
|
|
|
|
_outNode(str, node->fk_attrs);
|
|
|
|
appendStringInfo(str, " :pk_attrs ");
|
|
|
|
_outNode(str, node->pk_attrs);
|
2002-07-12 20:43:19 +02:00
|
|
|
appendStringInfo(str, " :fk_matchtype %c :fk_upd_action %c :fk_del_action %c :deferrable %s :initdeferred %s :skip_validation %s",
|
|
|
|
node->fk_matchtype,
|
|
|
|
node->fk_upd_action,
|
|
|
|
node->fk_del_action,
|
2001-10-25 16:08:11 +02:00
|
|
|
booltostr(node->deferrable),
|
2002-07-12 20:43:19 +02:00
|
|
|
booltostr(node->initdeferred),
|
|
|
|
booltostr(node->skip_validation));
|
2001-10-25 16:08:11 +02:00
|
|
|
}
|
|
|
|
|
1998-12-04 16:34:49 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2001-06-20 00:39:12 +02:00
|
|
|
/*
|
|
|
|
* NullTest
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outNullTest(StringInfo str, NullTest *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " NULLTEST :arg ");
|
|
|
|
_outNode(str, node->arg);
|
|
|
|
appendStringInfo(str, " :nulltesttype %d ",
|
|
|
|
(int) node->nulltesttype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BooleanTest
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outBooleanTest(StringInfo str, BooleanTest *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " BOOLEANTEST :arg ");
|
|
|
|
_outNode(str, node->arg);
|
|
|
|
appendStringInfo(str, " :booltesttype %d ",
|
|
|
|
(int) node->booltesttype);
|
|
|
|
}
|
|
|
|
|
2002-09-01 00:10:48 +02:00
|
|
|
/*
|
|
|
|
* ConstraintTest
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outConstraintTest(StringInfo str, ConstraintTest *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " CONSTRAINTTEST :arg ");
|
|
|
|
_outNode(str, node->arg);
|
|
|
|
appendStringInfo(str, " :testtype %d :name ",
|
|
|
|
(int) node->testtype);
|
|
|
|
_outToken(str, node->name);
|
2002-11-15 03:50:21 +01:00
|
|
|
appendStringInfo(str, " :domain ");
|
|
|
|
_outToken(str, node->domname);
|
2002-09-01 00:10:48 +02:00
|
|
|
appendStringInfo(str, " :check_expr ");
|
|
|
|
_outNode(str, node->check_expr);
|
|
|
|
}
|
|
|
|
|
2002-11-15 03:50:21 +01:00
|
|
|
/*
|
|
|
|
* ConstraintTestValue
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outConstraintTestValue(StringInfo str, ConstraintTestValue *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " CONSTRAINTTESTVALUE :typeid %u :typemod %d ",
|
|
|
|
node->typeId,
|
|
|
|
node->typeMod);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DomainConstraintValue
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
_outDomainConstraintValue(StringInfo str, DomainConstraintValue *node)
|
|
|
|
{
|
|
|
|
appendStringInfo(str, " DOMAINCONSTRAINTVALUE ");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2001-01-20 01:15:59 +01:00
|
|
|
else if (IsA(obj, Integer) || IsA(obj, Float) || IsA(obj, String) || IsA(obj, BitString))
|
2000-02-15 21:49:31 +01:00
|
|
|
{
|
|
|
|
/* 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;
|
2002-03-21 17:02:16 +01:00
|
|
|
case T_NotifyStmt:
|
|
|
|
_outNotifyStmt(str, obj);
|
|
|
|
break;
|
|
|
|
case T_SelectStmt:
|
|
|
|
_outSelectStmt(str, obj);
|
|
|
|
break;
|
1997-12-05 00:20:32 +01:00
|
|
|
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;
|
2002-05-12 22:10:05 +02:00
|
|
|
case T_FunctionScan:
|
|
|
|
_outFunctionScan(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;
|
1997-09-08 04:41:22 +02:00
|
|
|
case T_TargetEntry:
|
|
|
|
_outTargetEntry(str, obj);
|
|
|
|
break;
|
2002-03-21 17:02:16 +01:00
|
|
|
case T_Alias:
|
|
|
|
_outAlias(str, obj);
|
|
|
|
break;
|
1997-09-08 04:41:22 +02:00
|
|
|
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;
|
2002-11-06 01:00:45 +01:00
|
|
|
case T_ResultPath:
|
|
|
|
_outResultPath(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;
|
1997-12-23 20:50:54 +01:00
|
|
|
case T_A_Expr:
|
|
|
|
_outAExpr(str, obj);
|
|
|
|
break;
|
2002-03-21 17:02:16 +01:00
|
|
|
case T_RangeVar:
|
|
|
|
_outRangeVar(str, obj);
|
|
|
|
break;
|
|
|
|
case T_ColumnRef:
|
|
|
|
_outColumnRef(str, obj);
|
|
|
|
break;
|
|
|
|
case T_ParamRef:
|
|
|
|
_outParamRef(str, obj);
|
|
|
|
break;
|
1997-12-23 20:50:54 +01:00
|
|
|
case T_A_Const:
|
|
|
|
_outAConst(str, obj);
|
|
|
|
break;
|
2002-03-21 17:02:16 +01:00
|
|
|
case T_ExprFieldSelect:
|
|
|
|
_outExprFieldSelect(str, obj);
|
|
|
|
break;
|
1998-12-04 16:34:49 +01:00
|
|
|
case T_Constraint:
|
|
|
|
_outConstraint(str, obj);
|
|
|
|
break;
|
2001-10-25 16:08:11 +02:00
|
|
|
case T_FkConstraint:
|
|
|
|
_outFkConstraint(str, obj);
|
|
|
|
break;
|
1998-12-04 16:34:49 +01:00
|
|
|
case T_CaseExpr:
|
|
|
|
_outCaseExpr(str, obj);
|
|
|
|
break;
|
|
|
|
case T_CaseWhen:
|
|
|
|
_outCaseWhen(str, obj);
|
|
|
|
break;
|
2001-06-20 00:39:12 +02:00
|
|
|
case T_NullTest:
|
|
|
|
_outNullTest(str, obj);
|
|
|
|
break;
|
|
|
|
case T_BooleanTest:
|
|
|
|
_outBooleanTest(str, obj);
|
|
|
|
break;
|
2002-09-01 00:10:48 +02:00
|
|
|
case T_ConstraintTest:
|
|
|
|
_outConstraintTest(str, obj);
|
|
|
|
break;
|
2002-11-15 03:50:21 +01:00
|
|
|
case T_ConstraintTestValue:
|
|
|
|
_outConstraintTestValue(str, obj);
|
|
|
|
break;
|
1999-02-23 09:01:47 +01:00
|
|
|
case T_FuncCall:
|
|
|
|
_outFuncCall(str, obj);
|
|
|
|
break;
|
2002-11-15 03:50:21 +01:00
|
|
|
case T_DomainConstraintValue:
|
|
|
|
_outDomainConstraintValue(str, obj);
|
|
|
|
break;
|
1999-02-23 09:01:47 +01:00
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
default:
|
2002-03-06 07:10:59 +01:00
|
|
|
elog(WARNING, "_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
|
|
|
}
|