head	1.44;
access;
symbols
	Version_2_1:1.28;
locks; strict;
comment	@ * @;


1.44
date	92.07.26.17.07.05;	author mer;	state Exp;
branches;
next	1.43;

1.43
date	92.07.12.11.02.08;	author joey;	state Exp;
branches;
next	1.42;

1.42
date	92.07.08.20.36.14;	author joey;	state Exp;
branches;
next	1.41;

1.41
date	92.07.08.07.10.00;	author joey;	state Exp;
branches;
next	1.40;

1.40
date	92.07.06.22.21.58;	author mao;	state Exp;
branches;
next	1.39;

1.39
date	92.07.04.04.03.39;	author mao;	state Exp;
branches;
next	1.38;

1.38
date	92.07.01.02.34.33;	author joey;	state Exp;
branches;
next	1.37;

1.37
date	91.11.15.16.18.50;	author hong;	state Exp;
branches;
next	1.36;

1.36
date	91.11.14.14.52.24;	author jolly;	state Exp;
branches;
next	1.35;

1.35
date	91.08.15.17.57.35;	author caetta;	state Exp;
branches;
next	1.34;

1.34
date	91.08.08.00.37.30;	author glass;	state Exp;
branches;
next	1.33;

1.33
date	91.08.08.00.32.15;	author glass;	state Exp;
branches;
next	1.32;

1.32
date	91.08.06.12.44.14;	author sp;	state Exp;
branches;
next	1.31;

1.31
date	91.06.18.23.27.55;	author cimarron;	state Exp;
branches;
next	1.30;

1.30
date	91.03.28.22.41.43;	author kemnitz;	state Exp;
branches;
next	1.29;

1.29
date	91.03.27.13.13.16;	author choi;	state Exp;
branches;
next	1.28;

1.28
date	91.02.24.12.33.08;	author sp;	state Exp;
branches;
next	1.27;

1.27
date	91.01.12.16.39.03;	author sp;	state Exp;
branches;
next	1.26;

1.26
date	91.01.09.18.55.33;	author sp;	state Exp;
branches;
next	1.25;

1.25
date	90.12.27.19.17.31;	author sp;	state Exp;
branches;
next	1.24;

1.24
date	90.12.19.13.37.34;	author sp;	state Exp;
branches;
next	1.23;

1.23
date	90.11.12.11.27.23;	author kemnitz;	state Exp;
branches;
next	1.22;

1.22
date	90.10.19.20.58.45;	author sp;	state Exp;
branches;
next	1.21;

1.21
date	90.10.16.17.14.06;	author sp;	state Exp;
branches;
next	1.20;

1.20
date	90.10.10.18.49.30;	author hong;	state Exp;
branches;
next	1.19;

1.19
date	90.09.25.17.00.16;	author kemnitz;	state Exp;
branches;
next	1.18;

1.18
date	90.06.13.01.49.51;	author hong;	state Exp;
branches;
next	1.17;

1.17
date	90.06.07.18.20.05;	author cimarron;	state Exp;
branches;
next	1.16;

1.16
date	90.05.31.22.16.00;	author cimarron;	state Exp;
branches;
next	1.15;

1.15
date	90.05.25.12.10.51;	author kemnitz;	state Exp;
branches;
next	1.14;

1.14
date	90.04.30.12.23.44;	author sp;	state Exp;
branches;
next	1.13;

1.13
date	90.04.24.18.34.12;	author kemnitz;	state Exp;
branches;
next	1.12;

1.12
date	90.01.30.23.17.08;	author sp;	state Exp;
branches;
next	1.11;

1.11
date	90.01.30.15.40.06;	author jamesb;	state Exp;
branches;
next	1.10;

1.10
date	90.01.04.17.17.20;	author sp;	state Exp;
branches;
next	1.9;

1.9
date	89.12.03.19.09.34;	author sp;	state Exp;
branches;
next	1.8;

1.8
date	89.10.30.16.58.38;	author mao;	state Exp;
branches;
next	1.7;

1.7
date	89.10.19.12.25.57;	author hirohama;	state Exp;
branches;
next	1.6;

1.6
date	89.10.17.13.44.37;	author cimarron;	state Exp;
branches;
next	1.5;

1.5
date	89.10.16.18.44.07;	author sp;	state Exp;
branches;
next	1.4;

1.4
date	89.10.12.18.00.43;	author kemnitz;	state Exp;
branches;
next	1.3;

1.3
date	89.10.11.17.31.10;	author sp;	state Exp;
branches;
next	1.2;

1.2
date	89.10.11.17.14.35;	author sp;	state Exp;
branches;
next	1.1;

1.1
date	89.10.07.04.31.34;	author kemnitz;	state Exp;
branches;
next	;


desc
@This is the source for the plan reader functions.
@


1.44
log
@process new field (refattrlength) of array refs
@
text
@/*
 *  READFUNCS.C -- Reader functions for Postgres tree nodes.
 *
 *	These routines read in and allocate space for plans.
 *	The main function is at the bottom and figures out what particular
 *  	function to use.
 *
 *  	All these functions assume that lsptok already has its string.
 *
 *	XXX many of these functions have never been tested because
 *	    the nodes they support never appear in plans..  also there
 *	    are some nodes which greg needs to finish (they are missing
 *	    or incomplete).  -cim 5/31/90
 */


#include <stdio.h>
#include <math.h>
#include <strings.h>

#include "tmp/postgres.h"

RcsId("$Header: /private/mer/pg/src/lib/C/RCS/readfuncs.c,v 1.43 1992/07/12 11:02:08 joey Exp mer $");

#include "access/heapam.h"
#include "access/htup.h"
#include "utils/fmgr.h"
#include "utils/log.h"

#include "catalog/syscache.h"
#include "catalog/pg_type.h"

#include "tags.h"

#include "nodes/pg_lisp.h"
#include "nodes/nodes.h"
#include "nodes/primnodes.h"
#include "nodes/primnodes.a.h"
#include "nodes/plannodes.h"
#include "nodes/execnodes.h"
#include "nodes/execnodes.a.h"
#include "nodes/relation.h"

extern LispValue lispRead();
extern char *lsptok ARGS((char *string, int *length));
extern Datum readValue();

/* ----------------
 *	node creator declarations
 * ----------------
 */
extern Agg		RMakeAgg();
extern Append 		RMakeAppend();
extern CInfo 		RMakeCInfo();
extern Const 		RMakeConst();
extern EState 		RMakeEState();
extern Existential 	RMakeExistential();
extern Expr 		RMakeExpr();
extern Func 		RMakeFunc();
extern HInfo 		RMakeHInfo();
extern Hash 		RMakeHash();
extern HashJoin 	RMakeHashJoin();
extern HashPath 	RMakeHashPath();
extern IndexPath 	RMakeIndexPath();
extern IndexScan 	RMakeIndexScan();
extern JInfo 		RMakeJInfo();
extern Join 		RMakeJoin();
extern JoinKey 		RMakeJoinKey();
extern JoinMethod 	RMakeJoinMethod();
extern JoinPath 	RMakeJoinPath();
extern JoinRuleInfo	RMakeJoinRuleInfo();
extern MergeJoin 	RMakeMergeJoin();
extern MergeOrder 	RMakeMergeOrder();
extern MergePath 	RMakeMergePath();
extern NestLoop 	RMakeNestLoop();
extern Oper 		RMakeOper();
extern OrderKey 	RMakeOrderKey();
extern Param 		RMakeParam();
extern Path 		RMakePath();
extern Plan 		RMakePlan();
extern Rel 		RMakeRel();
extern Result 		RMakeResult();
extern Resdom 		RMakeResdom();
extern Scan 		RMakeScan();
extern SeqScan 		RMakeSeqScan();
extern Sort 		RMakeSort();
extern SortKey 		RMakeSortKey();
extern Temp 		RMakeTemp();
extern Unique		RMakeUnique();
extern Var 		RMakeVar();
extern Array 		RMakeArray();
extern ArrayRef		RMakeArrayRef();

/* ----------------
 *	_getPlan
 * ----------------
 */
void
_getPlan(node)
    Plan node;
{
	char *token;
	int length;

	token = lsptok(NULL, &length);    	/* first token is :cost */
	token = lsptok(NULL, &length);    	/* next is the actual cost */

	node->cost = (Cost) atof(token);

	token = lsptok(NULL, &length);		/* skip the :size */
	token = lsptok(NULL, &length);		/* get the plan_size */
	node->plan_size = (Count) atoi(token);

	token = lsptok(NULL, &length);		/* skip the :width */
	token = lsptok(NULL, &length);		/* get the plan_width */
	node->plan_width = (Count) atoi(token);

	token = lsptok(NULL, &length);    	/* eat the :fragment stuff */
	token = lsptok(NULL, &length);          /* get the fragment */
	node->fragment = (Count) atoi(token);

	token = lsptok(NULL, &length);    	/* eat the :parallel stuff */
	token = lsptok(NULL, &length);          /* get the parallel */
	node->parallel = (Count) atoi(token);

	token = lsptok(NULL, &length);    	/* eat the :state stuff */
	token = lsptok(NULL, &length);    	/* now get the state */ 

	if (!strncmp(token, "nil", 3))
	{
		node->state = (struct EState *) NULL;
	} 
	else /* Disgusting hack until I figure out what to do here */
	{
		node->state = (struct EState *) ! NULL;
	}

	token = lsptok(NULL, &length);    	/* eat :qptargetlist */

	node->qptargetlist = lispRead(true);

	token = lsptok(NULL, &length);    	/* eat :qpqual */

	node->qpqual = lispRead(true);

	token = lsptok(NULL, &length);    	/* eat :lefttree */

	node->lefttree = (struct Plan *) lispRead(true);

	token = lsptok(NULL, &length);    	/* eat :righttree */

	node->righttree = (struct Plan *) lispRead(true);

}

/*
 *  Stuff from plannodes.h
 */

/* ----------------
 *	_readPlan
 * ----------------
 */
Plan
_readPlan()
{
	char *token;
	int length;
	Plan local_node;

	local_node = RMakePlan();
	
	_getPlan(local_node);
	
	return( local_node );
}

/* ----------------
 *	_readResult
 *
 * 	Does some obscene, possibly unportable, magic with
 *	sizes of things.
 * ----------------
 */
Result
_readResult()
{
	Result	local_node;
	char *token;
	int length;

	local_node = RMakeResult();
	
	_getPlan(local_node);

	token = lsptok(NULL, &length);    	/* eat :resrellevelqual */

	local_node->resrellevelqual = lispRead(true);  /* now read it */

	token = lsptok(NULL, &length);    	/* eat :resconstantqual */

	local_node->resconstantqual = lispRead(true);	/* now read it */

	return( local_node );
}

/* ----------------
 *	_readExistential
 *
 *	Existential nodes are only used by the planner.
 * ----------------
 */

Existential
_readExistential()
{
	Existential	local_node;

	local_node = RMakeExistential();

	_getPlan(local_node);
	
	return( local_node );
}

/* ----------------
 *	_readAppend
 *
 *  Append is a subclass of Plan.
 * ----------------
 */

Append
_readAppend()
{
	Append local_node;
	char *token;
	int length;

	local_node = RMakeAppend();

	_getPlan(local_node);

	token = lsptok(NULL, &length);    		/* eat :unionplans */

	local_node->unionplans = lispRead(true); 	/* now read it */
	
	token = lsptok(NULL, &length);    		/* eat :unionrelid */
	token = lsptok(NULL, &length);    		/* get unionrelid */

	local_node->unionrelid = atoi(token);

	token = lsptok(NULL, &length);    	/* eat :unionrtentries */

	local_node->unionrtentries = lispRead(true);	/* now read it */

	return(local_node);
}

