Commit 4057b64f authored by Tom Lane's avatar Tom Lane

Modify readfuncs so that recursive use of stringToNode will not crash

and burn.  Just for added luck, change reading of CONST nodes so that
we do not need to consult pg_type rows while reading them; this means
that no database access occurs during stringToNode.  This requires
changing the order in which const-node fields are written, which means
an initdb is forced.
parent 14022014
/* /*
*
* outfuncs.c * outfuncs.c
* routines to convert a node to ascii representation * routines to convert a node to ascii representation
* *
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.135 2000/12/03 20:45:33 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.136 2001/01/07 01:08:47 tgl Exp $
* *
* NOTES * NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which * Every (plan) node in POSTGRES has an associated "out" routine which
* knows how to create its ascii representation. These functions are * knows how to create its ascii representation. These functions are
* useful for debugging as well as for storing plans in the system * useful for debugging as well as for storing plans in the system
* catalogs (eg. indexes). This is also the plan string sent out in * catalogs (eg. views).
* Mariposa.
*
* These functions update the in/out argument of type StringInfo
* passed to them. This argument contains the string holding the ASCII
* representation plus some other information (string length, etc.)
*
*/ */
#include "postgres.h" #include "postgres.h"
#include <ctype.h> #include <ctype.h>
#include "access/heapam.h"
#include "access/htup.h"
#include "catalog/pg_type.h"
#include "fmgr.h"
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#include "nodes/execnodes.h"
#include "nodes/nodes.h" #include "nodes/nodes.h"
#include "nodes/parsenodes.h" #include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
#include "nodes/plannodes.h" #include "nodes/plannodes.h"
#include "nodes/primnodes.h" #include "nodes/primnodes.h"
#include "nodes/relation.h" #include "nodes/relation.h"
#include "parser/parse.h" #include "parser/parse.h"
#include "utils/datum.h" #include "utils/datum.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
static void _outDatum(StringInfo str, Datum value, Oid type); static void _outDatum(StringInfo str, Datum value, int typlen, bool typbyval);
static void _outNode(StringInfo str, void *obj); static void _outNode(StringInfo str, void *obj);
/* /*
...@@ -63,8 +48,8 @@ _outToken(StringInfo str, char *s) ...@@ -63,8 +48,8 @@ _outToken(StringInfo str, char *s)
/* /*
* Look for characters or patterns that are treated specially by * Look for characters or patterns that are treated specially by
* read.c (either in lsptok() or in nodeRead()), and therefore need a * read.c (either in pg_strtok() or in nodeRead()), and therefore need
* protective backslash. * a protective backslash.
*/ */
/* These characters only need to be quoted at the start of the string */ /* These characters only need to be quoted at the start of the string */
if (*s == '<' || if (*s == '<' ||
...@@ -762,18 +747,17 @@ static void ...@@ -762,18 +747,17 @@ static void
_outConst(StringInfo str, Const *node) _outConst(StringInfo str, Const *node)
{ {
appendStringInfo(str, appendStringInfo(str,
" CONST :consttype %u :constlen %d :constisnull %s :constvalue ", " CONST :consttype %u :constlen %d :constbyval %s"
" :constisnull %s :constvalue ",
node->consttype, node->consttype,
node->constlen, node->constlen,
node->constbyval ? "true" : "false",
node->constisnull ? "true" : "false"); node->constisnull ? "true" : "false");
if (node->constisnull) if (node->constisnull)
appendStringInfo(str, "<>"); appendStringInfo(str, "<>");
else else
_outDatum(str, node->constvalue, node->consttype); _outDatum(str, node->constvalue, node->constlen, node->constbyval);
appendStringInfo(str, " :constbyval %s ",
node->constbyval ? "true" : "false");
} }
/* /*
...@@ -1234,38 +1218,31 @@ _outJoinInfo(StringInfo str, JoinInfo *node) ...@@ -1234,38 +1218,31 @@ _outJoinInfo(StringInfo str, JoinInfo *node)
* Print the value of a Datum given its type. * Print the value of a Datum given its type.
*/ */
static void static void
_outDatum(StringInfo str, Datum value, Oid type) _outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
{ {
int16 typeLength; Size length,
bool byValue; i;
Size length;
char *s; char *s;
int i;
/* length = datumGetSize(value, typbyval, typlen);
* find some information about the type and the "real" length of the
* datum.
*/
get_typlenbyval(type, &typeLength, &byValue);
length = datumGetSize(value, byValue, typeLength);
if (byValue) if (typbyval)
{ {
s = (char *) (&value); s = (char *) (&value);
appendStringInfo(str, " %u [ ", (unsigned int) length); appendStringInfo(str, " %u [ ", (unsigned int) length);
for (i = 0; i < (int) sizeof(Datum); i++) for (i = 0; i < (Size) sizeof(Datum); i++)
appendStringInfo(str, "%d ", (int) (s[i])); appendStringInfo(str, "%d ", (int) (s[i]));
appendStringInfo(str, "] "); appendStringInfo(str, "] ");
} }
else else
{ /* !byValue */ {
s = (char *) DatumGetPointer(value); s = (char *) DatumGetPointer(value);
if (!PointerIsValid(s)) if (!PointerIsValid(s))
appendStringInfo(str, " 0 [ ] "); appendStringInfo(str, " 0 [ ] ");
else else
{ {
appendStringInfo(str, " %u [ ", (unsigned int) length); appendStringInfo(str, " %u [ ", (unsigned int) length);
for (i = 0; i < (int) length; i++) for (i = 0; i < length; i++)
appendStringInfo(str, "%d ", (int) (s[i])); appendStringInfo(str, "%d ", (int) (s[i]));
appendStringInfo(str, "] "); appendStringInfo(str, "] ");
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.26 2000/12/03 20:45:33 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.27 2001/01/07 01:08:47 tgl Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
#include "nodes/pg_list.h" #include "nodes/pg_list.h"
#include "nodes/readfuncs.h" #include "nodes/readfuncs.h"
/* Static state for pg_strtok */
static char *pg_strtok_ptr = NULL;
/* /*
* stringToNode - * stringToNode -
* returns a Node with a given legal ASCII representation * returns a Node with a given legal ASCII representation
...@@ -32,10 +37,22 @@ ...@@ -32,10 +37,22 @@
void * void *
stringToNode(char *str) stringToNode(char *str)
{ {
char *save_strtok;
void *retval; void *retval;
lsptok(str, NULL); /* set the string used in lsptok */ /*
retval = nodeRead(true); /* start reading */ * We save and restore the pre-existing state of pg_strtok.
* This makes the world safe for re-entrant invocation of stringToNode,
* without incurring a lot of notational overhead by having to pass the
* next-character pointer around through all the readfuncs.c code.
*/
save_strtok = pg_strtok_ptr;
pg_strtok_ptr = str; /* point pg_strtok at the string to read */
retval = nodeRead(true); /* do the reading */
pg_strtok_ptr = save_strtok;
return retval; return retval;
} }
...@@ -47,7 +64,7 @@ stringToNode(char *str) ...@@ -47,7 +64,7 @@ stringToNode(char *str)
*****************************************************************************/ *****************************************************************************/
/* /*
* lsptok --- retrieve next "token" from a string. * pg_strtok --- retrieve next "token" from a string.
* *
* Works kinda like strtok, except it never modifies the source string. * Works kinda like strtok, except it never modifies the source string.
* (Instead of storing nulls into the string, the length of the token * (Instead of storing nulls into the string, the length of the token
...@@ -55,9 +72,7 @@ stringToNode(char *str) ...@@ -55,9 +72,7 @@ stringToNode(char *str)
* Also, the rules about what is a token are hard-wired rather than being * Also, the rules about what is a token are hard-wired rather than being
* configured by passing a set of terminating characters. * configured by passing a set of terminating characters.
* *
* The string is initially set by passing a non-NULL "string" value, * The string is assumed to have been initialized already by stringToNode.
* and subsequent calls with string==NULL read the previously given value.
* (Pass length==NULL to set the string without reading its first token.)
* *
* The rules for tokens are: * The rules for tokens are:
* * Whitespace (space, tab, newline) always separates tokens. * * Whitespace (space, tab, newline) always separates tokens.
...@@ -89,20 +104,12 @@ stringToNode(char *str) ...@@ -89,20 +104,12 @@ stringToNode(char *str)
* as a single token. * as a single token.
*/ */
char * char *
lsptok(char *string, int *length) pg_strtok(int *length)
{ {
static char *saved_str = NULL;
char *local_str; /* working pointer to string */ char *local_str; /* working pointer to string */
char *ret_str; /* start of token to return */ char *ret_str; /* start of token to return */
if (string != NULL) local_str = pg_strtok_ptr;
{
saved_str = string;
if (length == NULL)
return NULL;
}
local_str = saved_str;
while (*local_str == ' ' || *local_str == '\n' || *local_str == '\t') while (*local_str == ' ' || *local_str == '\n' || *local_str == '\t')
local_str++; local_str++;
...@@ -110,7 +117,7 @@ lsptok(char *string, int *length) ...@@ -110,7 +117,7 @@ lsptok(char *string, int *length)
if (*local_str == '\0') if (*local_str == '\0')
{ {
*length = 0; *length = 0;
saved_str = local_str; pg_strtok_ptr = local_str;
return NULL; /* no more tokens */ return NULL; /* no more tokens */
} }
...@@ -147,7 +154,7 @@ lsptok(char *string, int *length) ...@@ -147,7 +154,7 @@ lsptok(char *string, int *length)
if (*length == 2 && ret_str[0] == '<' && ret_str[1] == '>') if (*length == 2 && ret_str[0] == '<' && ret_str[1] == '>')
*length = 0; *length = 0;
saved_str = local_str; pg_strtok_ptr = local_str;
return ret_str; return ret_str;
} }
...@@ -223,7 +230,7 @@ nodeTokenType(char *token, int length) ...@@ -223,7 +230,7 @@ nodeTokenType(char *token, int length)
} }
/* /*
* these three cases do not need length checks, since lsptok() will * these three cases do not need length checks, since pg_strtok() will
* always treat them as single-byte tokens * always treat them as single-byte tokens
*/ */
else if (*token == '(') else if (*token == '(')
...@@ -248,12 +255,13 @@ nodeTokenType(char *token, int length) ...@@ -248,12 +255,13 @@ nodeTokenType(char *token, int length)
* Slightly higher-level reader. * Slightly higher-level reader.
* *
* This routine applies some semantic knowledge on top of the purely * This routine applies some semantic knowledge on top of the purely
* lexical tokenizer lsptok(). It can read * lexical tokenizer pg_strtok(). It can read
* * Value token nodes (integers, floats, or strings); * * Value token nodes (integers, floats, or strings);
* * Plan nodes (via parsePlanString() from readfuncs.c); * * Plan nodes (via parsePlanString() from readfuncs.c);
* * Lists of the above. * * Lists of the above.
* *
* Secrets: He assumes that lsptok already has the string (see above). * We assume pg_strtok is already initialized with a string to read (hence
* this should only be invoked from within a stringToNode operation).
* Any callers should set read_car_only to true. * Any callers should set read_car_only to true.
*/ */
void * void *
...@@ -266,7 +274,7 @@ nodeRead(bool read_car_only) ...@@ -266,7 +274,7 @@ nodeRead(bool read_car_only)
*return_value; *return_value;
bool make_dotted_pair_cell = false; bool make_dotted_pair_cell = false;
token = lsptok(NULL, &tok_len); token = pg_strtok(&tok_len);
if (token == NULL) if (token == NULL)
return NULL; return NULL;
...@@ -277,8 +285,8 @@ nodeRead(bool read_car_only) ...@@ -277,8 +285,8 @@ nodeRead(bool read_car_only)
{ {
case PLAN_SYM: case PLAN_SYM:
this_value = parsePlanString(); this_value = parsePlanString();
token = lsptok(NULL, &tok_len); token = pg_strtok(&tok_len);
if (token[0] != '}') if (token == NULL || token[0] != '}')
elog(ERROR, "nodeRead: did not find '}' at end of plan node"); elog(ERROR, "nodeRead: did not find '}' at end of plan node");
if (!read_car_only) if (!read_car_only)
make_dotted_pair_cell = true; make_dotted_pair_cell = true;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.102 2000/12/14 22:30:42 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.103 2001/01/07 01:08:47 tgl Exp $
* *
* NOTES * NOTES
* Most of the read functions for plan nodes are tested. (In fact, they * Most of the read functions for plan nodes are tested. (In fact, they
...@@ -23,22 +23,23 @@ ...@@ -23,22 +23,23 @@
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include <math.h>
#include "postgres.h" #include "postgres.h"
#include <math.h>
#include "nodes/plannodes.h" #include "nodes/plannodes.h"
#include "nodes/readfuncs.h" #include "nodes/readfuncs.h"
#include "nodes/relation.h" #include "nodes/relation.h"
#include "utils/lsyscache.h"
static Datum readDatum(bool typbyval);
/* ---------------- /* ----------------
* node creator declarations * node creator declarations
* ---------------- * ----------------
*/ */
static Datum readDatum(Oid type);
static List * static List *
toIntList(List *list) toIntList(List *list)
{ {
...@@ -65,12 +66,12 @@ _readQuery(void) ...@@ -65,12 +66,12 @@ _readQuery(void)
local_node = makeNode(Query); local_node = makeNode(Query);
token = lsptok(NULL, &length); /* skip the :command */ token = pg_strtok(&length); /* skip the :command */
token = lsptok(NULL, &length); /* get the commandType */ token = pg_strtok(&length); /* get the commandType */
local_node->commandType = atoi(token); local_node->commandType = atoi(token);
token = lsptok(NULL, &length); /* skip :utility */ token = pg_strtok(&length); /* skip :utility */
token = lsptok(NULL, &length); token = pg_strtok(&length);
if (length == 0) if (length == 0)
local_node->utilityStmt = NULL; local_node->utilityStmt = NULL;
else else
...@@ -86,71 +87,71 @@ _readQuery(void) ...@@ -86,71 +87,71 @@ _readQuery(void)
local_node->utilityStmt = (Node *) n; local_node->utilityStmt = (Node *) n;
} }
token = lsptok(NULL, &length); /* skip the :resultRelation */ token = pg_strtok(&length); /* skip the :resultRelation */
token = lsptok(NULL, &length); /* get the resultRelation */ token = pg_strtok(&length); /* get the resultRelation */
local_node->resultRelation = atoi(token); local_node->resultRelation = atoi(token);
token = lsptok(NULL, &length); /* skip :into */ token = pg_strtok(&length); /* skip :into */
token = lsptok(NULL, &length); /* get into */ token = pg_strtok(&length); /* get into */
if (length == 0) if (length == 0)
local_node->into = NULL; local_node->into = NULL;
else else
local_node->into = debackslash(token, length); local_node->into = debackslash(token, length);
token = lsptok(NULL, &length); /* skip :isPortal */ token = pg_strtok(&length); /* skip :isPortal */
token = lsptok(NULL, &length); /* get isPortal */ token = pg_strtok(&length); /* get isPortal */
local_node->isPortal = (token[0] == 't') ? true : false; local_node->isPortal = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* skip :isBinary */ token = pg_strtok(&length); /* skip :isBinary */
token = lsptok(NULL, &length); /* get isBinary */ token = pg_strtok(&length); /* get isBinary */
local_node->isBinary = (token[0] == 't') ? true : false; local_node->isBinary = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* skip :isTemp */ token = pg_strtok(&length); /* skip :isTemp */
token = lsptok(NULL, &length); /* get isTemp */ token = pg_strtok(&length); /* get isTemp */
local_node->isTemp = (token[0] == 't') ? true : false; local_node->isTemp = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* skip the :hasAggs */ token = pg_strtok(&length); /* skip the :hasAggs */
token = lsptok(NULL, &length); /* get hasAggs */ token = pg_strtok(&length); /* get hasAggs */
local_node->hasAggs = (token[0] == 't') ? true : false; local_node->hasAggs = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* skip the :hasSubLinks */ token = pg_strtok(&length); /* skip the :hasSubLinks */
token = lsptok(NULL, &length); /* get hasSubLinks */ token = pg_strtok(&length); /* get hasSubLinks */
local_node->hasSubLinks = (token[0] == 't') ? true : false; local_node->hasSubLinks = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* skip :rtable */ token = pg_strtok(&length); /* skip :rtable */
local_node->rtable = nodeRead(true); local_node->rtable = nodeRead(true);
token = lsptok(NULL, &length); /* skip :jointree */ token = pg_strtok(&length); /* skip :jointree */
local_node->jointree = nodeRead(true); local_node->jointree = nodeRead(true);
token = lsptok(NULL, &length); /* skip :rowMarks */ token = pg_strtok(&length); /* skip :rowMarks */
local_node->rowMarks = toIntList(nodeRead(true)); local_node->rowMarks = toIntList(nodeRead(true));
token = lsptok(NULL, &length); /* skip :targetlist */ token = pg_strtok(&length); /* skip :targetlist */
local_node->targetList = nodeRead(true); local_node->targetList = nodeRead(true);
token = lsptok(NULL, &length); /* skip :groupClause */ token = pg_strtok(&length); /* skip :groupClause */
local_node->groupClause = nodeRead(true); local_node->groupClause = nodeRead(true);
token = lsptok(NULL, &length); /* skip :havingQual */ token = pg_strtok(&length); /* skip :havingQual */
local_node->havingQual = nodeRead(true); local_node->havingQual = nodeRead(true);
token = lsptok(NULL, &length); /* skip :distinctClause */ token = pg_strtok(&length); /* skip :distinctClause */
local_node->distinctClause = nodeRead(true); local_node->distinctClause = nodeRead(true);
token = lsptok(NULL, &length); /* skip :sortClause */ token = pg_strtok(&length); /* skip :sortClause */
local_node->sortClause = nodeRead(true); local_node->sortClause = nodeRead(true);
token = lsptok(NULL, &length); /* skip :limitOffset */ token = pg_strtok(&length); /* skip :limitOffset */
local_node->limitOffset = nodeRead(true); local_node->limitOffset = nodeRead(true);
token = lsptok(NULL, &length); /* skip :limitCount */ token = pg_strtok(&length); /* skip :limitCount */
local_node->limitCount = nodeRead(true); local_node->limitCount = nodeRead(true);
token = lsptok(NULL, &length); /* skip :setOperations */ token = pg_strtok(&length); /* skip :setOperations */
local_node->setOperations = nodeRead(true); local_node->setOperations = nodeRead(true);
token = lsptok(NULL, &length); /* skip :resultRelations */ token = pg_strtok(&length); /* skip :resultRelations */
local_node->resultRelations = toIntList(nodeRead(true)); local_node->resultRelations = toIntList(nodeRead(true));
return local_node; return local_node;
...@@ -169,12 +170,12 @@ _readSortClause(void) ...@@ -169,12 +170,12 @@ _readSortClause(void)
local_node = makeNode(SortClause); local_node = makeNode(SortClause);
token = lsptok(NULL, &length); /* skip :tleSortGroupRef */ token = pg_strtok(&length); /* skip :tleSortGroupRef */
token = lsptok(NULL, &length); /* get tleSortGroupRef */ token = pg_strtok(&length); /* get tleSortGroupRef */
local_node->tleSortGroupRef = strtoul(token, NULL, 10); local_node->tleSortGroupRef = strtoul(token, NULL, 10);
token = lsptok(NULL, &length); /* skip :sortop */ token = pg_strtok(&length); /* skip :sortop */
token = lsptok(NULL, &length); /* get sortop */ token = pg_strtok(&length); /* get sortop */
local_node->sortop = strtoul(token, NULL, 10); local_node->sortop = strtoul(token, NULL, 10);
return local_node; return local_node;
...@@ -193,12 +194,12 @@ _readGroupClause(void) ...@@ -193,12 +194,12 @@ _readGroupClause(void)
local_node = makeNode(GroupClause); local_node = makeNode(GroupClause);
token = lsptok(NULL, &length); /* skip :tleSortGroupRef */ token = pg_strtok(&length); /* skip :tleSortGroupRef */
token = lsptok(NULL, &length); /* get tleSortGroupRef */ token = pg_strtok(&length); /* get tleSortGroupRef */
local_node->tleSortGroupRef = strtoul(token, NULL, 10); local_node->tleSortGroupRef = strtoul(token, NULL, 10);
token = lsptok(NULL, &length); /* skip :sortop */ token = pg_strtok(&length); /* skip :sortop */
token = lsptok(NULL, &length); /* get sortop */ token = pg_strtok(&length); /* get sortop */
local_node->sortop = strtoul(token, NULL, 10); local_node->sortop = strtoul(token, NULL, 10);
return local_node; return local_node;
...@@ -217,21 +218,21 @@ _readSetOperationStmt(void) ...@@ -217,21 +218,21 @@ _readSetOperationStmt(void)
local_node = makeNode(SetOperationStmt); local_node = makeNode(SetOperationStmt);
token = lsptok(NULL, &length); /* eat :op */ token = pg_strtok(&length); /* eat :op */
token = lsptok(NULL, &length); /* get op */ token = pg_strtok(&length); /* get op */
local_node->op = (SetOperation) atoi(token); local_node->op = (SetOperation) atoi(token);
token = lsptok(NULL, &length); /* eat :all */ token = pg_strtok(&length); /* eat :all */
token = lsptok(NULL, &length); /* get all */ token = pg_strtok(&length); /* get all */
local_node->all = (token[0] == 't') ? true : false; local_node->all = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :larg */ token = pg_strtok(&length); /* eat :larg */
local_node->larg = nodeRead(true); /* get larg */ local_node->larg = nodeRead(true); /* get larg */
token = lsptok(NULL, &length); /* eat :rarg */ token = pg_strtok(&length); /* eat :rarg */
local_node->rarg = nodeRead(true); /* get rarg */ local_node->rarg = nodeRead(true); /* get rarg */
token = lsptok(NULL, &length); /* eat :colTypes */ token = pg_strtok(&length); /* eat :colTypes */
local_node->colTypes = toIntList(nodeRead(true)); local_node->colTypes = toIntList(nodeRead(true));
return local_node; return local_node;
...@@ -247,32 +248,32 @@ _getPlan(Plan *node) ...@@ -247,32 +248,32 @@ _getPlan(Plan *node)
char *token; char *token;
int length; int length;
token = lsptok(NULL, &length); /* first token is :startup_cost */ token = pg_strtok(&length); /* first token is :startup_cost */
token = lsptok(NULL, &length); /* next is the actual cost */ token = pg_strtok(&length); /* next is the actual cost */
node->startup_cost = (Cost) atof(token); node->startup_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* skip the :total_cost */ token = pg_strtok(&length); /* skip the :total_cost */
token = lsptok(NULL, &length); /* next is the actual cost */ token = pg_strtok(&length); /* next is the actual cost */
node->total_cost = (Cost) atof(token); node->total_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* skip the :rows */ token = pg_strtok(&length); /* skip the :rows */
token = lsptok(NULL, &length); /* get the plan_rows */ token = pg_strtok(&length); /* get the plan_rows */
node->plan_rows = atof(token); node->plan_rows = atof(token);
token = lsptok(NULL, &length); /* skip the :width */ token = pg_strtok(&length); /* skip the :width */
token = lsptok(NULL, &length); /* get the plan_width */ token = pg_strtok(&length); /* get the plan_width */
node->plan_width = atoi(token); node->plan_width = atoi(token);
token = lsptok(NULL, &length); /* eat :qptargetlist */ token = pg_strtok(&length); /* eat :qptargetlist */
node->targetlist = nodeRead(true); node->targetlist = nodeRead(true);
token = lsptok(NULL, &length); /* eat :qpqual */ token = pg_strtok(&length); /* eat :qpqual */
node->qual = nodeRead(true); node->qual = nodeRead(true);
token = lsptok(NULL, &length); /* eat :lefttree */ token = pg_strtok(&length); /* eat :lefttree */
node->lefttree = (Plan *) nodeRead(true); node->lefttree = (Plan *) nodeRead(true);
token = lsptok(NULL, &length); /* eat :righttree */ token = pg_strtok(&length); /* eat :righttree */
node->righttree = (Plan *) nodeRead(true); node->righttree = (Plan *) nodeRead(true);
node->state = (EState *) NULL; /* never read in */ node->state = (EState *) NULL; /* never read in */
...@@ -315,7 +316,7 @@ _readResult(void) ...@@ -315,7 +316,7 @@ _readResult(void)
_getPlan((Plan *) local_node); _getPlan((Plan *) local_node);
token = lsptok(NULL, &length); /* eat :resconstantqual */ token = pg_strtok(&length); /* eat :resconstantqual */
local_node->resconstantqual = nodeRead(true); /* now read it */ local_node->resconstantqual = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -339,11 +340,11 @@ _readAppend(void) ...@@ -339,11 +340,11 @@ _readAppend(void)
_getPlan((Plan *) local_node); _getPlan((Plan *) local_node);
token = lsptok(NULL, &length); /* eat :appendplans */ token = pg_strtok(&length); /* eat :appendplans */
local_node->appendplans = nodeRead(true); /* now read it */ local_node->appendplans = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :isTarget */ token = pg_strtok(&length); /* eat :isTarget */
token = lsptok(NULL, &length); /* get isTarget */ token = pg_strtok(&length); /* get isTarget */
local_node->isTarget = (token[0] == 't') ? true : false; local_node->isTarget = (token[0] == 't') ? true : false;
return local_node; return local_node;
...@@ -361,11 +362,11 @@ _getJoin(Join *node) ...@@ -361,11 +362,11 @@ _getJoin(Join *node)
_getPlan((Plan *) node); _getPlan((Plan *) node);
token = lsptok(NULL, &length); /* skip the :jointype */ token = pg_strtok(&length); /* skip the :jointype */
token = lsptok(NULL, &length); /* get the jointype */ token = pg_strtok(&length); /* get the jointype */
node->jointype = (JoinType) atoi(token); node->jointype = (JoinType) atoi(token);
token = lsptok(NULL, &length); /* skip the :joinqual */ token = pg_strtok(&length); /* skip the :joinqual */
node->joinqual = nodeRead(true); /* get the joinqual */ node->joinqual = nodeRead(true); /* get the joinqual */
} }
...@@ -424,7 +425,7 @@ _readMergeJoin(void) ...@@ -424,7 +425,7 @@ _readMergeJoin(void)
_getJoin((Join *) local_node); _getJoin((Join *) local_node);
token = lsptok(NULL, &length); /* eat :mergeclauses */ token = pg_strtok(&length); /* eat :mergeclauses */
local_node->mergeclauses = nodeRead(true); /* now read it */ local_node->mergeclauses = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -447,11 +448,11 @@ _readHashJoin(void) ...@@ -447,11 +448,11 @@ _readHashJoin(void)
_getJoin((Join *) local_node); _getJoin((Join *) local_node);
token = lsptok(NULL, &length); /* eat :hashclauses */ token = pg_strtok(&length); /* eat :hashclauses */
local_node->hashclauses = nodeRead(true); /* now read it */ local_node->hashclauses = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :hashjoinop */ token = pg_strtok(&length); /* eat :hashjoinop */
token = lsptok(NULL, &length); /* get hashjoinop */ token = pg_strtok(&length); /* get hashjoinop */
local_node->hashjoinop = strtoul(token, NULL, 10); local_node->hashjoinop = strtoul(token, NULL, 10);
return local_node; return local_node;
...@@ -473,8 +474,8 @@ _getScan(Scan *node) ...@@ -473,8 +474,8 @@ _getScan(Scan *node)
_getPlan((Plan *) node); _getPlan((Plan *) node);
token = lsptok(NULL, &length); /* eat :scanrelid */ token = pg_strtok(&length); /* eat :scanrelid */
token = lsptok(NULL, &length); /* get scanrelid */ token = pg_strtok(&length); /* get scanrelid */
node->scanrelid = strtoul(token, NULL, 10); node->scanrelid = strtoul(token, NULL, 10);
} }
...@@ -531,17 +532,17 @@ _readIndexScan(void) ...@@ -531,17 +532,17 @@ _readIndexScan(void)
_getScan((Scan *) local_node); _getScan((Scan *) local_node);
token = lsptok(NULL, &length); /* eat :indxid */ token = pg_strtok(&length); /* eat :indxid */
local_node->indxid = toIntList(nodeRead(true)); /* now read it */ local_node->indxid = toIntList(nodeRead(true)); /* now read it */
token = lsptok(NULL, &length); /* eat :indxqual */ token = pg_strtok(&length); /* eat :indxqual */
local_node->indxqual = nodeRead(true); /* now read it */ local_node->indxqual = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :indxqualorig */ token = pg_strtok(&length); /* eat :indxqualorig */
local_node->indxqualorig = nodeRead(true); /* now read it */ local_node->indxqualorig = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :indxorderdir */ token = pg_strtok(&length); /* eat :indxorderdir */
token = lsptok(NULL, &length); /* get indxorderdir */ token = pg_strtok(&length); /* get indxorderdir */
local_node->indxorderdir = atoi(token); local_node->indxorderdir = atoi(token);
return local_node; return local_node;
...@@ -564,11 +565,11 @@ _readTidScan(void) ...@@ -564,11 +565,11 @@ _readTidScan(void)
_getScan((Scan *) local_node); _getScan((Scan *) local_node);
token = lsptok(NULL, &length); /* eat :needrescan */ token = pg_strtok(&length); /* eat :needrescan */
token = lsptok(NULL, &length); /* get needrescan */ token = pg_strtok(&length); /* get needrescan */
local_node->needRescan = atoi(token); local_node->needRescan = atoi(token);
token = lsptok(NULL, &length); /* eat :tideval */ token = pg_strtok(&length); /* eat :tideval */
local_node->tideval = nodeRead(true); /* now read it */ local_node->tideval = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -591,7 +592,7 @@ _readSubqueryScan(void) ...@@ -591,7 +592,7 @@ _readSubqueryScan(void)
_getScan((Scan *) local_node); _getScan((Scan *) local_node);
token = lsptok(NULL, &length); /* eat :subplan */ token = pg_strtok(&length); /* eat :subplan */
local_node->subplan = nodeRead(true); /* now read it */ local_node->subplan = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -614,8 +615,8 @@ _readSort(void) ...@@ -614,8 +615,8 @@ _readSort(void)
_getPlan((Plan *) local_node); _getPlan((Plan *) local_node);
token = lsptok(NULL, &length); /* eat :keycount */ token = pg_strtok(&length); /* eat :keycount */
token = lsptok(NULL, &length); /* get keycount */ token = pg_strtok(&length); /* get keycount */
local_node->keycount = atoi(token); local_node->keycount = atoi(token);
return local_node; return local_node;
...@@ -649,7 +650,7 @@ _readHash(void) ...@@ -649,7 +650,7 @@ _readHash(void)
_getPlan((Plan *) local_node); _getPlan((Plan *) local_node);
token = lsptok(NULL, &length); /* eat :hashkey */ token = pg_strtok(&length); /* eat :hashkey */
local_node->hashkey = nodeRead(true); local_node->hashkey = nodeRead(true);
return local_node; return local_node;
...@@ -674,39 +675,39 @@ _readResdom(void) ...@@ -674,39 +675,39 @@ _readResdom(void)
local_node = makeNode(Resdom); local_node = makeNode(Resdom);
token = lsptok(NULL, &length); /* eat :resno */ token = pg_strtok(&length); /* eat :resno */
token = lsptok(NULL, &length); /* get resno */ token = pg_strtok(&length); /* get resno */
local_node->resno = atoi(token); local_node->resno = atoi(token);
token = lsptok(NULL, &length); /* eat :restype */ token = pg_strtok(&length); /* eat :restype */
token = lsptok(NULL, &length); /* get restype */ token = pg_strtok(&length); /* get restype */
local_node->restype = (Oid) atol(token); local_node->restype = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :restypmod */ token = pg_strtok(&length); /* eat :restypmod */
token = lsptok(NULL, &length); /* get restypmod */ token = pg_strtok(&length); /* get restypmod */
local_node->restypmod = atoi(token); local_node->restypmod = atoi(token);
token = lsptok(NULL, &length); /* eat :resname */ token = pg_strtok(&length); /* eat :resname */
token = lsptok(NULL, &length); /* get the name */ token = pg_strtok(&length); /* get the name */
if (length == 0) if (length == 0)
local_node->resname = NULL; local_node->resname = NULL;
else else
local_node->resname = debackslash(token, length); local_node->resname = debackslash(token, length);
token = lsptok(NULL, &length); /* eat :reskey */ token = pg_strtok(&length); /* eat :reskey */
token = lsptok(NULL, &length); /* get reskey */ token = pg_strtok(&length); /* get reskey */
local_node->reskey = strtoul(token, NULL, 10); local_node->reskey = strtoul(token, NULL, 10);
token = lsptok(NULL, &length); /* eat :reskeyop */ token = pg_strtok(&length); /* eat :reskeyop */
token = lsptok(NULL, &length); /* get reskeyop */ token = pg_strtok(&length); /* get reskeyop */
local_node->reskeyop = (Oid) atol(token); local_node->reskeyop = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :ressortgroupref */ token = pg_strtok(&length); /* eat :ressortgroupref */
token = lsptok(NULL, &length); /* get ressortgroupref */ token = pg_strtok(&length); /* get ressortgroupref */
local_node->ressortgroupref = strtoul(token, NULL, 10); local_node->ressortgroupref = strtoul(token, NULL, 10);
token = lsptok(NULL, &length); /* eat :resjunk */ token = pg_strtok(&length); /* eat :resjunk */
token = lsptok(NULL, &length); /* get resjunk */ token = pg_strtok(&length); /* get resjunk */
local_node->resjunk = (token[0] == 't') ? true : false; local_node->resjunk = (token[0] == 't') ? true : false;
return local_node; return local_node;
...@@ -727,12 +728,12 @@ _readExpr(void) ...@@ -727,12 +728,12 @@ _readExpr(void)
local_node = makeNode(Expr); local_node = makeNode(Expr);
token = lsptok(NULL, &length); /* eat :typeOid */ token = pg_strtok(&length); /* eat :typeOid */
token = lsptok(NULL, &length); /* get typeOid */ token = pg_strtok(&length); /* get typeOid */
local_node->typeOid = (Oid) atol(token); local_node->typeOid = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :opType */ token = pg_strtok(&length); /* eat :opType */
token = lsptok(NULL, &length); /* get opType */ token = pg_strtok(&length); /* get opType */
if (!strncmp(token, "op", 2)) if (!strncmp(token, "op", 2))
local_node->opType = OP_EXPR; local_node->opType = OP_EXPR;
else if (!strncmp(token, "func", 4)) else if (!strncmp(token, "func", 4))
...@@ -748,10 +749,10 @@ _readExpr(void) ...@@ -748,10 +749,10 @@ _readExpr(void)
else else
elog(ERROR, "_readExpr: unknown opType \"%.10s\"", token); elog(ERROR, "_readExpr: unknown opType \"%.10s\"", token);
token = lsptok(NULL, &length); /* eat :oper */ token = pg_strtok(&length); /* eat :oper */
local_node->oper = nodeRead(true); local_node->oper = nodeRead(true);
token = lsptok(NULL, &length); /* eat :args */ token = pg_strtok(&length); /* eat :args */
local_node->args = nodeRead(true); /* now read it */ local_node->args = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -772,17 +773,17 @@ _readCaseExpr(void) ...@@ -772,17 +773,17 @@ _readCaseExpr(void)
local_node = makeNode(CaseExpr); local_node = makeNode(CaseExpr);
token = lsptok(NULL, &length); /* eat :casetype */ token = pg_strtok(&length); /* eat :casetype */
token = lsptok(NULL, &length); /* get casetype */ token = pg_strtok(&length); /* get casetype */
local_node->casetype = (Oid) atol(token); local_node->casetype = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :arg */ token = pg_strtok(&length); /* eat :arg */
local_node->arg = nodeRead(true); local_node->arg = nodeRead(true);
token = lsptok(NULL, &length); /* eat :args */ token = pg_strtok(&length); /* eat :args */
local_node->args = nodeRead(true); local_node->args = nodeRead(true);
token = lsptok(NULL, &length); /* eat :defresult */ token = pg_strtok(&length); /* eat :defresult */
local_node->defresult = nodeRead(true); local_node->defresult = nodeRead(true);
return local_node; return local_node;
...@@ -804,7 +805,7 @@ _readCaseWhen(void) ...@@ -804,7 +805,7 @@ _readCaseWhen(void)
local_node = makeNode(CaseWhen); local_node = makeNode(CaseWhen);
local_node->expr = nodeRead(true); local_node->expr = nodeRead(true);
token = lsptok(NULL, &length); /* eat :then */ token = pg_strtok(&length); /* eat :then */
local_node->result = nodeRead(true); local_node->result = nodeRead(true);
return local_node; return local_node;
...@@ -825,32 +826,32 @@ _readVar(void) ...@@ -825,32 +826,32 @@ _readVar(void)
local_node = makeNode(Var); local_node = makeNode(Var);
token = lsptok(NULL, &length); /* eat :varno */ token = pg_strtok(&length); /* eat :varno */
token = lsptok(NULL, &length); /* get varno */ token = pg_strtok(&length); /* get varno */
local_node->varno = strtoul(token, NULL, 10); local_node->varno = strtoul(token, NULL, 10);
token = lsptok(NULL, &length); /* eat :varattno */ token = pg_strtok(&length); /* eat :varattno */
token = lsptok(NULL, &length); /* get varattno */ token = pg_strtok(&length); /* get varattno */
local_node->varattno = atoi(token); local_node->varattno = atoi(token);
token = lsptok(NULL, &length); /* eat :vartype */ token = pg_strtok(&length); /* eat :vartype */
token = lsptok(NULL, &length); /* get vartype */ token = pg_strtok(&length); /* get vartype */
local_node->vartype = (Oid) atol(token); local_node->vartype = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :vartypmod */ token = pg_strtok(&length); /* eat :vartypmod */
token = lsptok(NULL, &length); /* get vartypmod */ token = pg_strtok(&length); /* get vartypmod */
local_node->vartypmod = atoi(token); local_node->vartypmod = atoi(token);
token = lsptok(NULL, &length); /* eat :varlevelsup */ token = pg_strtok(&length); /* eat :varlevelsup */
token = lsptok(NULL, &length); /* get varlevelsup */ token = pg_strtok(&length); /* get varlevelsup */
local_node->varlevelsup = (Index) atoi(token); local_node->varlevelsup = (Index) atoi(token);
token = lsptok(NULL, &length); /* eat :varnoold */ token = pg_strtok(&length); /* eat :varnoold */
token = lsptok(NULL, &length); /* get varnoold */ token = pg_strtok(&length); /* get varnoold */
local_node->varnoold = (Index) atoi(token); local_node->varnoold = (Index) atoi(token);
token = lsptok(NULL, &length); /* eat :varoattno */ token = pg_strtok(&length); /* eat :varoattno */
token = lsptok(NULL, &length); /* eat :varoattno */ token = pg_strtok(&length); /* eat :varoattno */
local_node->varoattno = atoi(token); local_node->varoattno = atoi(token);
return local_node; return local_node;
...@@ -871,32 +872,32 @@ _readArrayRef(void) ...@@ -871,32 +872,32 @@ _readArrayRef(void)
local_node = makeNode(ArrayRef); local_node = makeNode(ArrayRef);
token = lsptok(NULL, &length); /* eat :refelemtype */ token = pg_strtok(&length); /* eat :refelemtype */
token = lsptok(NULL, &length); /* get refelemtype */ token = pg_strtok(&length); /* get refelemtype */
local_node->refelemtype = strtoul(token, NULL, 10); local_node->refelemtype = strtoul(token, NULL, 10);
token = lsptok(NULL, &length); /* eat :refattrlength */ token = pg_strtok(&length); /* eat :refattrlength */
token = lsptok(NULL, &length); /* get refattrlength */ token = pg_strtok(&length); /* get refattrlength */
local_node->refattrlength = atoi(token); local_node->refattrlength = atoi(token);
token = lsptok(NULL, &length); /* eat :refelemlength */ token = pg_strtok(&length); /* eat :refelemlength */
token = lsptok(NULL, &length); /* get refelemlength */ token = pg_strtok(&length); /* get refelemlength */
local_node->refelemlength = atoi(token); local_node->refelemlength = atoi(token);
token = lsptok(NULL, &length); /* eat :refelembyval */ token = pg_strtok(&length); /* eat :refelembyval */
token = lsptok(NULL, &length); /* get refelembyval */ token = pg_strtok(&length); /* get refelembyval */
local_node->refelembyval = (token[0] == 't') ? true : false; local_node->refelembyval = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :refupperindex */ token = pg_strtok(&length); /* eat :refupperindex */
local_node->refupperindexpr = nodeRead(true); local_node->refupperindexpr = nodeRead(true);
token = lsptok(NULL, &length); /* eat :reflowerindex */ token = pg_strtok(&length); /* eat :reflowerindex */
local_node->reflowerindexpr = nodeRead(true); local_node->reflowerindexpr = nodeRead(true);
token = lsptok(NULL, &length); /* eat :refexpr */ token = pg_strtok(&length); /* eat :refexpr */
local_node->refexpr = nodeRead(true); local_node->refexpr = nodeRead(true);
token = lsptok(NULL, &length); /* eat :refassgnexpr */ token = pg_strtok(&length); /* eat :refassgnexpr */
local_node->refassgnexpr = nodeRead(true); local_node->refassgnexpr = nodeRead(true);
return local_node; return local_node;
...@@ -917,47 +918,41 @@ _readConst(void) ...@@ -917,47 +918,41 @@ _readConst(void)
local_node = makeNode(Const); local_node = makeNode(Const);
token = lsptok(NULL, &length); /* get :consttype */ token = pg_strtok(&length); /* get :consttype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->consttype = (Oid) atol(token); local_node->consttype = (Oid) atol(token);
token = pg_strtok(&length); /* get :constlen */
token = lsptok(NULL, &length); /* get :constlen */ token = pg_strtok(&length); /* now read it */
token = lsptok(NULL, &length); /* now read it */
local_node->constlen = strtol(token, NULL, 10); local_node->constlen = strtol(token, NULL, 10);
token = lsptok(NULL, &length); /* get :constisnull */ token = pg_strtok(&length); /* get :constbyval */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
if (!strncmp(token, "true", 4))
local_node->constbyval = true;
else
local_node->constbyval = false;
token = pg_strtok(&length); /* get :constisnull */
token = pg_strtok(&length); /* now read it */
if (!strncmp(token, "true", 4)) if (!strncmp(token, "true", 4))
local_node->constisnull = true; local_node->constisnull = true;
else else
local_node->constisnull = false; local_node->constisnull = false;
token = pg_strtok(&length); /* get :constvalue */
token = lsptok(NULL, &length); /* get :constvalue */
if (local_node->constisnull) if (local_node->constisnull)
{ {
token = lsptok(NULL, &length); /* skip "NIL" */ token = pg_strtok(&length); /* skip "NIL" */
} }
else else
{ {
local_node->constvalue = readDatum(local_node->constbyval);
/*
* read the value
*/
local_node->constvalue = readDatum(local_node->consttype);
} }
token = lsptok(NULL, &length); /* get :constbyval */
token = lsptok(NULL, &length); /* now read it */
if (!strncmp(token, "true", 4))
local_node->constbyval = true;
else
local_node->constbyval = false;
return local_node; return local_node;
} }
...@@ -976,12 +971,12 @@ _readFunc(void) ...@@ -976,12 +971,12 @@ _readFunc(void)
local_node = makeNode(Func); local_node = makeNode(Func);
token = lsptok(NULL, &length); /* get :funcid */ token = pg_strtok(&length); /* get :funcid */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->funcid = (Oid) atol(token); local_node->funcid = (Oid) atol(token);
token = lsptok(NULL, &length); /* get :functype */ token = pg_strtok(&length); /* get :functype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->functype = (Oid) atol(token); local_node->functype = (Oid) atol(token);
local_node->func_fcache = NULL; local_node->func_fcache = NULL;
...@@ -1004,16 +999,16 @@ _readOper(void) ...@@ -1004,16 +999,16 @@ _readOper(void)
local_node = makeNode(Oper); local_node = makeNode(Oper);
token = lsptok(NULL, &length); /* get :opno */ token = pg_strtok(&length); /* get :opno */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->opno = (Oid) atol(token); local_node->opno = (Oid) atol(token);
token = lsptok(NULL, &length); /* get :opid */ token = pg_strtok(&length); /* get :opid */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->opid = (Oid) atol(token); local_node->opid = (Oid) atol(token);
token = lsptok(NULL, &length); /* get :opresulttype */ token = pg_strtok(&length); /* get :opresulttype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->opresulttype = (Oid) atol(token); local_node->opresulttype = (Oid) atol(token);
local_node->op_fcache = NULL; local_node->op_fcache = NULL;
...@@ -1036,23 +1031,23 @@ _readParam(void) ...@@ -1036,23 +1031,23 @@ _readParam(void)
local_node = makeNode(Param); local_node = makeNode(Param);
token = lsptok(NULL, &length); /* get :paramkind */ token = pg_strtok(&length); /* get :paramkind */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->paramkind = atoi(token); local_node->paramkind = atoi(token);
token = lsptok(NULL, &length); /* get :paramid */ token = pg_strtok(&length); /* get :paramid */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->paramid = atol(token); local_node->paramid = atol(token);
token = lsptok(NULL, &length); /* get :paramname */ token = pg_strtok(&length); /* get :paramname */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
if (length == 0) if (length == 0)
local_node->paramname = NULL; local_node->paramname = NULL;
else else
local_node->paramname = debackslash(token, length); local_node->paramname = debackslash(token, length);
token = lsptok(NULL, &length); /* get :paramtype */ token = pg_strtok(&length); /* get :paramtype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->paramtype = (Oid) atol(token); local_node->paramtype = (Oid) atol(token);
return local_node; return local_node;
...@@ -1073,27 +1068,27 @@ _readAggref(void) ...@@ -1073,27 +1068,27 @@ _readAggref(void)
local_node = makeNode(Aggref); local_node = makeNode(Aggref);
token = lsptok(NULL, &length); /* eat :aggname */ token = pg_strtok(&length); /* eat :aggname */
token = lsptok(NULL, &length); /* get aggname */ token = pg_strtok(&length); /* get aggname */
local_node->aggname = debackslash(token, length); local_node->aggname = debackslash(token, length);
token = lsptok(NULL, &length); /* eat :basetype */ token = pg_strtok(&length); /* eat :basetype */
token = lsptok(NULL, &length); /* get basetype */ token = pg_strtok(&length); /* get basetype */
local_node->basetype = (Oid) atol(token); local_node->basetype = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :aggtype */ token = pg_strtok(&length); /* eat :aggtype */
token = lsptok(NULL, &length); /* get aggtype */ token = pg_strtok(&length); /* get aggtype */
local_node->aggtype = (Oid) atol(token); local_node->aggtype = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :target */ token = pg_strtok(&length); /* eat :target */
local_node->target = nodeRead(true); /* now read it */ local_node->target = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :aggstar */ token = pg_strtok(&length); /* eat :aggstar */
token = lsptok(NULL, &length); /* get aggstar */ token = pg_strtok(&length); /* get aggstar */
local_node->aggstar = (token[0] == 't') ? true : false; local_node->aggstar = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :aggdistinct */ token = pg_strtok(&length); /* eat :aggdistinct */
token = lsptok(NULL, &length); /* get aggdistinct */ token = pg_strtok(&length); /* get aggdistinct */
local_node->aggdistinct = (token[0] == 't') ? true : false; local_node->aggdistinct = (token[0] == 't') ? true : false;
return local_node; return local_node;
...@@ -1114,21 +1109,21 @@ _readSubLink(void) ...@@ -1114,21 +1109,21 @@ _readSubLink(void)
local_node = makeNode(SubLink); local_node = makeNode(SubLink);
token = lsptok(NULL, &length); /* eat :subLinkType */ token = pg_strtok(&length); /* eat :subLinkType */
token = lsptok(NULL, &length); /* get subLinkType */ token = pg_strtok(&length); /* get subLinkType */
local_node->subLinkType = atoi(token); local_node->subLinkType = atoi(token);
token = lsptok(NULL, &length); /* eat :useor */ token = pg_strtok(&length); /* eat :useor */
token = lsptok(NULL, &length); /* get useor */ token = pg_strtok(&length); /* get useor */
local_node->useor = (token[0] == 't') ? true : false; local_node->useor = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :lefthand */ token = pg_strtok(&length); /* eat :lefthand */
local_node->lefthand = nodeRead(true); /* now read it */ local_node->lefthand = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :oper */ token = pg_strtok(&length); /* eat :oper */
local_node->oper = nodeRead(true); /* now read it */ local_node->oper = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :subselect */ token = pg_strtok(&length); /* eat :subselect */
local_node->subselect = nodeRead(true); /* now read it */ local_node->subselect = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1149,19 +1144,19 @@ _readFieldSelect(void) ...@@ -1149,19 +1144,19 @@ _readFieldSelect(void)
local_node = makeNode(FieldSelect); local_node = makeNode(FieldSelect);
token = lsptok(NULL, &length); /* eat :arg */ token = pg_strtok(&length); /* eat :arg */
local_node->arg = nodeRead(true); /* now read it */ local_node->arg = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :fieldnum */ token = pg_strtok(&length); /* eat :fieldnum */
token = lsptok(NULL, &length); /* get fieldnum */ token = pg_strtok(&length); /* get fieldnum */
local_node->fieldnum = (AttrNumber) atoi(token); local_node->fieldnum = (AttrNumber) atoi(token);
token = lsptok(NULL, &length); /* eat :resulttype */ token = pg_strtok(&length); /* eat :resulttype */
token = lsptok(NULL, &length); /* get resulttype */ token = pg_strtok(&length); /* get resulttype */
local_node->resulttype = (Oid) atol(token); local_node->resulttype = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :resulttypmod */ token = pg_strtok(&length); /* eat :resulttypmod */
token = lsptok(NULL, &length); /* get resulttypmod */ token = pg_strtok(&length); /* get resulttypmod */
local_node->resulttypmod = atoi(token); local_node->resulttypmod = atoi(token);
return local_node; return local_node;
...@@ -1182,15 +1177,15 @@ _readRelabelType(void) ...@@ -1182,15 +1177,15 @@ _readRelabelType(void)
local_node = makeNode(RelabelType); local_node = makeNode(RelabelType);
token = lsptok(NULL, &length); /* eat :arg */ token = pg_strtok(&length); /* eat :arg */
local_node->arg = nodeRead(true); /* now read it */ local_node->arg = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :resulttype */ token = pg_strtok(&length); /* eat :resulttype */
token = lsptok(NULL, &length); /* get resulttype */ token = pg_strtok(&length); /* get resulttype */
local_node->resulttype = (Oid) atol(token); local_node->resulttype = (Oid) atol(token);
token = lsptok(NULL, &length); /* eat :resulttypmod */ token = pg_strtok(&length); /* eat :resulttypmod */
token = lsptok(NULL, &length); /* get resulttypmod */ token = pg_strtok(&length); /* get resulttypmod */
local_node->resulttypmod = atoi(token); local_node->resulttypmod = atoi(token);
return local_node; return local_node;
...@@ -1211,7 +1206,7 @@ _readRangeTblRef(void) ...@@ -1211,7 +1206,7 @@ _readRangeTblRef(void)
local_node = makeNode(RangeTblRef); local_node = makeNode(RangeTblRef);
token = lsptok(NULL, &length); /* get rtindex */ token = pg_strtok(&length); /* get rtindex */
local_node->rtindex = atoi(token); local_node->rtindex = atoi(token);
return local_node; return local_node;
...@@ -1232,10 +1227,10 @@ _readFromExpr(void) ...@@ -1232,10 +1227,10 @@ _readFromExpr(void)
local_node = makeNode(FromExpr); local_node = makeNode(FromExpr);
token = lsptok(NULL, &length); /* eat :fromlist */ token = pg_strtok(&length); /* eat :fromlist */
local_node->fromlist = nodeRead(true); /* now read it */ local_node->fromlist = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :quals */ token = pg_strtok(&length); /* eat :quals */
local_node->quals = nodeRead(true); /* now read it */ local_node->quals = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1256,33 +1251,33 @@ _readJoinExpr(void) ...@@ -1256,33 +1251,33 @@ _readJoinExpr(void)
local_node = makeNode(JoinExpr); local_node = makeNode(JoinExpr);
token = lsptok(NULL, &length); /* eat :jointype */ token = pg_strtok(&length); /* eat :jointype */
token = lsptok(NULL, &length); /* get jointype */ token = pg_strtok(&length); /* get jointype */
local_node->jointype = (JoinType) atoi(token); local_node->jointype = (JoinType) atoi(token);
token = lsptok(NULL, &length); /* eat :isNatural */ token = pg_strtok(&length); /* eat :isNatural */
token = lsptok(NULL, &length); /* get :isNatural */ token = pg_strtok(&length); /* get :isNatural */
local_node->isNatural = (token[0] == 't') ? true : false; local_node->isNatural = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :larg */ token = pg_strtok(&length); /* eat :larg */
local_node->larg = nodeRead(true); /* now read it */ local_node->larg = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :rarg */ token = pg_strtok(&length); /* eat :rarg */
local_node->rarg = nodeRead(true); /* now read it */ local_node->rarg = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :using */ token = pg_strtok(&length); /* eat :using */
local_node->using = nodeRead(true); /* now read it */ local_node->using = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :quals */ token = pg_strtok(&length); /* eat :quals */
local_node->quals = nodeRead(true); /* now read it */ local_node->quals = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :alias */ token = pg_strtok(&length); /* eat :alias */
local_node->alias = nodeRead(true); /* now read it */ local_node->alias = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :colnames */ token = pg_strtok(&length); /* eat :colnames */
local_node->colnames = nodeRead(true); /* now read it */ local_node->colnames = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :colvars */ token = pg_strtok(&length); /* eat :colvars */
local_node->colvars = nodeRead(true); /* now read it */ local_node->colvars = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1305,66 +1300,66 @@ _readRelOptInfo(void) ...@@ -1305,66 +1300,66 @@ _readRelOptInfo(void)
local_node = makeNode(RelOptInfo); local_node = makeNode(RelOptInfo);
token = lsptok(NULL, &length); /* get :relids */ token = pg_strtok(&length); /* get :relids */
local_node->relids = toIntList(nodeRead(true)); /* now read it */ local_node->relids = toIntList(nodeRead(true)); /* now read it */
token = lsptok(NULL, &length); /* get :rows */ token = pg_strtok(&length); /* get :rows */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->rows = atof(token); local_node->rows = atof(token);
token = lsptok(NULL, &length); /* get :width */ token = pg_strtok(&length); /* get :width */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->width = atoi(token); local_node->width = atoi(token);
token = lsptok(NULL, &length); /* get :targetlist */ token = pg_strtok(&length); /* get :targetlist */
local_node->targetlist = nodeRead(true); /* now read it */ local_node->targetlist = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :pathlist */ token = pg_strtok(&length); /* get :pathlist */
local_node->pathlist = nodeRead(true); /* now read it */ local_node->pathlist = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :cheapest_startup_path */ token = pg_strtok(&length); /* get :cheapest_startup_path */
local_node->cheapest_startup_path = nodeRead(true); /* now read it */ local_node->cheapest_startup_path = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :cheapest_total_path */ token = pg_strtok(&length); /* get :cheapest_total_path */
local_node->cheapest_total_path = nodeRead(true); /* now read it */ local_node->cheapest_total_path = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :pruneable */ token = pg_strtok(&length); /* eat :pruneable */
token = lsptok(NULL, &length); /* get :pruneable */ token = pg_strtok(&length); /* get :pruneable */
local_node->pruneable = (token[0] == 't') ? true : false; local_node->pruneable = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* get :issubquery */ token = pg_strtok(&length); /* get :issubquery */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->issubquery = (token[0] == 't') ? true : false; local_node->issubquery = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* get :indexed */ token = pg_strtok(&length); /* get :indexed */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->indexed = (token[0] == 't') ? true : false; local_node->indexed = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* get :pages */ token = pg_strtok(&length); /* get :pages */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->pages = atol(token); local_node->pages = atol(token);
token = lsptok(NULL, &length); /* get :tuples */ token = pg_strtok(&length); /* get :tuples */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->tuples = atof(token); local_node->tuples = atof(token);
token = lsptok(NULL, &length); /* get :subplan */ token = pg_strtok(&length); /* get :subplan */
local_node->subplan = nodeRead(true); /* now read it */ local_node->subplan = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :baserestrictinfo */ token = pg_strtok(&length); /* get :baserestrictinfo */
local_node->baserestrictinfo = nodeRead(true); /* now read it */ local_node->baserestrictinfo = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :baserestrictcost */ token = pg_strtok(&length); /* get :baserestrictcost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->baserestrictcost = (Cost) atof(token); local_node->baserestrictcost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :outerjoinset */ token = pg_strtok(&length); /* get :outerjoinset */
local_node->outerjoinset = toIntList(nodeRead(true)); /* now read it */ local_node->outerjoinset = toIntList(nodeRead(true)); /* now read it */
token = lsptok(NULL, &length); /* get :joininfo */ token = pg_strtok(&length); /* get :joininfo */
local_node->joininfo = nodeRead(true); /* now read it */ local_node->joininfo = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :innerjoin */ token = pg_strtok(&length); /* get :innerjoin */
local_node->innerjoin = nodeRead(true); /* now read it */ local_node->innerjoin = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1383,10 +1378,10 @@ _readTargetEntry(void) ...@@ -1383,10 +1378,10 @@ _readTargetEntry(void)
local_node = makeNode(TargetEntry); local_node = makeNode(TargetEntry);
token = lsptok(NULL, &length); /* get :resdom */ token = pg_strtok(&length); /* get :resdom */
local_node->resdom = nodeRead(true); /* now read it */ local_node->resdom = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :expr */ token = pg_strtok(&length); /* get :expr */
local_node->expr = nodeRead(true); /* now read it */ local_node->expr = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1401,11 +1396,11 @@ _readAttr(void) ...@@ -1401,11 +1396,11 @@ _readAttr(void)
local_node = makeNode(Attr); local_node = makeNode(Attr);
token = lsptok(NULL, &length); /* eat :relname */ token = pg_strtok(&length); /* eat :relname */
token = lsptok(NULL, &length); /* get relname */ token = pg_strtok(&length); /* get relname */
local_node->relname = debackslash(token, length); local_node->relname = debackslash(token, length);
token = lsptok(NULL, &length); /* eat :attrs */ token = pg_strtok(&length); /* eat :attrs */
local_node->attrs = nodeRead(true); /* now read it */ local_node->attrs = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1424,44 +1419,44 @@ _readRangeTblEntry(void) ...@@ -1424,44 +1419,44 @@ _readRangeTblEntry(void)
local_node = makeNode(RangeTblEntry); local_node = makeNode(RangeTblEntry);
token = lsptok(NULL, &length); /* eat :relname */ token = pg_strtok(&length); /* eat :relname */
token = lsptok(NULL, &length); /* get :relname */ token = pg_strtok(&length); /* get :relname */
if (length == 0) if (length == 0)
local_node->relname = NULL; local_node->relname = NULL;
else else
local_node->relname = debackslash(token, length); local_node->relname = debackslash(token, length);
token = lsptok(NULL, &length); /* eat :relid */ token = pg_strtok(&length); /* eat :relid */
token = lsptok(NULL, &length); /* get :relid */ token = pg_strtok(&length); /* get :relid */
local_node->relid = strtoul(token, NULL, 10); local_node->relid = strtoul(token, NULL, 10);
token = lsptok(NULL, &length); /* eat :subquery */ token = pg_strtok(&length); /* eat :subquery */
local_node->subquery = nodeRead(true); /* now read it */ local_node->subquery = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :alias */ token = pg_strtok(&length); /* eat :alias */
local_node->alias = nodeRead(true); /* now read it */ local_node->alias = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :eref */ token = pg_strtok(&length); /* eat :eref */
local_node->eref = nodeRead(true); /* now read it */ local_node->eref = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* eat :inh */ token = pg_strtok(&length); /* eat :inh */
token = lsptok(NULL, &length); /* get :inh */ token = pg_strtok(&length); /* get :inh */
local_node->inh = (token[0] == 't') ? true : false; local_node->inh = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :inFromCl */ token = pg_strtok(&length); /* eat :inFromCl */
token = lsptok(NULL, &length); /* get :inFromCl */ token = pg_strtok(&length); /* get :inFromCl */
local_node->inFromCl = (token[0] == 't') ? true : false; local_node->inFromCl = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :checkForRead */ token = pg_strtok(&length); /* eat :checkForRead */
token = lsptok(NULL, &length); /* get :checkForRead */ token = pg_strtok(&length); /* get :checkForRead */
local_node->checkForRead = (token[0] == 't') ? true : false; local_node->checkForRead = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :checkForWrite */ token = pg_strtok(&length); /* eat :checkForWrite */
token = lsptok(NULL, &length); /* get :checkForWrite */ token = pg_strtok(&length); /* get :checkForWrite */
local_node->checkForWrite = (token[0] == 't') ? true : false; local_node->checkForWrite = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* eat :checkAsUser */ token = pg_strtok(&length); /* eat :checkAsUser */
token = lsptok(NULL, &length); /* get :checkAsUser */ token = pg_strtok(&length); /* get :checkAsUser */
local_node->checkAsUser = strtoul(token, NULL, 10); local_node->checkAsUser = strtoul(token, NULL, 10);
return local_node; return local_node;
...@@ -1482,19 +1477,19 @@ _readPath(void) ...@@ -1482,19 +1477,19 @@ _readPath(void)
local_node = makeNode(Path); local_node = makeNode(Path);
token = lsptok(NULL, &length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->pathtype = atol(token); local_node->pathtype = atol(token);
token = lsptok(NULL, &length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->startup_cost = (Cost) atof(token); local_node->startup_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :total_cost */ token = pg_strtok(&length); /* get :total_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->total_cost = (Cost) atof(token); local_node->total_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :pathkeys */ token = pg_strtok(&length); /* get :pathkeys */
local_node->pathkeys = nodeRead(true); /* now read it */ local_node->pathkeys = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1515,40 +1510,40 @@ _readIndexPath(void) ...@@ -1515,40 +1510,40 @@ _readIndexPath(void)
local_node = makeNode(IndexPath); local_node = makeNode(IndexPath);
token = lsptok(NULL, &length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.pathtype = atol(token); local_node->path.pathtype = atol(token);
token = lsptok(NULL, &length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.startup_cost = (Cost) atof(token); local_node->path.startup_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :total_cost */ token = pg_strtok(&length); /* get :total_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.total_cost = (Cost) atof(token); local_node->path.total_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :pathkeys */ token = pg_strtok(&length); /* get :pathkeys */
local_node->path.pathkeys = nodeRead(true); /* now read it */ local_node->path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :indexid */ token = pg_strtok(&length); /* get :indexid */
local_node->indexid = toIntList(nodeRead(true)); local_node->indexid = toIntList(nodeRead(true));
token = lsptok(NULL, &length); /* get :indexqual */ token = pg_strtok(&length); /* get :indexqual */
local_node->indexqual = nodeRead(true); /* now read it */ local_node->indexqual = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :indexscandir */ token = pg_strtok(&length); /* get :indexscandir */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->indexscandir = (ScanDirection) atoi(token); local_node->indexscandir = (ScanDirection) atoi(token);
token = lsptok(NULL, &length); /* get :joinrelids */ token = pg_strtok(&length); /* get :joinrelids */
local_node->joinrelids = toIntList(nodeRead(true)); local_node->joinrelids = toIntList(nodeRead(true));
token = lsptok(NULL, &length); /* get :alljoinquals */ token = pg_strtok(&length); /* get :alljoinquals */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->alljoinquals = (token[0] == 't') ? true : false; local_node->alljoinquals = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* get :rows */ token = pg_strtok(&length); /* get :rows */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->rows = atof(token); local_node->rows = atof(token);
return local_node; return local_node;
...@@ -1569,25 +1564,25 @@ _readTidPath(void) ...@@ -1569,25 +1564,25 @@ _readTidPath(void)
local_node = makeNode(TidPath); local_node = makeNode(TidPath);
token = lsptok(NULL, &length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.pathtype = atol(token); local_node->path.pathtype = atol(token);
token = lsptok(NULL, &length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.startup_cost = (Cost) atof(token); local_node->path.startup_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :total_cost */ token = pg_strtok(&length); /* get :total_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.total_cost = (Cost) atof(token); local_node->path.total_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :pathkeys */ token = pg_strtok(&length); /* get :pathkeys */
local_node->path.pathkeys = nodeRead(true); /* now read it */ local_node->path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :tideval */ token = pg_strtok(&length); /* get :tideval */
local_node->tideval = nodeRead(true); /* now read it */ local_node->tideval = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :unjoined_relids */ token = pg_strtok(&length); /* get :unjoined_relids */
local_node->unjoined_relids = toIntList(nodeRead(true)); local_node->unjoined_relids = toIntList(nodeRead(true));
return local_node; return local_node;
...@@ -1608,22 +1603,22 @@ _readAppendPath(void) ...@@ -1608,22 +1603,22 @@ _readAppendPath(void)
local_node = makeNode(AppendPath); local_node = makeNode(AppendPath);
token = lsptok(NULL, &length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.pathtype = atol(token); local_node->path.pathtype = atol(token);
token = lsptok(NULL, &length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.startup_cost = (Cost) atof(token); local_node->path.startup_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :total_cost */ token = pg_strtok(&length); /* get :total_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.total_cost = (Cost) atof(token); local_node->path.total_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :pathkeys */ token = pg_strtok(&length); /* get :pathkeys */
local_node->path.pathkeys = nodeRead(true); /* now read it */ local_node->path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :subpaths */ token = pg_strtok(&length); /* get :subpaths */
local_node->subpaths = nodeRead(true); /* now read it */ local_node->subpaths = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1644,32 +1639,32 @@ _readNestPath(void) ...@@ -1644,32 +1639,32 @@ _readNestPath(void)
local_node = makeNode(NestPath); local_node = makeNode(NestPath);
token = lsptok(NULL, &length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.pathtype = atol(token); local_node->path.pathtype = atol(token);
token = lsptok(NULL, &length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.startup_cost = (Cost) atof(token); local_node->path.startup_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :total_cost */ token = pg_strtok(&length); /* get :total_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.total_cost = (Cost) atof(token); local_node->path.total_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :pathkeys */ token = pg_strtok(&length); /* get :pathkeys */
local_node->path.pathkeys = nodeRead(true); /* now read it */ local_node->path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :jointype */ token = pg_strtok(&length); /* get :jointype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jointype = (JoinType) atoi(token); local_node->jointype = (JoinType) atoi(token);
token = lsptok(NULL, &length); /* get :outerjoinpath */ token = pg_strtok(&length); /* get :outerjoinpath */
local_node->outerjoinpath = nodeRead(true); /* now read it */ local_node->outerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :innerjoinpath */ token = pg_strtok(&length); /* get :innerjoinpath */
local_node->innerjoinpath = nodeRead(true); /* now read it */ local_node->innerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :joinrestrictinfo */ token = pg_strtok(&length); /* get :joinrestrictinfo */
local_node->joinrestrictinfo = nodeRead(true); /* now read it */ local_node->joinrestrictinfo = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1690,41 +1685,41 @@ _readMergePath(void) ...@@ -1690,41 +1685,41 @@ _readMergePath(void)
local_node = makeNode(MergePath); local_node = makeNode(MergePath);
token = lsptok(NULL, &length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.path.pathtype = atol(token); local_node->jpath.path.pathtype = atol(token);
token = lsptok(NULL, &length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.path.startup_cost = (Cost) atof(token); local_node->jpath.path.startup_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :total_cost */ token = pg_strtok(&length); /* get :total_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.path.total_cost = (Cost) atof(token); local_node->jpath.path.total_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :pathkeys */ token = pg_strtok(&length); /* get :pathkeys */
local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :jointype */ token = pg_strtok(&length); /* get :jointype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.jointype = (JoinType) atoi(token); local_node->jpath.jointype = (JoinType) atoi(token);
token = lsptok(NULL, &length); /* get :outerjoinpath */ token = pg_strtok(&length); /* get :outerjoinpath */
local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */ local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :innerjoinpath */ token = pg_strtok(&length); /* get :innerjoinpath */
local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */ local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :joinrestrictinfo */ token = pg_strtok(&length); /* get :joinrestrictinfo */
local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */ local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :path_mergeclauses */ token = pg_strtok(&length); /* get :path_mergeclauses */
local_node->path_mergeclauses = nodeRead(true); /* now read it */ local_node->path_mergeclauses = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :outersortkeys */ token = pg_strtok(&length); /* get :outersortkeys */
local_node->outersortkeys = nodeRead(true); /* now read it */ local_node->outersortkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :innersortkeys */ token = pg_strtok(&length); /* get :innersortkeys */
local_node->innersortkeys = nodeRead(true); /* now read it */ local_node->innersortkeys = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1745,35 +1740,35 @@ _readHashPath(void) ...@@ -1745,35 +1740,35 @@ _readHashPath(void)
local_node = makeNode(HashPath); local_node = makeNode(HashPath);
token = lsptok(NULL, &length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.path.pathtype = atol(token); local_node->jpath.path.pathtype = atol(token);
token = lsptok(NULL, &length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.path.startup_cost = (Cost) atof(token); local_node->jpath.path.startup_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :total_cost */ token = pg_strtok(&length); /* get :total_cost */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.path.total_cost = (Cost) atof(token); local_node->jpath.path.total_cost = (Cost) atof(token);
token = lsptok(NULL, &length); /* get :pathkeys */ token = pg_strtok(&length); /* get :pathkeys */
local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */ local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :jointype */ token = pg_strtok(&length); /* get :jointype */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.jointype = (JoinType) atoi(token); local_node->jpath.jointype = (JoinType) atoi(token);
token = lsptok(NULL, &length); /* get :outerjoinpath */ token = pg_strtok(&length); /* get :outerjoinpath */
local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */ local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :innerjoinpath */ token = pg_strtok(&length); /* get :innerjoinpath */
local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */ local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :joinrestrictinfo */ token = pg_strtok(&length); /* get :joinrestrictinfo */
local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */ local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :path_hashclauses */ token = pg_strtok(&length); /* get :path_hashclauses */
local_node->path_hashclauses = nodeRead(true); /* now read it */ local_node->path_hashclauses = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1794,12 +1789,12 @@ _readPathKeyItem(void) ...@@ -1794,12 +1789,12 @@ _readPathKeyItem(void)
local_node = makeNode(PathKeyItem); local_node = makeNode(PathKeyItem);
token = lsptok(NULL, &length); /* get :sortop */ token = pg_strtok(&length); /* get :sortop */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->sortop = (Oid) atol(token); local_node->sortop = (Oid) atol(token);
token = lsptok(NULL, &length); /* get :key */ token = pg_strtok(&length); /* get :key */
local_node->key = nodeRead(true); /* now read it */ local_node->key = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1820,30 +1815,30 @@ _readRestrictInfo(void) ...@@ -1820,30 +1815,30 @@ _readRestrictInfo(void)
local_node = makeNode(RestrictInfo); local_node = makeNode(RestrictInfo);
token = lsptok(NULL, &length); /* get :clause */ token = pg_strtok(&length); /* get :clause */
local_node->clause = nodeRead(true); /* now read it */ local_node->clause = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :ispusheddown */ token = pg_strtok(&length); /* get :ispusheddown */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->ispusheddown = (token[0] == 't') ? true : false; local_node->ispusheddown = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* get :subclauseindices */ token = pg_strtok(&length); /* get :subclauseindices */
local_node->subclauseindices = nodeRead(true); /* now read it */ local_node->subclauseindices = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :mergejoinoperator */ token = pg_strtok(&length); /* get :mergejoinoperator */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->mergejoinoperator = (Oid) atol(token); local_node->mergejoinoperator = (Oid) atol(token);
token = lsptok(NULL, &length); /* get :left_sortop */ token = pg_strtok(&length); /* get :left_sortop */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->left_sortop = (Oid) atol(token); local_node->left_sortop = (Oid) atol(token);
token = lsptok(NULL, &length); /* get :right_sortop */ token = pg_strtok(&length); /* get :right_sortop */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->right_sortop = (Oid) atol(token); local_node->right_sortop = (Oid) atol(token);
token = lsptok(NULL, &length); /* get :hashjoinoperator */ token = pg_strtok(&length); /* get :hashjoinoperator */
token = lsptok(NULL, &length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->hashjoinoperator = (Oid) atol(token); local_node->hashjoinoperator = (Oid) atol(token);
/* eval_cost is not part of saved representation; compute on first use */ /* eval_cost is not part of saved representation; compute on first use */
...@@ -1872,10 +1867,10 @@ _readJoinInfo(void) ...@@ -1872,10 +1867,10 @@ _readJoinInfo(void)
local_node = makeNode(JoinInfo); local_node = makeNode(JoinInfo);
token = lsptok(NULL, &length); /* get :unjoined_relids */ token = pg_strtok(&length); /* get :unjoined_relids */
local_node->unjoined_relids = toIntList(nodeRead(true)); /* now read it */ local_node->unjoined_relids = toIntList(nodeRead(true)); /* now read it */
token = lsptok(NULL, &length); /* get :jinfo_restrictinfo */ token = pg_strtok(&length); /* get :jinfo_restrictinfo */
local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */ local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1895,7 +1890,7 @@ _readIter(void) ...@@ -1895,7 +1890,7 @@ _readIter(void)
local_node = makeNode(Iter); local_node = makeNode(Iter);
token = lsptok(NULL, &length); /* eat :iterexpr */ token = pg_strtok(&length); /* eat :iterexpr */
local_node->iterexpr = nodeRead(true); /* now read it */ local_node->iterexpr = nodeRead(true); /* now read it */
return local_node; return local_node;
...@@ -1908,7 +1903,7 @@ _readIter(void) ...@@ -1908,7 +1903,7 @@ _readIter(void)
* Given a character string containing a plan, parsePlanString sets up the * Given a character string containing a plan, parsePlanString sets up the
* plan structure representing that plan. * plan structure representing that plan.
* *
* The string to be read must already have been loaded into lsptok(). * The string to be read must already have been loaded into pg_strtok().
* ---------------- * ----------------
*/ */
Node * Node *
...@@ -1918,7 +1913,7 @@ parsePlanString(void) ...@@ -1918,7 +1913,7 @@ parsePlanString(void)
int length; int length;
void *return_value = NULL; void *return_value = NULL;
token = lsptok(NULL, &length); token = pg_strtok(&length);
if (length == 4 && strncmp(token, "PLAN", length) == 0) if (length == 4 && strncmp(token, "PLAN", length) == 0)
return_value = _readPlan(); return_value = _readPlan();
...@@ -2033,39 +2028,38 @@ parsePlanString(void) ...@@ -2033,39 +2028,38 @@ parsePlanString(void)
/* ---------------- /* ----------------
* readDatum * readDatum
* *
* given a string representation of the value of the given type, * Given a string representation of a constant, recreate the appropriate
* create the appropriate Datum * Datum. The string representation embeds length info, but not byValue,
* so we must be told that.
* ---------------- * ----------------
*/ */
static Datum static Datum
readDatum(Oid type) readDatum(bool typbyval)
{ {
int length; int length;
int tokenLength; int tokenLength;
char *token; char *token;
bool byValue;
Datum res; Datum res;
char *s; char *s;
int i; int i;
byValue = get_typbyval(type);
/* /*
* read the actual length of the value * read the actual length of the value
*/ */
token = lsptok(NULL, &tokenLength); token = pg_strtok(&tokenLength);
length = atoi(token); length = atoi(token);
token = lsptok(NULL, &tokenLength); /* skip the '[' */
if (byValue) token = pg_strtok(&tokenLength); /* skip the '[' */
if (typbyval)
{ {
if ((Size) length > sizeof(Datum)) if ((Size) length > sizeof(Datum))
elog(ERROR, "readValue: byval & length = %d", length); elog(ERROR, "readDatum: byval & length = %d", length);
res = (Datum) 0; res = (Datum) 0;
s = (char *) (&res); s = (char *) (&res);
for (i = 0; i < (int) sizeof(Datum); i++) for (i = 0; i < (int) sizeof(Datum); i++)
{ {
token = lsptok(NULL, &tokenLength); token = pg_strtok(&tokenLength);
s[i] = (char) atoi(token); s[i] = (char) atoi(token);
} }
} }
...@@ -2076,15 +2070,15 @@ readDatum(Oid type) ...@@ -2076,15 +2070,15 @@ readDatum(Oid type)
s = (char *) palloc(length); s = (char *) palloc(length);
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
token = lsptok(NULL, &tokenLength); token = pg_strtok(&tokenLength);
s[i] = (char) atoi(token); s[i] = (char) atoi(token);
} }
res = PointerGetDatum(s); res = PointerGetDatum(s);
} }
token = lsptok(NULL, &tokenLength); /* skip the ']' */ token = pg_strtok(&tokenLength); /* skip the ']' */
if (token[0] != ']') if (token == NULL || token[0] != ']')
elog(ERROR, "readValue: ']' expected, length =%d", length); elog(ERROR, "readDatum: ']' expected, length = %d", length);
return res; return res;
} }
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: catversion.h,v 1.67 2000/12/28 13:00:27 vadim Exp $ * $Id: catversion.h,v 1.68 2001/01/07 01:08:48 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 200012280 #define CATALOG_VERSION_NO 200101061
#endif #endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: readfuncs.h,v 1.9 2000/01/26 05:58:17 momjian Exp $ * $Id: readfuncs.h,v 1.10 2001/01/07 01:08:48 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
/* /*
* prototypes for functions in read.c (the lisp token parser) * prototypes for functions in read.c (the lisp token parser)
*/ */
extern char *lsptok(char *string, int *length); extern char *pg_strtok(int *length);
extern char *debackslash(char *token, int length); extern char *debackslash(char *token, int length);
extern void *nodeRead(bool read_car_only); extern void *nodeRead(bool read_car_only);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment