1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-23 03:21:12 +03:00

Ye-old pgindent run. Same 4-space tabs.

This commit is contained in:
Bruce Momjian
2000-04-12 17:17:23 +00:00
parent db4518729d
commit 52f77df613
434 changed files with 24799 additions and 21246 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.112 2000/04/08 00:21:15 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.113 2000/04/12 17:15:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -143,7 +143,7 @@ _copyResult(Result *from)
*/
if (from->plan.subPlan != NIL)
newnode->plan.subPlan = nconc(newnode->plan.subPlan,
pull_subplans(newnode->resconstantqual));
pull_subplans(newnode->resconstantqual));
return newnode;
}
@ -259,25 +259,25 @@ _copyIndexScan(IndexScan *from)
if (from->scan.plan.subPlan != NIL)
{
newnode->scan.plan.subPlan = nconc(newnode->scan.plan.subPlan,
pull_subplans((Node *) newnode->indxqual));
pull_subplans((Node *) newnode->indxqual));
newnode->scan.plan.subPlan = nconc(newnode->scan.plan.subPlan,
pull_subplans((Node *) newnode->indxqualorig));
pull_subplans((Node *) newnode->indxqualorig));
}
return newnode;
}
/* ----------------
* _copyTidScan
* _copyTidScan
* ----------------
*/
static TidScan *
_copyTidScan(TidScan *from)
{
TidScan *newnode = makeNode(TidScan);
TidScan *newnode = makeNode(TidScan);
/* ----------------
* copy node superclass fields
* copy node superclass fields
* ----------------
*/
CopyPlanFields((Plan *) from, (Plan *) newnode);
@ -292,7 +292,7 @@ _copyTidScan(TidScan *from)
return newnode;
}
/* ----------------
* CopyJoinFields
*
@ -375,7 +375,7 @@ _copyMergeJoin(MergeJoin *from)
*/
if (from->join.subPlan != NIL)
newnode->join.subPlan = nconc(newnode->join.subPlan,
pull_subplans((Node *) newnode->mergeclauses));
pull_subplans((Node *) newnode->mergeclauses));
return newnode;
}
@ -408,7 +408,7 @@ _copyHashJoin(HashJoin *from)
*/
if (from->join.subPlan != NIL)
newnode->join.subPlan = nconc(newnode->join.subPlan,
pull_subplans((Node *) newnode->hashclauses));
pull_subplans((Node *) newnode->hashclauses));
return newnode;
}
@ -871,7 +871,7 @@ _copyAggref(Aggref *from)
newnode->usenulls = from->usenulls;
newnode->aggstar = from->aggstar;
newnode->aggdistinct = from->aggdistinct;
newnode->aggno = from->aggno; /* probably not needed */
newnode->aggno = from->aggno; /* probably not needed */
return newnode;
}
@ -905,7 +905,7 @@ _copySubLink(SubLink *from)
static RelabelType *
_copyRelabelType(RelabelType *from)
{
RelabelType *newnode = makeNode(RelabelType);
RelabelType *newnode = makeNode(RelabelType);
/* ----------------
* copy remainder of node
@ -1108,6 +1108,7 @@ _copyIndexOptInfo(IndexOptInfo *from)
static void
CopyPathFields(Path *from, Path *newnode)
{
/*
* Modify the next line, since it causes the copying to cycle (i.e.
* the parent points right back here! -- JMH, 7/7/92. Old version:
@ -1166,13 +1167,13 @@ _copyIndexPath(IndexPath *from)
}
/* ----------------
* _copyTidPath
* _copyTidPath
* ----------------
*/
static TidPath *
_copyTidPath(TidPath *from)
{
TidPath *newnode = makeNode(TidPath);
TidPath *newnode = makeNode(TidPath);
/* ----------------
* copy the node superclass fields
@ -1189,6 +1190,7 @@ _copyTidPath(TidPath *from)
return newnode;
}
/* ----------------
* CopyJoinPathFields
*
@ -1282,7 +1284,7 @@ _copyHashPath(HashPath *from)
static PathKeyItem *
_copyPathKeyItem(PathKeyItem *from)
{
PathKeyItem *newnode = makeNode(PathKeyItem);
PathKeyItem *newnode = makeNode(PathKeyItem);
/* ----------------
* copy remainder of node
@ -1497,8 +1499,8 @@ _copyQuery(Query *from)
/*
* We do not copy the planner internal fields: base_rel_list,
* join_rel_list, equi_key_list, query_pathkeys.
* Not entirely clear if this is right?
* join_rel_list, equi_key_list, query_pathkeys. Not entirely clear if
* this is right?
*/
return newnode;
@ -1507,7 +1509,7 @@ _copyQuery(Query *from)
static ClosePortalStmt *
_copyClosePortalStmt(ClosePortalStmt *from)
{
ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
ClosePortalStmt *newnode = makeNode(ClosePortalStmt);
if (from->portalname)
newnode->portalname = pstrdup(from->portalname);
@ -1518,7 +1520,7 @@ _copyClosePortalStmt(ClosePortalStmt *from)
static TruncateStmt *
_copyTruncateStmt(TruncateStmt *from)
{
TruncateStmt *newnode = makeNode(TruncateStmt);
TruncateStmt *newnode = makeNode(TruncateStmt);
newnode->relName = pstrdup(from->relName);
@ -1528,7 +1530,7 @@ _copyTruncateStmt(TruncateStmt *from)
static NotifyStmt *
_copyNotifyStmt(NotifyStmt *from)
{
NotifyStmt *newnode = makeNode(NotifyStmt);
NotifyStmt *newnode = makeNode(NotifyStmt);
if (from->relname)
newnode->relname = pstrdup(from->relname);
@ -1539,7 +1541,7 @@ _copyNotifyStmt(NotifyStmt *from)
static ListenStmt *
_copyListenStmt(ListenStmt *from)
{
ListenStmt *newnode = makeNode(ListenStmt);
ListenStmt *newnode = makeNode(ListenStmt);
if (from->relname)
newnode->relname = pstrdup(from->relname);
@ -1550,7 +1552,7 @@ _copyListenStmt(ListenStmt *from)
static UnlistenStmt *
_copyUnlistenStmt(UnlistenStmt *from)
{
UnlistenStmt *newnode = makeNode(UnlistenStmt);
UnlistenStmt *newnode = makeNode(UnlistenStmt);
if (from->relname)
newnode->relname = pstrdup(from->relname);
@ -1561,7 +1563,7 @@ _copyUnlistenStmt(UnlistenStmt *from)
static TransactionStmt *
_copyTransactionStmt(TransactionStmt *from)
{
TransactionStmt *newnode = makeNode(TransactionStmt);
TransactionStmt *newnode = makeNode(TransactionStmt);
newnode->command = from->command;
@ -1571,7 +1573,7 @@ _copyTransactionStmt(TransactionStmt *from)
static LoadStmt *
_copyLoadStmt(LoadStmt *from)
{
LoadStmt *newnode = makeNode(LoadStmt);
LoadStmt *newnode = makeNode(LoadStmt);
if (from->filename)
newnode->filename = pstrdup(from->filename);
@ -1582,7 +1584,7 @@ _copyLoadStmt(LoadStmt *from)
static VariableSetStmt *
_copyVariableSetStmt(VariableSetStmt *from)
{
VariableSetStmt *newnode = makeNode(VariableSetStmt);
VariableSetStmt *newnode = makeNode(VariableSetStmt);
if (from->name)
newnode->name = pstrdup(from->name);
@ -1595,7 +1597,7 @@ _copyVariableSetStmt(VariableSetStmt *from)
static VariableResetStmt *
_copyVariableResetStmt(VariableResetStmt *from)
{
VariableResetStmt *newnode = makeNode(VariableResetStmt);
VariableResetStmt *newnode = makeNode(VariableResetStmt);
if (from->name)
newnode->name = pstrdup(from->name);
@ -1606,7 +1608,7 @@ _copyVariableResetStmt(VariableResetStmt *from)
static LockStmt *
_copyLockStmt(LockStmt *from)
{
LockStmt *newnode = makeNode(LockStmt);
LockStmt *newnode = makeNode(LockStmt);
if (from->relname)
newnode->relname = pstrdup(from->relname);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.65 2000/03/22 22:08:32 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.66 2000/04/12 17:15:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -81,9 +81,11 @@ _equalFjoin(Fjoin *a, Fjoin *b)
static bool
_equalExpr(Expr *a, Expr *b)
{
/* We do not examine typeOid, since the optimizer often doesn't
* bother to set it in created nodes, and it is logically a
* derivative of the oper field anyway.
/*
* We do not examine typeOid, since the optimizer often doesn't bother
* to set it in created nodes, and it is logically a derivative of the
* oper field anyway.
*/
if (a->opType != b->opType)
return false;
@ -134,7 +136,9 @@ _equalOper(Oper *a, Oper *b)
return false;
if (a->opresulttype != b->opresulttype)
return false;
/* We do not examine opid, opsize, or op_fcache, since these are
/*
* We do not examine opid, opsize, or op_fcache, since these are
* logically derived from opno, and they may not be set yet depending
* on how far along the node is in the parse/plan pipeline.
*
@ -156,10 +160,11 @@ _equalConst(Const *a, Const *b)
if (a->constbyval != b->constbyval)
return false;
/* XXX What about constisset and constiscast? */
/*
* We treat all NULL constants of the same type as equal.
* Someday this might need to change? But datumIsEqual
* doesn't work on nulls, so...
* We treat all NULL constants of the same type as equal. Someday this
* might need to change? But datumIsEqual doesn't work on nulls,
* so...
*/
if (a->constisnull)
return true;
@ -320,7 +325,9 @@ _equalArrayRef(ArrayRef *a, ArrayRef *b)
static bool
_equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
{
/* We treat RelOptInfos as equal if they refer to the same base rels
/*
* We treat RelOptInfos as equal if they refer to the same base rels
* joined in the same order. Is this sufficient?
*/
return equali(a->relids, b->relids);
@ -329,8 +336,10 @@ _equalRelOptInfo(RelOptInfo *a, RelOptInfo *b)
static bool
_equalIndexOptInfo(IndexOptInfo *a, IndexOptInfo *b)
{
/* We treat IndexOptInfos as equal if they refer to the same index.
* Is this sufficient?
/*
* We treat IndexOptInfos as equal if they refer to the same index. Is
* this sufficient?
*/
if (a->indexoid != b->indexoid)
return false;
@ -354,7 +363,9 @@ _equalPath(Path *a, Path *b)
return false;
if (!equal(a->parent, b->parent))
return false;
/* do not check path costs, since they may not be set yet, and being
/*
* do not check path costs, since they may not be set yet, and being
* float values there are roundoff error issues anyway...
*/
if (!equal(a->pathkeys, b->pathkeys))
@ -375,8 +386,10 @@ _equalIndexPath(IndexPath *a, IndexPath *b)
return false;
if (!equali(a->joinrelids, b->joinrelids))
return false;
/* Skip 'rows' because of possibility of floating-point roundoff error.
* It should be derivable from the other fields anyway.
/*
* Skip 'rows' because of possibility of floating-point roundoff
* error. It should be derivable from the other fields anyway.
*/
return true;
}
@ -442,12 +455,13 @@ _equalHashPath(HashPath *a, HashPath *b)
/* XXX This equality function is a quick hack, should be
* fixed to compare all fields.
*
* XXX Why is this even here? We don't have equal() funcs for
* any other kinds of Plan nodes... likely this is dead code...
* XXX Why is this even here? We don't have equal() funcs for
* any other kinds of Plan nodes... likely this is dead code...
*/
static bool
_equalIndexScan(IndexScan *a, IndexScan *b)
{
/*
* if(a->scan.plan.cost != b->scan.plan.cost) return(false);
*/
@ -642,9 +656,9 @@ _equalQuery(Query *a, Query *b)
/*
* We do not check the internal-to-the-planner fields: base_rel_list,
* join_rel_list, equi_key_list, query_pathkeys.
* They might not be set yet, and in any case they should be derivable
* from the other fields.
* join_rel_list, equi_key_list, query_pathkeys. They might not be set
* yet, and in any case they should be derivable from the other
* fields.
*/
return true;
}
@ -882,7 +896,8 @@ equal(void *a, void *b)
List *lb = (List *) b;
List *l;
/* Try to reject by length check before we grovel through
/*
* Try to reject by length check before we grovel through
* all the elements...
*/
if (length(la) != length(lb))

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.39 2000/03/14 23:06:28 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.40 2000/04/12 17:15:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -746,7 +746,9 @@ _freeRelOptInfo(RelOptInfo *node)
freeObject(node->targetlist);
freeObject(node->pathlist);
/* XXX is this right? cheapest-path fields will typically be pointers
/*
* XXX is this right? cheapest-path fields will typically be pointers
* into pathlist, not separate structs...
*/
freeObject(node->cheapest_startup_path);
@ -870,7 +872,9 @@ FreeJoinPathFields(JoinPath *node)
{
freeObject(node->outerjoinpath);
freeObject(node->innerjoinpath);
/* XXX probably wrong, since ordinarily a JoinPath would share its
/*
* XXX probably wrong, since ordinarily a JoinPath would share its
* restrictinfo list with other paths made for the same join?
*/
freeObject(node->joinrestrictinfo);
@ -970,7 +974,9 @@ _freeRestrictInfo(RestrictInfo *node)
* ----------------
*/
freeObject(node->clause);
/* this is certainly wrong? IndexOptInfos don't belong to
/*
* this is certainly wrong? IndexOptInfos don't belong to
* RestrictInfo...
*/
freeObject(node->subclauseindices);
@ -1131,8 +1137,8 @@ _freeValue(Value *node)
{
switch (node->type)
{
case T_Float:
case T_String:
case T_Float:
case T_String:
pfree(node->val.str);
break;
default:

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.30 2000/02/21 18:47:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.31 2000/04/12 17:15:16 momjian Exp $
*
* NOTES
* XXX a few of the following functions are duplicated to handle
@ -251,9 +251,9 @@ length(List *l)
* freeList
*
* Free the List nodes of a list
* The pointed-to nodes, if any, are NOT freed.
* This works for integer lists too.
*
* The pointed-to nodes, if any, are NOT freed.
* This works for integer lists too.
*
*/
void
freeList(List *list)
@ -314,7 +314,7 @@ LispUnion(List *l1, List *l2)
foreach(i, l2)
{
if (! member(lfirst(i), retval))
if (!member(lfirst(i), retval))
retval = lappend(retval, lfirst(i));
}
return retval;
@ -328,7 +328,7 @@ LispUnioni(List *l1, List *l2)
foreach(i, l2)
{
if (! intMember(lfirsti(i), retval))
if (!intMember(lfirsti(i), retval))
retval = lappendi(retval, lfirsti(i));
}
return retval;
@ -459,7 +459,7 @@ intLispRemove(int elem, List *list)
List *
ltruncate(int n, List *list)
{
List *ptr;
List *ptr;
if (n <= 0)
return NIL; /* truncate to zero length */
@ -494,7 +494,7 @@ set_difference(List *l1, List *l2)
foreach(i, l1)
{
if (! member(lfirst(i), l2))
if (!member(lfirst(i), l2))
result = lappend(result, lfirst(i));
}
return result;
@ -516,7 +516,7 @@ set_differencei(List *l1, List *l2)
foreach(i, l1)
{
if (! intMember(lfirsti(i), l2))
if (!intMember(lfirsti(i), l2))
result = lappendi(result, lfirsti(i));
}
return result;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.20 2000/02/15 03:37:09 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.21 2000/04/12 17:15:16 momjian Exp $
*
* NOTES
* Creator functions in POSTGRES 4.2 are generated automatically. Most of
@ -62,11 +62,13 @@ makeVar(Index varno,
var->vartype = vartype;
var->vartypmod = vartypmod;
var->varlevelsup = varlevelsup;
/*
* Since few if any routines ever create Var nodes with varnoold/varoattno
* different from varno/varattno, we don't provide separate arguments
* for them, but just initialize them to the given varno/varattno.
* This reduces code clutter and chance of error for most callers.
* Since few if any routines ever create Var nodes with
* varnoold/varoattno different from varno/varattno, we don't provide
* separate arguments for them, but just initialize them to the given
* varno/varattno. This reduces code clutter and chance of error for
* most callers.
*/
var->varnoold = varno;
var->varoattno = varattno;
@ -107,7 +109,9 @@ makeResdom(AttrNumber resno,
resdom->restype = restype;
resdom->restypmod = restypmod;
resdom->resname = resname;
/* For historical reasons, ressortgroupref defaults to 0 while
/*
* For historical reasons, ressortgroupref defaults to 0 while
* reskey/reskeyop are passed in explicitly. This is pretty silly.
*/
resdom->ressortgroupref = 0;
@ -159,8 +163,3 @@ makeAttr(char *relname, char *attname)
return a;
}

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.12 2000/01/26 05:56:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.13 2000/04/12 17:15:16 momjian Exp $
*
* HISTORY
* Andrew Yu Oct 20, 1994 file creation
@ -33,7 +33,7 @@ newNode(Size size, NodeTag tag)
{
Node *newNode;
Assert(size >= sizeof(Node)); /* need the tag, at least */
Assert(size >= sizeof(Node)); /* need the tag, at least */
newNode = (Node *) palloc(size);
MemSet((char *) newNode, 0, size);

View File

@ -6,7 +6,7 @@
* 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.113 2000/03/24 02:58:25 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.114 2000/04/12 17:15:16 momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@ -60,10 +60,11 @@ _outToken(StringInfo str, char *s)
appendStringInfo(str, "<>");
return;
}
/*
* Look for characters or patterns that are treated specially by
* read.c (either in lsptok() or in nodeRead()), and therefore need
* a protective backslash.
* read.c (either in lsptok() or in nodeRead()), and therefore need a
* protective backslash.
*/
/* These characters only need to be quoted at the start of the string */
if (*s == '<' ||
@ -256,7 +257,7 @@ _outQuery(StringInfo str, Query *node)
_outToken(str, node->into);
appendStringInfo(str,
" :isPortal %s :isBinary %s :isTemp %s :unionall %s :distinctClause ",
" :isPortal %s :isBinary %s :isTemp %s :unionall %s :distinctClause ",
node->isPortal ? "true" : "false",
node->isBinary ? "true" : "false",
node->isTemp ? "true" : "false",
@ -633,7 +634,7 @@ static void
_outResdom(StringInfo str, Resdom *node)
{
appendStringInfo(str,
" RESDOM :resno %d :restype %u :restypmod %d :resname ",
" RESDOM :resno %d :restype %u :restypmod %d :resname ",
node->resno,
node->restype,
node->restypmod);
@ -925,7 +926,7 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
_outIntList(str, node->relids);
appendStringInfo(str,
" :rows %.0f :width %d :indexed %s :pages %ld :tuples %.0f :targetlist ",
" :rows %.0f :width %d :indexed %s :pages %ld :tuples %.0f :targetlist ",
node->rows,
node->width,
node->indexed ? "true" : "false",
@ -983,7 +984,7 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
appendStringInfo(str, " :ref ");
_outNode(str, node->ref);
appendStringInfo(str,
" :relid %u :inh %s :inFromCl %s :inJoinSet %s :skipAcl %s",
" :relid %u :inh %s :inFromCl %s :inJoinSet %s :skipAcl %s",
node->relid,
node->inh ? "true" : "false",
node->inFromCl ? "true" : "false",
@ -1004,7 +1005,7 @@ static void
_outPath(StringInfo str, Path *node)
{
appendStringInfo(str,
" PATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
" PATH :pathtype %d :startup_cost %.2f :total_cost %.2f :pathkeys ",
node->pathtype,
node->startup_cost,
node->total_cost);
@ -1282,12 +1283,14 @@ _outValue(StringInfo str, Value *value)
{
switch (value->type)
{
case T_Integer:
case T_Integer:
appendStringInfo(str, " %ld ", value->val.ival);
break;
case T_Float:
/* We assume the value is a valid numeric literal
* and so does not need quoting.
/*
* We assume the value is a valid numeric literal and so does
* not need quoting.
*/
appendStringInfo(str, " %s ", value->val.str);
break;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.37 2000/02/15 20:49:12 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.38 2000/04/12 17:15:16 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -176,7 +176,7 @@ print_expr(Node *expr, List *rtable)
rt = rt_fetch(var->varno, rtable);
relname = rt->relname;
if (rt->ref && rt->ref->relname)
relname = rt->ref->relname; /* table renamed */
relname = rt->ref->relname; /* table renamed */
attname = get_attname(rt->relid, var->varattno);
}
break;
@ -221,7 +221,7 @@ print_pathkeys(List *pathkeys, List *rtable)
printf("(");
foreach(k, pathkey)
{
PathKeyItem *item = lfirst(k);
PathKeyItem *item = lfirst(k);
print_expr(item->key, rtable);
if (lnext(k))

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.21 2000/02/21 18:47:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.22 2000/04/12 17:15:16 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -60,31 +60,31 @@ stringToNode(char *str)
* (Pass length==NULL to set the string without reading its first token.)
*
* The rules for tokens are:
* * Whitespace (space, tab, newline) always separates tokens.
* * The characters '(', ')', '{', '}' form individual tokens even
* without any whitespace around them.
* * Otherwise, a token is all the characters up to the next whitespace
* or occurrence of one of the four special characters.
* * A backslash '\' can be used to quote whitespace or one of the four
* special characters, so that it is treated as a plain token character.
* Backslashes themselves must also be backslashed for consistency.
* Any other character can be, but need not be, backslashed as well.
* * If the resulting token is '<>' (with no backslash), it is returned
* as a non-NULL pointer to the token but with length == 0. Note that
* there is no other way to get a zero-length token.
* * Whitespace (space, tab, newline) always separates tokens.
* * The characters '(', ')', '{', '}' form individual tokens even
* without any whitespace around them.
* * Otherwise, a token is all the characters up to the next whitespace
* or occurrence of one of the four special characters.
* * A backslash '\' can be used to quote whitespace or one of the four
* special characters, so that it is treated as a plain token character.
* Backslashes themselves must also be backslashed for consistency.
* Any other character can be, but need not be, backslashed as well.
* * If the resulting token is '<>' (with no backslash), it is returned
* as a non-NULL pointer to the token but with length == 0. Note that
* there is no other way to get a zero-length token.
*
* Returns a pointer to the start of the next token, and the length of the
* token (including any embedded backslashes!) in *length. If there are
* token (including any embedded backslashes!) in *length. If there are
* no more tokens, NULL and 0 are returned.
*
* NOTE: this routine doesn't remove backslashes; the caller must do so
* if necessary (see "debackslash").
*
* NOTE: prior to release 7.0, this routine also had a special case to treat
* a token starting with '"' as extending to the next '"'. This code was
* a token starting with '"' as extending to the next '"'. This code was
* broken, however, since it would fail to cope with a string containing an
* embedded '"'. I have therefore removed this special case, and instead
* introduced rules for using backslashes to quote characters. Higher-level
* introduced rules for using backslashes to quote characters. Higher-level
* code should add backslashes to a string constant to ensure it is treated
* as a single token.
*/
@ -160,8 +160,8 @@ lsptok(char *string, int *length)
char *
debackslash(char *token, int length)
{
char *result = palloc(length+1);
char *ptr = result;
char *result = palloc(length + 1);
char *ptr = result;
while (length > 0)
{
@ -208,22 +208,23 @@ nodeTokenType(char *token, int length)
if ((numlen > 0 && isdigit(*numptr)) ||
(numlen > 1 && *numptr == '.' && isdigit(numptr[1])))
{
/*
* Yes. Figure out whether it is integral or float;
* this requires both a syntax check and a range check.
* strtol() can do both for us.
* We know the token will end at a character that strtol will
* Yes. Figure out whether it is integral or float; this requires
* both a syntax check and a range check. strtol() can do both for
* us. We know the token will end at a character that strtol will
* stop at, so we do not need to modify the string.
*/
errno = 0;
(void) strtol(token, &endptr, 10);
if (endptr != token+length || errno == ERANGE)
if (endptr != token + length || errno == ERANGE)
return T_Float;
return T_Integer;
}
/*
* these three cases do not need length checks, since lsptok()
* will always treat them as single-byte tokens
* these three cases do not need length checks, since lsptok() will
* always treat them as single-byte tokens
*/
else if (*token == '(')
retval = LEFT_PAREN;
@ -233,7 +234,7 @@ nodeTokenType(char *token, int length)
retval = PLAN_SYM;
else if (*token == '@' && length == 1)
retval = AT_SYMBOL;
else if (*token == '\"' && length > 1 && token[length-1] == '\"')
else if (*token == '\"' && length > 1 && token[length - 1] == '\"')
retval = T_String;
else
retval = ATOM_TOKEN;
@ -245,10 +246,10 @@ nodeTokenType(char *token, int length)
* Slightly higher-level reader.
*
* This routine applies some semantic knowledge on top of the purely
* lexical tokenizer lsptok(). It can read
* lexical tokenizer lsptok(). It can read
* * Value token nodes (integers, floats, or strings);
* * Plan nodes (via parsePlanString() from readfuncs.c);
* * Lists of the above.
* * Plan nodes (via parsePlanString() from readfuncs.c);
* * Lists of the above.
*
* Secrets: He assumes that lsptok already has the string (see above).
* Any callers should set read_car_only to true.
@ -305,6 +306,7 @@ nodeRead(bool read_car_only)
{
/* must be "<>" */
this_value = NULL;
/*
* It might be NULL but it is an atom!
*/
@ -321,13 +323,17 @@ nodeRead(bool read_car_only)
}
break;
case T_Integer:
/* we know that the token terminates on a char atol will stop at */
/*
* we know that the token terminates on a char atol will stop
* at
*/
this_value = (Node *) makeInteger(atol(token));
make_dotted_pair_cell = true;
break;
case T_Float:
{
char *fval = (char *) palloc(tok_len + 1);
char *fval = (char *) palloc(tok_len + 1);
memcpy(fval, token, tok_len);
fval[tok_len] = '\0';
@ -337,7 +343,7 @@ nodeRead(bool read_car_only)
break;
case T_String:
/* need to remove leading and trailing quotes, and backslashes */
this_value = (Node *) makeString(debackslash(token+1, tok_len-2));
this_value = (Node *) makeString(debackslash(token + 1, tok_len - 2));
make_dotted_pair_cell = true;
break;
default:

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.87 2000/03/22 22:08:32 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.88 2000/04/12 17:15:17 momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
@ -538,7 +538,7 @@ _readIndexScan()
static TidScan *
_readTidScan()
{
TidScan *local_node;
TidScan *local_node;
char *token;
int length;
@ -551,7 +551,7 @@ _readTidScan()
local_node->needRescan = atoi(token);
token = lsptok(NULL, &length); /* eat :tideval */
local_node->tideval = nodeRead(true); /* now read it */
local_node->tideval = nodeRead(true); /* now read it */
return local_node;
}
@ -1308,17 +1308,17 @@ _readRelOptInfo()
local_node->pathlist = nodeRead(true); /* now read it */
token = lsptok(NULL, &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 */
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 = lsptok(NULL, &length); /* get :pruneable */
local_node->pruneable = (token[0] == 't') ? true : false;
token = lsptok(NULL, &length); /* get :baserestrictinfo */
local_node->baserestrictinfo = nodeRead(true); /* now read it */
local_node->baserestrictinfo = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :joininfo */
local_node->joininfo = nodeRead(true); /* now read it */
@ -1365,7 +1365,7 @@ _readAttr()
local_node->relname = debackslash(token, length);
token = lsptok(NULL, &length); /* eat :attrs */
local_node->attrs = nodeRead(true); /* now read it */
local_node->attrs = nodeRead(true); /* now read it */
return local_node;
}
@ -1526,7 +1526,7 @@ _readIndexPath()
static TidPath *
_readTidPath()
{
TidPath *local_node;
TidPath *local_node;
char *token;
int length;
@ -1548,7 +1548,7 @@ _readTidPath()
local_node->path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &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 */
local_node->unjoined_relids = toIntList(nodeRead(true));
@ -1593,7 +1593,7 @@ _readNestPath()
local_node->innerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &length); /* get :joinrestrictinfo */
local_node->joinrestrictinfo = nodeRead(true); /* now read it */
local_node->joinrestrictinfo = nodeRead(true); /* now read it */
return local_node;
}
@ -1629,13 +1629,13 @@ _readMergePath()
local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &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 */
local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &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 */
local_node->path_mergeclauses = nodeRead(true); /* now read it */
@ -1680,13 +1680,13 @@ _readHashPath()
local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
token = lsptok(NULL, &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 */
local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
token = lsptok(NULL, &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 */
local_node->path_hashclauses = nodeRead(true); /* now read it */