/* ----------------
 * 	_readJoinRuleInfo
 *
 * ----------------
 */
JoinRuleInfo
_readJoinRuleInfo()
{
	JoinRuleInfo	local_node;
	char *token;
	int length;

	local_node = RMakeJoinRuleInfo();

	token = lsptok(NULL, &length);    		/* eat :operator */
	token = lsptok(NULL, &length);    		/* get operator */
	
	local_node->jri_operator = atol(token);

	token = lsptok(NULL, &length);    		/* eat :inattrno */
	token = lsptok(NULL, &length);    		/* get inattrno */
	
	local_node->jri_inattrno = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :outattrno */
	token = lsptok(NULL, &length);    		/* get outattrno */
	
	local_node->jri_outattrno = atoi(token);

	/*
	 * a rule lock is printed as a string enclosed in double
	 * quotes. So, we first read the string and then
	 * call `StringToRuleLock()' to get the actual RuleLock
	 * structure.
	 */
	token = lsptok(NULL, &length);    		/* eat :lock */
	token = lsptok(NULL, &length);			/* get lock */
	/*
	 * peel off the double quotes...
	 */
	token++;
	token[length - 2] = '\0';
	local_node->jri_lock = StringToRuleLock(token);
	token[length - 2] = '\"';

	token = lsptok(NULL, &length);    		/* eat :ruleid */
	token = lsptok(NULL, &length);    		/* get ruleId */
	
	local_node->jri_ruleid = atol(token);

	token = lsptok(NULL, &length);    		/* eat :stubid */
	token = lsptok(NULL, &length);    		/* get stubid */
	
	local_node->jri_stubid = atoi(token);

	/*
	 * remember: JoinRuleInfo->stub is only temporarily used.
	 * so its actual value is of no interest.
	 * Always initialize it to NULL
	 */
	token = lsptok(NULL, &length);    		/* eat :stub */
	token = lsptok(NULL, &length);    		/* skip stub */
	local_node->jri_stub = (Prs2OneStub) NULL;

	return(local_node);
}

/* ----------------
 *	_getJoin
 *
 * In case Join is not the same structure as Plan someday.
 * ----------------
 */
void
_getJoin(node)
    Join node;
{
	char		*token;
	int length;

	_getPlan(node);

	token = lsptok(NULL, &length);	/* skip ruleinfo: */
	node->ruleinfo = (struct JoinRuleInfo *) lispRead(true);

}


/* ----------------
 *	_readJoin
 *
 *  Join is a subclass of Plan
 * ----------------
 */
Join
_readJoin()
{
	Join	local_node;

	local_node = RMakeJoin();

	_getJoin(local_node);
	
	return( local_node );
}

/* ----------------
 *	_readNestLoop
 *	
 *  NestLoop is a subclass of Join
 * ----------------
 */

NestLoop
_readNestLoop()
{
	NestLoop	local_node;

	local_node = RMakeNestLoop();

	_getJoin(local_node);
	
	return( local_node );
}

/* ----------------
 *	_readMergeJoin
 *	
 *  MergeJoin is a subclass of Join
 * ----------------
 */

MergeJoin
_readMergeJoin()
{
	MergeJoin	local_node;
	char		*token;
	int length;

	local_node = RMakeMergeJoin();

	_getJoin(local_node);
	token = lsptok(NULL, &length);    		/* eat :mergeclauses */
	
	local_node->mergeclauses = lispRead(true);	/* now read it */

	token = lsptok(NULL, &length);    		/* eat :mergesortop */

	token = lsptok(NULL, &length);    		/* get mergesortop */

	local_node->mergesortop = atol(token);

	return( local_node );
}

/* ----------------
 *	_readHashJoin
 *	
 *  HashJoin is a subclass of Join.
 * ----------------
 */

HashJoin
_readHashJoin()
{
	HashJoin	local_node;
	char 		*token;
	int length;

	local_node = RMakeHashJoin();

	_getJoin(local_node);

	token = lsptok(NULL, &length);    		/* eat :hashclauses */
	local_node->hashclauses = lispRead(true);	/* now read it */

	token = lsptok(NULL, &length);    		/* eat :hashjoinop */
	token = lsptok(NULL, &length);    		/* get hashjoinop */
	local_node->hashjoinop = atoi(token);

	token = lsptok(NULL, &length);		/* eat :hashjointable */
	token = lsptok(NULL, &length);		/* eat hashjointable */
	local_node->hashjointable = NULL;
	
	token = lsptok(NULL, &length);		/* eat :hashjointablekey */
	token = lsptok(NULL, &length);		/* eat hashjointablekey */
	local_node->hashjointablekey = 0;
	
	token = lsptok(NULL, &length);		/* eat :hashjointablesize */
	token = lsptok(NULL, &length);		/* eat hashjointablesize */
	local_node->hashjointablesize = 0;
	
	token = lsptok(NULL, &length);		/* eat :hashdone */
	token = lsptok(NULL, &length);		/* eat hashdone */
	local_node->hashdone = false;
	
	return( local_node );
}

/* ----------------
 *	_getScan
 *
 *  Scan is a subclass of Node
 *  (Actually, according to the plannodes.h include file, it is a
 *  subclass of Plan.  This is why _getPlan is used here.)
 *
 *  Scan gets its own get function since stuff inherits it.
 * ----------------
 */
void
_getScan(node)
    Scan node;
{
	char *token;
	int length;

	_getPlan(node);
	
	token = lsptok(NULL, &length);    		/* eat :scanrelid */

	token = lsptok(NULL, &length);    		/* get scanrelid */

	node->scanrelid = atoi(token);
}

/* ----------------
 *	_readScan
 *	
 * Scan is a subclass of Plan (Not Node, see above).
 * ----------------
 */
Scan
_readScan()
{
	Scan 	local_node;

	local_node = RMakeScan();

	_getScan(local_node);

	return(local_node);
}

/* ----------------
 *	_readSeqScan
 *	
 *  SeqScan is a subclass of Scan
 * ----------------
 */
SeqScan
_readSeqScan()
{
	SeqScan 	local_node;

	local_node = RMakeSeqScan();

	_getScan(local_node);

	return(local_node);
}

/* ----------------
 *	_readIndexScan
 *	
 *  IndexScan is a subclass of Scan
 * ----------------
 */
IndexScan
_readIndexScan()
{
	IndexScan	local_node;
	char		*token;
	int length;

	local_node = RMakeIndexScan();

	_getScan(local_node);

	token = lsptok(NULL, &length);    		/* eat :indxid */

	local_node->indxid = lispRead(true);		/* now read it */
	
	token = lsptok(NULL, &length);    		/* eat :indxqual */

	local_node->indxqual = lispRead(true); 		/* now read it */

	return(local_node);
}

/* ----------------
 *	_readTemp
 *	
 *  Temp is a subclass of Plan
 * ----------------
 */
Temp
_readTemp()
{
	Temp		local_node;
	char		*token;
	int length;

	local_node = RMakeTemp();

	_getPlan(local_node);

	token = lsptok(NULL, &length);    		/* eat :tempid */
	token = lsptok(NULL, &length);    		/* get tempid */

	local_node->tempid = atol(token);

	token = lsptok(NULL, &length);    		/* eat :keycount */

	token = lsptok(NULL, &length);    		/* get keycount */

	local_node->keycount = atoi(token);

	return(local_node);
}

/* ----------------
 *	_readSort
 *	
 *  Sort is a subclass of Temp
 * ----------------
 */
Sort
_readSort()
{
	Sort		local_node;
	char		*token;
	int length;

	local_node = RMakeSort();

	_getPlan(local_node);

	token = lsptok(NULL, &length);    		/* eat :tempid */
	token = lsptok(NULL, &length);    		/* get tempid */

	local_node->tempid = atol(token);

	token = lsptok(NULL, &length);    		/* eat :keycount */

	token = lsptok(NULL, &length);    		/* get keycount */

	local_node->keycount = atoi(token);

	return(local_node);
}

Agg
_readAgg()
{
	Agg             local_node;
	char            *token;
	int length;

	local_node = RMakeAgg();
	_getPlan(local_node);

	token = lsptok(NULL, &length);                  /* eat :tempid */
	token = lsptok(NULL, &length);                  /* get tempid */

	local_node->tempid = atol(token);

	token = lsptok(NULL, &length);                  /* eat :keycount */
	token = lsptok(NULL, &length);                  /* get keycount */

	local_node->tempid = atoi(token);

	return(local_node);
}

/* ----------------
 *	_readUnique
 *
 * For some reason, unique is a subclass of Temp.
 */
Unique
_readUnique()
{
	Unique		local_node;
	char		*token;
	int		length;

	local_node = RMakeUnique();

	_getPlan(local_node);

	token = lsptok(NULL, &length);    		/* eat :tempid */
	token = lsptok(NULL, &length);    		/* get :tempid */
	local_node->tempid = atol(token);

	token = lsptok(NULL, &length);    		/* eat :keycount */
	token = lsptok(NULL, &length);    		/* get :keycount */
	local_node->keycount = atoi(token);

	return(local_node);
}

/* ----------------
 *	_readHash
 *	
 *  Hash is a subclass of Temp
 * ----------------
 */
Hash
_readHash()
{
	Hash		local_node;
	char		*token;
	int length;

	local_node = RMakeHash();

	_getPlan(local_node);

	token = lsptok(NULL, &length);    		/* eat :hashkey */
	local_node->hashkey = (Var) lispRead(true);

	token = lsptok(NULL, &length);    	/* eat :hashtable */
	token = lsptok(NULL, &length);    	/* eat hashtable address*/
	local_node->hashtable = NULL;

	token = lsptok(NULL, &length);    	/* eat :hashtablekey*/
	token = lsptok(NULL, &length);    	/* get hashtablekey */
	local_node->hashtablekey = 0;

	token = lsptok(NULL, &length);    	/* eat :hashtablesize*/
	token = lsptok(NULL, &length);    	/* get hashtablesize */
	local_node->hashtablesize = 0;

	return(local_node);
}

/*
 *  Stuff from primnodes.h.
 */

/* ----------------
 *	_readResdom
 *	
 *  Resdom is a subclass of Node
 * ----------------
 */
Resdom
_readResdom()
{
	Resdom		local_node;
	char		*token;
	int length;

	local_node = RMakeResdom();

	token = lsptok(NULL, &length);    		/* eat :resno */
	token = lsptok(NULL, &length);    		/* get resno */

	local_node->resno = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :restype */
	token = lsptok(NULL, &length);    		/* get restype */

	local_node->restype = atol(token);

	token = lsptok(NULL, &length);    		/* eat :rescomplex */
	token = lsptok(NULL, &length);    		/* get rescomplex */

	if (!strncmp(token, "true", 4))
	{
		local_node->rescomplex = true;
	}
	else
	{
		local_node->rescomplex = false;
	}

	token = lsptok(NULL, &length);    		/* eat :reslen */
	token = lsptok(NULL, &length);    		/* get reslen */

	local_node->reslen = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :resname */
	token = lsptok(NULL, &length);    		/* get the name */

	if (!strncmp(token, "\"null\"", 5))
	{
		local_node->resname = NULL;
	}
	else
	{
		/*
		 * Peel off ""'s, then make a true copy.
		 */

		token++;
		token[length - 2] = '\0';

		local_node->resname = (Name) palloc(sizeof(char16));
		strcpy(local_node->resname, token);
		token[length - 2] = '\"';
	}

	token = lsptok(NULL, &length);    		/* eat :reskey */
	token = lsptok(NULL, &length);    		/* get reskey */

	local_node->reskey = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :reskeyop */

	token = lsptok(NULL, &length);    		/* get reskeyop */

	local_node->reskeyop = (OperatorTupleForm) atol(token);

	token = lsptok(NULL, &length);    		/* eat :resjunk */
	token = lsptok(NULL, &length);    		/* get resjunk */
	local_node->resjunk = atoi(token);

	return(local_node);
}

/* ----------------
 *	_readExpr
 *	
 *  Expr is a subclass of Node
 * ----------------
 */
Expr
_readExpr()
{
	Expr local_node;

	local_node = RMakeExpr();

	return(local_node);
}

/* ----------------
 *	_readVar
 *	
 *  Var is a subclass of Expr
 * ----------------
 */
Var
_readVar()
{
	Var		local_node;
	char		*token;
	int length;

	local_node = RMakeVar();

	token = lsptok(NULL, &length);    		/* eat :varno */
	token = lsptok(NULL, &length);    		/* get varno */
	
	local_node->varno = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :varattno */
	token = lsptok(NULL, &length);    		/* get varattno */
	
	local_node->varattno = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :vartype */
	token = lsptok(NULL, &length);    		/* get vartype */
	
	local_node->vartype = (ObjectId) atol(token);

	token = lsptok(NULL, &length);    		/* eat :varid */
	local_node->varid = lispRead(true); 		/* now read it */

	return(local_node);
}

/* ----------------
 * _readArray
 *
 * Array is a subclass of Expr
 * ----------------
 */

Array
_readArray()

{
	Array		local_node;
	char		*token;
	int length;

	local_node = RMakeArray();

	token = lsptok(NULL, &length);    		/* eat :arrayelemtype */
	token = lsptok(NULL, &length);    		/* get arrayelemtype */
	
	local_node->arrayelemtype = (ObjectId) atoi(token);

	token = lsptok(NULL, &length);    		/* eat :arrayelemlength */
	token = lsptok(NULL, &length);    		/* get arrayelemlength */
	
	local_node->arrayelemlength = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :arrayelembyval */
	token = lsptok(NULL, &length);    		/* get arrayelembyval */
	
	local_node->arrayelembyval = (token[0] == 't') ? true : false;

	token = lsptok(NULL, &length);    		/* eat :arraylow */
	token = lsptok(NULL, &length);    		/* get arraylow */

	local_node->arraylow = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :arrayhigh */
	token = lsptok(NULL, &length);    		/* get arrayhigh */

	local_node->arrayhigh = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :arraylen */
	token = lsptok(NULL, &length);    		/* get arraylen */

	local_node->arraylen = atoi(token);

	return(local_node);
}

/* ----------------
 * _readArrayRef
 *
 * ArrayRef is a subclass of Expr
 * ----------------
 */

ArrayRef
_readArrayRef()

{
	ArrayRef	local_node;
	char		*token;
	int		length;

	local_node = RMakeArrayRef();

	token = lsptok(NULL, &length);    		/* eat :refelemtype */
	token = lsptok(NULL, &length);    		/* get refelemtype */
	
	local_node->refelemtype = (ObjectId) atoi(token);

	token = lsptok(NULL, &length);    		/* eat :refattrlength */
	token = lsptok(NULL, &length);    		/* get refattrlength */
	
	local_node->refattrlength = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :refelemlength */
	token = lsptok(NULL, &length);    		/* get refelemlength */
	
	local_node->refelemlength = atoi(token);

	token = lsptok(NULL, &length);    		/* eat :refelembyval */
	token = lsptok(NULL, &length);    		/* get refelembyval */
	
	local_node->refelembyval = (token[0] == 't') ? true : false;

	token = lsptok(NULL, &length);    		/* eat :refindex */
	local_node->refindexpr = (LispValue) lispRead(true);

	token = lsptok(NULL, &length);    		/* eat :refexpr */
	local_node->refexpr = (LispValue) lispRead(true);

	return(local_node);
}

/* ----------------
 *	_readConst
 *	
 *  Const is a subclass of Expr
 * ----------------
 */
Const
_readConst()
{
	Const	local_node;
	char *token;
	int length;

	local_node = RMakeConst();

	token = lsptok(NULL, &length);      /* get :consttype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->consttype = atol(token);


	token = lsptok(NULL, &length);      /* get :constlen */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->constlen = atoi(token);

	token = lsptok(NULL, &length);      /* get :constisnull */
	token = lsptok(NULL, &length);      /* now read it */

	if (!strncmp(token, "true", 4))
	{
		local_node->constisnull = true;
	}
	else
	{
		local_node->constisnull = false;
	}


	token = lsptok(NULL, &length);      /* get :constvalue */

	if (local_node->constisnull) {
	    token = lsptok(NULL, &length);      /* skip "NIL" */
	} else {
	    /*
	     * read the value
	     */
	    local_node->constvalue = readValue(local_node->consttype);
	}

	token = lsptok(NULL, &length);      /* get :constbyval */
	token = lsptok(NULL, &length);      /* now read it */

	if (!strncmp(token, "true", 4))
	{
		local_node->constbyval = true;
	}
	else
	{
		local_node->constbyval = false;
	}
	
	return(local_node);
}

/* ----------------
 *	_readFunc
 *	
 *  Func is a subclass of Expr
 * ----------------
 */
Func
_readFunc()
{
	Func	local_node;
	char *token;
	int length;

	local_node = RMakeFunc();

	token = lsptok(NULL, &length);      /* get :funcid */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->funcid = atol(token);

	token = lsptok(NULL, &length);      /* get :functype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->functype = atol(token);

	token = lsptok(NULL, &length);      /* get :funcisindex */
	token = lsptok(NULL, &length);      /* now read it */

	if (!strncmp(token, "true", 4))
	{
		local_node->funcisindex = true;
	}
	else
	{
		local_node->funcisindex = false;
	}
	local_node->func_fcache = (FunctionCache *) NULL;

	token = lsptok(NULL, &length);            /* get :func_tlist */
	local_node->func_tlist = lispRead(true);  /* now read it */

	token = lsptok(NULL, &length);              /* get :func_planlist */
	local_node->func_planlist = lispRead(true); /* now read it */
	
	return(local_node);
}

/* ----------------
 *	_readOper
 *	
 *  Oper is a subclass of Expr
 * ----------------
 */
Oper
_readOper()
{
	Oper	local_node;
	char 	*token;
	int length;

	local_node = RMakeOper();

	token = lsptok(NULL, &length);      /* get :opno */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->opno = atol(token);

	token = lsptok(NULL, &length);      /* get :opid */
	token = lsptok(NULL, &length);      /* now read it */
	local_node->opid = atol(token);

	token = lsptok(NULL, &length);      /* get :oprelationlevel */
	token = lsptok(NULL, &length);      /* now read it */

	if (!strncmp(token, "non-nil", 7))
	{
		local_node->oprelationlevel = true;
	}
	else
	{
		local_node->oprelationlevel = false;
	}

	token = lsptok(NULL, &length);      /* get :opresulttype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->opresulttype = atol(token);

	/*
	 * NOTE: Alternatively we can call 'replace_opid' 
	 * which initializes both 'opid' and 'op_fcache'.
	 */
	local_node->op_fcache = (FunctionCache *) NULL;

	return(local_node);
}

/* ----------------
 *	_readParam
 *	
 *  Param is a subclass of Expr
 * ----------------
 */
Param
_readParam()
{
	Param	local_node;
	char 	*token;
	int length;

	local_node = RMakeParam();

	token = lsptok(NULL, &length);      /* get :paramkind */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->paramkind = atoi(token);

	token = lsptok(NULL, &length);      /* get :paramid */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->paramid = atol(token);

	token = lsptok(NULL, &length);      /* get :paramname */
	token = lsptok(NULL, &length);      /* now read it */
	token++;			    /* skip the first `"' */
	token[length - 2] = '\0';	    /* this is the 2nd `"' */

	local_node->paramname = (Name) palloc(sizeof(char16));
	strcpy(local_node->paramname, token);
	token[length - 2] = '\"';	/* restore the 2nd `"' */

	token = lsptok(NULL, &length);      /* get :paramtype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->paramtype = atol(token);
	token = lsptok(NULL, &length);             /* get :param_tlist */
	local_node->param_tlist = lispRead(true);  /* now read it */
	
	return(local_node);
}

/*
 *  Stuff from execnodes.h
 */

/* ----------------
 *	_readEState
 *	
 *  EState is a subclass of Node.
 * ----------------
 */
EState
_readEState()
{
	EState	local_node;
	char *token;
	int length;

	local_node = RMakeEState();

	token = lsptok(NULL, &length);      /* get :direction */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->es_direction = atoi(token);

	token = lsptok(NULL, &length);      /* get :time */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->es_time = (unsigned long) atoi(token);

	token = lsptok(NULL, &length);      /* get :owner */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->es_owner = atol(token);

	token = lsptok(NULL, &length);      /* get :locks */

	local_node->es_locks = lispRead(true);   /* now read it */

	token = lsptok(NULL, &length);      /* get :subplan_info */

	local_node->es_subplan_info = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :error_message */
	token = lsptok(NULL, &length);      /* now read it */
	token++;
	token[length-2] = '\0';

	local_node->es_error_message = (Name) palloc(sizeof(char16));
	strcpy(local_node->es_error_message, token);

	token[length-2] = '\"';

	token = lsptok(NULL, &length);      /* get :range_table */

	local_node->es_locks = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :qualification_tuple */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	sscanf(token, "%x", &local_node->es_qualification_tuple);

	token = lsptok(NULL, &length);      /* get :qualification_tuple_id */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	sscanf(token, "%x", &local_node->es_qualification_tuple_id);

	token = lsptok(NULL, &length); /* get :relation_relation_descriptor */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	sscanf(token, "%x", &local_node->es_relation_relation_descriptor);

	token = lsptok(NULL, &length);      /* get :result_relation_info */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	sscanf(token, "%x", &local_node->es_result_relation_info);
	
	return(local_node);
}

/*
 *  Stuff from relation.h
 */

/* ----------------
 *	_readRel
 * ----------------
 */
Rel
_readRel()
{
	Rel	local_node;
	char 	*token;
	int length;

	local_node = RMakeRel();

	token = lsptok(NULL, &length);      /* get :relids */
	local_node->relids = lispRead(true);/* now read it */

	token = lsptok(NULL, &length);      /* get :indexed */
	token = lsptok(NULL, &length);      /* now read it */

	if (!strncmp(token, "true", 4))
	{
		local_node->indexed = true;
	}
	else
	{
		local_node->indexed = false;
	}

	token = lsptok(NULL, &length);      /* get :pages */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->pages = (unsigned int) atoi(token);

	token = lsptok(NULL, &length);      /* get :tuples */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->tuples = (unsigned int) atoi(token);

	token = lsptok(NULL, &length);      /* get :size */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->size = (unsigned int) atoi(token);

	token = lsptok(NULL, &length);      /* get :width */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->width = (unsigned int) atoi(token);

	token = lsptok(NULL, &length);      /* get :targetlist */
	local_node->targetlist = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :pathlist */
	local_node->pathlist = lispRead(true); /* now read it */

	/*
	 *  Not sure if these are nodes or not.  They're declared as
	 *  struct Path *.  Since i don't know, i'll just print the
	 *  addresses for now.  This can be changed later, if necessary.
	 */

	token = lsptok(NULL, &length);      /* get :unorderpath */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	sscanf(token, "%x", &local_node->unorderedpath);

	token = lsptok(NULL, &length);      /* get :cheapestpath */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	sscanf(token, "%x", &local_node->cheapestpath);

	token = lsptok(NULL, &length);      /* get :classlist */
	local_node->classlist = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :indexkeys */
	local_node->indexkeys = lispRead(true);/* now read it */

	token = lsptok(NULL, &length);      /* get :ordering */
	local_node->ordering = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :clauseinfo */
	local_node->clauseinfo = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :joininfo */
	local_node->joininfo = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :innerjoin */
	local_node->innerjoin = lispRead(true); /* now read it */
	
	return(local_node);
}

/* ----------------
 *	_readSortKey
 *	
 *  SortKey is a subclass of Node.
 * ----------------
 */

SortKey
_readSortKey()
{
	SortKey		local_node;
	char		*token;
	int length;

	local_node = RMakeSortKey();
	token = lsptok(NULL, &length);      /* get :varkeys */
	local_node->varkeys = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :sortkeys */
	local_node->sortkeys = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :relid */
	local_node->relid = lispRead(true);      /* now read it */

	token = lsptok(NULL, &length);      /* get :sortorder */
	local_node->sortorder = lispRead(true);      /* now read it */
	
	return(local_node);
}

/* ----------------
 *	_readPath
 *	
 *  Path is a subclass of Node.
 * ----------------
 */
Path
_readPath()
{
	Path	local_node;
	char 	*token;
	int length;

	local_node = RMakePath();

	token = lsptok(NULL, &length);      /* get :pathtype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->pathtype = atol(token);

	token = lsptok(NULL, &length);      /* get :cost */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->path_cost = (Cost) atof(token);

	token = lsptok(NULL, &length);      /* get :p_ordering */
	local_node->p_ordering = lispRead(true);      /* now read it */

	token = lsptok(NULL, &length);      /* get :keys */
	local_node->keys = lispRead(true);       /* now read it */

	token = lsptok(NULL, &length);      /* get :pathsortkey */
	local_node->pathsortkey = (SortKey) lispRead(true);

	return(local_node);
}

/* ----------------
 *	_readIndexPath
 *	
 *  IndexPath is a subclass of Path.
 * ----------------
 */
IndexPath
_readIndexPath()
{
	IndexPath	local_node;
	char		*token;
	int length;

	local_node = RMakeIndexPath();

	token = lsptok(NULL, &length);      /* get :pathtype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->pathtype = atol(token);

	token = lsptok(NULL, &length);      /* get :cost */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->path_cost = (Cost) atof(token);

	token = lsptok(NULL, &length);      /* get :p_ordering */
	local_node->p_ordering = lispRead(true);      /* now read it */

	token = lsptok(NULL, &length);      /* get :keys */
	local_node->keys = lispRead(true);       /* now read it */

	token = lsptok(NULL, &length);      /* get :pathsortkey */
	local_node->pathsortkey = (SortKey) lispRead(true);

	token = lsptok(NULL, &length);      /* get :indexid */
	local_node->indexid = lispRead(true);

	token = lsptok(NULL, &length);      /* get :indexqual */
	local_node->indexqual = lispRead(true);      /* now read it */

	return(local_node);
}

/* ----------------
 *	_readJoinPath
 *	
 *  JoinPath is a subclass of Path
 * ----------------
 */
JoinPath
_readJoinPath()
{
	JoinPath	local_node;
	char		*token;
	int length;


	local_node = RMakeJoinPath();

	token = lsptok(NULL, &length);      /* get :pathtype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->pathtype = atol(token);

	token = lsptok(NULL, &length);      /* get :cost */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->path_cost = (Cost) atof(token);

	token = lsptok(NULL, &length);      /* get :p_ordering */
	local_node->p_ordering = lispRead(true);           /* now read it */

	token = lsptok(NULL, &length);      /* get :keys */
	local_node->keys = lispRead(true);            /* now read it */

	token = lsptok(NULL, &length);      /* get :pathsortkey */
	local_node->pathsortkey = (SortKey) lispRead(true);

	token = lsptok(NULL, &length);      /* get :pathclauseinfo */
	local_node->pathclauseinfo = lispRead(true);         /* now read it */

	/*
	 *  Not sure if these are nodes; they're declared as "struct path *".
	 *  For now, i'll just print the addresses.
	 *
	 * GJK:  Since I am parsing this stuff, I'll just ignore the addresses,
	 * and initialize these pointers to NULL.
	 */

	token = lsptok(NULL, &length);      /* get :outerjoinpath */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->outerjoinpath = NULL;

	token = lsptok(NULL, &length);      /* get :innerjoinpath */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->innerjoinpath = NULL;

	token = lsptok(NULL, &length);      /* get :outerjoincost */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->outerjoincost = (Cost) atof(token);

	token = lsptok(NULL, &length);      /* get :joinid */
	local_node->joinid = lispRead(true);          /* now read it */

	return(local_node);
}

/* ----------------
 *	_readMergePath
 *	
 *  MergePath is a subclass of JoinPath.
 * ----------------
 */

MergePath
_readMergePath()
{
	MergePath	local_node;
	char 		*token;
	int length;

	local_node = RMakeMergePath();

	token = lsptok(NULL, &length);      /* get :pathtype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->pathtype = atol(token);

	token = lsptok(NULL, &length);      /* get :cost */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->path_cost = (Cost) atof(token);

	token = lsptok(NULL, &length);      /* get :p_ordering */
	local_node->p_ordering = lispRead(true);           /* now read it */

	token = lsptok(NULL, &length);      /* get :keys */
	local_node->keys = lispRead(true);            /* now read it */

	token = lsptok(NULL, &length);      /* get :pathsortkey */
	local_node->pathsortkey = (SortKey) lispRead(true);

	token = lsptok(NULL, &length);      /* get :pathclauseinfo */
	local_node->pathclauseinfo = lispRead(true);        /* now read it */

	/*
	 *  Not sure if these are nodes; they're declared as "struct path *".
	 *  For now, i'll just print the addresses.
	 *
	 * GJK:  Since I am parsing this stuff, I'll just ignore the addresses,
	 * and initialize these pointers to NULL.
	 */

	token = lsptok(NULL, &length);      /* get :outerjoinpath */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->outerjoinpath = NULL;

	token = lsptok(NULL, &length);      /* get :innerjoinpath */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->innerjoinpath = NULL;

	token = lsptok(NULL, &length);      /* get :outerjoincost */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->outerjoincost = (Cost) atof(token);

	token = lsptok(NULL, &length);      /* get :joinid */
	local_node->joinid = lispRead(true);          /* now read it */

	token = lsptok(NULL, &length);      /* get :path_mergeclauses */
	local_node->path_mergeclauses = lispRead(true);      /* now read it */

	token = lsptok(NULL, &length);      /* get :outersortkeys */
	local_node->outersortkeys = lispRead(true);           /* now read it */

	token = lsptok(NULL, &length);      /* get :innersortkeys */
	local_node->innersortkeys = lispRead(true);           /* now read it */

	return(local_node);
}

/* ----------------
 *	_readHashPath
 *	
 *  HashPath is a subclass of JoinPath.
 * ----------------
 */
HashPath
_readHashPath()
{
	HashPath	local_node;
	char 		*token;
	int length;

	local_node = RMakeHashPath();

	token = lsptok(NULL, &length);      /* get :pathtype */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->pathtype = atol(token);

	token = lsptok(NULL, &length);      /* get :cost */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->path_cost = (Cost) atof(token);

	token = lsptok(NULL, &length);      /* get :p_ordering */
	local_node->p_ordering = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :keys */
	local_node->keys = lispRead(true);       /* now read it */

	token = lsptok(NULL, &length);      /* get :pathsortkey */
	local_node->pathsortkey = (SortKey) lispRead(true);

	token = lsptok(NULL, &length);      /* get :pathclauseinfo */
	local_node->pathclauseinfo = lispRead(true); /* now read it */

	/*
	 *  Not sure if these are nodes; they're declared as "struct path *".
	 *  For now, i'll just print the addresses.
	 *
	 * GJK:  Since I am parsing this stuff, I'll just ignore the addresses,
	 * and initialize these pointers to NULL.
	 */

	token = lsptok(NULL, &length);      /* get :outerjoinpath */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->outerjoinpath = NULL;

	token = lsptok(NULL, &length);      /* get :innerjoinpath */
	token = lsptok(NULL, &length);      /* get @@ */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->innerjoinpath = NULL;

	token = lsptok(NULL, &length);      /* get :outerjoincost */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->outerjoincost = (Cost) atof(token);

	token = lsptok(NULL, &length);      /* get :joinid */
	local_node->joinid = lispRead(true);     /* now read it */

	token = lsptok(NULL, &length);      /* get :path_hashclauses */
	local_node->path_hashclauses = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :outerhashkeys */
	local_node->outerhashkeys = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :innerhashkeys */
	local_node->innerhashkeys = lispRead(true); /* now read it */

	return(local_node);
}

/* ----------------
 *	_readOrderKey
 *	
 *  OrderKey is a subclass of Node.
 * ----------------
 */
OrderKey
_readOrderKey()
{
	OrderKey	local_node;
	char		*token;
	int length;

	local_node = RMakeOrderKey();

	token = lsptok(NULL, &length);      /* get :attribute_number */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->attribute_number = atoi(token);
	
	token = lsptok(NULL, &length);      /* get :array_index */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->array_index = atoi(token);

	return(local_node);
}

/* ----------------
 *	_readJoinKey
 *	
 *  JoinKey is a subclass of Node.
 * ----------------
 */

JoinKey
_readJoinKey()
{
	JoinKey		local_node;
	char		*token;
	int length;

	local_node = RMakeJoinKey();

	token = lsptok(NULL, &length);      /* get :outer */
	local_node->outer = lispRead(true);      /* now read it */

	token = lsptok(NULL, &length);      /* get :inner */
	local_node->inner = lispRead(true);      /* now read it */
	
	return(local_node);
}

/* ----------------
 *	_readMergeOrder
 *	
 *  MergeOrder is a subclass of Node.
 * ----------------
 */
MergeOrder
_readMergeOrder()
{
	MergeOrder	local_node;
	char		*token;
	int length;

	local_node = RMakeMergeOrder();
	token = lsptok(NULL, &length);      /* get :join_operator */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->join_operator = atol(token);

	token = lsptok(NULL, &length);      /* get :left_operator */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->left_operator = atol(token);

	token = lsptok(NULL, &length);      /* get :right_operator */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->right_operator = atol(token);

	token = lsptok(NULL, &length);      /* get :left_type */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->left_type = atol(token);

	token = lsptok(NULL, &length);      /* get :right_type */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->right_type = atol(token);

	return(local_node);
}

/* ----------------
 *	_readCInfo
 *	
 *  CInfo is a subclass of Node.
 * ----------------
 */
CInfo
_readCInfo()
{
	CInfo	local_node;
	char 	*token;
	int length;

	local_node = RMakeCInfo();

	token = lsptok(NULL, &length);      /* get :clause */
	local_node->clause = (LispValue) lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :selectivity */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->selectivity = atof(token);

	token = lsptok(NULL, &length);      /* get :notclause */
	token = lsptok(NULL, &length);      /* now read it */

	if (!strncmp(token, "true", 4))
	{
		local_node->notclause = true;
	}
	else
	{
		local_node->notclause = false;
	}
 
	token = lsptok(NULL, &length);      /* get :indexids */
	local_node->indexids = lispRead(true);   /* now read it */

	token = lsptok(NULL, &length);      /* get :mergesortorder */
	local_node->mergesortorder = (MergeOrder) lispRead(true);

	token = lsptok(NULL, &length);      /* get :hashjoinoperator */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->hashjoinoperator = atol(token);

	return(local_node);
}

/* ----------------
 *	_readJoinMethod
 *	
 *  JoinMethod is a subclass of Node.
 * ----------------
 */
JoinMethod
_readJoinMethod()
{
     	JoinMethod 	local_node;
	char		*token;
	int length;

	local_node = RMakeJoinMethod();

	token = lsptok(NULL, &length);      /* get :jmkeys */
	local_node->jmkeys = lispRead(true);/* now read it */

	token = lsptok(NULL, &length);      /* get :clauses */
	local_node->clauses = lispRead(true); /* now read it */

	return(local_node);
}

/* ----------------
 *	_readHInfo
 *	
 * HInfo is a subclass of JoinMethod.
 * ----------------
 */
HInfo
_readHInfo()
{
	HInfo 	local_node;
	char 	*token;
	int length;

	local_node = RMakeHInfo();

	token = lsptok(NULL, &length);      /* get :hashop */
	token = lsptok(NULL, &length);      /* now read it */
	
	local_node->hashop = atoi(token);

	token = lsptok(NULL, &length);      /* get :jmkeys */
	local_node->jmkeys = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :clauses */
	local_node->clauses = lispRead(true);           /* now read it */

	return(local_node);
}

/* ----------------
 *	_readJInfo()
 *	
 *  JInfo is a subclass of Node.
 * ----------------
 */
JInfo
_readJInfo()
{
	JInfo	local_node;
	char	*token;
	int length;

	local_node = RMakeJInfo();

	token = lsptok(NULL, &length);      /* get :otherrels */
	local_node->otherrels = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :jinfoclauseinfo */
	local_node->jinfoclauseinfo = lispRead(true); /* now read it */

	token = lsptok(NULL, &length);      /* get :mergesortable */

	if (!strncmp(token, "true", 4))
	{
		local_node->mergesortable = true;
	}
	else
	{
		local_node->mergesortable = false;
	}

	token = lsptok(NULL, &length);      /* get :hashjoinable */

	if (!strncmp(token, "true", 4))
	{
		local_node->hashjoinable = true;
	}
	else
	{
		local_node->hashjoinable = false;
	}

	return(local_node);
}


/* ----------------
 *	parsePlanString
 *
 * Given a character string containing a plan, parsePlanString sets up the
 * plan structure representing that plan.
 *
 * The string passed to parsePlanString must be null-terminated.
 * ----------------
 */
LispValue
parsePlanString()
{
	char *token;
	int length;
	LispValue return_value;

	token = lsptok(NULL, &length);

	if (!strncmp(token, "plan", 4))
	{
		return_value = (LispValue) _readPlan();
		return_value->type = T_Plan;
	}
	else if (!strncmp(token, "result", 6))
	{
		return_value = (LispValue) _readResult();
		return_value->type = T_Result;
	}
	else if (!strncmp(token, "existential", 11))
	{
		return_value = (LispValue) _readExistential();
		return_value->type = T_Existential;
	}
	else if (!strncmp(token, "append", 6))
	{
		return_value = (LispValue) _readAppend();
		return_value->type = T_Append;
	}
	else if (!strncmp(token, "joinruleinfo", 12))
	{
		/*
		 * NOTE: 'joinruleinfo' must be checked BEFORE
		 * 'join', because both `strncmp' test will
		 * succeeed !
		 */
		return_value = (LispValue) _readJoinRuleInfo();
		return_value->type = T_JoinRuleInfo;
	}
	else if (!strncmp(token, "join", 4))
	{
		return_value = (LispValue) _readJoin();
		return_value->type = T_Join;
	}
	else if (!strncmp(token, "nestloop", 8))
	{
		return_value = (LispValue) _readNestLoop();
		return_value->type = T_NestLoop;
	}
	else if (!strncmp(token, "mergejoin", 9))
	{
		return_value = (LispValue) _readMergeJoin();
		return_value->type = T_MergeJoin;
	}
	else if (!strncmp(token, "hashjoin", 8))
	{
		return_value = (LispValue) _readHashJoin();
		return_value->type = T_HashJoin;
	}
	else if (!strncmp(token, "scan", 4))
	{
		return_value = (LispValue) _readScan();
		return_value->type = T_Scan;
	}
	else if (!strncmp(token, "seqscan", 7))
	{
		return_value = (LispValue) _readSeqScan();
		return_value->type = T_SeqScan;
	}
	else if (!strncmp(token, "indexscan", 9))
	{
		return_value = (LispValue) _readIndexScan();
		return_value->type = T_IndexScan;
	}
	else if (!strncmp(token, "temp", 4))
	{
		return_value = (LispValue) _readTemp();
		return_value->type = T_Temp;
	}
	else if (!strncmp(token, "sort", 4))
	{
		return_value = (LispValue) _readSort();
		return_value->type = T_Sort;
	}
	else if (!strncmp(token, "hash", 4))
	{
		return_value = (LispValue) _readHash();
		return_value->type = T_Hash;
	}
	else if (!strncmp(token, "resdom", 6))
	{
		return_value = (LispValue) _readResdom();
		return_value->type = T_Resdom;
	}
	else if (!strncmp(token, "expr", 4))
	{
		return_value = (LispValue) _readExpr();
		return_value->type = T_Expr;
	}
	else if (!strncmp(token, "var", 3))
	{
		return_value = (LispValue) _readVar();
		return_value->type = T_Var;
	}
	else if (!strncmp(token, "const", 5))
	{
		return_value = (LispValue) _readConst();
		return_value->type = T_Const;
	}
	else if (!strncmp(token, "func", 4))
	{
		return_value = (LispValue) _readFunc();
		return_value->type = T_Func;
	}
	else if (!strncmp(token, "oper", 4))
	{
		return_value = (LispValue) _readOper();
		return_value->type = T_Oper;
	}
	else if (!strncmp(token, "param", 5))
	{
		return_value = (LispValue) _readParam();
		return_value->type = T_Param;
	}
	else if (!strncmp(token, "estate", 6))
	{
		return_value = (LispValue) _readEState();
		return_value->type = T_EState;
	}
	else if (!strncmp(token, "rel", 3))
	{
		return_value = (LispValue) _readRel();
		return_value->type = T_Rel;
	}
	else if (!strncmp(token, "sortkey", 7))
	{
		return_value = (LispValue) _readSortKey();
		return_value->type = T_SortKey;
	}
	else if (!strncmp(token, "path", 4))
	{
		return_value = (LispValue) _readPath();
		return_value->type = T_Path;
	}
	else if (!strncmp(token, "indexpath", 9))
	{
		return_value = (LispValue) _readIndexPath();
		return_value->type = T_IndexPath;
	}
	else if (!strncmp(token, "joinpath", 8))
	{
		return_value = (LispValue) _readJoinPath();
		return_value->type = T_JoinPath;
	}
	else if (!strncmp(token, "mergepath", 9))
	{
		return_value = (LispValue) _readMergePath();
		return_value->type = T_MergePath;
	}
	else if (!strncmp(token, "hashpath", 8))
	{
		return_value = (LispValue) _readHashPath();
		return_value->type = T_HashPath;
	}
	else if (!strncmp(token, "orderkey", 8))
	{
		return_value = (LispValue) _readOrderKey();
		return_value->type = T_OrderKey;
	}
	else if (!strncmp(token, "joinkey", 7))
	{
		return_value = (LispValue) _readJoinKey();
		return_value->type = T_JoinKey;
	}
	else if (!strncmp(token, "mergeorder", 10))
	{
		return_value = (LispValue) _readMergeOrder();
		return_value->type = T_MergeOrder;
	}
	else if (!strncmp(token, "cinfo", 5))
	{
		return_value = (LispValue) _readCInfo();
		return_value->type = T_CInfo;
	}
	else if (!strncmp(token, "joinmethod", 10))
	{
		return_value = (LispValue) _readJoinMethod();
		return_value->type = T_JoinMethod;
	}
	else if (!strncmp(token, "jinfo", 5))
	{
		return_value = (LispValue) _readJInfo();
		return_value->type = T_JInfo;
	}
	else if (!strncmp(token, "array", 5))
	{
		return_value = (LispValue) _readArray();
		return_value->type = T_Array;
	}
	else
	{
		fprintf(stderr, "badly formatted planstring\n");
		return_value = (LispValue) NULL;
	}
	return(return_value);
}
/*------------------------------------------------------------*/

/* ----------------
 *	readValue
 *
 * given a string representation of the value of the given type,
 * create the appropriate Datum
 * ----------------
 */
Datum
readValue(type)
    ObjectId type;
{
    int 	length;
    int 	tokenLength;
    char 	*token;
    Boolean	byValue;
    Datum 	res;
    char 	*s;
    int 	i;

    byValue	= get_typbyval(type);

    /*
     * read the actual length of the value
     */
    token = lsptok(NULL, &tokenLength);
    length = atoi(token);
    token = lsptok(NULL, &tokenLength);	/* skip the '{' */

    if (byValue) {
	if (length > sizeof(Datum)) {
	    elog(WARN, "readValue: byval & length = %d", length);
	}
	s = (char *) (&res);
	for (i=0; i<sizeof(Datum); i++) {
	    token = lsptok(NULL, &tokenLength);
	    s[i] = (char) atoi(token);
	}
    } else if (length <= 0) {
	s = NULL;
    } else if (length >= 1) {
	s = (char*)palloc(length);
	Assert( s!=NULL );
	for (i=0; i<length; i++) {
	    token = lsptok(NULL, &tokenLength);
	    s[i] = (char) atoi(token);
	}
	res = PointerGetDatum(s);
    }

    token = lsptok(NULL, &tokenLength);	/* skip the '}' */
    if (token[0] != '}') {
	elog(WARN, "readValue: '}' expected, length =%d", length);
    }

    return(res);
}
@


1.43
log
@made _equalCInfo handle clause as a LispValue
@
text
@d23 1
a23 1
RcsId("$Header: /private/joey/pg/src/lib/C/RCS/readfuncs.c,v 1.42 1992/07/08 20:36:14 joey Exp joey $");
d904 5
@


1.42
log
@Fix for resdom->rescomplex, func->func_planlist
@
text
@d23 1
a23 1
RcsId("$Header: /private/joey/pg/src/lib/C/RCS/readfuncs.c,v 1.41 1992/07/08 07:10:00 joey Exp joey $");
d1755 1
a1755 1
	local_node->clause = (Expr) lispRead(true); /* now read it */
@


1.41
log
@Fix readParam and readFunc to correctly get their tlists in.
@
text
@d23 1
a23 1
RcsId("$Header: /private/joey/pg/src/lib/C/RCS/readfuncs.c,v 1.40 1992/07/06 22:21:58 mao Exp joey $");
d725 12
d1026 1
d1029 3
@


1.40
log
@ArrayRef nodes now allow arbitrary int4 expressions as array indices,
not just integer constants
@
text
@d23 1
a23 1
RcsId("$Header: /private/mao/postgres/src/lib/C/RCS/readfuncs.c,v 1.39 1992/07/04 04:03:39 mao Exp mao $");
d1014 2
a1015 1
	local_node->func_tlist = LispNil;
