* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* 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
* Every (plan) node in POSTGRES has an associated "out" routine which
#include "utils/datum.h"
+#define booltostr(x) ((x) ? "true" : "false")
+
static void _outDatum(StringInfo str, Datum value, int typlen, bool typbyval);
static void _outNode(StringInfo str, void *obj);
*s == '\"' ||
*s == '@' ||
isdigit((unsigned char) *s) ||
- (*s == '-' && isdigit((unsigned char) s[1])))
+ ((*s == '+' || *s == '-') &&
+ (isdigit((unsigned char) s[1]) || s[1] == '.')))
appendStringInfoChar(str, '\\');
while (*s)
{
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
_outCreateStmt(StringInfo str, CreateStmt *node)
{
_outToken(str, node->relname);
appendStringInfo(str, " :istemp %s ",
- node->istemp ? "true" : "false");
+ booltostr(node->istemp));
appendStringInfo(str, " :columns ");
_outNode(str, node->tableElts);
_outNode(str, node->rangetable);
appendStringInfo(str, " :unique %s :primary %s ",
- node->unique ? "true" : "false",
- node->primary ? "true" : "false");
+ booltostr(node->unique),
+ booltostr(node->primary));
}
static void
appendStringInfo(str, " :args ");
_outNode(str, node->args);
appendStringInfo(str, " :agg_star %s :agg_distinct %s ",
- node->agg_star ? "true" : "false",
- node->agg_distinct ? "true" : "false");
+ booltostr(node->agg_star),
+ booltostr(node->agg_distinct));
}
static void
appendStringInfo(str, " :typename ");
_outNode(str, node->typename);
appendStringInfo(str, " :is_not_null %s :is_sequence %s :raw_default ",
- node->is_not_null ? "true" : "false",
- node->is_sequence ? "true" : "false");
+ booltostr(node->is_not_null),
+ booltostr(node->is_sequence));
_outNode(str, node->raw_default);
appendStringInfo(str, " :cooked_default ");
_outToken(str, node->cooked_default);
appendStringInfo(str, " TYPENAME :name ");
_outToken(str, node->name);
appendStringInfo(str, " :timezone %s :setof %s typmod %d :arrayBounds ",
- node->timezone ? "true" : "false",
- node->setof ? "true" : "false",
+ booltostr(node->timezone),
+ booltostr(node->setof),
node->typmod);
_outNode(str, node->arrayBounds);
}
appendStringInfo(str, " :isPortal %s :isBinary %s :isTemp %s"
" :hasAggs %s :hasSubLinks %s :rtable ",
- node->isPortal ? "true" : "false",
- node->isBinary ? "true" : "false",
- node->isTemp ? "true" : "false",
- node->hasAggs ? "true" : "false",
- node->hasSubLinks ? "true" : "false");
+ booltostr(node->isPortal),
+ booltostr(node->isBinary),
+ booltostr(node->isTemp),
+ booltostr(node->hasAggs),
+ booltostr(node->hasSubLinks));
_outNode(str, node->rtable);
appendStringInfo(str, " :jointree ");
static void
_outSortClause(StringInfo str, SortClause *node)
{
- appendStringInfo(str, " SORTCLAUSE :tleSortGroupRef %d :sortop %u ",
+ appendStringInfo(str, " SORTCLAUSE :tleSortGroupRef %u :sortop %u ",
node->tleSortGroupRef, node->sortop);
}
static void
_outGroupClause(StringInfo str, GroupClause *node)
{
- appendStringInfo(str, " GROUPCLAUSE :tleSortGroupRef %d :sortop %u ",
+ appendStringInfo(str, " GROUPCLAUSE :tleSortGroupRef %u :sortop %u ",
node->tleSortGroupRef, node->sortop);
}
{
appendStringInfo(str, " SETOPERATIONSTMT :op %d :all %s :larg ",
(int) node->op,
- node->all ? "true" : "false");
+ booltostr(node->all));
_outNode(str, node->larg);
appendStringInfo(str, " :rarg ");
_outNode(str, node->rarg);
appendStringInfo(str, " :colTypes ");
- _outIntList(str, node->colTypes);
+ _outOidList(str, node->colTypes);
}
/*
_outNode(str, node->appendplans);
appendStringInfo(str, " :isTarget %s ",
- node->isTarget ? "true" : "false");
+ booltostr(node->isTarget));
}
/*
appendStringInfo(str, " SUBPLAN :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);
appendStringInfo(str, " :setprm ");
_outPlanInfo(str, (Plan *) node);
appendStringInfo(str, " :scanrelid %u :indxid ", node->scan.scanrelid);
- _outIntList(str, node->indxid);
+ _outOidList(str, node->indxid);
appendStringInfo(str, " :indxqual ");
_outNode(str, node->indxqual);
/* the actual Group fields */
appendStringInfo(str, " :numCols %d :tuplePerGroup %s ",
node->numCols,
- node->tuplePerGroup ? "true" : "false");
+ booltostr(node->tuplePerGroup));
}
static void
node->restype,
node->restypmod);
_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->reskeyop,
node->ressortgroupref,
- node->resjunk ? "true" : "false");
+ booltostr(node->resjunk));
}
static void
int i;
appendStringInfo(str, " FJOIN :initialized %s :nNodes %d ",
- node->fj_initialized ? "true" : "false",
+ booltostr(node->fj_initialized),
node->fj_nNodes);
appendStringInfo(str, " :innerNode ");
node->fj_results);
for (i = 0; i < node->fj_nNodes; i++)
- appendStringInfo(str, (node->fj_alwaysDone[i]) ? "true" : "false");
+ appendStringInfo(str,
+ booltostr(node->fj_alwaysDone[i]));
}
/*
_outVar(StringInfo str, Var *node)
{
appendStringInfo(str,
- " VAR :varno %d :varattno %d :vartype %u :vartypmod %d ",
+ " VAR :varno %u :varattno %d :vartype %u :vartypmod %d ",
node->varno,
node->varattno,
node->vartype,
node->vartypmod);
- appendStringInfo(str, " :varlevelsup %u :varnoold %d :varoattno %d",
+ appendStringInfo(str, " :varlevelsup %u :varnoold %u :varoattno %d",
node->varlevelsup,
node->varnoold,
node->varoattno);
" :constisnull %s :constvalue ",
node->consttype,
node->constlen,
- node->constbyval ? "true" : "false",
- node->constisnull ? "true" : "false");
+ booltostr(node->constbyval),
+ booltostr(node->constisnull));
if (node->constisnull)
appendStringInfo(str, "<>");
_outNode(str, node->target);
appendStringInfo(str, " :aggstar %s :aggdistinct %s ",
- node->aggstar ? "true" : "false",
- node->aggdistinct ? "true" : "false");
+ booltostr(node->aggstar),
+ booltostr(node->aggdistinct));
/* aggno is not dumped */
}
appendStringInfo(str,
" SUBLINK :subLinkType %d :useor %s :lefthand ",
node->subLinkType,
- node->useor ? "true" : "false");
+ booltostr(node->useor));
_outNode(str, node->lefthand);
appendStringInfo(str, " :oper ");
{
appendStringInfo(str, " JOINEXPR :jointype %d :isNatural %s :larg ",
(int) node->jointype,
- node->isNatural ? "true" : "false");
+ booltostr(node->isNatural));
_outNode(str, node->larg);
appendStringInfo(str, " :rarg ");
_outNode(str, node->rarg);
_outNode(str, node->cheapest_total_path);
appendStringInfo(str, " :pruneable %s :issubquery %s :indexed %s :pages %ld :tuples %.0f :subplan ",
- node->pruneable ? "true" : "false",
- node->issubquery ? "true" : "false",
- node->indexed ? "true" : "false",
+ booltostr(node->pruneable),
+ booltostr(node->issubquery),
+ booltostr(node->indexed),
node->pages,
node->tuples);
_outNode(str, node->subplan);
_outNode(str, node->eref);
appendStringInfo(str, " :inh %s :inFromCl %s :checkForRead %s"
" :checkForWrite %s :checkAsUser %u",
- node->inh ? "true" : "false",
- node->inFromCl ? "true" : "false",
- node->checkForRead ? "true" : "false",
- node->checkForWrite ? "true" : "false",
+ booltostr(node->inh),
+ booltostr(node->inFromCl),
+ booltostr(node->checkForRead),
+ booltostr(node->checkForWrite),
node->checkAsUser);
}
_outNode(str, node->path.pathkeys);
appendStringInfo(str, " :indexid ");
- _outIntList(str, node->indexid);
+ _outOidList(str, node->indexid);
appendStringInfo(str, " :indexqual ");
_outNode(str, node->indexqual);
_outIntList(str, node->joinrelids);
appendStringInfo(str, " :alljoinquals %s :rows %.2f ",
- node->alljoinquals ? "true" : "false",
+ booltostr(node->alljoinquals),
node->rows);
}
_outNode(str, node->clause);
appendStringInfo(str, " :ispusheddown %s :subclauseindices ",
- node->ispusheddown ? "true" : "false");
+ booltostr(node->ispusheddown));
_outNode(str, node->subclauseindices);
appendStringInfo(str, " :mergejoinoperator %u ", node->mergejoinoperator);
{
switch (value->type)
{
- case T_Integer:
+ case T_Integer:
appendStringInfo(str, " %ld ", value->val.ival);
break;
case T_Float:
*
*
* 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
* Most of the read functions for plan nodes are tested. (In fact, they
#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);
* ----------------
*/
+/* Convert Value list returned by nodeRead into list of integers */
static List *
toIntList(List *list)
{
foreach(l, list)
{
- /* ugly manipulation, should probably free the Value node too */
- lfirst(l) = (void *) intVal(lfirst(l));
+ Value *v = (Value *) 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;
}
token = pg_strtok(&length); /* skip :into */
token = pg_strtok(&length); /* get into */
- if (length == 0)
- local_node->into = NULL;
- else
- local_node->into = debackslash(token, length);
+ local_node->into = nullable_string(token, length);
token = pg_strtok(&length); /* skip :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); /* 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); /* 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); /* 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); /* get hasSubLinks */
- local_node->hasSubLinks = (token[0] == 't') ? true : false;
+ local_node->hasSubLinks = strtobool(token);
token = pg_strtok(&length); /* skip :rtable */
local_node->rtable = nodeRead(true);
token = pg_strtok(&length); /* skip :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); /* get sortop */
- local_node->sortop = strtoul(token, NULL, 10);
+ local_node->sortop = atooid(token);
return local_node;
}
token = pg_strtok(&length); /* skip :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); /* get sortop */
- local_node->sortop = strtoul(token, NULL, 10);
+ local_node->sortop = atooid(token);
return local_node;
}
token = pg_strtok(&length); /* eat :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 */
local_node->larg = nodeRead(true); /* get larg */
local_node->rarg = nodeRead(true); /* get rarg */
token = pg_strtok(&length); /* eat :colTypes */
- local_node->colTypes = toIntList(nodeRead(true));
+ local_node->colTypes = toOidList(nodeRead(true));
return local_node;
}
token = pg_strtok(&length); /* eat :isTarget */
token = pg_strtok(&length); /* get isTarget */
- local_node->isTarget = (token[0] == 't') ? true : false;
+ local_node->isTarget = strtobool(token);
return local_node;
}
token = pg_strtok(&length); /* eat :hashjoinop */
token = pg_strtok(&length); /* get hashjoinop */
- local_node->hashjoinop = strtoul(token, NULL, 10);
+ local_node->hashjoinop = atooid(token);
return local_node;
}
token = pg_strtok(&length); /* eat :scanrelid */
token = pg_strtok(&length); /* get scanrelid */
- node->scanrelid = strtoul(token, NULL, 10);
+ node->scanrelid = atoui(token);
}
/* ----------------
_getScan((Scan *) local_node);
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 */
local_node->indxqual = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* eat :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); /* get restypmod */
token = pg_strtok(&length); /* eat :resname */
token = pg_strtok(&length); /* get the name */
- if (length == 0)
- local_node->resname = NULL;
- else
- local_node->resname = debackslash(token, length);
+ local_node->resname = nullable_string(token, length);
token = pg_strtok(&length); /* eat :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); /* get reskeyop */
- local_node->reskeyop = (Oid) atol(token);
+ local_node->reskeyop = atooid(token);
token = pg_strtok(&length); /* eat :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); /* get resjunk */
- local_node->resjunk = (token[0] == 't') ? true : false;
+ local_node->resjunk = strtobool(token);
return local_node;
}
token = pg_strtok(&length); /* eat :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); /* get opType */
- if (!strncmp(token, "op", 2))
+ if (strncmp(token, "op", 2) == 0)
local_node->opType = OP_EXPR;
- else if (!strncmp(token, "func", 4))
+ else if (strncmp(token, "func", 4) == 0)
local_node->opType = FUNC_EXPR;
- else if (!strncmp(token, "or", 2))
+ else if (strncmp(token, "or", 2) == 0)
local_node->opType = OR_EXPR;
- else if (!strncmp(token, "and", 3))
+ else if (strncmp(token, "and", 3) == 0)
local_node->opType = AND_EXPR;
- else if (!strncmp(token, "not", 3))
+ else if (strncmp(token, "not", 3) == 0)
local_node->opType = NOT_EXPR;
- else if (!strncmp(token, "subp", 4))
+ else if (strncmp(token, "subp", 4) == 0)
local_node->opType = SUBPLAN_EXPR;
else
- elog(ERROR, "_readExpr: unknown opType \"%.10s\"", token);
+ elog(ERROR, "_readExpr: unknown opType \"%.*s\"", length, token);
token = pg_strtok(&length); /* eat :oper */
local_node->oper = nodeRead(true);
token = pg_strtok(&length); /* eat :casetype */
token = pg_strtok(&length); /* get casetype */
- local_node->casetype = (Oid) atol(token);
+ local_node->casetype = atooid(token);
token = pg_strtok(&length); /* eat :arg */
local_node->arg = nodeRead(true);
token = pg_strtok(&length); /* eat :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); /* get varattno */
token = pg_strtok(&length); /* eat :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); /* get vartypmod */
token = pg_strtok(&length); /* eat :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); /* 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 :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); /* get refattrlength */
token = pg_strtok(&length); /* eat :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 */
local_node->refupperindexpr = nodeRead(true);
token = pg_strtok(&length); /* get :consttype */
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); /* 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); /* now read it */
-
- if (!strncmp(token, "true", 4))
- local_node->constbyval = true;
- else
- local_node->constbyval = false;
+ local_node->constbyval = strtobool(token);
token = pg_strtok(&length); /* get :constisnull */
token = pg_strtok(&length); /* now read it */
-
- if (!strncmp(token, "true", 4))
- local_node->constisnull = true;
- else
- local_node->constisnull = false;
+ local_node->constisnull = strtobool(token);
token = pg_strtok(&length); /* get :constvalue */
token = pg_strtok(&length); /* get :funcid */
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); /* now read it */
- local_node->functype = (Oid) atol(token);
+ local_node->functype = atooid(token);
local_node->func_fcache = NULL;
token = pg_strtok(&length); /* get :opno */
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); /* now read it */
- local_node->opid = (Oid) atol(token);
+ local_node->opid = atooid(token);
token = pg_strtok(&length); /* get :opresulttype */
token = pg_strtok(&length); /* now read it */
- local_node->opresulttype = (Oid) atol(token);
+ local_node->opresulttype = atooid(token);
local_node->op_fcache = NULL;
token = pg_strtok(&length); /* get :paramid */
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); /* now read it */
- if (length == 0)
- local_node->paramname = NULL;
- else
- local_node->paramname = debackslash(token, length);
+ local_node->paramname = nullable_string(token, length);
token = pg_strtok(&length); /* get :paramtype */
token = pg_strtok(&length); /* now read it */
- local_node->paramtype = (Oid) atol(token);
+ local_node->paramtype = atooid(token);
return local_node;
}
token = pg_strtok(&length); /* eat :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); /* get aggtype */
- local_node->aggtype = (Oid) atol(token);
+ local_node->aggtype = atooid(token);
token = pg_strtok(&length); /* eat :target */
local_node->target = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* eat :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); /* get aggdistinct */
- local_node->aggdistinct = (token[0] == 't') ? true : false;
+ local_node->aggdistinct = strtobool(token);
return local_node;
}
token = pg_strtok(&length); /* eat :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 */
local_node->lefthand = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* eat :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); /* get resulttypmod */
token = pg_strtok(&length); /* eat :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); /* get resulttypmod */
token = pg_strtok(&length); /* eat :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 */
local_node->larg = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* eat :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); /* 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); /* 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); /* now read it */
token = pg_strtok(&length); /* eat :relname */
token = pg_strtok(&length); /* get :relname */
- if (length == 0)
- local_node->relname = NULL;
- else
- local_node->relname = debackslash(token, length);
+ local_node->relname = nullable_string(token, length);
token = pg_strtok(&length); /* eat :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 */
local_node->subquery = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* eat :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); /* 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); /* 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); /* 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); /* get :checkAsUser */
- local_node->checkAsUser = strtoul(token, NULL, 10);
+ local_node->checkAsUser = atooid(token);
return local_node;
}
token = pg_strtok(&length); /* get :pathtype */
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); /* now read it */
token = pg_strtok(&length); /* get :pathtype */
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); /* now read it */
local_node->path.pathkeys = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* get :indexid */
- local_node->indexid = toIntList(nodeRead(true));
+ local_node->indexid = toOidList(nodeRead(true));
token = pg_strtok(&length); /* get :indexqual */
local_node->indexqual = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* get :alljoinquals */
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); /* now read it */
token = pg_strtok(&length); /* get :pathtype */
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); /* now read it */
token = pg_strtok(&length); /* get :pathtype */
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); /* now read it */
token = pg_strtok(&length); /* get :pathtype */
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); /* now read it */
token = pg_strtok(&length); /* get :pathtype */
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); /* now read it */
token = pg_strtok(&length); /* get :pathtype */
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); /* now read it */
token = pg_strtok(&length); /* get :sortop */
token = pg_strtok(&length); /* now read it */
-
- local_node->sortop = (Oid) atol(token);
+ local_node->sortop = atooid(token);
token = pg_strtok(&length); /* get :key */
local_node->key = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* get :ispusheddown */
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 */
local_node->subclauseindices = nodeRead(true); /* now read it */
token = pg_strtok(&length); /* get :mergejoinoperator */
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); /* 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); /* 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); /* 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 */
local_node->eval_cost = -1;
static Datum
readDatum(bool typbyval)
{
- int length;
+ Size length,
+ i;
int tokenLength;
char *token;
Datum res;
char *s;
- int i;
/*
* read the actual length of the value
*/
token = pg_strtok(&tokenLength);
- length = atoi(token);
+ length = atoui(token);
token = pg_strtok(&tokenLength); /* skip the '[' */
if (typbyval)
{
- if ((Size) length > sizeof(Datum))
- elog(ERROR, "readDatum: byval & length = %d", length);
+ if (length > (Size) sizeof(Datum))
+ elog(ERROR, "readDatum: byval & length = %u", length);
res = (Datum) 0;
s = (char *) (&res);
- for (i = 0; i < (int) sizeof(Datum); i++)
+ for (i = 0; i < (Size) sizeof(Datum); i++)
{
token = pg_strtok(&tokenLength);
s[i] = (char) atoi(token);