1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* readfuncs.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* Reader functions for Postgres tree nodes.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2013-01-01 23:15:01 +01:00
|
|
|
* Portions Copyright (c) 1996-2013, 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
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/backend/nodes/readfuncs.c
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
2002-11-25 19:12:12 +01:00
|
|
|
* Path and Plan nodes do not have any readfuncs support, because we
|
2003-08-04 02:43:34 +02:00
|
|
|
* never have occasion to read them in. (There was once code here that
|
2002-12-13 20:46:01 +01:00
|
|
|
* claimed to read them, but it was broken as well as unused.) We
|
|
|
|
* never read executor state trees, either.
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
2008-08-29 01:09:48 +02:00
|
|
|
* Parse location fields are written out by outfuncs.c, but only for
|
|
|
|
* possible debugging use. When reading a location field, we discard
|
|
|
|
* the stored value and set the location field to -1 (ie, "unknown").
|
|
|
|
* This is because nodes coming from a stored rule should not be thought
|
|
|
|
* to have a known location in the current query's text.
|
|
|
|
*
|
1996-07-09 08:22:35 +02:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
#include "nodes/parsenodes.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "nodes/readfuncs.h"
|
2002-11-25 19:12:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macros to simplify reading of different kinds of fields. Use these
|
2003-08-04 02:43:34 +02:00
|
|
|
* wherever possible to reduce the chance for silly typos. Note that these
|
2002-11-25 19:12:12 +01:00
|
|
|
* hard-wire conventions about the names of the local variables in a Read
|
|
|
|
* routine.
|
|
|
|
*/
|
|
|
|
|
2004-05-26 06:41:50 +02:00
|
|
|
/* Macros for declaring appropriate local variables */
|
2002-11-25 19:12:12 +01:00
|
|
|
|
|
|
|
/* A few guys need only local_node */
|
|
|
|
#define READ_LOCALS_NO_FIELDS(nodeTypeName) \
|
|
|
|
nodeTypeName *local_node = makeNode(nodeTypeName)
|
|
|
|
|
|
|
|
/* And a few guys need only the pg_strtok support fields */
|
2004-05-26 06:41:50 +02:00
|
|
|
#define READ_TEMP_LOCALS() \
|
|
|
|
char *token; \
|
2012-07-01 04:27:49 +02:00
|
|
|
int length
|
2002-11-25 19:12:12 +01:00
|
|
|
|
2004-05-26 06:41:50 +02:00
|
|
|
/* ... but most need both */
|
|
|
|
#define READ_LOCALS(nodeTypeName) \
|
|
|
|
READ_LOCALS_NO_FIELDS(nodeTypeName); \
|
|
|
|
READ_TEMP_LOCALS()
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/* Read an integer field (anything written as ":fldname %d") */
|
|
|
|
#define READ_INT_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
|
|
|
local_node->fldname = atoi(token)
|
|
|
|
|
|
|
|
/* Read an unsigned integer field (anything written as ":fldname %u") */
|
|
|
|
#define READ_UINT_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
|
|
|
local_node->fldname = atoui(token)
|
|
|
|
|
|
|
|
/* Read an OID field (don't hard-wire assumption that OID is same as uint) */
|
|
|
|
#define READ_OID_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
|
|
|
local_node->fldname = atooid(token)
|
|
|
|
|
|
|
|
/* Read a char field (ie, one ascii character) */
|
|
|
|
#define READ_CHAR_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
|
|
|
local_node->fldname = token[0]
|
|
|
|
|
|
|
|
/* Read an enumerated-type field that was written as an integer code */
|
|
|
|
#define READ_ENUM_FIELD(fldname, enumtype) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
|
|
|
local_node->fldname = (enumtype) atoi(token)
|
|
|
|
|
|
|
|
/* Read a float field */
|
|
|
|
#define READ_FLOAT_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
|
|
|
local_node->fldname = atof(token)
|
|
|
|
|
|
|
|
/* Read a boolean field */
|
|
|
|
#define READ_BOOL_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
|
|
|
local_node->fldname = strtobool(token)
|
|
|
|
|
|
|
|
/* Read a character-string field */
|
|
|
|
#define READ_STRING_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
|
|
|
local_node->fldname = nullable_string(token, length)
|
|
|
|
|
2008-08-29 01:09:48 +02:00
|
|
|
/* Read a parse location field (and throw away the value, per notes above) */
|
|
|
|
#define READ_LOCATION_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
token = pg_strtok(&length); /* get field value */ \
|
2009-06-11 16:49:15 +02:00
|
|
|
local_node->fldname = -1 /* set field to "unknown" */
|
2008-08-29 01:09:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/* Read a Node field */
|
|
|
|
#define READ_NODE_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
2012-07-01 04:27:49 +02:00
|
|
|
(void) token; /* in case not used elsewhere */ \
|
2004-05-06 16:01:33 +02:00
|
|
|
local_node->fldname = nodeRead(NULL, 0)
|
2002-11-25 19:12:12 +01:00
|
|
|
|
2009-01-22 21:16:10 +01:00
|
|
|
/* Read a bitmapset field */
|
|
|
|
#define READ_BITMAPSET_FIELD(fldname) \
|
|
|
|
token = pg_strtok(&length); /* skip :fldname */ \
|
|
|
|
local_node->fldname = _readBitmapset()
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/* Routine exit */
|
|
|
|
#define READ_DONE() \
|
|
|
|
return local_node
|
2001-01-07 02:08:48 +01:00
|
|
|
|
|
|
|
|
2001-01-08 01:31:43 +01:00
|
|
|
/*
|
|
|
|
* NOTE: use atoi() to read values written with %d, or atoui() to read
|
|
|
|
* values written with %u in outfuncs.c. An exception is OID values,
|
2001-03-22 05:01:46 +01:00
|
|
|
* for which use atooid(). (As of 7.1, outfuncs.c writes OIDs as %u,
|
2001-01-08 01:31:43 +01:00
|
|
|
* but this will probably change in the future.)
|
|
|
|
*/
|
|
|
|
#define atoui(x) ((unsigned int) strtoul((x), NULL, 10))
|
|
|
|
|
|
|
|
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
|
|
|
|
|
|
|
|
#define strtobool(x) ((*(x) == 't') ? true : false)
|
|
|
|
|
|
|
|
#define nullable_string(token,length) \
|
2004-01-07 19:56:30 +01:00
|
|
|
((length) == 0 ? NULL : debackslash(token, length))
|
2001-01-08 01:31:43 +01:00
|
|
|
|
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
static Datum readDatum(bool typbyval);
|
|
|
|
|
2009-01-22 21:16:10 +01:00
|
|
|
/*
|
|
|
|
* _readBitmapset
|
|
|
|
*/
|
|
|
|
static Bitmapset *
|
|
|
|
_readBitmapset(void)
|
|
|
|
{
|
2009-06-11 16:49:15 +02:00
|
|
|
Bitmapset *result = NULL;
|
|
|
|
|
2009-01-22 21:16:10 +01:00
|
|
|
READ_TEMP_LOCALS();
|
|
|
|
|
|
|
|
token = pg_strtok(&length);
|
|
|
|
if (token == NULL)
|
|
|
|
elog(ERROR, "incomplete Bitmapset structure");
|
|
|
|
if (length != 1 || token[0] != '(')
|
|
|
|
elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
|
|
|
|
|
|
|
|
token = pg_strtok(&length);
|
|
|
|
if (token == NULL)
|
|
|
|
elog(ERROR, "incomplete Bitmapset structure");
|
|
|
|
if (length != 1 || token[0] != 'b')
|
|
|
|
elog(ERROR, "unrecognized token: \"%.*s\"", length, token);
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2009-06-11 16:49:15 +02:00
|
|
|
int val;
|
|
|
|
char *endptr;
|
2009-01-22 21:16:10 +01:00
|
|
|
|
|
|
|
token = pg_strtok(&length);
|
|
|
|
if (token == NULL)
|
|
|
|
elog(ERROR, "unterminated Bitmapset structure");
|
|
|
|
if (length == 1 && token[0] == ')')
|
|
|
|
break;
|
|
|
|
val = (int) strtol(token, &endptr, 10);
|
|
|
|
if (endptr != token + length)
|
|
|
|
elog(ERROR, "unrecognized integer: \"%.*s\"", length, token);
|
|
|
|
result = bms_add_member(result, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readQuery
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Query *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readQuery(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(Query);
|
|
|
|
|
|
|
|
READ_ENUM_FIELD(commandType, CmdType);
|
|
|
|
READ_ENUM_FIELD(querySource, QuerySource);
|
2012-06-10 21:20:04 +02:00
|
|
|
local_node->queryId = 0; /* not saved in output format */
|
2003-05-02 22:54:36 +02:00
|
|
|
READ_BOOL_FIELD(canSetTag);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(utilityStmt);
|
|
|
|
READ_INT_FIELD(resultRelation);
|
|
|
|
READ_BOOL_FIELD(hasAggs);
|
2008-12-28 19:54:01 +01:00
|
|
|
READ_BOOL_FIELD(hasWindowFuncs);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_BOOL_FIELD(hasSubLinks);
|
2008-08-02 23:32:01 +02:00
|
|
|
READ_BOOL_FIELD(hasDistinctOn);
|
2008-10-04 23:56:55 +02:00
|
|
|
READ_BOOL_FIELD(hasRecursive);
|
2011-02-26 00:56:23 +01:00
|
|
|
READ_BOOL_FIELD(hasModifyingCTE);
|
2009-10-28 15:55:47 +01:00
|
|
|
READ_BOOL_FIELD(hasForUpdate);
|
2008-10-04 23:56:55 +02:00
|
|
|
READ_NODE_FIELD(cteList);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(rtable);
|
|
|
|
READ_NODE_FIELD(jointree);
|
|
|
|
READ_NODE_FIELD(targetList);
|
2006-08-12 04:52:06 +02:00
|
|
|
READ_NODE_FIELD(returningList);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(groupClause);
|
|
|
|
READ_NODE_FIELD(havingQual);
|
2008-12-28 19:54:01 +01:00
|
|
|
READ_NODE_FIELD(windowClause);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(distinctClause);
|
|
|
|
READ_NODE_FIELD(sortClause);
|
|
|
|
READ_NODE_FIELD(limitOffset);
|
|
|
|
READ_NODE_FIELD(limitCount);
|
2006-04-30 20:30:40 +02:00
|
|
|
READ_NODE_FIELD(rowMarks);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(setOperations);
|
2010-08-07 04:44:09 +02:00
|
|
|
READ_NODE_FIELD(constraintDeps);
|
2000-11-12 01:37:02 +01:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1998-01-06 19:53:02 +01:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readNotifyStmt
|
2002-03-21 17:02:16 +01:00
|
|
|
*/
|
|
|
|
static NotifyStmt *
|
|
|
|
_readNotifyStmt(void)
|
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(NotifyStmt);
|
2002-03-21 17:02:16 +01:00
|
|
|
|
2008-09-01 22:42:46 +02:00
|
|
|
READ_STRING_FIELD(conditionname);
|
2010-02-16 23:34:57 +01:00
|
|
|
READ_STRING_FIELD(payload);
|
2002-03-21 17:02:16 +01:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
2002-03-21 17:02:16 +01:00
|
|
|
}
|
|
|
|
|
2003-03-10 04:53:52 +01:00
|
|
|
/*
|
|
|
|
* _readDeclareCursorStmt
|
|
|
|
*/
|
|
|
|
static DeclareCursorStmt *
|
|
|
|
_readDeclareCursorStmt(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(DeclareCursorStmt);
|
|
|
|
|
|
|
|
READ_STRING_FIELD(portalname);
|
|
|
|
READ_INT_FIELD(options);
|
|
|
|
READ_NODE_FIELD(query);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
2008-08-02 23:32:01 +02:00
|
|
|
* _readSortGroupClause
|
1998-01-06 19:53:02 +01:00
|
|
|
*/
|
2008-08-02 23:32:01 +02:00
|
|
|
static SortGroupClause *
|
|
|
|
_readSortGroupClause(void)
|
1998-01-06 19:53:02 +01:00
|
|
|
{
|
2008-08-02 23:32:01 +02:00
|
|
|
READ_LOCALS(SortGroupClause);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_UINT_FIELD(tleSortGroupRef);
|
2008-08-02 23:32:01 +02:00
|
|
|
READ_OID_FIELD(eqop);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_OID_FIELD(sortop);
|
2007-01-09 03:14:16 +01:00
|
|
|
READ_BOOL_FIELD(nulls_first);
|
2010-10-31 02:55:20 +01:00
|
|
|
READ_BOOL_FIELD(hashable);
|
1999-05-12 17:02:39 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2008-12-28 19:54:01 +01:00
|
|
|
/*
|
|
|
|
* _readWindowClause
|
|
|
|
*/
|
|
|
|
static WindowClause *
|
|
|
|
_readWindowClause(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(WindowClause);
|
|
|
|
|
|
|
|
READ_STRING_FIELD(name);
|
|
|
|
READ_STRING_FIELD(refname);
|
|
|
|
READ_NODE_FIELD(partitionClause);
|
|
|
|
READ_NODE_FIELD(orderClause);
|
2008-12-31 01:08:39 +01:00
|
|
|
READ_INT_FIELD(frameOptions);
|
2010-02-12 18:33:21 +01:00
|
|
|
READ_NODE_FIELD(startOffset);
|
|
|
|
READ_NODE_FIELD(endOffset);
|
2008-12-28 19:54:01 +01:00
|
|
|
READ_UINT_FIELD(winref);
|
|
|
|
READ_BOOL_FIELD(copiedOrder);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2006-04-30 20:30:40 +02:00
|
|
|
/*
|
|
|
|
* _readRowMarkClause
|
|
|
|
*/
|
|
|
|
static RowMarkClause *
|
|
|
|
_readRowMarkClause(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(RowMarkClause);
|
|
|
|
|
|
|
|
READ_UINT_FIELD(rti);
|
|
|
|
READ_BOOL_FIELD(forUpdate);
|
|
|
|
READ_BOOL_FIELD(noWait);
|
2009-10-28 15:55:47 +01:00
|
|
|
READ_BOOL_FIELD(pushedDown);
|
2006-04-30 20:30:40 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2008-10-04 23:56:55 +02:00
|
|
|
/*
|
|
|
|
* _readCommonTableExpr
|
|
|
|
*/
|
|
|
|
static CommonTableExpr *
|
|
|
|
_readCommonTableExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(CommonTableExpr);
|
|
|
|
|
|
|
|
READ_STRING_FIELD(ctename);
|
|
|
|
READ_NODE_FIELD(aliascolnames);
|
|
|
|
READ_NODE_FIELD(ctequery);
|
|
|
|
READ_LOCATION_FIELD(location);
|
|
|
|
READ_BOOL_FIELD(cterecursive);
|
|
|
|
READ_INT_FIELD(cterefcount);
|
|
|
|
READ_NODE_FIELD(ctecolnames);
|
|
|
|
READ_NODE_FIELD(ctecoltypes);
|
|
|
|
READ_NODE_FIELD(ctecoltypmods);
|
2011-02-08 22:04:18 +01:00
|
|
|
READ_NODE_FIELD(ctecolcollations);
|
2008-10-04 23:56:55 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readSetOperationStmt
|
2000-10-05 21:11:39 +02:00
|
|
|
*/
|
|
|
|
static SetOperationStmt *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readSetOperationStmt(void)
|
2000-10-05 21:11:39 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(SetOperationStmt);
|
2000-10-05 21:11:39 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_ENUM_FIELD(op, SetOperation);
|
|
|
|
READ_BOOL_FIELD(all);
|
|
|
|
READ_NODE_FIELD(larg);
|
|
|
|
READ_NODE_FIELD(rarg);
|
2004-05-26 06:41:50 +02:00
|
|
|
READ_NODE_FIELD(colTypes);
|
2006-08-10 04:36:29 +02:00
|
|
|
READ_NODE_FIELD(colTypmods);
|
2011-02-08 22:04:18 +01:00
|
|
|
READ_NODE_FIELD(colCollations);
|
2008-08-07 03:11:52 +02:00
|
|
|
READ_NODE_FIELD(groupClauses);
|
2000-10-05 21:11:39 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
|
|
|
}
|
2000-10-05 21:11:39 +02:00
|
|
|
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* Stuff from primnodes.h.
|
|
|
|
*/
|
2000-10-05 21:11:39 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
static Alias *
|
|
|
|
_readAlias(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_LOCALS(Alias);
|
2000-02-15 21:49:31 +01:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_STRING_FIELD(aliasname);
|
|
|
|
READ_NODE_FIELD(colnames);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_DONE();
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
static RangeVar *
|
|
|
|
_readRangeVar(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(RangeVar);
|
|
|
|
|
|
|
|
local_node->catalogname = NULL; /* not currently saved in output
|
|
|
|
* format */
|
|
|
|
|
|
|
|
READ_STRING_FIELD(schemaname);
|
|
|
|
READ_STRING_FIELD(relname);
|
|
|
|
READ_ENUM_FIELD(inhOpt, InhOption);
|
2010-12-13 18:34:26 +01:00
|
|
|
READ_CHAR_FIELD(relpersistence);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_NODE_FIELD(alias);
|
2008-09-01 22:42:46 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2007-02-20 18:32:18 +01:00
|
|
|
static IntoClause *
|
|
|
|
_readIntoClause(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(IntoClause);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(rel);
|
|
|
|
READ_NODE_FIELD(colNames);
|
|
|
|
READ_NODE_FIELD(options);
|
|
|
|
READ_ENUM_FIELD(onCommit, OnCommitAction);
|
|
|
|
READ_STRING_FIELD(tableSpaceName);
|
2011-11-25 05:21:06 +01:00
|
|
|
READ_BOOL_FIELD(skipData);
|
2007-02-20 18:32:18 +01:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readVar
|
|
|
|
*/
|
|
|
|
static Var *
|
|
|
|
_readVar(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(Var);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_UINT_FIELD(varno);
|
|
|
|
READ_INT_FIELD(varattno);
|
|
|
|
READ_OID_FIELD(vartype);
|
|
|
|
READ_INT_FIELD(vartypmod);
|
2011-02-08 22:04:18 +01:00
|
|
|
READ_OID_FIELD(varcollid);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_UINT_FIELD(varlevelsup);
|
|
|
|
READ_UINT_FIELD(varnoold);
|
|
|
|
READ_INT_FIELD(varoattno);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2000-11-12 01:37:02 +01:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readConst
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-11-25 19:12:12 +01:00
|
|
|
static Const *
|
|
|
|
_readConst(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(Const);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_OID_FIELD(consttype);
|
2007-03-17 01:11:05 +01:00
|
|
|
READ_INT_FIELD(consttypmod);
|
2011-02-08 22:04:18 +01:00
|
|
|
READ_OID_FIELD(constcollid);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_INT_FIELD(constlen);
|
|
|
|
READ_BOOL_FIELD(constbyval);
|
|
|
|
READ_BOOL_FIELD(constisnull);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
token = pg_strtok(&length); /* skip :constvalue */
|
|
|
|
if (local_node->constisnull)
|
|
|
|
token = pg_strtok(&length); /* skip "<>" */
|
|
|
|
else
|
|
|
|
local_node->constvalue = readDatum(local_node->constbyval);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
2002-12-12 16:49:42 +01:00
|
|
|
* _readParam
|
|
|
|
*/
|
|
|
|
static Param *
|
|
|
|
_readParam(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(Param);
|
|
|
|
|
2006-04-22 03:26:01 +02:00
|
|
|
READ_ENUM_FIELD(paramkind, ParamKind);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_INT_FIELD(paramid);
|
|
|
|
READ_OID_FIELD(paramtype);
|
2006-12-10 23:13:27 +01:00
|
|
|
READ_INT_FIELD(paramtypmod);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(paramcollid);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2002-12-12 16:49:42 +01:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _readAggref
|
|
|
|
*/
|
|
|
|
static Aggref *
|
|
|
|
_readAggref(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(Aggref);
|
|
|
|
|
|
|
|
READ_OID_FIELD(aggfnoid);
|
|
|
|
READ_OID_FIELD(aggtype);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(aggcollid);
|
|
|
|
READ_OID_FIELD(inputcollid);
|
2006-07-27 21:52:07 +02:00
|
|
|
READ_NODE_FIELD(args);
|
2009-12-15 18:57:48 +01:00
|
|
|
READ_NODE_FIELD(aggorder);
|
|
|
|
READ_NODE_FIELD(aggdistinct);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_BOOL_FIELD(aggstar);
|
2009-12-15 18:57:48 +01:00
|
|
|
READ_UINT_FIELD(agglevelsup);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2002-12-12 16:49:42 +01:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2008-12-28 19:54:01 +01:00
|
|
|
/*
|
|
|
|
* _readWindowFunc
|
|
|
|
*/
|
|
|
|
static WindowFunc *
|
|
|
|
_readWindowFunc(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(WindowFunc);
|
|
|
|
|
|
|
|
READ_OID_FIELD(winfnoid);
|
|
|
|
READ_OID_FIELD(wintype);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(wincollid);
|
|
|
|
READ_OID_FIELD(inputcollid);
|
2008-12-28 19:54:01 +01:00
|
|
|
READ_NODE_FIELD(args);
|
|
|
|
READ_UINT_FIELD(winref);
|
|
|
|
READ_BOOL_FIELD(winstar);
|
|
|
|
READ_BOOL_FIELD(winagg);
|
|
|
|
READ_LOCATION_FIELD(location);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
/*
|
|
|
|
* _readArrayRef
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-12-12 16:49:42 +01:00
|
|
|
static ArrayRef *
|
|
|
|
_readArrayRef(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_LOCALS(ArrayRef);
|
|
|
|
|
2003-04-09 01:20:04 +02:00
|
|
|
READ_OID_FIELD(refarraytype);
|
|
|
|
READ_OID_FIELD(refelemtype);
|
2007-03-17 01:11:05 +01:00
|
|
|
READ_INT_FIELD(reftypmod);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(refcollid);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_NODE_FIELD(refupperindexpr);
|
|
|
|
READ_NODE_FIELD(reflowerindexpr);
|
|
|
|
READ_NODE_FIELD(refexpr);
|
|
|
|
READ_NODE_FIELD(refassgnexpr);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _readFuncExpr
|
|
|
|
*/
|
|
|
|
static FuncExpr *
|
|
|
|
_readFuncExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(FuncExpr);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_OID_FIELD(funcid);
|
|
|
|
READ_OID_FIELD(funcresulttype);
|
|
|
|
READ_BOOL_FIELD(funcretset);
|
2013-01-22 02:25:26 +01:00
|
|
|
READ_BOOL_FIELD(funcvariadic);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_ENUM_FIELD(funcformat, CoercionForm);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(funccollid);
|
|
|
|
READ_OID_FIELD(inputcollid);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_NODE_FIELD(args);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2009-10-08 04:39:25 +02:00
|
|
|
/*
|
|
|
|
* _readNamedArgExpr
|
|
|
|
*/
|
|
|
|
static NamedArgExpr *
|
|
|
|
_readNamedArgExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(NamedArgExpr);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_STRING_FIELD(name);
|
|
|
|
READ_INT_FIELD(argnumber);
|
|
|
|
READ_LOCATION_FIELD(location);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
2002-12-12 16:49:42 +01:00
|
|
|
* _readOpExpr
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-12-12 16:49:42 +01:00
|
|
|
static OpExpr *
|
|
|
|
_readOpExpr(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_LOCALS(OpExpr);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_OID_FIELD(opno);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_OID_FIELD(opfuncid);
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* The opfuncid is stored in the textual format primarily for debugging
|
|
|
|
* and documentation reasons. We want to always read it as zero to force
|
|
|
|
* it to be re-looked-up in the pg_operator entry. This ensures that
|
|
|
|
* stored rules don't have hidden dependencies on operators' functions.
|
|
|
|
* (We don't currently support an ALTER OPERATOR command, but might
|
|
|
|
* someday.)
|
2002-12-12 16:49:42 +01:00
|
|
|
*/
|
|
|
|
local_node->opfuncid = InvalidOid;
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_OID_FIELD(opresulttype);
|
|
|
|
READ_BOOL_FIELD(opretset);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(opcollid);
|
|
|
|
READ_OID_FIELD(inputcollid);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_NODE_FIELD(args);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
2002-12-12 16:49:42 +01:00
|
|
|
* _readDistinctExpr
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-12-12 16:49:42 +01:00
|
|
|
static DistinctExpr *
|
|
|
|
_readDistinctExpr(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_LOCALS(DistinctExpr);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_OID_FIELD(opno);
|
|
|
|
READ_OID_FIELD(opfuncid);
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* The opfuncid is stored in the textual format primarily for debugging
|
|
|
|
* and documentation reasons. We want to always read it as zero to force
|
|
|
|
* it to be re-looked-up in the pg_operator entry. This ensures that
|
|
|
|
* stored rules don't have hidden dependencies on operators' functions.
|
|
|
|
* (We don't currently support an ALTER OPERATOR command, but might
|
|
|
|
* someday.)
|
2002-12-12 16:49:42 +01:00
|
|
|
*/
|
|
|
|
local_node->opfuncid = InvalidOid;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_OID_FIELD(opresulttype);
|
|
|
|
READ_BOOL_FIELD(opretset);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(opcollid);
|
|
|
|
READ_OID_FIELD(inputcollid);
|
|
|
|
READ_NODE_FIELD(args);
|
|
|
|
READ_LOCATION_FIELD(location);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _readNullIfExpr
|
|
|
|
*/
|
|
|
|
static NullIfExpr *
|
|
|
|
_readNullIfExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(NullIfExpr);
|
|
|
|
|
|
|
|
READ_OID_FIELD(opno);
|
|
|
|
READ_OID_FIELD(opfuncid);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The opfuncid is stored in the textual format primarily for debugging
|
|
|
|
* and documentation reasons. We want to always read it as zero to force
|
|
|
|
* it to be re-looked-up in the pg_operator entry. This ensures that
|
|
|
|
* stored rules don't have hidden dependencies on operators' functions.
|
|
|
|
* (We don't currently support an ALTER OPERATOR command, but might
|
|
|
|
* someday.)
|
|
|
|
*/
|
|
|
|
local_node->opfuncid = InvalidOid;
|
|
|
|
|
|
|
|
READ_OID_FIELD(opresulttype);
|
|
|
|
READ_BOOL_FIELD(opretset);
|
|
|
|
READ_OID_FIELD(opcollid);
|
|
|
|
READ_OID_FIELD(inputcollid);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_NODE_FIELD(args);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2003-06-29 02:33:44 +02:00
|
|
|
/*
|
|
|
|
* _readScalarArrayOpExpr
|
|
|
|
*/
|
|
|
|
static ScalarArrayOpExpr *
|
|
|
|
_readScalarArrayOpExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(ScalarArrayOpExpr);
|
|
|
|
|
|
|
|
READ_OID_FIELD(opno);
|
|
|
|
READ_OID_FIELD(opfuncid);
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2003-06-29 02:33:44 +02:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* The opfuncid is stored in the textual format primarily for debugging
|
|
|
|
* and documentation reasons. We want to always read it as zero to force
|
|
|
|
* it to be re-looked-up in the pg_operator entry. This ensures that
|
|
|
|
* stored rules don't have hidden dependencies on operators' functions.
|
|
|
|
* (We don't currently support an ALTER OPERATOR command, but might
|
|
|
|
* someday.)
|
2003-06-29 02:33:44 +02:00
|
|
|
*/
|
|
|
|
local_node->opfuncid = InvalidOid;
|
|
|
|
|
|
|
|
READ_BOOL_FIELD(useOr);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(inputcollid);
|
2003-06-29 02:33:44 +02:00
|
|
|
READ_NODE_FIELD(args);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2003-06-29 02:33:44 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
/*
|
|
|
|
* _readBoolExpr
|
|
|
|
*/
|
|
|
|
static BoolExpr *
|
|
|
|
_readBoolExpr(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_LOCALS(BoolExpr);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
/* do-it-yourself enum representation */
|
|
|
|
token = pg_strtok(&length); /* skip :boolop */
|
|
|
|
token = pg_strtok(&length); /* get field value */
|
|
|
|
if (strncmp(token, "and", 3) == 0)
|
|
|
|
local_node->boolop = AND_EXPR;
|
|
|
|
else if (strncmp(token, "or", 2) == 0)
|
|
|
|
local_node->boolop = OR_EXPR;
|
|
|
|
else if (strncmp(token, "not", 3) == 0)
|
|
|
|
local_node->boolop = NOT_EXPR;
|
|
|
|
else
|
2003-07-23 01:30:39 +02:00
|
|
|
elog(ERROR, "unrecognized boolop \"%.*s\"", length, token);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_NODE_FIELD(args);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readSubLink
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-11-25 19:12:12 +01:00
|
|
|
static SubLink *
|
|
|
|
_readSubLink(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(SubLink);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_ENUM_FIELD(subLinkType, SubLinkType);
|
2005-12-28 02:30:02 +01:00
|
|
|
READ_NODE_FIELD(testexpr);
|
2003-01-10 22:08:15 +01:00
|
|
|
READ_NODE_FIELD(operName);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(subselect);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
/*
|
2002-12-14 01:17:59 +01:00
|
|
|
* _readSubPlan is not needed since it doesn't appear in stored rules.
|
2002-12-12 16:49:42 +01:00
|
|
|
*/
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readFieldSelect
|
|
|
|
*/
|
|
|
|
static FieldSelect *
|
|
|
|
_readFieldSelect(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(FieldSelect);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_INT_FIELD(fieldnum);
|
|
|
|
READ_OID_FIELD(resulttype);
|
|
|
|
READ_INT_FIELD(resulttypmod);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(resultcollid);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2004-06-09 21:08:20 +02:00
|
|
|
/*
|
|
|
|
* _readFieldStore
|
|
|
|
*/
|
|
|
|
static FieldStore *
|
|
|
|
_readFieldStore(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(FieldStore);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_NODE_FIELD(newvals);
|
|
|
|
READ_NODE_FIELD(fieldnums);
|
|
|
|
READ_OID_FIELD(resulttype);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readRelabelType
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-11-25 19:12:12 +01:00
|
|
|
static RelabelType *
|
|
|
|
_readRelabelType(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(RelabelType);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_OID_FIELD(resulttype);
|
|
|
|
READ_INT_FIELD(resulttypmod);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(resultcollid);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_ENUM_FIELD(relabelformat, CoercionForm);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2007-06-05 23:31:09 +02:00
|
|
|
/*
|
|
|
|
* _readCoerceViaIO
|
|
|
|
*/
|
|
|
|
static CoerceViaIO *
|
|
|
|
_readCoerceViaIO(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(CoerceViaIO);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_OID_FIELD(resulttype);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(resultcollid);
|
2007-06-05 23:31:09 +02:00
|
|
|
READ_ENUM_FIELD(coerceformat, CoercionForm);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2007-06-05 23:31:09 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2007-03-28 01:21:12 +02:00
|
|
|
/*
|
|
|
|
* _readArrayCoerceExpr
|
|
|
|
*/
|
|
|
|
static ArrayCoerceExpr *
|
|
|
|
_readArrayCoerceExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(ArrayCoerceExpr);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_OID_FIELD(elemfuncid);
|
|
|
|
READ_OID_FIELD(resulttype);
|
|
|
|
READ_INT_FIELD(resulttypmod);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(resultcollid);
|
2007-03-28 01:21:12 +02:00
|
|
|
READ_BOOL_FIELD(isExplicit);
|
|
|
|
READ_ENUM_FIELD(coerceformat, CoercionForm);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2007-03-28 01:21:12 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2004-12-12 00:26:51 +01:00
|
|
|
/*
|
|
|
|
* _readConvertRowtypeExpr
|
|
|
|
*/
|
|
|
|
static ConvertRowtypeExpr *
|
|
|
|
_readConvertRowtypeExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(ConvertRowtypeExpr);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_OID_FIELD(resulttype);
|
|
|
|
READ_ENUM_FIELD(convertformat, CoercionForm);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2004-12-12 00:26:51 +01:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2011-03-11 22:27:51 +01:00
|
|
|
/*
|
|
|
|
* _readCollateExpr
|
|
|
|
*/
|
|
|
|
static CollateExpr *
|
|
|
|
_readCollateExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(CollateExpr);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_OID_FIELD(collOid);
|
|
|
|
READ_LOCATION_FIELD(location);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readCaseExpr
|
|
|
|
*/
|
|
|
|
static CaseExpr *
|
|
|
|
_readCaseExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(CaseExpr);
|
1998-11-22 11:48:45 +01:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_OID_FIELD(casetype);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(casecollid);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_NODE_FIELD(args);
|
|
|
|
READ_NODE_FIELD(defresult);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1999-08-09 08:20:27 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readCaseWhen
|
1999-11-23 21:07:06 +01:00
|
|
|
*/
|
2002-11-25 19:12:12 +01:00
|
|
|
static CaseWhen *
|
|
|
|
_readCaseWhen(void)
|
1999-11-23 21:07:06 +01:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(CaseWhen);
|
1999-11-23 21:07:06 +01:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(expr);
|
|
|
|
READ_NODE_FIELD(result);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1999-11-23 21:07:06 +01:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1999-11-23 21:07:06 +01:00
|
|
|
}
|
|
|
|
|
2004-03-17 21:48:43 +01:00
|
|
|
/*
|
|
|
|
* _readCaseTestExpr
|
|
|
|
*/
|
|
|
|
static CaseTestExpr *
|
|
|
|
_readCaseTestExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(CaseTestExpr);
|
|
|
|
|
|
|
|
READ_OID_FIELD(typeId);
|
|
|
|
READ_INT_FIELD(typeMod);
|
2011-02-08 22:04:18 +01:00
|
|
|
READ_OID_FIELD(collation);
|
2004-03-17 21:48:43 +01:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2003-04-09 01:20:04 +02:00
|
|
|
/*
|
|
|
|
* _readArrayExpr
|
|
|
|
*/
|
|
|
|
static ArrayExpr *
|
|
|
|
_readArrayExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(ArrayExpr);
|
|
|
|
|
|
|
|
READ_OID_FIELD(array_typeid);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(array_collid);
|
2003-04-09 01:20:04 +02:00
|
|
|
READ_OID_FIELD(element_typeid);
|
|
|
|
READ_NODE_FIELD(elements);
|
2003-08-18 01:43:27 +02:00
|
|
|
READ_BOOL_FIELD(multidims);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2003-04-09 01:20:04 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2004-05-11 00:44:49 +02:00
|
|
|
/*
|
|
|
|
* _readRowExpr
|
|
|
|
*/
|
|
|
|
static RowExpr *
|
|
|
|
_readRowExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(RowExpr);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(args);
|
|
|
|
READ_OID_FIELD(row_typeid);
|
|
|
|
READ_ENUM_FIELD(row_format, CoercionForm);
|
2008-10-06 19:39:26 +02:00
|
|
|
READ_NODE_FIELD(colnames);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2004-05-11 00:44:49 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2005-12-28 02:30:02 +01:00
|
|
|
/*
|
|
|
|
* _readRowCompareExpr
|
|
|
|
*/
|
|
|
|
static RowCompareExpr *
|
|
|
|
_readRowCompareExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(RowCompareExpr);
|
|
|
|
|
|
|
|
READ_ENUM_FIELD(rctype, RowCompareType);
|
|
|
|
READ_NODE_FIELD(opnos);
|
2006-12-23 01:43:13 +01:00
|
|
|
READ_NODE_FIELD(opfamilies);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_NODE_FIELD(inputcollids);
|
2005-12-28 02:30:02 +01:00
|
|
|
READ_NODE_FIELD(largs);
|
|
|
|
READ_NODE_FIELD(rargs);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2003-02-16 03:30:39 +01:00
|
|
|
/*
|
|
|
|
* _readCoalesceExpr
|
|
|
|
*/
|
|
|
|
static CoalesceExpr *
|
|
|
|
_readCoalesceExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(CoalesceExpr);
|
|
|
|
|
|
|
|
READ_OID_FIELD(coalescetype);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(coalescecollid);
|
2003-02-16 03:30:39 +01:00
|
|
|
READ_NODE_FIELD(args);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2003-02-16 03:30:39 +01:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2005-06-27 00:05:42 +02:00
|
|
|
/*
|
|
|
|
* _readMinMaxExpr
|
|
|
|
*/
|
|
|
|
static MinMaxExpr *
|
|
|
|
_readMinMaxExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(MinMaxExpr);
|
|
|
|
|
|
|
|
READ_OID_FIELD(minmaxtype);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(minmaxcollid);
|
|
|
|
READ_OID_FIELD(inputcollid);
|
2005-06-27 00:05:42 +02:00
|
|
|
READ_ENUM_FIELD(op, MinMaxOp);
|
|
|
|
READ_NODE_FIELD(args);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2005-06-27 00:05:42 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2006-12-24 01:29:20 +01:00
|
|
|
/*
|
|
|
|
* _readXmlExpr
|
|
|
|
*/
|
|
|
|
static XmlExpr *
|
|
|
|
_readXmlExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(XmlExpr);
|
|
|
|
|
|
|
|
READ_ENUM_FIELD(op, XmlExprOp);
|
|
|
|
READ_STRING_FIELD(name);
|
|
|
|
READ_NODE_FIELD(named_args);
|
|
|
|
READ_NODE_FIELD(arg_names);
|
|
|
|
READ_NODE_FIELD(args);
|
2007-02-03 15:06:56 +01:00
|
|
|
READ_ENUM_FIELD(xmloption, XmlOptionType);
|
|
|
|
READ_OID_FIELD(type);
|
|
|
|
READ_INT_FIELD(typmod);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2006-12-24 01:29:20 +01:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readNullTest
|
2000-09-29 20:21:41 +02:00
|
|
|
*/
|
2002-11-25 19:12:12 +01:00
|
|
|
static NullTest *
|
|
|
|
_readNullTest(void)
|
2000-09-29 20:21:41 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(NullTest);
|
2000-09-29 20:21:41 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_ENUM_FIELD(nulltesttype, NullTestType);
|
2010-01-02 00:03:10 +01:00
|
|
|
READ_BOOL_FIELD(argisrow);
|
2000-09-29 20:21:41 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
2000-09-29 20:21:41 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readBooleanTest
|
2002-05-12 22:10:05 +02:00
|
|
|
*/
|
2002-11-25 19:12:12 +01:00
|
|
|
static BooleanTest *
|
|
|
|
_readBooleanTest(void)
|
2002-05-12 22:10:05 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(BooleanTest);
|
2002-05-12 22:10:05 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(arg);
|
|
|
|
READ_ENUM_FIELD(booltesttype, BoolTestType);
|
2002-05-12 22:10:05 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
2002-05-12 22:10:05 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
2003-02-03 22:15:45 +01:00
|
|
|
* _readCoerceToDomain
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2003-02-03 22:15:45 +01:00
|
|
|
static CoerceToDomain *
|
|
|
|
_readCoerceToDomain(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2003-02-03 22:15:45 +01:00
|
|
|
READ_LOCALS(CoerceToDomain);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(arg);
|
2003-02-03 22:15:45 +01:00
|
|
|
READ_OID_FIELD(resulttype);
|
|
|
|
READ_INT_FIELD(resulttypmod);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(resultcollid);
|
2003-02-03 22:15:45 +01:00
|
|
|
READ_ENUM_FIELD(coercionformat, CoercionForm);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
2003-02-03 22:15:45 +01:00
|
|
|
* _readCoerceToDomainValue
|
2002-11-25 19:12:12 +01:00
|
|
|
*/
|
2003-02-03 22:15:45 +01:00
|
|
|
static CoerceToDomainValue *
|
|
|
|
_readCoerceToDomainValue(void)
|
2002-11-25 19:12:12 +01:00
|
|
|
{
|
2003-02-03 22:15:45 +01:00
|
|
|
READ_LOCALS(CoerceToDomainValue);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_OID_FIELD(typeId);
|
|
|
|
READ_INT_FIELD(typeMod);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(collation);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2003-07-03 18:34:26 +02:00
|
|
|
/*
|
|
|
|
* _readSetToDefault
|
|
|
|
*/
|
|
|
|
static SetToDefault *
|
|
|
|
_readSetToDefault(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(SetToDefault);
|
|
|
|
|
|
|
|
READ_OID_FIELD(typeId);
|
|
|
|
READ_INT_FIELD(typeMod);
|
2011-03-20 01:29:08 +01:00
|
|
|
READ_OID_FIELD(collation);
|
2008-08-29 01:09:48 +02:00
|
|
|
READ_LOCATION_FIELD(location);
|
2003-07-03 18:34:26 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
2007-06-11 03:16:30 +02:00
|
|
|
/*
|
|
|
|
* _readCurrentOfExpr
|
|
|
|
*/
|
|
|
|
static CurrentOfExpr *
|
|
|
|
_readCurrentOfExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(CurrentOfExpr);
|
|
|
|
|
|
|
|
READ_UINT_FIELD(cvarno);
|
|
|
|
READ_STRING_FIELD(cursor_name);
|
2007-06-12 00:22:42 +02:00
|
|
|
READ_INT_FIELD(cursor_param);
|
2007-06-11 03:16:30 +02:00
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
2002-11-25 19:12:12 +01:00
|
|
|
* _readTargetEntry
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2002-11-25 19:12:12 +01:00
|
|
|
static TargetEntry *
|
|
|
|
_readTargetEntry(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(TargetEntry);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(expr);
|
2005-04-06 18:34:07 +02:00
|
|
|
READ_INT_FIELD(resno);
|
|
|
|
READ_STRING_FIELD(resname);
|
|
|
|
READ_UINT_FIELD(ressortgroupref);
|
|
|
|
READ_OID_FIELD(resorigtbl);
|
|
|
|
READ_INT_FIELD(resorigcol);
|
|
|
|
READ_BOOL_FIELD(resjunk);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
/*
|
|
|
|
* _readRangeTblRef
|
|
|
|
*/
|
|
|
|
static RangeTblRef *
|
|
|
|
_readRangeTblRef(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(RangeTblRef);
|
|
|
|
|
|
|
|
READ_INT_FIELD(rtindex);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _readJoinExpr
|
|
|
|
*/
|
|
|
|
static JoinExpr *
|
|
|
|
_readJoinExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(JoinExpr);
|
|
|
|
|
|
|
|
READ_ENUM_FIELD(jointype, JoinType);
|
|
|
|
READ_BOOL_FIELD(isNatural);
|
|
|
|
READ_NODE_FIELD(larg);
|
|
|
|
READ_NODE_FIELD(rarg);
|
2009-07-16 08:33:46 +02:00
|
|
|
READ_NODE_FIELD(usingClause);
|
2002-12-12 16:49:42 +01:00
|
|
|
READ_NODE_FIELD(quals);
|
|
|
|
READ_NODE_FIELD(alias);
|
|
|
|
READ_INT_FIELD(rtindex);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _readFromExpr
|
|
|
|
*/
|
|
|
|
static FromExpr *
|
|
|
|
_readFromExpr(void)
|
|
|
|
{
|
|
|
|
READ_LOCALS(FromExpr);
|
|
|
|
|
|
|
|
READ_NODE_FIELD(fromlist);
|
|
|
|
READ_NODE_FIELD(quals);
|
|
|
|
|
|
|
|
READ_DONE();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stuff from parsenodes.h.
|
|
|
|
*/
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* _readRangeTblEntry
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static RangeTblEntry *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readRangeTblEntry(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_LOCALS(RangeTblEntry);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/* put alias + eref first to make dump more legible */
|
|
|
|
READ_NODE_FIELD(alias);
|
|
|
|
READ_NODE_FIELD(eref);
|
|
|
|
READ_ENUM_FIELD(rtekind, RTEKind);
|
2002-03-22 03:56:37 +01:00
|
|
|
|
|
|
|
switch (local_node->rtekind)
|
|
|
|
{
|
|
|
|
case RTE_RELATION:
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_OID_FIELD(relid);
|
2011-02-23 01:23:23 +01:00
|
|
|
READ_CHAR_FIELD(relkind);
|
2002-03-22 03:56:37 +01:00
|
|
|
break;
|
|
|
|
case RTE_SUBQUERY:
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(subquery);
|
2011-12-22 22:15:57 +01:00
|
|
|
READ_BOOL_FIELD(security_barrier);
|
2002-03-22 03:56:37 +01:00
|
|
|
break;
|
2008-10-04 23:56:55 +02:00
|
|
|
case RTE_JOIN:
|
|
|
|
READ_ENUM_FIELD(jointype, JoinType);
|
|
|
|
READ_NODE_FIELD(joinaliasvars);
|
|
|
|
break;
|
2002-05-12 22:10:05 +02:00
|
|
|
case RTE_FUNCTION:
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_NODE_FIELD(funcexpr);
|
2006-03-16 01:31:55 +01:00
|
|
|
READ_NODE_FIELD(funccoltypes);
|
|
|
|
READ_NODE_FIELD(funccoltypmods);
|
2011-02-08 22:04:18 +01:00
|
|
|
READ_NODE_FIELD(funccolcollations);
|
2002-05-12 22:10:05 +02:00
|
|
|
break;
|
2006-08-02 03:59:48 +02:00
|
|
|
case RTE_VALUES:
|
|
|
|
READ_NODE_FIELD(values_lists);
|
2011-04-18 21:31:52 +02:00
|
|
|
READ_NODE_FIELD(values_collations);
|
2006-08-02 03:59:48 +02:00
|
|
|
break;
|
2008-10-04 23:56:55 +02:00
|
|
|
case RTE_CTE:
|
|
|
|
READ_STRING_FIELD(ctename);
|
|
|
|
READ_UINT_FIELD(ctelevelsup);
|
|
|
|
READ_BOOL_FIELD(self_reference);
|
|
|
|
READ_NODE_FIELD(ctecoltypes);
|
|
|
|
READ_NODE_FIELD(ctecoltypmods);
|
2011-02-08 22:04:18 +01:00
|
|
|
READ_NODE_FIELD(ctecolcollations);
|
2002-03-22 03:56:37 +01:00
|
|
|
break;
|
|
|
|
default:
|
2003-07-23 01:30:39 +02:00
|
|
|
elog(ERROR, "unrecognized RTE kind: %d",
|
|
|
|
(int) local_node->rtekind);
|
2002-03-22 03:56:37 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-08-08 01:02:54 +02:00
|
|
|
READ_BOOL_FIELD(lateral);
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_BOOL_FIELD(inh);
|
|
|
|
READ_BOOL_FIELD(inFromCl);
|
2004-01-15 00:01:55 +01:00
|
|
|
READ_UINT_FIELD(requiredPerms);
|
2005-06-28 07:09:14 +02:00
|
|
|
READ_OID_FIELD(checkAsUser);
|
2009-01-22 21:16:10 +01:00
|
|
|
READ_BITMAPSET_FIELD(selectedCols);
|
|
|
|
READ_BITMAPSET_FIELD(modifiedCols);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_DONE();
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* parseNodeString
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2002-11-25 19:12:12 +01:00
|
|
|
* Given a character string representing a node tree, parseNodeString creates
|
|
|
|
* the internal node structure.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2001-01-07 02:08:48 +01:00
|
|
|
* The string to be read must already have been loaded into pg_strtok().
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1998-02-26 05:46:47 +01:00
|
|
|
Node *
|
2002-11-25 19:12:12 +01:00
|
|
|
parseNodeString(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2002-11-25 19:12:12 +01:00
|
|
|
void *return_value;
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
READ_TEMP_LOCALS();
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
token = pg_strtok(&length);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
#define MATCH(tokname, namelen) \
|
2010-12-22 04:11:40 +01:00
|
|
|
(length == namelen && memcmp(token, tokname, namelen) == 0)
|
2002-11-25 19:12:12 +01:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
if (MATCH("QUERY", 5))
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readQuery();
|
2008-08-02 23:32:01 +02:00
|
|
|
else if (MATCH("SORTGROUPCLAUSE", 15))
|
|
|
|
return_value = _readSortGroupClause();
|
2008-12-28 19:54:01 +01:00
|
|
|
else if (MATCH("WINDOWCLAUSE", 12))
|
|
|
|
return_value = _readWindowClause();
|
2006-04-30 20:30:40 +02:00
|
|
|
else if (MATCH("ROWMARKCLAUSE", 13))
|
|
|
|
return_value = _readRowMarkClause();
|
2008-10-04 23:56:55 +02:00
|
|
|
else if (MATCH("COMMONTABLEEXPR", 15))
|
|
|
|
return_value = _readCommonTableExpr();
|
2002-11-25 19:12:12 +01:00
|
|
|
else if (MATCH("SETOPERATIONSTMT", 16))
|
2000-10-05 21:11:39 +02:00
|
|
|
return_value = _readSetOperationStmt();
|
2002-12-12 16:49:42 +01:00
|
|
|
else if (MATCH("ALIAS", 5))
|
|
|
|
return_value = _readAlias();
|
|
|
|
else if (MATCH("RANGEVAR", 8))
|
|
|
|
return_value = _readRangeVar();
|
2007-02-20 18:32:18 +01:00
|
|
|
else if (MATCH("INTOCLAUSE", 10))
|
|
|
|
return_value = _readIntoClause();
|
2002-12-12 16:49:42 +01:00
|
|
|
else if (MATCH("VAR", 3))
|
|
|
|
return_value = _readVar();
|
|
|
|
else if (MATCH("CONST", 5))
|
|
|
|
return_value = _readConst();
|
|
|
|
else if (MATCH("PARAM", 5))
|
|
|
|
return_value = _readParam();
|
|
|
|
else if (MATCH("AGGREF", 6))
|
|
|
|
return_value = _readAggref();
|
2008-12-28 19:54:01 +01:00
|
|
|
else if (MATCH("WINDOWFUNC", 10))
|
|
|
|
return_value = _readWindowFunc();
|
2002-12-12 16:49:42 +01:00
|
|
|
else if (MATCH("ARRAYREF", 8))
|
|
|
|
return_value = _readArrayRef();
|
|
|
|
else if (MATCH("FUNCEXPR", 8))
|
|
|
|
return_value = _readFuncExpr();
|
2009-10-08 04:39:25 +02:00
|
|
|
else if (MATCH("NAMEDARGEXPR", 12))
|
|
|
|
return_value = _readNamedArgExpr();
|
2002-12-12 16:49:42 +01:00
|
|
|
else if (MATCH("OPEXPR", 6))
|
|
|
|
return_value = _readOpExpr();
|
|
|
|
else if (MATCH("DISTINCTEXPR", 12))
|
|
|
|
return_value = _readDistinctExpr();
|
2011-03-20 01:29:08 +01:00
|
|
|
else if (MATCH("NULLIFEXPR", 10))
|
|
|
|
return_value = _readNullIfExpr();
|
2003-06-29 02:33:44 +02:00
|
|
|
else if (MATCH("SCALARARRAYOPEXPR", 17))
|
|
|
|
return_value = _readScalarArrayOpExpr();
|
2002-12-12 16:49:42 +01:00
|
|
|
else if (MATCH("BOOLEXPR", 8))
|
|
|
|
return_value = _readBoolExpr();
|
|
|
|
else if (MATCH("SUBLINK", 7))
|
|
|
|
return_value = _readSubLink();
|
|
|
|
else if (MATCH("FIELDSELECT", 11))
|
|
|
|
return_value = _readFieldSelect();
|
2004-06-09 21:08:20 +02:00
|
|
|
else if (MATCH("FIELDSTORE", 10))
|
|
|
|
return_value = _readFieldStore();
|
2002-12-12 16:49:42 +01:00
|
|
|
else if (MATCH("RELABELTYPE", 11))
|
|
|
|
return_value = _readRelabelType();
|
2007-06-05 23:31:09 +02:00
|
|
|
else if (MATCH("COERCEVIAIO", 11))
|
|
|
|
return_value = _readCoerceViaIO();
|
2007-03-28 01:21:12 +02:00
|
|
|
else if (MATCH("ARRAYCOERCEEXPR", 15))
|
|
|
|
return_value = _readArrayCoerceExpr();
|
2004-12-12 00:26:51 +01:00
|
|
|
else if (MATCH("CONVERTROWTYPEEXPR", 18))
|
|
|
|
return_value = _readConvertRowtypeExpr();
|
2011-03-11 22:27:51 +01:00
|
|
|
else if (MATCH("COLLATE", 7))
|
|
|
|
return_value = _readCollateExpr();
|
2002-11-25 19:12:12 +01:00
|
|
|
else if (MATCH("CASE", 4))
|
1998-12-14 01:02:17 +01:00
|
|
|
return_value = _readCaseExpr();
|
2002-11-25 19:12:12 +01:00
|
|
|
else if (MATCH("WHEN", 4))
|
1998-12-14 01:02:17 +01:00
|
|
|
return_value = _readCaseWhen();
|
2004-03-17 21:48:43 +01:00
|
|
|
else if (MATCH("CASETESTEXPR", 12))
|
|
|
|
return_value = _readCaseTestExpr();
|
2003-04-09 01:20:04 +02:00
|
|
|
else if (MATCH("ARRAY", 5))
|
|
|
|
return_value = _readArrayExpr();
|
2004-05-11 00:44:49 +02:00
|
|
|
else if (MATCH("ROW", 3))
|
|
|
|
return_value = _readRowExpr();
|
2005-12-28 02:30:02 +01:00
|
|
|
else if (MATCH("ROWCOMPARE", 10))
|
|
|
|
return_value = _readRowCompareExpr();
|
2003-02-16 03:30:39 +01:00
|
|
|
else if (MATCH("COALESCE", 8))
|
|
|
|
return_value = _readCoalesceExpr();
|
2005-06-27 00:05:42 +02:00
|
|
|
else if (MATCH("MINMAX", 6))
|
|
|
|
return_value = _readMinMaxExpr();
|
2006-12-24 01:29:20 +01:00
|
|
|
else if (MATCH("XMLEXPR", 7))
|
|
|
|
return_value = _readXmlExpr();
|
2002-11-25 19:12:12 +01:00
|
|
|
else if (MATCH("NULLTEST", 8))
|
2001-06-20 00:39:12 +02:00
|
|
|
return_value = _readNullTest();
|
2002-11-25 19:12:12 +01:00
|
|
|
else if (MATCH("BOOLEANTEST", 11))
|
2001-06-20 00:39:12 +02:00
|
|
|
return_value = _readBooleanTest();
|
2003-02-03 22:15:45 +01:00
|
|
|
else if (MATCH("COERCETODOMAIN", 14))
|
|
|
|
return_value = _readCoerceToDomain();
|
|
|
|
else if (MATCH("COERCETODOMAINVALUE", 19))
|
|
|
|
return_value = _readCoerceToDomainValue();
|
2003-07-03 18:34:26 +02:00
|
|
|
else if (MATCH("SETTODEFAULT", 12))
|
|
|
|
return_value = _readSetToDefault();
|
2007-06-11 03:16:30 +02:00
|
|
|
else if (MATCH("CURRENTOFEXPR", 13))
|
|
|
|
return_value = _readCurrentOfExpr();
|
2002-12-12 16:49:42 +01:00
|
|
|
else if (MATCH("TARGETENTRY", 11))
|
|
|
|
return_value = _readTargetEntry();
|
|
|
|
else if (MATCH("RANGETBLREF", 11))
|
|
|
|
return_value = _readRangeTblRef();
|
|
|
|
else if (MATCH("JOINEXPR", 8))
|
|
|
|
return_value = _readJoinExpr();
|
|
|
|
else if (MATCH("FROMEXPR", 8))
|
|
|
|
return_value = _readFromExpr();
|
|
|
|
else if (MATCH("RTE", 3))
|
|
|
|
return_value = _readRangeTblEntry();
|
2003-03-10 04:53:52 +01:00
|
|
|
else if (MATCH("NOTIFY", 6))
|
|
|
|
return_value = _readNotifyStmt();
|
|
|
|
else if (MATCH("DECLARECURSOR", 13))
|
|
|
|
return_value = _readDeclareCursorStmt();
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
2002-11-25 19:12:12 +01:00
|
|
|
{
|
|
|
|
elog(ERROR, "badly formatted node string \"%.32s\"...", token);
|
|
|
|
return_value = NULL; /* keep compiler quiet */
|
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return (Node *) return_value;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2002-11-25 19:12:12 +01:00
|
|
|
/*
|
|
|
|
* readDatum
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2001-01-07 02:08:48 +01:00
|
|
|
* Given a string representation of a constant, recreate the appropriate
|
|
|
|
* Datum. The string representation embeds length info, but not byValue,
|
|
|
|
* so we must be told that.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Datum
|
2001-01-07 02:08:48 +01:00
|
|
|
readDatum(bool typbyval)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2001-01-08 01:31:43 +01:00
|
|
|
Size length,
|
|
|
|
i;
|
1997-09-08 04:41:22 +02:00
|
|
|
int tokenLength;
|
|
|
|
char *token;
|
|
|
|
Datum res;
|
|
|
|
char *s;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* read the actual length of the value
|
|
|
|
*/
|
2001-01-07 02:08:48 +01:00
|
|
|
token = pg_strtok(&tokenLength);
|
2001-01-08 01:31:43 +01:00
|
|
|
length = atoui(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-07-03 18:52:48 +02:00
|
|
|
token = pg_strtok(&tokenLength); /* read the '[' */
|
|
|
|
if (token == NULL || token[0] != '[')
|
2003-07-23 01:30:39 +02:00
|
|
|
elog(ERROR, "expected \"[\" to start datum, but got \"%s\"; length = %lu",
|
|
|
|
token ? (const char *) token : "[NULL]",
|
2001-07-03 18:52:48 +02:00
|
|
|
(unsigned long) length);
|
2001-01-07 02:08:48 +01:00
|
|
|
|
|
|
|
if (typbyval)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2001-01-08 01:31:43 +01:00
|
|
|
if (length > (Size) sizeof(Datum))
|
2003-07-23 01:30:39 +02:00
|
|
|
elog(ERROR, "byval datum but length = %lu",
|
2001-02-12 22:03:03 +01:00
|
|
|
(unsigned long) length);
|
2000-01-14 01:53:21 +01:00
|
|
|
res = (Datum) 0;
|
1997-09-07 07:04:48 +02:00
|
|
|
s = (char *) (&res);
|
2001-01-08 01:31:43 +01:00
|
|
|
for (i = 0; i < (Size) sizeof(Datum); i++)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2001-01-07 02:08:48 +01:00
|
|
|
token = pg_strtok(&tokenLength);
|
1997-09-07 07:04:48 +02:00
|
|
|
s[i] = (char) atoi(token);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (length <= 0)
|
2000-01-14 01:53:21 +01:00
|
|
|
res = (Datum) NULL;
|
|
|
|
else
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
|
|
|
s = (char *) palloc(length);
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
{
|
2001-01-07 02:08:48 +01:00
|
|
|
token = pg_strtok(&tokenLength);
|
1997-09-07 07:04:48 +02:00
|
|
|
s[i] = (char) atoi(token);
|
|
|
|
}
|
|
|
|
res = PointerGetDatum(s);
|
|
|
|
}
|
|
|
|
|
2001-07-03 18:52:48 +02:00
|
|
|
token = pg_strtok(&tokenLength); /* read the ']' */
|
2001-01-07 02:08:48 +01:00
|
|
|
if (token == NULL || token[0] != ']')
|
2003-07-23 01:30:39 +02:00
|
|
|
elog(ERROR, "expected \"]\" to end datum, but got \"%s\"; length = %lu",
|
|
|
|
token ? (const char *) token : "[NULL]",
|
2001-02-12 22:03:03 +01:00
|
|
|
(unsigned long) length);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return res;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|