d1108 2
a1109 1
	local_node->param_tlist = LispNil;
@


1.39
log
@fixes for arrays, array refs, and nested dots
@
text
@d23 1
a23 1
RcsId("$Header: /private/mao/postgres/src/lib/C/RCS/readfuncs.c,v 1.38 1992/07/01 02:34:33 joey Exp mao $");
d904 1
a904 3
	token = lsptok(NULL, &length);    		/* get refindex */

	local_node->refindex = atoi(token);
@


1.38
log
@bring up to date for new fields in Param and Func
@
text
@d23 1
a23 1
RcsId("$Header: /private/joey/pg/src/lib/C/RCS/readfuncs.c,v 1.37 1991/11/15 16:18:50 hong Exp joey $");
d92 1
a814 11
	token = lsptok(NULL, &length);    		/* eat :vardotfields */


	/* What to do about the extra ")"'s??? */

	local_node->vardotfields = lispRead(true); 	/* now read it */

	token = lsptok(NULL, &length);    	       /* eat :vararraylist */
	
	local_node->vararraylist = lispRead(true);	/* now read it */

a815 1

d821 1
a821 2
/*
 * ----------------
d871 26
d898 15
@


1.37
log
@for prototyping
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.36 91/11/14 14:52:24 jolly Exp Locker: hong $");
d987 1
d1080 1
@


1.36
log
@cleaned up for function prototyping
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.35 91/08/15 17:57:35 caetta Exp Locker: jolly $");
d1324 2
a1325 2
	token = lsptok(NULL, &length);      /* get :sortpath */
	local_node->sortpath = (SortKey) lispRead(true);
d1361 2
a1362 2
	token = lsptok(NULL, &length);      /* get :sortpath */
	local_node->sortpath = (SortKey) lispRead(true);
d1405 2
a1406 2
	token = lsptok(NULL, &length);      /* get :sortpath */
	local_node->sortpath = (SortKey) lispRead(true);
d1474 2
a1475 2
	token = lsptok(NULL, &length);      /* get :sortpath */
	local_node->sortpath = (SortKey) lispRead(true);
d1551 2
a1552 2
	token = lsptok(NULL, &length);      /* get :sortpath */
	local_node->sortpath = (SortKey) lispRead(true);
@


1.35
log
@and more agg stuff
@
text
@d23 1
a23 1
RcsId("$Header: lib/C/RCS/readfuncs.c,v 1.34 91/08/08 00:37:30 glass Exp Locker: caetta $");
d82 1
a83 1
extern Result 		RMakeResult();
d2098 1
a2098 1
	s = palloc(length);
@


1.34
log
@oops. checked in wrong file.
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.32 91/08/06 12:44:14 sp Exp Locker: glass $");
d52 1
d606 23
@


1.33
log
@fixed incredible bug in _readResdom that trashed resnames
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.31 91/06/18 23:27:55 cimarron Exp $");
d708 1
a708 1
	if (!strncmp(token, "\"null\", 5"))
d2019 5
@


1.32
log
@Bug fix: _readArray was never called!
@
text
@a2019 5
	else if (!strncmp(token, "array", 5))
	{
		return_value = (LispValue) _readArray();
		return_value->type = T_Array;
	}
@


1.31
log
@reorganized executor to use tuple table properly for nested dot stuff
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.30 91/03/28 22:41:43 kemnitz Exp Locker: cimarron $");
d2019 5
@


1.30
log
@added array node read function.
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.29 91/03/27 13:13:16 choi Exp Locker: kemnitz $");
a79 1
extern Recursive 	RMakeRecursive();
d208 2
a209 6
 *  Existential is a subclass of Plan.
 *  In fact, it is identical.
 * 
 *| Wrong! an Existential inherits Plan and has a field called exstate
 *| -cim 5/31/90
 * ----------------
a218 4
	/* ----------------
	 *	XXX this doesn't read the exstate field... -cim
	 * ----------------
	 */
a257 1

a258 42
 *	_readRecursive
 *
 *  Recursive is a subclass of Plan.
 * ----------------
 */
Recursive
_readRecursive()
{
        Recursive local_node;
        char *token;
        int length;

        local_node = RMakeRecursive();

        _getPlan(local_node);

        token = lsptok(NULL, &length);               /* eat :recurMethod */
        token = lsptok(NULL, &length);               /* get recurMethod */
        local_node->recurMethod = (RecursiveMethod) atoi(token);

        token = lsptok(NULL, &length);               /* eat :recurCommand */
        local_node->recurCommand = lispRead(true); /* now read it */

        token = lsptok(NULL, &length);               /* eat :recurInitPlans */
        local_node->recurInitPlans = lispRead(true); /* now read it */

        token = lsptok(NULL, &length);               /* eat :recurLoopPlans */
        local_node->recurLoopPlans = lispRead(true); /* now read it */

        token = lsptok(NULL, &length);		/* eat :recurCleanupPlans */
        local_node->recurCleanupPlans = lispRead(true); /* now read it */

        token = lsptok(NULL, &length);       	/* eat :recurCheckpoints */
        local_node->recurCheckpoints = lispRead(true); /* now read it */

        token = lsptok(NULL, &length);       /* eat :recurResultRelationName */
        local_node->recurResultRelationName = lispRead(true); /* now read it */

        return(local_node);
}

/* ----------------
a2018 5
	}
	else if (!strncmp(token, "recursive", 9))
	{
		return_value = (LispValue) _readRecursive();
		return_value->type = T_Recursive;
@


1.29
log
@varnode->vararrayindex became vanode->vararraylist
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.28 91/02/24 12:33:08 sp Exp Locker: choi $");
d91 1
d859 53
@


1.28
log
@_readHash and _readHashJoin were out of sync with the out funcs...
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.27 91/01/12 16:39:03 sp Exp $");
d848 1
a848 2
	token = lsptok(NULL, &length);    	       /* eat :vararrayindex */
	token = lsptok(NULL, &length);    		/* get vararrayindex */
d850 1
a850 1
	local_node->vararrayindex = atoi(token);
a854 4

	token = lsptok(NULL, &length);    		/* eat :varelemtype */
	token = lsptok(NULL, &length);
	local_node->varelemtype = (ObjectId) atoi(token);
@


1.27
log
@when reading/printing 'Const' nodes make sure that if this is a
null value (i.e. constisnull==true) then do not call 'printValue'
or 'readValue' (they might bomb if they are given an invalid datum
as argument).
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.26 91/01/09 18:55:33 sp Exp Locker: sp $");
a482 1
	
a485 1

d487 1
d489 3
a491 1
	local_node->hashjoinop = atoi(token);
d493 12
d706 12
@


1.26
log
@Use 'get_typbyval' instead of directly accessing the cache.
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.25 90/12/27 19:17:31 sp Exp Locker: sp $");
a864 8
	token = lsptok(NULL, &length);      /* get :constvalue */

	/*
	/* token = lsptok(NULL, &length);      /* now read it */
	/* local_node->constvalue = Int32GetDatum(atoi(token));
	/* */
	local_node->constvalue = readValue(local_node->consttype);

d875 12
@


1.25
log
@Oper nodes now have a new field (opid) where the oid of the regproc
is stored (that used to be stored in 'opno' overriding the pg_operator
oid).
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.24 90/12/19 13:37:34 sp Exp $");
d2022 1
a2022 2
    Boolean	 byValue;
    HeapTuple 	typeTuple;
d2027 1
a2027 8
    typeTuple = SearchSysCacheTuple(TYPOID,
				    (char *) type,
				    (char *) NULL,
				    (char *) NULL,
				    (char *) NULL);
    if (!HeapTupleIsValid(typeTuple)) {
	elog(WARN, "readValue: Cache lookup of type %d failed", type);
    }
a2028 9
    /*---- this is the length as storedin pg_type. But it might noy
     * be the actual length (e.g. variable length types...
     *  length	= ((ObjectId) ((TypeTupleForm)
     *		        GETSTRUCT(typeTuple))->typlen);
     */
    
    byValue	= ((ObjectId) ((TypeTupleForm)
			GETSTRUCT(typeTuple))->typbyval);

d2030 1
a2030 1
     * read the actual length of teh value
@


1.24
log
@the 'fcache' attribute of Func & Oper nodes should be initialized
to NULL. 'init_fcache' should only be called by the executor...
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.23 90/11/12 11:27:23 kemnitz Exp Locker: sp $");
d961 4
d981 5
@


1.23
log
@Added code to func and oper readfuncs to init function cache.
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.22 90/10/19 20:58:45 sp Exp Locker: kemnitz $");
a28 1
#include "utils/fcache.h"
d936 1
a936 1
	local_node->func_fcache = (FunctionCache *) init_fcache(local_node->funcid);
d977 1
a977 1
	local_node->op_fcache = (FunctionCache *) init_fcache(local_node->opno);
@


1.22
log
@printfuncs.c & redfuncs.c where out of sync in more than
a few places... 
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.21 90/10/16 17:14:06 sp Exp $");
d29 1
d937 1
d978 1
@


1.21
log
@Bug fix in _readResdom: read the "resjunk" info too...
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.20 90/10/10 18:49:30 hong Exp Locker: sp $");
d89 1
d116 8
d326 1
a326 1
	local_node->jri_operator = atoi(token);
d357 1
a357 1
	local_node->jri_ruleid = atoi(token);
d459 1
a459 1
	local_node->mergesortop = atoi(token);
d605 1
a605 1
	local_node->tempid = atoi(token);
d636 1
a636 1
	local_node->tempid = atoi(token);
d648 27
d691 2
a692 2
	token = lsptok(NULL, &length);    		/* eat :tempid */
	token = lsptok(NULL, &length);    		/* get tempid */
a693 6

	token = lsptok(NULL, &length);    		/* eat :keycount */

	token = lsptok(NULL, &length);    		/* get keycount */


d724 1
a724 1
	local_node->restype = atoi(token);
d761 1
a761 1
	local_node->reskeyop = (OperatorTupleForm) atoi(token);
d814 1
a814 1
	local_node->vartype = (ObjectId) atoi(token);
d857 1
a857 1
	local_node->consttype = atoi(token);
d918 1
a918 1
	local_node->funcid = atoi(token);
d923 1
a923 1
	local_node->functype = atoi(token);
d958 1
a958 1
	local_node->opno = atoi(token);
d975 1
a975 1
	local_node->opresulttype = atoi(token);
d1003 1
a1003 1
	local_node->paramid = atoi(token);
d1017 1
a1017 1
	local_node->paramtype = atoi(token);
d1054 1
a1054 1
	local_node->es_owner = atoi(token);
d1250 1
a1250 1
	local_node->pathtype = atoi(token);
d1287 1
a1287 1
	local_node->pathtype = atoi(token);
d1304 1
a1304 1
	token = lsptok(NULL, &length);      /* now read it */
a1305 2
	local_node->indexid = lispCons(lispInteger(atoi(token)), LispNil);

d1331 1
a1331 1
	local_node->pathtype = atoi(token);
d1400 1
a1400 1
	local_node->pathtype = atoi(token);
d1477 1
a1477 1
	local_node->pathtype = atoi(token);
d1606 1
a1606 1
	local_node->join_operator = atoi(token);
d1611 1
a1611 1
	local_node->left_operator = atoi(token);
d1616 1
a1616 1
	local_node->right_operator = atoi(token);
d1621 1
a1621 1
	local_node->left_type = atoi(token);
d1626 1
a1626 1
	local_node->right_type = atoi(token);
