Commit 1112a2a0 authored by Tom Lane's avatar Tom Lane

Make outfuncs/readfuncs treat OIDs properly as unsigned values. Clean up

inconsistent coding practices for handling Index values and booleans,
too.
parent a4ddbbd1
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,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
* *
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.136 2001/01/07 01:08:47 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.137 2001/01/08 00:31:43 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
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "utils/datum.h" #include "utils/datum.h"
#define booltostr(x) ((x) ? "true" : "false")
static void _outDatum(StringInfo str, Datum value, int typlen, bool typbyval); 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);
...@@ -56,7 +58,8 @@ _outToken(StringInfo str, char *s) ...@@ -56,7 +58,8 @@ _outToken(StringInfo str, char *s)
*s == '\"' || *s == '\"' ||
*s == '@' || *s == '@' ||
isdigit((unsigned char) *s) || isdigit((unsigned char) *s) ||
(*s == '-' && isdigit((unsigned char) s[1]))) ((*s == '+' || *s == '-') &&
(isdigit((unsigned char) s[1]) || s[1] == '.')))
appendStringInfoChar(str, '\\'); appendStringInfoChar(str, '\\');
while (*s) while (*s)
{ {
...@@ -84,6 +87,21 @@ _outIntList(StringInfo str, List *list) ...@@ -84,6 +87,21 @@ _outIntList(StringInfo str, List *list)
appendStringInfoChar(str, ')'); appendStringInfoChar(str, ')');
} }
/*
* _outOidList -
* converts a List of OIDs
*/
static void
_outOidList(StringInfo str, List *list)
{
List *l;
appendStringInfoChar(str, '(');
foreach(l, list)
appendStringInfo(str, " %u", (Oid) lfirsti(l));
appendStringInfoChar(str, ')');
}
static void static void
_outCreateStmt(StringInfo str, CreateStmt *node) _outCreateStmt(StringInfo str, CreateStmt *node)
{ {
...@@ -91,7 +109,7 @@ _outCreateStmt(StringInfo str, CreateStmt *node) ...@@ -91,7 +109,7 @@ _outCreateStmt(StringInfo str, CreateStmt *node)
_outToken(str, node->relname); _outToken(str, node->relname);
appendStringInfo(str, " :istemp %s ", appendStringInfo(str, " :istemp %s ",
node->istemp ? "true" : "false"); booltostr(node->istemp));
appendStringInfo(str, " :columns "); appendStringInfo(str, " :columns ");
_outNode(str, node->tableElts); _outNode(str, node->tableElts);
...@@ -125,8 +143,8 @@ _outIndexStmt(StringInfo str, IndexStmt *node) ...@@ -125,8 +143,8 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
_outNode(str, node->rangetable); _outNode(str, node->rangetable);
appendStringInfo(str, " :unique %s :primary %s ", appendStringInfo(str, " :unique %s :primary %s ",
node->unique ? "true" : "false", booltostr(node->unique),
node->primary ? "true" : "false"); booltostr(node->primary));
} }
static void static void
...@@ -145,8 +163,8 @@ _outFuncCall(StringInfo str, FuncCall *node) ...@@ -145,8 +163,8 @@ _outFuncCall(StringInfo str, FuncCall *node)
appendStringInfo(str, " :args "); appendStringInfo(str, " :args ");
_outNode(str, node->args); _outNode(str, node->args);
appendStringInfo(str, " :agg_star %s :agg_distinct %s ", appendStringInfo(str, " :agg_star %s :agg_distinct %s ",
node->agg_star ? "true" : "false", booltostr(node->agg_star),
node->agg_distinct ? "true" : "false"); booltostr(node->agg_distinct));
} }
static void static void
...@@ -157,8 +175,8 @@ _outColumnDef(StringInfo str, ColumnDef *node) ...@@ -157,8 +175,8 @@ _outColumnDef(StringInfo str, ColumnDef *node)
appendStringInfo(str, " :typename "); appendStringInfo(str, " :typename ");
_outNode(str, node->typename); _outNode(str, node->typename);
appendStringInfo(str, " :is_not_null %s :is_sequence %s :raw_default ", appendStringInfo(str, " :is_not_null %s :is_sequence %s :raw_default ",
node->is_not_null ? "true" : "false", booltostr(node->is_not_null),
node->is_sequence ? "true" : "false"); booltostr(node->is_sequence));
_outNode(str, node->raw_default); _outNode(str, node->raw_default);
appendStringInfo(str, " :cooked_default "); appendStringInfo(str, " :cooked_default ");
_outToken(str, node->cooked_default); _outToken(str, node->cooked_default);
...@@ -172,8 +190,8 @@ _outTypeName(StringInfo str, TypeName *node) ...@@ -172,8 +190,8 @@ _outTypeName(StringInfo str, TypeName *node)
appendStringInfo(str, " TYPENAME :name "); appendStringInfo(str, " TYPENAME :name ");
_outToken(str, node->name); _outToken(str, node->name);
appendStringInfo(str, " :timezone %s :setof %s typmod %d :arrayBounds ", appendStringInfo(str, " :timezone %s :setof %s typmod %d :arrayBounds ",
node->timezone ? "true" : "false", booltostr(node->timezone),
node->setof ? "true" : "false", booltostr(node->setof),
node->typmod); node->typmod);
_outNode(str, node->arrayBounds); _outNode(str, node->arrayBounds);
} }
...@@ -245,11 +263,11 @@ _outQuery(StringInfo str, Query *node) ...@@ -245,11 +263,11 @@ _outQuery(StringInfo str, Query *node)
appendStringInfo(str, " :isPortal %s :isBinary %s :isTemp %s" appendStringInfo(str, " :isPortal %s :isBinary %s :isTemp %s"
" :hasAggs %s :hasSubLinks %s :rtable ", " :hasAggs %s :hasSubLinks %s :rtable ",
node->isPortal ? "true" : "false", booltostr(node->isPortal),
node->isBinary ? "true" : "false", booltostr(node->isBinary),
node->isTemp ? "true" : "false", booltostr(node->isTemp),
node->hasAggs ? "true" : "false", booltostr(node->hasAggs),
node->hasSubLinks ? "true" : "false"); booltostr(node->hasSubLinks));
_outNode(str, node->rtable); _outNode(str, node->rtable);
appendStringInfo(str, " :jointree "); appendStringInfo(str, " :jointree ");
...@@ -289,14 +307,14 @@ _outQuery(StringInfo str, Query *node) ...@@ -289,14 +307,14 @@ _outQuery(StringInfo str, Query *node)
static void static void
_outSortClause(StringInfo str, SortClause *node) _outSortClause(StringInfo str, SortClause *node)
{ {
appendStringInfo(str, " SORTCLAUSE :tleSortGroupRef %d :sortop %u ", appendStringInfo(str, " SORTCLAUSE :tleSortGroupRef %u :sortop %u ",
node->tleSortGroupRef, node->sortop); node->tleSortGroupRef, node->sortop);
} }
static void static void
_outGroupClause(StringInfo str, GroupClause *node) _outGroupClause(StringInfo str, GroupClause *node)
{ {
appendStringInfo(str, " GROUPCLAUSE :tleSortGroupRef %d :sortop %u ", appendStringInfo(str, " GROUPCLAUSE :tleSortGroupRef %u :sortop %u ",
node->tleSortGroupRef, node->sortop); node->tleSortGroupRef, node->sortop);
} }
...@@ -305,12 +323,12 @@ _outSetOperationStmt(StringInfo str, SetOperationStmt *node) ...@@ -305,12 +323,12 @@ _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
{ {
appendStringInfo(str, " SETOPERATIONSTMT :op %d :all %s :larg ", appendStringInfo(str, " SETOPERATIONSTMT :op %d :all %s :larg ",
(int) node->op, (int) node->op,
node->all ? "true" : "false"); booltostr(node->all));
_outNode(str, node->larg); _outNode(str, node->larg);
appendStringInfo(str, " :rarg "); appendStringInfo(str, " :rarg ");
_outNode(str, node->rarg); _outNode(str, node->rarg);
appendStringInfo(str, " :colTypes "); appendStringInfo(str, " :colTypes ");
_outIntList(str, node->colTypes); _outOidList(str, node->colTypes);
} }
/* /*
...@@ -384,7 +402,7 @@ _outAppend(StringInfo str, Append *node) ...@@ -384,7 +402,7 @@ _outAppend(StringInfo str, Append *node)
_outNode(str, node->appendplans); _outNode(str, node->appendplans);
appendStringInfo(str, " :isTarget %s ", appendStringInfo(str, " :isTarget %s ",
node->isTarget ? "true" : "false"); booltostr(node->isTarget));
} }
/* /*
...@@ -453,7 +471,7 @@ _outSubPlan(StringInfo str, SubPlan *node) ...@@ -453,7 +471,7 @@ _outSubPlan(StringInfo str, SubPlan *node)
appendStringInfo(str, " SUBPLAN :plan "); appendStringInfo(str, " SUBPLAN :plan ");
_outNode(str, node->plan); _outNode(str, node->plan);
appendStringInfo(str, " :planid %u :rtable ", node->plan_id); appendStringInfo(str, " :planid %d :rtable ", node->plan_id);
_outNode(str, node->rtable); _outNode(str, node->rtable);
appendStringInfo(str, " :setprm "); appendStringInfo(str, " :setprm ");
...@@ -500,7 +518,7 @@ _outIndexScan(StringInfo str, IndexScan *node) ...@@ -500,7 +518,7 @@ _outIndexScan(StringInfo str, IndexScan *node)
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
appendStringInfo(str, " :scanrelid %u :indxid ", node->scan.scanrelid); appendStringInfo(str, " :scanrelid %u :indxid ", node->scan.scanrelid);
_outIntList(str, node->indxid); _outOidList(str, node->indxid);
appendStringInfo(str, " :indxqual "); appendStringInfo(str, " :indxqual ");
_outNode(str, node->indxqual); _outNode(str, node->indxqual);
...@@ -578,7 +596,7 @@ _outGroup(StringInfo str, Group *node) ...@@ -578,7 +596,7 @@ _outGroup(StringInfo str, Group *node)
/* the actual Group fields */ /* the actual Group fields */
appendStringInfo(str, " :numCols %d :tuplePerGroup %s ", appendStringInfo(str, " :numCols %d :tuplePerGroup %s ",
node->numCols, node->numCols,
node->tuplePerGroup ? "true" : "false"); booltostr(node->tuplePerGroup));
} }
static void static void
...@@ -654,11 +672,11 @@ _outResdom(StringInfo str, Resdom *node) ...@@ -654,11 +672,11 @@ _outResdom(StringInfo str, Resdom *node)
node->restype, node->restype,
node->restypmod); node->restypmod);
_outToken(str, node->resname); _outToken(str, node->resname);
appendStringInfo(str, " :reskey %d :reskeyop %u :ressortgroupref %d :resjunk %s ", appendStringInfo(str, " :reskey %u :reskeyop %u :ressortgroupref %u :resjunk %s ",
node->reskey, node->reskey,
node->reskeyop, node->reskeyop,
node->ressortgroupref, node->ressortgroupref,
node->resjunk ? "true" : "false"); booltostr(node->resjunk));
} }
static void static void
...@@ -667,7 +685,7 @@ _outFjoin(StringInfo str, Fjoin *node) ...@@ -667,7 +685,7 @@ _outFjoin(StringInfo str, Fjoin *node)
int i; int i;
appendStringInfo(str, " FJOIN :initialized %s :nNodes %d ", appendStringInfo(str, " FJOIN :initialized %s :nNodes %d ",
node->fj_initialized ? "true" : "false", booltostr(node->fj_initialized),
node->fj_nNodes); node->fj_nNodes);
appendStringInfo(str, " :innerNode "); appendStringInfo(str, " :innerNode ");
...@@ -677,7 +695,8 @@ _outFjoin(StringInfo str, Fjoin *node) ...@@ -677,7 +695,8 @@ _outFjoin(StringInfo str, Fjoin *node)
node->fj_results); node->fj_results);
for (i = 0; i < node->fj_nNodes; i++) for (i = 0; i < node->fj_nNodes; i++)
appendStringInfo(str, (node->fj_alwaysDone[i]) ? "true" : "false"); appendStringInfo(str,
booltostr(node->fj_alwaysDone[i]));
} }
/* /*
...@@ -728,13 +747,13 @@ static void ...@@ -728,13 +747,13 @@ static void
_outVar(StringInfo str, Var *node) _outVar(StringInfo str, Var *node)
{ {
appendStringInfo(str, appendStringInfo(str,
" VAR :varno %d :varattno %d :vartype %u :vartypmod %d ", " VAR :varno %u :varattno %d :vartype %u :vartypmod %d ",
node->varno, node->varno,
node->varattno, node->varattno,
node->vartype, node->vartype,
node->vartypmod); node->vartypmod);
appendStringInfo(str, " :varlevelsup %u :varnoold %d :varoattno %d", appendStringInfo(str, " :varlevelsup %u :varnoold %u :varoattno %d",
node->varlevelsup, node->varlevelsup,
node->varnoold, node->varnoold,
node->varoattno); node->varoattno);
...@@ -751,8 +770,8 @@ _outConst(StringInfo str, Const *node) ...@@ -751,8 +770,8 @@ _outConst(StringInfo str, Const *node)
" :constisnull %s :constvalue ", " :constisnull %s :constvalue ",
node->consttype, node->consttype,
node->constlen, node->constlen,
node->constbyval ? "true" : "false", booltostr(node->constbyval),
node->constisnull ? "true" : "false"); booltostr(node->constisnull));
if (node->constisnull) if (node->constisnull)
appendStringInfo(str, "<>"); appendStringInfo(str, "<>");
...@@ -773,8 +792,8 @@ _outAggref(StringInfo str, Aggref *node) ...@@ -773,8 +792,8 @@ _outAggref(StringInfo str, Aggref *node)
_outNode(str, node->target); _outNode(str, node->target);
appendStringInfo(str, " :aggstar %s :aggdistinct %s ", appendStringInfo(str, " :aggstar %s :aggdistinct %s ",
node->aggstar ? "true" : "false", booltostr(node->aggstar),
node->aggdistinct ? "true" : "false"); booltostr(node->aggdistinct));
/* aggno is not dumped */ /* aggno is not dumped */
} }
...@@ -787,7 +806,7 @@ _outSubLink(StringInfo str, SubLink *node) ...@@ -787,7 +806,7 @@ _outSubLink(StringInfo str, SubLink *node)
appendStringInfo(str, appendStringInfo(str,
" SUBLINK :subLinkType %d :useor %s :lefthand ", " SUBLINK :subLinkType %d :useor %s :lefthand ",
node->subLinkType, node->subLinkType,
node->useor ? "true" : "false"); booltostr(node->useor));
_outNode(str, node->lefthand); _outNode(str, node->lefthand);
appendStringInfo(str, " :oper "); appendStringInfo(str, " :oper ");
...@@ -916,7 +935,7 @@ _outJoinExpr(StringInfo str, JoinExpr *node) ...@@ -916,7 +935,7 @@ _outJoinExpr(StringInfo str, JoinExpr *node)
{ {
appendStringInfo(str, " JOINEXPR :jointype %d :isNatural %s :larg ", appendStringInfo(str, " JOINEXPR :jointype %d :isNatural %s :larg ",
(int) node->jointype, (int) node->jointype,
node->isNatural ? "true" : "false"); booltostr(node->isNatural));
_outNode(str, node->larg); _outNode(str, node->larg);
appendStringInfo(str, " :rarg "); appendStringInfo(str, " :rarg ");
_outNode(str, node->rarg); _outNode(str, node->rarg);
...@@ -955,9 +974,9 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node) ...@@ -955,9 +974,9 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
_outNode(str, node->cheapest_total_path); _outNode(str, node->cheapest_total_path);
appendStringInfo(str, " :pruneable %s :issubquery %s :indexed %s :pages %ld :tuples %.0f :subplan ", appendStringInfo(str, " :pruneable %s :issubquery %s :indexed %s :pages %ld :tuples %.0f :subplan ",
node->pruneable ? "true" : "false", booltostr(node->pruneable),
node->issubquery ? "true" : "false", booltostr(node->issubquery),
node->indexed ? "true" : "false", booltostr(node->indexed),
node->pages, node->pages,
node->tuples); node->tuples);
_outNode(str, node->subplan); _outNode(str, node->subplan);
...@@ -1010,10 +1029,10 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node) ...@@ -1010,10 +1029,10 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
_outNode(str, node->eref); _outNode(str, node->eref);
appendStringInfo(str, " :inh %s :inFromCl %s :checkForRead %s" appendStringInfo(str, " :inh %s :inFromCl %s :checkForRead %s"
" :checkForWrite %s :checkAsUser %u", " :checkForWrite %s :checkAsUser %u",
node->inh ? "true" : "false", booltostr(node->inh),
node->inFromCl ? "true" : "false", booltostr(node->inFromCl),
node->checkForRead ? "true" : "false", booltostr(node->checkForRead),
node->checkForWrite ? "true" : "false", booltostr(node->checkForWrite),
node->checkAsUser); node->checkAsUser);
} }
...@@ -1045,7 +1064,7 @@ _outIndexPath(StringInfo str, IndexPath *node) ...@@ -1045,7 +1064,7 @@ _outIndexPath(StringInfo str, IndexPath *node)
_outNode(str, node->path.pathkeys); _outNode(str, node->path.pathkeys);
appendStringInfo(str, " :indexid "); appendStringInfo(str, " :indexid ");
_outIntList(str, node->indexid); _outOidList(str, node->indexid);
appendStringInfo(str, " :indexqual "); appendStringInfo(str, " :indexqual ");
_outNode(str, node->indexqual); _outNode(str, node->indexqual);
...@@ -1055,7 +1074,7 @@ _outIndexPath(StringInfo str, IndexPath *node) ...@@ -1055,7 +1074,7 @@ _outIndexPath(StringInfo str, IndexPath *node)
_outIntList(str, node->joinrelids); _outIntList(str, node->joinrelids);
appendStringInfo(str, " :alljoinquals %s :rows %.2f ", appendStringInfo(str, " :alljoinquals %s :rows %.2f ",
node->alljoinquals ? "true" : "false", booltostr(node->alljoinquals),
node->rows); node->rows);
} }
...@@ -1192,7 +1211,7 @@ _outRestrictInfo(StringInfo str, RestrictInfo *node) ...@@ -1192,7 +1211,7 @@ _outRestrictInfo(StringInfo str, RestrictInfo *node)
_outNode(str, node->clause); _outNode(str, node->clause);
appendStringInfo(str, " :ispusheddown %s :subclauseindices ", appendStringInfo(str, " :ispusheddown %s :subclauseindices ",
node->ispusheddown ? "true" : "false"); booltostr(node->ispusheddown));
_outNode(str, node->subclauseindices); _outNode(str, node->subclauseindices);
appendStringInfo(str, " :mergejoinoperator %u ", node->mergejoinoperator); appendStringInfo(str, " :mergejoinoperator %u ", node->mergejoinoperator);
...@@ -1313,7 +1332,7 @@ _outValue(StringInfo str, Value *value) ...@@ -1313,7 +1332,7 @@ _outValue(StringInfo str, Value *value)
{ {
switch (value->type) switch (value->type)
{ {
case T_Integer: case T_Integer:
appendStringInfo(str, " %ld ", value->val.ival); appendStringInfo(str, " %ld ", value->val.ival);
break; break;
case T_Float: case T_Float:
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.103 2001/01/07 01:08:47 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.104 2001/01/08 00:31:43 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
...@@ -32,6 +32,22 @@ ...@@ -32,6 +32,22 @@
#include "nodes/relation.h" #include "nodes/relation.h"
/*
* 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,
* for which use atooid(). (As of 7.1, outfuncs.c writes OIDs as %u,
* 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) \
((length) == 0 ? (char *) NULL : debackslash(token, length))
static Datum readDatum(bool typbyval); static Datum readDatum(bool typbyval);
...@@ -40,6 +56,7 @@ static Datum readDatum(bool typbyval); ...@@ -40,6 +56,7 @@ static Datum readDatum(bool typbyval);
* ---------------- * ----------------
*/ */
/* Convert Value list returned by nodeRead into list of integers */
static List * static List *
toIntList(List *list) toIntList(List *list)
{ {
...@@ -47,8 +64,44 @@ toIntList(List *list) ...@@ -47,8 +64,44 @@ toIntList(List *list)
foreach(l, list) foreach(l, list)
{ {
/* ugly manipulation, should probably free the Value node too */ Value *v = (Value *) lfirst(l);
lfirst(l) = (void *) intVal(lfirst(l));
if (!IsA(v, Integer))
elog(ERROR, "toIntList: unexpected datatype");
lfirsti(l) = intVal(v);
pfree(v);
}
return list;
}
/* Convert Value list returned by nodeRead into list of OIDs */
static List *
toOidList(List *list)
{
List *l;
foreach(l, list)
{
Value *v = (Value *) lfirst(l);
/*
* This is a bit tricky because OID is unsigned, and so nodeRead
* might have concluded the value doesn't fit in an integer.
* Must cope with T_Float as well.
*/
if (IsA(v, Integer))
{
lfirsti(l) = (Oid) intVal(v);
pfree(v);
}
else if (IsA(v, Float))
{
lfirsti(l) = atooid(strVal(v));
pfree(strVal(v));
pfree(v);
}
else
elog(ERROR, "toOidList: unexpected datatype");
} }
return list; return list;
} }
...@@ -93,30 +146,27 @@ _readQuery(void) ...@@ -93,30 +146,27 @@ _readQuery(void)
token = pg_strtok(&length); /* skip :into */ token = pg_strtok(&length); /* skip :into */
token = pg_strtok(&length); /* get into */ token = pg_strtok(&length); /* get into */
if (length == 0) local_node->into = nullable_string(token, length);
local_node->into = NULL;
else
local_node->into = debackslash(token, length);
token = pg_strtok(&length); /* skip :isPortal */ token = pg_strtok(&length); /* skip :isPortal */
token = pg_strtok(&length); /* get isPortal */ token = pg_strtok(&length); /* get isPortal */
local_node->isPortal = (token[0] == 't') ? true : false; local_node->isPortal = strtobool(token);
token = pg_strtok(&length); /* skip :isBinary */ token = pg_strtok(&length); /* skip :isBinary */
token = pg_strtok(&length); /* get isBinary */ token = pg_strtok(&length); /* get isBinary */
local_node->isBinary = (token[0] == 't') ? true : false; local_node->isBinary = strtobool(token);
token = pg_strtok(&length); /* skip :isTemp */ token = pg_strtok(&length); /* skip :isTemp */
token = pg_strtok(&length); /* get isTemp */ token = pg_strtok(&length); /* get isTemp */
local_node->isTemp = (token[0] == 't') ? true : false; local_node->isTemp = strtobool(token);
token = pg_strtok(&length); /* skip the :hasAggs */ token = pg_strtok(&length); /* skip the :hasAggs */
token = pg_strtok(&length); /* get hasAggs */ token = pg_strtok(&length); /* get hasAggs */
local_node->hasAggs = (token[0] == 't') ? true : false; local_node->hasAggs = strtobool(token);
token = pg_strtok(&length); /* skip the :hasSubLinks */ token = pg_strtok(&length); /* skip the :hasSubLinks */
token = pg_strtok(&length); /* get hasSubLinks */ token = pg_strtok(&length); /* get hasSubLinks */
local_node->hasSubLinks = (token[0] == 't') ? true : false; local_node->hasSubLinks = strtobool(token);
token = pg_strtok(&length); /* skip :rtable */ token = pg_strtok(&length); /* skip :rtable */
local_node->rtable = nodeRead(true); local_node->rtable = nodeRead(true);
...@@ -172,11 +222,11 @@ _readSortClause(void) ...@@ -172,11 +222,11 @@ _readSortClause(void)
token = pg_strtok(&length); /* skip :tleSortGroupRef */ token = pg_strtok(&length); /* skip :tleSortGroupRef */
token = pg_strtok(&length); /* get tleSortGroupRef */ token = pg_strtok(&length); /* get tleSortGroupRef */
local_node->tleSortGroupRef = strtoul(token, NULL, 10); local_node->tleSortGroupRef = atoui(token);
token = pg_strtok(&length); /* skip :sortop */ token = pg_strtok(&length); /* skip :sortop */
token = pg_strtok(&length); /* get sortop */ token = pg_strtok(&length); /* get sortop */
local_node->sortop = strtoul(token, NULL, 10); local_node->sortop = atooid(token);
return local_node; return local_node;
} }
...@@ -196,11 +246,11 @@ _readGroupClause(void) ...@@ -196,11 +246,11 @@ _readGroupClause(void)
token = pg_strtok(&length); /* skip :tleSortGroupRef */ token = pg_strtok(&length); /* skip :tleSortGroupRef */
token = pg_strtok(&length); /* get tleSortGroupRef */ token = pg_strtok(&length); /* get tleSortGroupRef */
local_node->tleSortGroupRef = strtoul(token, NULL, 10); local_node->tleSortGroupRef = atoui(token);
token = pg_strtok(&length); /* skip :sortop */ token = pg_strtok(&length); /* skip :sortop */
token = pg_strtok(&length); /* get sortop */ token = pg_strtok(&length); /* get sortop */
local_node->sortop = strtoul(token, NULL, 10); local_node->sortop = atooid(token);
return local_node; return local_node;
} }
...@@ -224,7 +274,7 @@ _readSetOperationStmt(void) ...@@ -224,7 +274,7 @@ _readSetOperationStmt(void)
token = pg_strtok(&length); /* eat :all */ token = pg_strtok(&length); /* eat :all */
token = pg_strtok(&length); /* get all */ token = pg_strtok(&length); /* get all */
local_node->all = (token[0] == 't') ? true : false; local_node->all = strtobool(token);
token = pg_strtok(&length); /* eat :larg */ token = pg_strtok(&length); /* eat :larg */
local_node->larg = nodeRead(true); /* get larg */ local_node->larg = nodeRead(true); /* get larg */
...@@ -233,7 +283,7 @@ _readSetOperationStmt(void) ...@@ -233,7 +283,7 @@ _readSetOperationStmt(void)
local_node->rarg = nodeRead(true); /* get rarg */ local_node->rarg = nodeRead(true); /* get rarg */
token = pg_strtok(&length); /* eat :colTypes */ token = pg_strtok(&length); /* eat :colTypes */
local_node->colTypes = toIntList(nodeRead(true)); local_node->colTypes = toOidList(nodeRead(true));
return local_node; return local_node;
} }
...@@ -345,7 +395,7 @@ _readAppend(void) ...@@ -345,7 +395,7 @@ _readAppend(void)
token = pg_strtok(&length); /* eat :isTarget */ token = pg_strtok(&length); /* eat :isTarget */
token = pg_strtok(&length); /* get isTarget */ token = pg_strtok(&length); /* get isTarget */
local_node->isTarget = (token[0] == 't') ? true : false; local_node->isTarget = strtobool(token);
return local_node; return local_node;
} }
...@@ -453,7 +503,7 @@ _readHashJoin(void) ...@@ -453,7 +503,7 @@ _readHashJoin(void)
token = pg_strtok(&length); /* eat :hashjoinop */ token = pg_strtok(&length); /* eat :hashjoinop */
token = pg_strtok(&length); /* get hashjoinop */ token = pg_strtok(&length); /* get hashjoinop */
local_node->hashjoinop = strtoul(token, NULL, 10); local_node->hashjoinop = atooid(token);
return local_node; return local_node;
} }
...@@ -476,7 +526,7 @@ _getScan(Scan *node) ...@@ -476,7 +526,7 @@ _getScan(Scan *node)
token = pg_strtok(&length); /* eat :scanrelid */ token = pg_strtok(&length); /* eat :scanrelid */
token = pg_strtok(&length); /* get scanrelid */ token = pg_strtok(&length); /* get scanrelid */
node->scanrelid = strtoul(token, NULL, 10); node->scanrelid = atoui(token);
} }
/* ---------------- /* ----------------
...@@ -533,7 +583,7 @@ _readIndexScan(void) ...@@ -533,7 +583,7 @@ _readIndexScan(void)
_getScan((Scan *) local_node); _getScan((Scan *) local_node);
token = pg_strtok(&length); /* eat :indxid */ token = pg_strtok(&length); /* eat :indxid */
local_node->indxid = toIntList(nodeRead(true)); /* now read it */ local_node->indxid = toOidList(nodeRead(true)); /* now read it */
token = pg_strtok(&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 */
...@@ -681,7 +731,7 @@ _readResdom(void) ...@@ -681,7 +731,7 @@ _readResdom(void)
token = pg_strtok(&length); /* eat :restype */ token = pg_strtok(&length); /* eat :restype */
token = pg_strtok(&length); /* get restype */ token = pg_strtok(&length); /* get restype */
local_node->restype = (Oid) atol(token); local_node->restype = atooid(token);
token = pg_strtok(&length); /* eat :restypmod */ token = pg_strtok(&length); /* eat :restypmod */
token = pg_strtok(&length); /* get restypmod */ token = pg_strtok(&length); /* get restypmod */
...@@ -689,26 +739,23 @@ _readResdom(void) ...@@ -689,26 +739,23 @@ _readResdom(void)
token = pg_strtok(&length); /* eat :resname */ token = pg_strtok(&length); /* eat :resname */
token = pg_strtok(&length); /* get the name */ token = pg_strtok(&length); /* get the name */
if (length == 0) local_node->resname = nullable_string(token, length);
local_node->resname = NULL;
else
local_node->resname = debackslash(token, length);
token = pg_strtok(&length); /* eat :reskey */ token = pg_strtok(&length); /* eat :reskey */
token = pg_strtok(&length); /* get reskey */ token = pg_strtok(&length); /* get reskey */
local_node->reskey = strtoul(token, NULL, 10); local_node->reskey = atoui(token);
token = pg_strtok(&length); /* eat :reskeyop */ token = pg_strtok(&length); /* eat :reskeyop */
token = pg_strtok(&length); /* get reskeyop */ token = pg_strtok(&length); /* get reskeyop */
local_node->reskeyop = (Oid) atol(token); local_node->reskeyop = atooid(token);
token = pg_strtok(&length); /* eat :ressortgroupref */ token = pg_strtok(&length); /* eat :ressortgroupref */
token = pg_strtok(&length); /* get ressortgroupref */ token = pg_strtok(&length); /* get ressortgroupref */
local_node->ressortgroupref = strtoul(token, NULL, 10); local_node->ressortgroupref = atoui(token);
token = pg_strtok(&length); /* eat :resjunk */ token = pg_strtok(&length); /* eat :resjunk */
token = pg_strtok(&length); /* get resjunk */ token = pg_strtok(&length); /* get resjunk */
local_node->resjunk = (token[0] == 't') ? true : false; local_node->resjunk = strtobool(token);
return local_node; return local_node;
} }
...@@ -730,24 +777,24 @@ _readExpr(void) ...@@ -730,24 +777,24 @@ _readExpr(void)
token = pg_strtok(&length); /* eat :typeOid */ token = pg_strtok(&length); /* eat :typeOid */
token = pg_strtok(&length); /* get typeOid */ token = pg_strtok(&length); /* get typeOid */
local_node->typeOid = (Oid) atol(token); local_node->typeOid = atooid(token);
token = pg_strtok(&length); /* eat :opType */ token = pg_strtok(&length); /* eat :opType */
token = pg_strtok(&length); /* get opType */ token = pg_strtok(&length); /* get opType */
if (!strncmp(token, "op", 2)) if (strncmp(token, "op", 2) == 0)
local_node->opType = OP_EXPR; local_node->opType = OP_EXPR;
else if (!strncmp(token, "func", 4)) else if (strncmp(token, "func", 4) == 0)
local_node->opType = FUNC_EXPR; local_node->opType = FUNC_EXPR;
else if (!strncmp(token, "or", 2)) else if (strncmp(token, "or", 2) == 0)
local_node->opType = OR_EXPR; local_node->opType = OR_EXPR;
else if (!strncmp(token, "and", 3)) else if (strncmp(token, "and", 3) == 0)
local_node->opType = AND_EXPR; local_node->opType = AND_EXPR;
else if (!strncmp(token, "not", 3)) else if (strncmp(token, "not", 3) == 0)
local_node->opType = NOT_EXPR; local_node->opType = NOT_EXPR;
else if (!strncmp(token, "subp", 4)) else if (strncmp(token, "subp", 4) == 0)
local_node->opType = SUBPLAN_EXPR; local_node->opType = SUBPLAN_EXPR;
else else
elog(ERROR, "_readExpr: unknown opType \"%.10s\"", token); elog(ERROR, "_readExpr: unknown opType \"%.*s\"", length, token);
token = pg_strtok(&length); /* eat :oper */ token = pg_strtok(&length); /* eat :oper */
local_node->oper = nodeRead(true); local_node->oper = nodeRead(true);
...@@ -775,7 +822,7 @@ _readCaseExpr(void) ...@@ -775,7 +822,7 @@ _readCaseExpr(void)
token = pg_strtok(&length); /* eat :casetype */ token = pg_strtok(&length); /* eat :casetype */
token = pg_strtok(&length); /* get casetype */ token = pg_strtok(&length); /* get casetype */
local_node->casetype = (Oid) atol(token); local_node->casetype = atooid(token);
token = pg_strtok(&length); /* eat :arg */ token = pg_strtok(&length); /* eat :arg */
local_node->arg = nodeRead(true); local_node->arg = nodeRead(true);
...@@ -828,7 +875,7 @@ _readVar(void) ...@@ -828,7 +875,7 @@ _readVar(void)
token = pg_strtok(&length); /* eat :varno */ token = pg_strtok(&length); /* eat :varno */
token = pg_strtok(&length); /* get varno */ token = pg_strtok(&length); /* get varno */
local_node->varno = strtoul(token, NULL, 10); local_node->varno = atoui(token);
token = pg_strtok(&length); /* eat :varattno */ token = pg_strtok(&length); /* eat :varattno */
token = pg_strtok(&length); /* get varattno */ token = pg_strtok(&length); /* get varattno */
...@@ -836,7 +883,7 @@ _readVar(void) ...@@ -836,7 +883,7 @@ _readVar(void)
token = pg_strtok(&length); /* eat :vartype */ token = pg_strtok(&length); /* eat :vartype */
token = pg_strtok(&length); /* get vartype */ token = pg_strtok(&length); /* get vartype */
local_node->vartype = (Oid) atol(token); local_node->vartype = atooid(token);
token = pg_strtok(&length); /* eat :vartypmod */ token = pg_strtok(&length); /* eat :vartypmod */
token = pg_strtok(&length); /* get vartypmod */ token = pg_strtok(&length); /* get vartypmod */
...@@ -844,11 +891,11 @@ _readVar(void) ...@@ -844,11 +891,11 @@ _readVar(void)
token = pg_strtok(&length); /* eat :varlevelsup */ token = pg_strtok(&length); /* eat :varlevelsup */
token = pg_strtok(&length); /* get varlevelsup */ token = pg_strtok(&length); /* get varlevelsup */
local_node->varlevelsup = (Index) atoi(token); local_node->varlevelsup = atoui(token);
token = pg_strtok(&length); /* eat :varnoold */ token = pg_strtok(&length); /* eat :varnoold */
token = pg_strtok(&length); /* get varnoold */ token = pg_strtok(&length); /* get varnoold */
local_node->varnoold = (Index) atoi(token); local_node->varnoold = atoui(token);
token = pg_strtok(&length); /* eat :varoattno */ token = pg_strtok(&length); /* eat :varoattno */
token = pg_strtok(&length); /* eat :varoattno */ token = pg_strtok(&length); /* eat :varoattno */
...@@ -874,7 +921,7 @@ _readArrayRef(void) ...@@ -874,7 +921,7 @@ _readArrayRef(void)
token = pg_strtok(&length); /* eat :refelemtype */ token = pg_strtok(&length); /* eat :refelemtype */
token = pg_strtok(&length); /* get refelemtype */ token = pg_strtok(&length); /* get refelemtype */
local_node->refelemtype = strtoul(token, NULL, 10); local_node->refelemtype = atooid(token);
token = pg_strtok(&length); /* eat :refattrlength */ token = pg_strtok(&length); /* eat :refattrlength */
token = pg_strtok(&length); /* get refattrlength */ token = pg_strtok(&length); /* get refattrlength */
...@@ -886,7 +933,7 @@ _readArrayRef(void) ...@@ -886,7 +933,7 @@ _readArrayRef(void)
token = pg_strtok(&length); /* eat :refelembyval */ token = pg_strtok(&length); /* eat :refelembyval */
token = pg_strtok(&length); /* get refelembyval */ token = pg_strtok(&length); /* get refelembyval */
local_node->refelembyval = (token[0] == 't') ? true : false; local_node->refelembyval = strtobool(token);
token = pg_strtok(&length); /* eat :refupperindex */ token = pg_strtok(&length); /* eat :refupperindex */
local_node->refupperindexpr = nodeRead(true); local_node->refupperindexpr = nodeRead(true);
...@@ -920,27 +967,19 @@ _readConst(void) ...@@ -920,27 +967,19 @@ _readConst(void)
token = pg_strtok(&length); /* get :consttype */ token = pg_strtok(&length); /* get :consttype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->consttype = (Oid) atol(token); local_node->consttype = atooid(token);
token = pg_strtok(&length); /* get :constlen */ token = pg_strtok(&length); /* get :constlen */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->constlen = strtol(token, NULL, 10); local_node->constlen = atoi(token);
token = pg_strtok(&length); /* get :constbyval */ token = pg_strtok(&length); /* get :constbyval */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->constbyval = strtobool(token);
if (!strncmp(token, "true", 4))
local_node->constbyval = true;
else
local_node->constbyval = false;
token = pg_strtok(&length); /* get :constisnull */ token = pg_strtok(&length); /* get :constisnull */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->constisnull = strtobool(token);
if (!strncmp(token, "true", 4))
local_node->constisnull = true;
else
local_node->constisnull = false;
token = pg_strtok(&length); /* get :constvalue */ token = pg_strtok(&length); /* get :constvalue */
...@@ -973,11 +1012,11 @@ _readFunc(void) ...@@ -973,11 +1012,11 @@ _readFunc(void)
token = pg_strtok(&length); /* get :funcid */ token = pg_strtok(&length); /* get :funcid */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->funcid = (Oid) atol(token); local_node->funcid = atooid(token);
token = pg_strtok(&length); /* get :functype */ token = pg_strtok(&length); /* get :functype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->functype = (Oid) atol(token); local_node->functype = atooid(token);
local_node->func_fcache = NULL; local_node->func_fcache = NULL;
...@@ -1001,15 +1040,15 @@ _readOper(void) ...@@ -1001,15 +1040,15 @@ _readOper(void)
token = pg_strtok(&length); /* get :opno */ token = pg_strtok(&length); /* get :opno */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->opno = (Oid) atol(token); local_node->opno = atooid(token);
token = pg_strtok(&length); /* get :opid */ token = pg_strtok(&length); /* get :opid */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->opid = (Oid) atol(token); local_node->opid = atooid(token);
token = pg_strtok(&length); /* get :opresulttype */ token = pg_strtok(&length); /* get :opresulttype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->opresulttype = (Oid) atol(token); local_node->opresulttype = atooid(token);
local_node->op_fcache = NULL; local_node->op_fcache = NULL;
...@@ -1037,18 +1076,15 @@ _readParam(void) ...@@ -1037,18 +1076,15 @@ _readParam(void)
token = pg_strtok(&length); /* get :paramid */ token = pg_strtok(&length); /* get :paramid */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->paramid = atol(token); local_node->paramid = atoi(token);
token = pg_strtok(&length); /* get :paramname */ token = pg_strtok(&length); /* get :paramname */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
if (length == 0) local_node->paramname = nullable_string(token, length);
local_node->paramname = NULL;
else
local_node->paramname = debackslash(token, length);
token = pg_strtok(&length); /* get :paramtype */ token = pg_strtok(&length); /* get :paramtype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->paramtype = (Oid) atol(token); local_node->paramtype = atooid(token);
return local_node; return local_node;
} }
...@@ -1074,22 +1110,22 @@ _readAggref(void) ...@@ -1074,22 +1110,22 @@ _readAggref(void)
token = pg_strtok(&length); /* eat :basetype */ token = pg_strtok(&length); /* eat :basetype */
token = pg_strtok(&length); /* get basetype */ token = pg_strtok(&length); /* get basetype */
local_node->basetype = (Oid) atol(token); local_node->basetype = atooid(token);
token = pg_strtok(&length); /* eat :aggtype */ token = pg_strtok(&length); /* eat :aggtype */
token = pg_strtok(&length); /* get aggtype */ token = pg_strtok(&length); /* get aggtype */
local_node->aggtype = (Oid) atol(token); local_node->aggtype = atooid(token);
token = pg_strtok(&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 = pg_strtok(&length); /* eat :aggstar */ token = pg_strtok(&length); /* eat :aggstar */
token = pg_strtok(&length); /* get aggstar */ token = pg_strtok(&length); /* get aggstar */
local_node->aggstar = (token[0] == 't') ? true : false; local_node->aggstar = strtobool(token);
token = pg_strtok(&length); /* eat :aggdistinct */ token = pg_strtok(&length); /* eat :aggdistinct */
token = pg_strtok(&length); /* get aggdistinct */ token = pg_strtok(&length); /* get aggdistinct */
local_node->aggdistinct = (token[0] == 't') ? true : false; local_node->aggdistinct = strtobool(token);
return local_node; return local_node;
} }
...@@ -1115,7 +1151,7 @@ _readSubLink(void) ...@@ -1115,7 +1151,7 @@ _readSubLink(void)
token = pg_strtok(&length); /* eat :useor */ token = pg_strtok(&length); /* eat :useor */
token = pg_strtok(&length); /* get useor */ token = pg_strtok(&length); /* get useor */
local_node->useor = (token[0] == 't') ? true : false; local_node->useor = strtobool(token);
token = pg_strtok(&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 */
...@@ -1153,7 +1189,7 @@ _readFieldSelect(void) ...@@ -1153,7 +1189,7 @@ _readFieldSelect(void)
token = pg_strtok(&length); /* eat :resulttype */ token = pg_strtok(&length); /* eat :resulttype */
token = pg_strtok(&length); /* get resulttype */ token = pg_strtok(&length); /* get resulttype */
local_node->resulttype = (Oid) atol(token); local_node->resulttype = atooid(token);
token = pg_strtok(&length); /* eat :resulttypmod */ token = pg_strtok(&length); /* eat :resulttypmod */
token = pg_strtok(&length); /* get resulttypmod */ token = pg_strtok(&length); /* get resulttypmod */
...@@ -1182,7 +1218,7 @@ _readRelabelType(void) ...@@ -1182,7 +1218,7 @@ _readRelabelType(void)
token = pg_strtok(&length); /* eat :resulttype */ token = pg_strtok(&length); /* eat :resulttype */
token = pg_strtok(&length); /* get resulttype */ token = pg_strtok(&length); /* get resulttype */
local_node->resulttype = (Oid) atol(token); local_node->resulttype = atooid(token);
token = pg_strtok(&length); /* eat :resulttypmod */ token = pg_strtok(&length); /* eat :resulttypmod */
token = pg_strtok(&length); /* get resulttypmod */ token = pg_strtok(&length); /* get resulttypmod */
...@@ -1257,7 +1293,7 @@ _readJoinExpr(void) ...@@ -1257,7 +1293,7 @@ _readJoinExpr(void)
token = pg_strtok(&length); /* eat :isNatural */ token = pg_strtok(&length); /* eat :isNatural */
token = pg_strtok(&length); /* get :isNatural */ token = pg_strtok(&length); /* get :isNatural */
local_node->isNatural = (token[0] == 't') ? true : false; local_node->isNatural = strtobool(token);
token = pg_strtok(&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 */
...@@ -1325,15 +1361,15 @@ _readRelOptInfo(void) ...@@ -1325,15 +1361,15 @@ _readRelOptInfo(void)
token = pg_strtok(&length); /* eat :pruneable */ token = pg_strtok(&length); /* eat :pruneable */
token = pg_strtok(&length); /* get :pruneable */ token = pg_strtok(&length); /* get :pruneable */
local_node->pruneable = (token[0] == 't') ? true : false; local_node->pruneable = strtobool(token);
token = pg_strtok(&length); /* get :issubquery */ token = pg_strtok(&length); /* get :issubquery */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->issubquery = (token[0] == 't') ? true : false; local_node->issubquery = strtobool(token);
token = pg_strtok(&length); /* get :indexed */ token = pg_strtok(&length); /* get :indexed */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->indexed = (token[0] == 't') ? true : false; local_node->indexed = strtobool(token);
token = pg_strtok(&length); /* get :pages */ token = pg_strtok(&length); /* get :pages */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1421,14 +1457,11 @@ _readRangeTblEntry(void) ...@@ -1421,14 +1457,11 @@ _readRangeTblEntry(void)
token = pg_strtok(&length); /* eat :relname */ token = pg_strtok(&length); /* eat :relname */
token = pg_strtok(&length); /* get :relname */ token = pg_strtok(&length); /* get :relname */
if (length == 0) local_node->relname = nullable_string(token, length);
local_node->relname = NULL;
else
local_node->relname = debackslash(token, length);
token = pg_strtok(&length); /* eat :relid */ token = pg_strtok(&length); /* eat :relid */
token = pg_strtok(&length); /* get :relid */ token = pg_strtok(&length); /* get :relid */
local_node->relid = strtoul(token, NULL, 10); local_node->relid = atooid(token);
token = pg_strtok(&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 */
...@@ -1441,23 +1474,23 @@ _readRangeTblEntry(void) ...@@ -1441,23 +1474,23 @@ _readRangeTblEntry(void)
token = pg_strtok(&length); /* eat :inh */ token = pg_strtok(&length); /* eat :inh */
token = pg_strtok(&length); /* get :inh */ token = pg_strtok(&length); /* get :inh */
local_node->inh = (token[0] == 't') ? true : false; local_node->inh = strtobool(token);
token = pg_strtok(&length); /* eat :inFromCl */ token = pg_strtok(&length); /* eat :inFromCl */
token = pg_strtok(&length); /* get :inFromCl */ token = pg_strtok(&length); /* get :inFromCl */
local_node->inFromCl = (token[0] == 't') ? true : false; local_node->inFromCl = strtobool(token);
token = pg_strtok(&length); /* eat :checkForRead */ token = pg_strtok(&length); /* eat :checkForRead */
token = pg_strtok(&length); /* get :checkForRead */ token = pg_strtok(&length); /* get :checkForRead */
local_node->checkForRead = (token[0] == 't') ? true : false; local_node->checkForRead = strtobool(token);
token = pg_strtok(&length); /* eat :checkForWrite */ token = pg_strtok(&length); /* eat :checkForWrite */
token = pg_strtok(&length); /* get :checkForWrite */ token = pg_strtok(&length); /* get :checkForWrite */
local_node->checkForWrite = (token[0] == 't') ? true : false; local_node->checkForWrite = strtobool(token);
token = pg_strtok(&length); /* eat :checkAsUser */ token = pg_strtok(&length); /* eat :checkAsUser */
token = pg_strtok(&length); /* get :checkAsUser */ token = pg_strtok(&length); /* get :checkAsUser */
local_node->checkAsUser = strtoul(token, NULL, 10); local_node->checkAsUser = atooid(token);
return local_node; return local_node;
} }
...@@ -1479,7 +1512,7 @@ _readPath(void) ...@@ -1479,7 +1512,7 @@ _readPath(void)
token = pg_strtok(&length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->pathtype = atol(token); local_node->pathtype = atoi(token);
token = pg_strtok(&length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1512,7 +1545,7 @@ _readIndexPath(void) ...@@ -1512,7 +1545,7 @@ _readIndexPath(void)
token = pg_strtok(&length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.pathtype = atol(token); local_node->path.pathtype = atoi(token);
token = pg_strtok(&length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1526,7 +1559,7 @@ _readIndexPath(void) ...@@ -1526,7 +1559,7 @@ _readIndexPath(void)
local_node->path.pathkeys = nodeRead(true); /* now read it */ local_node->path.pathkeys = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* get :indexid */ token = pg_strtok(&length); /* get :indexid */
local_node->indexid = toIntList(nodeRead(true)); local_node->indexid = toOidList(nodeRead(true));
token = pg_strtok(&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 */
...@@ -1540,7 +1573,7 @@ _readIndexPath(void) ...@@ -1540,7 +1573,7 @@ _readIndexPath(void)
token = pg_strtok(&length); /* get :alljoinquals */ token = pg_strtok(&length); /* get :alljoinquals */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->alljoinquals = (token[0] == 't') ? true : false; local_node->alljoinquals = strtobool(token);
token = pg_strtok(&length); /* get :rows */ token = pg_strtok(&length); /* get :rows */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1566,7 +1599,7 @@ _readTidPath(void) ...@@ -1566,7 +1599,7 @@ _readTidPath(void)
token = pg_strtok(&length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.pathtype = atol(token); local_node->path.pathtype = atoi(token);
token = pg_strtok(&length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1605,7 +1638,7 @@ _readAppendPath(void) ...@@ -1605,7 +1638,7 @@ _readAppendPath(void)
token = pg_strtok(&length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.pathtype = atol(token); local_node->path.pathtype = atoi(token);
token = pg_strtok(&length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1641,7 +1674,7 @@ _readNestPath(void) ...@@ -1641,7 +1674,7 @@ _readNestPath(void)
token = pg_strtok(&length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->path.pathtype = atol(token); local_node->path.pathtype = atoi(token);
token = pg_strtok(&length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1687,7 +1720,7 @@ _readMergePath(void) ...@@ -1687,7 +1720,7 @@ _readMergePath(void)
token = pg_strtok(&length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.path.pathtype = atol(token); local_node->jpath.path.pathtype = atoi(token);
token = pg_strtok(&length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1742,7 +1775,7 @@ _readHashPath(void) ...@@ -1742,7 +1775,7 @@ _readHashPath(void)
token = pg_strtok(&length); /* get :pathtype */ token = pg_strtok(&length); /* get :pathtype */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->jpath.path.pathtype = atol(token); local_node->jpath.path.pathtype = atoi(token);
token = pg_strtok(&length); /* get :startup_cost */ token = pg_strtok(&length); /* get :startup_cost */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
...@@ -1791,8 +1824,7 @@ _readPathKeyItem(void) ...@@ -1791,8 +1824,7 @@ _readPathKeyItem(void)
token = pg_strtok(&length); /* get :sortop */ token = pg_strtok(&length); /* get :sortop */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->sortop = atooid(token);
local_node->sortop = (Oid) atol(token);
token = pg_strtok(&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 */
...@@ -1820,26 +1852,26 @@ _readRestrictInfo(void) ...@@ -1820,26 +1852,26 @@ _readRestrictInfo(void)
token = pg_strtok(&length); /* get :ispusheddown */ token = pg_strtok(&length); /* get :ispusheddown */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->ispusheddown = (token[0] == 't') ? true : false; local_node->ispusheddown = strtobool(token);
token = pg_strtok(&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 = pg_strtok(&length); /* get :mergejoinoperator */ token = pg_strtok(&length); /* get :mergejoinoperator */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->mergejoinoperator = (Oid) atol(token); local_node->mergejoinoperator = atooid(token);
token = pg_strtok(&length); /* get :left_sortop */ token = pg_strtok(&length); /* get :left_sortop */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->left_sortop = (Oid) atol(token); local_node->left_sortop = atooid(token);
token = pg_strtok(&length); /* get :right_sortop */ token = pg_strtok(&length); /* get :right_sortop */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->right_sortop = (Oid) atol(token); local_node->right_sortop = atooid(token);
token = pg_strtok(&length); /* get :hashjoinoperator */ token = pg_strtok(&length); /* get :hashjoinoperator */
token = pg_strtok(&length); /* now read it */ token = pg_strtok(&length); /* now read it */
local_node->hashjoinoperator = (Oid) atol(token); local_node->hashjoinoperator = atooid(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 */
local_node->eval_cost = -1; local_node->eval_cost = -1;
...@@ -2036,28 +2068,28 @@ parsePlanString(void) ...@@ -2036,28 +2068,28 @@ parsePlanString(void)
static Datum static Datum
readDatum(bool typbyval) readDatum(bool typbyval)
{ {
int length; Size length,
i;
int tokenLength; int tokenLength;
char *token; char *token;
Datum res; Datum res;
char *s; char *s;
int i;
/* /*
* read the actual length of the value * read the actual length of the value
*/ */
token = pg_strtok(&tokenLength); token = pg_strtok(&tokenLength);
length = atoi(token); length = atoui(token);
token = pg_strtok(&tokenLength); /* skip the '[' */ token = pg_strtok(&tokenLength); /* skip the '[' */
if (typbyval) if (typbyval)
{ {
if ((Size) length > sizeof(Datum)) if (length > (Size) sizeof(Datum))
elog(ERROR, "readDatum: byval & length = %d", length); elog(ERROR, "readDatum: byval & length = %u", 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 < (Size) sizeof(Datum); i++)
{ {
token = pg_strtok(&tokenLength); token = pg_strtok(&tokenLength);
s[i] = (char) atoi(token); s[i] = (char) atoi(token);
......
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