d1675 1
a1675 1
	local_node->hashjoinoperator = atoi(token);
@


1.20
log
@added a new field to Resdom node
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.19 90/09/25 17:00:16 kemnitz Exp Locker: hong $");
d733 3
a735 1
	local_node->resjunk = 0;
@


1.19
log
@Updating from revision 1.18 to revision 1.23
@
text
@d23 1
a23 1
RcsId("$Header: RCS/readfuncs.c,v 1.23 90/08/18 00:39:42 cimarron Exp $");
d732 2
@


1.18
log
@some changes for hashjoin
@
text
@d21 1
a21 11
#include "c.h"
#include "datum.h"
#include "pg_lisp.h"
#include "nodes.h"
#include "primnodes.h"
#include "primnodes.a.h"
#include "plannodes.h"
#include "execnodes.h"
#include "execnodes.a.h"
#include "relation.h"
#include "tags.h"
d23 1
a23 6
#include "fmgr.h"
#include "heapam.h"
#include "log.h"
#include "oid.h"
#include "syscache.h"
#include "htup.h"
d25 4
d30 2
a31 1
RcsId("$Header: RCS/readfuncs.c,v 1.17 90/06/07 18:20:05 cimarron Exp Locker: hong $");
d33 11
d70 1
d107 8
d131 1
a131 1
	token = lsptok(NULL, &length);    	/* eat :qpqpal */
d301 67
d377 3
d381 4
d717 1
a717 1
		local_node->resname = (Name) palloc(sizeof(Char16Data));
d780 1
a780 1
	local_node->vartype = atoi(token);
a796 1
	/* token = lsptok(NULL, &length); */    	/* eat last ) */
d798 4
d976 1
a976 1
	local_node->paramname = (Name) palloc(sizeof(Char16Data));
d1035 1
a1035 1
	local_node->es_error_message = (Name) palloc(sizeof(Char16Data));
d1785 10
@


1.17
log
@made changes to simplify header include files
@
text
@d41 1
a41 1
RcsId("$Header: RCS/readfuncs.c,v 1.16 90/05/31 22:16:00 cimarron Exp $");
a573 1
	local_node->tempid = atoi(token);
a578 1
	local_node->keycount = atoi(token);
@


1.16
log
@made changes to support constbyval and new RMake creators.
@
text
@d38 1
a38 1
#include "tuple.h"
d41 1
a41 1
RcsId("$Header: RCS/readfuncs.c,v 1.14 90/04/30 12:23:44 sp Exp $");
@


1.15
log
@Changed the _readVar routine to deal with the new varnode entry.
@
text
@d6 1
a6 1
 *  function to use.
d8 6
a13 1
 *  All these functions assume that lsptok already has its string.
d41 1
a41 1
RcsId("$Header: RCS/readfuncs.c,v 1.14 90/04/30 12:23:44 sp Exp Locker: kemnitz $");
d47 46
d95 1
a95 3

Plan node;

d139 6
a144 1
Plan _readPlan()
d150 2
a151 1
	local_node = (Plan) palloc(sizeof(struct _Plan));
d153 1
a153 3
	local_node->printFunc = PrintPlan;
	local_node->equalFunc = EqualPlan;

d157 6
a162 3

/*
 * Does some obscene, possibly unportable, magic with sizes of things.
d164 2
a165 3

Result _readResult()

d171 2
a172 1
	local_node = (Result) palloc(sizeof(struct _Result));
a181 2
	local_node->printFunc = PrintResult;
	local_node->equalFunc = EqualResult;
d186 3
a188 1
/*
a189 1
 *
d191 4
d197 2
a198 2
Existential _readExistential()

d202 1
a202 1
	local_node = (Existential) palloc(sizeof(struct _Existential));
d204 4
d209 1
a209 4

	local_node->printFunc = PrintExistential;
	local_node->equalFunc = EqualExistential;

d213 3
a215 1
/*
d217 1
d220 2
a221 2
Append _readAppend()

d227 1
a227 1
	local_node = (Append) palloc(sizeof(struct _Append));
d233 1
a233 1
	local_node->unionplans = lispRead(true); 		/* now read it */
a243 2
	local_node->printFunc = PrintAppend;
	local_node->equalFunc = EqualAppend;
d247 4
a250 1
/*
d252 1
d254 2
a255 3

Recursive _readRecursive()

d261 1
a261 1
        local_node = (Recursive) palloc(sizeof(struct _Recursive));
d278 1
a278 1
        token = lsptok(NULL, &length);          /* eat :recurCleanupPlans */
d281 1
a281 1
        token = lsptok(NULL, &length);               /* eat :recurCheckpoints */
a286 2
        local_node->printFunc = PrintRecursive;
        local_node->equalFunc = EqualRecursive;
d290 3
a292 1
/*
d294 1
d296 3
a298 5

void _getJoin(node)

Join node;

d303 4
a306 1
/*
d308 1
d310 2
a311 3

Join _readJoin()

d315 1
a315 1
	local_node = (Join) palloc(sizeof(struct _Join));
d318 1
a318 2
	local_node->printFunc = PrintJoin;
	local_node->equalFunc = EqualJoin;
d322 3
a324 1
/*
d326 1
d329 2
a330 2
NestLoop _readNestLoop()

d334 1
a334 1
	local_node = (NestLoop) palloc(sizeof(struct _NestLoop));
d337 1
a337 2
	local_node->printFunc = PrintNestLoop;
	local_node->equalFunc = EqualNestLoop;
d341 3
a343 1
/*
d345 1
d348 2
a349 2
MergeJoin _readMergeJoin(node)

d355 1
a355 1
	local_node = (MergeJoin) palloc(sizeof(struct _MergeJoin));
d360 1
a360 1
	local_node->mergeclauses = lispRead(true);		/* now read it */
a367 3
	local_node->printFunc = PrintMergeJoin;
	local_node->equalFunc = EqualMergeJoin;
	
d371 3
a373 1
/*
d375 1
d378 2
a379 2
HashJoin _readHashJoin()

d385 1
a385 1
	local_node = (HashJoin) palloc(sizeof(struct _HashJoin));
d391 1
a391 1
	local_node->hashclauses = lispRead(true);	 	/* now read it */
a397 2
	local_node->printFunc = PrintHashJoin;
	local_node->equalFunc = EqualHashJoin;
d402 3
a404 1
/*
d408 3
d412 3
a414 9

/*
 * Scan gets its own get function since stuff inherits it.
 */

void _getScan(node)

Scan node;

d428 3
a430 1
/*
d432 1
d434 2
a435 3

Scan _readScan()

d437 1
a437 1
	Scan 		local_node;
d439 1
a439 1
	local_node = (Scan) palloc(sizeof(struct _Scan));
a441 2
	local_node->printFunc = PrintScan;
	local_node->equalFunc = EqualScan;
d446 3
a448 1
/*
d450 1
d452 2
a453 3

SeqScan _readSeqScan()

d457 1
a457 1
	local_node = (SeqScan) palloc(sizeof(struct _SeqScan));
a459 2
	local_node->printFunc = PrintSeqScan;
	local_node->equalFunc = EqualSeqScan;
d464 3
a466 1
/*
d468 1
d470 2
a471 3

IndexScan _readIndexScan()

d477 1
a477 1
	local_node = (IndexScan) palloc(sizeof(struct _IndexScan));
a480 1
	
a487 2
	local_node->printFunc = PrintIndexScan;
	local_node->equalFunc = EqualIndexScan;
d492 3
a494 1
/*
d496 1
d498 2
a499 3

Temp _readTemp()

d505 1
a505 1
	local_node = (Temp) palloc(sizeof(struct _Temp));
a519 2
	local_node->printFunc = PrintTemp;
	local_node->equalFunc = EqualTemp;
d523 3
a525 1
/*
d527 1
d529 2
a530 2
Sort _readSort()

d536 1
a536 1
	local_node = (Sort) palloc(sizeof(struct _Sort));
a549 2
	local_node->printFunc = PrintSort;
	local_node->equalFunc = EqualSort;
d554 3
a556 1
/*
d558 1
d560 2
a561 3

Hash _readHash()

d567 1
a567 1
	local_node = (Hash) palloc(sizeof(struct _Hash));
a580 2
	local_node->printFunc = PrintHash;
	local_node->equalFunc = EqualHash;
d585 1
a585 1
/*
d587 1
a587 1
*/
d589 3
a591 1
/*
d593 1
d595 2
a596 3

Resdom _readResdom()

d602 1
a602 1
	local_node = (Resdom) palloc(sizeof(struct _Resdom));
a649 2
	local_node->printFunc = PrintResdom;
	local_node->equalFunc = EqualResdom;
d654 3
a656 1
/*
d658 1
d660 2
a661 3

Expr _readExpr()

d665 1
a665 1
	local_node = (Expr) palloc(sizeof(struct _Expr));
a666 2
	local_node->printFunc = PrintExpr;
	local_node->equalFunc = EqualExpr;
d670 3
a672 1
/*
d674 1
d676 2
a677 3

Var _readVar()

d683 1
a683 1
	local_node = (Var) palloc(sizeof(struct _Var));
d707 1
a707 1
	token = lsptok(NULL, &length);    		/* eat :vararrayindex */
d715 1
a716 8
	token = lsptok(NULL, &length);			/* eat :varelemtype */

	token = lsptok(NULL, &length);    		/* get varelemtype */
	local_node->varelemtype = atoi(token);
	/* token = lsptok(NULL, &length); */    		/* eat last ) */
	local_node->printFunc = PrintVar;
	local_node->equalFunc = EqualVar;

d720 3
a722 1
/*
d724 1
d726 2
a727 3

Const _readConst()

d733 1
a733 1
	local_node = (Const) palloc(sizeof(struct _Const));
d765 13
a777 2
	local_node->printFunc = PrintConst;
	local_node->equalFunc = EqualConst;
d781 3
a783 1
/*
d785 1
d787 2
a788 3

Func _readFunc()

d794 1
a794 1
	local_node = (Func) palloc(sizeof(struct _Func));
d817 1
a817 2
	local_node->printFunc = PrintFunc;
	local_node->equalFunc = EqualFunc;
d821 3
a823 1
/*
d825 1
d827 2
a828 3

Oper _readOper()

d834 1
a834 1
	local_node = (Oper) palloc(sizeof(struct _Oper));
a857 2
	local_node->printFunc = PrintOper;
	local_node->equalFunc = EqualOper;
d861 3
a863 1
/*
d865 1
d867 2
a868 3

Param _readParam()

d874 1
a874 1
	local_node = (Param) palloc(sizeof(struct _Param));
d899 1
a899 2
	local_node->printFunc = PrintParam;
	local_node->equalFunc = EqualParam;
d907 3
a909 1
/*
d911 1
d913 2
a914 3

EState _readEState()

d920 1
a920 1
	local_node = (EState) palloc(sizeof(struct _EState));
d971 1
a971 1
	token = lsptok(NULL, &length);      /* get :relation_relation_descriptor */
d982 1
a982 2
	local_node->printFunc = PrintEState;
	local_node->equalFunc = EqualEState;
d990 6
a995 2
Rel _readRel()

d1001 1
a1001 1
	local_node = (Rel) palloc(sizeof(struct _Rel));
d1079 1
a1079 2
	local_node->printFunc = PrintRel;
	local_node->equalFunc = EqualRel;
d1083 3
a1085 40
/*
 *  TLE is a subclass of Node.
 */
/*
TLE _readTLE()

{
	TLE	local_node;
	char	*token;
	int length;

	local_node = (TLE) palloc(sizeof(struct _TLE));

	token = lsptok(NULL, &length);      

	local_node->resdom = _readResdom();

	token = lsptok(NULL, &length);     
	local_node->expr = _readExpr();
	return(local_node);
}
*/
/*
 *  TL is a subclass of Node.
 */
/*
void
_readTL(node)
	TL	node;
{
	printf("tl ");
	printf(" :entry ");
	node->entry->printFunc(node->entry);

	printf(" :joinlist ");
	lispDisplay(node->joinlist,0);
}
*/

/*
d1087 1
d1090 2
a1091 2
SortKey _readSortKey()

d1097 1
a1097 1
	local_node = (SortKey) palloc(sizeof(struct _SortKey));
a1109 2
	local_node->printFunc = PrintSortKey;
	local_node->equalFunc = EqualSortKey;
d1113 3
a1115 1
/*
d1117 1
d1119 2
a1120 3

Path _readPath()

d1126 1
a1126 1
	local_node = (Path) palloc(sizeof(struct _Path));
a1145 2
	local_node->printFunc = PrintPath;
	local_node->equalFunc = EqualPath;
d1150 3
a1152 1
/*
d1154 1
d1156 2
a1157 3

IndexPath _readIndexPath()

d1163 1
a1163 1
	local_node = (IndexPath) palloc(sizeof(struct _IndexPath));
a1190 2
	local_node->printFunc = PrintIndexPath;
	local_node->equalFunc = EqualIndexPath;
d1195 3
a1197 1
/*
d1199 1
d1201 2
a1202 3

JoinPath _readJoinPath()

d1209 1
a1209 1
	local_node = (JoinPath) palloc(sizeof(struct _JoinPath));
d1231 1
a1231 1
	local_node->pathclauseinfo = lispRead(true);           /* now read it */
a1260 2
	local_node->printFunc = PrintJoinPath;
	local_node->equalFunc = EqualJoinPath;
d1264 3
a1266 1
/*
d1268 1
d1271 2
a1272 2
MergePath _readMergePath()

d1278 1
a1278 1
	local_node = (MergePath) palloc(sizeof(struct _MergePath));
d1300 1
a1300 1
	local_node->pathclauseinfo = lispRead(true);           /* now read it */
d1331 1
a1331 1
	local_node->path_mergeclauses = lispRead(true);           /* now read it */
a1338 2
	local_node->printFunc = PrintMergePath;
	local_node->equalFunc = EqualMergePath;
d1342 3
a1344 1
/*
d1346 1
d1348 2
a1349 3

HashPath _readHashPath()

d1355 1
a1355 1
	local_node = (HashPath) palloc(sizeof(struct _HashPath));
a1414 2
	local_node->printFunc = PrintHashPath;
	local_node->equalFunc = EqualHashPath;
d1419 3
a1421 1
/*
d1423 1
d1425 2
a1426 3

OrderKey _readOrderKey()

d1432 1
a1432 1
	local_node = (OrderKey) palloc(sizeof(struct _OrderKey));
a1443 2
	local_node->printFunc = PrintOrderKey;
	local_node->equalFunc = EqualOrderKey;
d1447 3
a1449 1
/*
d1451 1
d1454 2
a1455 2
JoinKey _readJoinKey()

d1461 1
a1461 1
	local_node = (JoinKey) palloc(sizeof(struct _JoinKey));
a1468 2
	local_node->printFunc = PrintJoinKey;
	local_node->equalFunc = EqualJoinKey;
d1472 3
a1474 1
/*
d1476 1
d1478 2
a1479 3

MergeOrder _readMergeOrder()

d1485 1
a1485 1
	local_node = (MergeOrder) palloc(sizeof(struct _MergeOrder));
a1510 2
	local_node->printFunc = PrintMergeOrder;
	local_node->equalFunc = EqualMergeOrder;
d1514 3
a1516 1
/*
d1518 1
d1520 2
a1521 3

CInfo _readCInfo()

d1527 1
a1527 1
	local_node = (CInfo) palloc(sizeof(struct _CInfo));
a1559 2
	local_node->printFunc = PrintCInfo;
	local_node->equalFunc = EqualCInfo;
d1563 3
a1565 1
/*
d1567 1
d1569 2
a1570 3

JoinMethod _readJoinMethod()

d1576 1
a1576 1
	local_node = (JoinMethod) palloc(sizeof(struct _JoinMethod));
a1583 2
	local_node->printFunc = PrintJoinMethod;
	local_node->equalFunc = NULL; /* EqualJoinMethod; */
d1587 3
a1589 1
/*
d1591 1
d1593 2
a1594 3

HInfo _readHInfo()

d1600 1
a1600 1
	local_node = (HInfo) palloc(sizeof(struct _HInfo));
a1612 2
	local_node->printFunc = PrintHInfo;
	local_node->equalFunc = EqualHInfo;
d1616 3
a1618 1
/*
d1620 1
d1622 2
a1623 3

JInfo _readJInfo()

d1629 1
a1629 1
	local_node = (JInfo) palloc(sizeof(struct _JInfo));
d1658 1
a1658 2
	local_node->printFunc = PrintJInfo;
	local_node->equalFunc = EqualJInfo;
d1663 3
a1665 1
/* 
d1670 1
d1672 2
a1673 4

LispValue parsePlanString()


d1870 3
a1872 1
/*
d1875 1
d1879 1
a1879 1
ObjectId type;
d1881 8
a1888 8
    int length;
    int tokenLength;
    char *token;
    Boolean byValue;
    HeapTuple typeTuple;
    Datum res;
    char *s;
    int i;
d1901 4
a1904 3
    length	= ((ObjectId) ((TypeTupleForm)
			GETSTRUCT(typeTuple))->typlen);
    */
@


1.14
log
@minor bug fix in _readOper()
@
text
@d36 1
a36 1
RcsId("$Header: RCS/readfuncs.c,v 1.13 90/04/24 18:34:12 kemnitz Exp $");
d646 5
@


1.13
log
@Initialized MergeOrder stuff.
@
text
@d36 1
a36 1
RcsId("$Header: RCS/readfuncs.c,v 1.12 90/01/30 23:17:08 sp Exp Locker: kemnitz $");
d772 2
@


1.12
log
@all the RuleLockNode stuff has been removed
(that used to belong to the 'old' rule system)
Plus now 'parsePlanString()' understands the jamesbs
Recursive nodes...
@
text
@d36 1
a36 1
RcsId("$Header: RCS/readfuncs.c,v 1.11 90/01/30 15:40:06 jamesb Exp Locker: sp $");
d1431 1
@


1.11
log
@provided for Recursive Node
@
text
@d36 1
a36 1
RcsId("$Header: RCS/readfuncs.c,v 1.10 90/01/04 17:17:20 sp Exp Locker: jamesb $");
a1608 35
RuleLockNode _readRuleLockNode()

{
	RuleLockNode	local_node;
	char 		*token;
	int length;

	local_node = (RuleLockNode) palloc(sizeof(struct _RuleLockNode));

	token = lsptok(NULL, &length);      /* get :type */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->rltype = (LockType) atoi(token);

	token = lsptok(NULL, &length);      /* get :relation */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->rlrelation = atoi(token);
    
	token = lsptok(NULL, &length);      /* get :attribute */
	token = lsptok(NULL, &length);      /* now read it */

	local_node->rlattribute = atoi(token);
    
	token = lsptok(NULL, &length);      /* get :var */
	local_node->rlvar = (Var) lispRead(true);

	token = lsptok(NULL, &length);      /* get :plan */
	local_node->rlplan = lispRead(true); /* now read it */

	local_node->printFunc = PrintRuleLockNode;
	local_node->equalFunc = NULL; /* EqualRuleLockNode; */
	return(local_node);
}

d1801 1
a1801 1
	else if (!strncmp(token, "rulelock", 8))
d1803 2
a1804 2
		return_value = (LispValue) _readRuleLockNode();
		return_value->type = T_RuleLockNode;
@


1.10
log
@The 'Param' nodes have now a new field, called 'paramkind'.
(see comments in lib/H/primnodes.h). 
@
text
@d36 1
a36 1
RcsId("$Header: RCS/readfuncs.c,v 1.9 89/12/03 19:09:34 sp Exp Locker: sp $");
d184 42
@


1.9
log
@now readValue() reads all 4 bytes ( = sizeof(Datum) ) in case
of a type with byval = true.
@
text
@d36 1
a36 1
RcsId("$Header: RCS/readfuncs.c,v 1.8 89/10/30 16:58:38 mao Exp $");
d749 5
d761 2
a762 2
	token++;
	token[length - 2] = '\0';
d766 1
a766 1
	token[length - 2] = '\"';
@


1.8
log
@fix IndexPath reader -- indexid is a list of lispIntegers.
also add RcsId().
@
text
@d36 1
a36 1
RcsId("$Header$");
d1849 1
a1849 1
	for (i=0; i<length; i++) {
@


1.7
log
@now reads/writes NULL Const nodes correctly
@
text
@d36 2
d1088 1
a1088 1
	local_node->indexid = atoi(token);
@


1.6
log
@changes to support MergeJoins in the executor.
@
text
@d1851 3
a1853 1
    } else {
@


1.5
log
@Now _readConst() can handle pointer types (such as Name etc.)
@
text
@d231 1
a231 1
 *  MergeSort is a subclass of Join
d234 1
a234 1
MergeSort _readMergeSort(node)
d237 1
a237 1
	MergeSort	local_node;
d241 1
a241 1
	local_node = (MergeSort) palloc(sizeof(struct _MergeSort));
d254 2
a255 2
	local_node->printFunc = PrintMergeSort;
	local_node->equalFunc = EqualMergeSort;
d1642 1
a1642 1
	else if (!strncmp(token, "mergesort", 9))
d1644 2
a1645 2
		return_value = (LispValue) _readMergeSort();
		return_value->type = T_MergeSort;
@


1.4
log
@fixed complaining about mismatched types
@
text
@d28 6
d35 1
d38 1
a633 1
	token = lsptok(NULL, &length);      /* now read it */
d635 5
a639 1
	local_node->constvalue = Int32GetDatum(atoi(token));
d1798 69
@


1.3
log
@bug fix: Now _readParam is allocating space for the node.
@
text
@d60 1
a60 1
	node->qptargetlist = lispRead(true);/* now read it */
d64 1
a64 1
	node->qpqual = lispRead(true);		/* now read it */
d68 1
a68 1
	node->lefttree = lispRead(true);
d72 1
a72 1
	node->righttree = lispRead(true);
a115 1

d241 1
d272 1
d303 1
d395 1
d425 1
d456 1
d525 1
d1033 1
a1033 1
	local_node->sortpath = lispRead(true);
d1070 1
a1070 1
	local_node->sortpath = lispRead(true);
d1116 1
a1116 1
	local_node->sortpath = lispRead(true);
d1184 1
a1184 1
	local_node->sortpath = lispRead(true);
d1261 1
a1261 1
	local_node->sortpath = lispRead(true);
d1415 1
a1415 1
	local_node->clause = lispRead(true);     /* now read it */
d1438 1
a1438 1
	local_node->mergesortorder = lispRead(true); /* now read it */
d1574 1
a1574 1
	local_node->rlvar = lispRead(true); /* now read it */
@


1.2
log
@bug fix: Now the value of 'constisnull' field in _readConst is
set up properly...
@
text
@d728 2
@


1.1
log
@Initial revision
@
text
@d627 1
a627 1
	if (strncmp(token, "true", 4))
@
