1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* readfuncs.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* Reader functions for Postgres tree nodes.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2002-06-20 22:29:54 +02:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2002-07-04 17:24:11 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.124 2002/07/04 15:23:54 thomas Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
1997-09-07 07:04:48 +02:00
|
|
|
* Most of the read functions for plan nodes are tested. (In fact, they
|
|
|
|
* pass the regression test as of 11/8/94.) The rest (for path selection)
|
|
|
|
* are probably never used. No effort has been made to get them to work.
|
|
|
|
* The simplest way to test these functions is by doing the following in
|
|
|
|
* ProcessQuery (before executing the plan):
|
|
|
|
* plan = stringToNode(nodeToString(plan));
|
|
|
|
* Then, run the regression test. Let's just say you'll notice if either
|
|
|
|
* of the above function are not properly done.
|
|
|
|
* - ay 11/94
|
|
|
|
*
|
1996-07-09 08:22:35 +02:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
#include <math.h>
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "nodes/plannodes.h"
|
|
|
|
#include "nodes/readfuncs.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "nodes/relation.h"
|
2001-01-07 02:08:48 +01:00
|
|
|
|
|
|
|
|
2001-01-08 01:31:43 +01:00
|
|
|
/*
|
|
|
|
* NOTE: use atoi() to read values written with %d, or atoui() to read
|
|
|
|
* values written with %u in outfuncs.c. An exception is OID values,
|
2001-03-22 05:01:46 +01:00
|
|
|
* for which use atooid(). (As of 7.1, outfuncs.c writes OIDs as %u,
|
2001-01-08 01:31:43 +01:00
|
|
|
* but this will probably change in the future.)
|
|
|
|
*/
|
|
|
|
#define atoui(x) ((unsigned int) strtoul((x), NULL, 10))
|
|
|
|
|
|
|
|
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
|
|
|
|
|
|
|
|
#define strtobool(x) ((*(x) == 't') ? true : false)
|
|
|
|
|
|
|
|
#define nullable_string(token,length) \
|
|
|
|
((length) == 0 ? (char *) NULL : debackslash(token, length))
|
|
|
|
|
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
static Datum readDatum(bool typbyval);
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* node creator declarations
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
2001-01-08 01:31:43 +01:00
|
|
|
/* Convert Value list returned by nodeRead into list of integers */
|
1997-09-08 04:41:22 +02:00
|
|
|
static List *
|
1997-09-08 23:56:23 +02:00
|
|
|
toIntList(List *list)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
List *l;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
foreach(l, list)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
Value *v = (Value *) lfirst(l);
|
2001-01-08 01:31:43 +01:00
|
|
|
|
|
|
|
if (!IsA(v, Integer))
|
|
|
|
elog(ERROR, "toIntList: unexpected datatype");
|
|
|
|
lfirsti(l) = intVal(v);
|
|
|
|
pfree(v);
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert Value list returned by nodeRead into list of OIDs */
|
|
|
|
static List *
|
|
|
|
toOidList(List *list)
|
|
|
|
{
|
|
|
|
List *l;
|
|
|
|
|
|
|
|
foreach(l, list)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
Value *v = (Value *) lfirst(l);
|
2001-01-08 01:31:43 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a bit tricky because OID is unsigned, and so nodeRead
|
2001-03-22 05:01:46 +01:00
|
|
|
* might have concluded the value doesn't fit in an integer. Must
|
|
|
|
* cope with T_Float as well.
|
2001-01-08 01:31:43 +01:00
|
|
|
*/
|
|
|
|
if (IsA(v, Integer))
|
|
|
|
{
|
|
|
|
lfirsti(l) = (Oid) intVal(v);
|
|
|
|
pfree(v);
|
|
|
|
}
|
|
|
|
else if (IsA(v, Float))
|
|
|
|
{
|
|
|
|
lfirsti(l) = atooid(strVal(v));
|
|
|
|
pfree(strVal(v));
|
|
|
|
pfree(v);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
elog(ERROR, "toOidList: unexpected datatype");
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
return list;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readQuery
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Query *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readQuery(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Query *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1998-02-26 05:46:47 +01:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node = makeNode(Query);
|
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
token = pg_strtok(&length); /* skip :command */
|
|
|
|
token = pg_strtok(&length); /* get commandType */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->commandType = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :utility */
|
2002-03-21 17:02:16 +01:00
|
|
|
local_node->utilityStmt = nodeRead(true);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
token = pg_strtok(&length); /* skip :resultRelation */
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get the resultRelation */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->resultRelation = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :into */
|
2002-03-21 17:02:16 +01:00
|
|
|
local_node->into = nodeRead(true);
|
1998-01-06 19:53:02 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :isPortal */
|
|
|
|
token = pg_strtok(&length); /* get isPortal */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->isPortal = strtobool(token);
|
1998-02-26 05:46:47 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :isBinary */
|
|
|
|
token = pg_strtok(&length); /* get isBinary */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->isBinary = strtobool(token);
|
1998-02-26 05:46:47 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip the :hasAggs */
|
|
|
|
token = pg_strtok(&length); /* get hasAggs */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->hasAggs = strtobool(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip the :hasSubLinks */
|
|
|
|
token = pg_strtok(&length); /* get hasSubLinks */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->hasSubLinks = strtobool(token);
|
1998-01-06 19:53:02 +01:00
|
|
|
|
2002-02-26 23:47:12 +01:00
|
|
|
/* we always want originalQuery to be false in a read-in query */
|
|
|
|
local_node->originalQuery = false;
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :rtable */
|
1998-01-06 19:53:02 +01:00
|
|
|
local_node->rtable = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :jointree */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->jointree = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :rowMarks */
|
2000-09-29 20:21:41 +02:00
|
|
|
local_node->rowMarks = toIntList(nodeRead(true));
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :targetlist */
|
2000-10-05 21:11:39 +02:00
|
|
|
local_node->targetList = nodeRead(true);
|
1998-01-06 19:53:02 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :groupClause */
|
1998-01-06 19:53:02 +01:00
|
|
|
local_node->groupClause = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :havingQual */
|
1998-01-06 19:53:02 +01:00
|
|
|
local_node->havingQual = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :distinctClause */
|
2000-10-05 21:11:39 +02:00
|
|
|
local_node->distinctClause = nodeRead(true);
|
1999-05-25 18:15:34 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :sortClause */
|
2000-10-05 21:11:39 +02:00
|
|
|
local_node->sortClause = nodeRead(true);
|
Hi!
INTERSECT and EXCEPT is available for postgresql-v6.4!
The patch against v6.4 is included at the end of the current text
(in uuencoded form!)
I also included the text of my Master's Thesis. (a postscript
version). I hope that you find something of it useful and would be
happy if parts of it find their way into the PostgreSQL documentation
project (If so, tell me, then I send the sources of the document!)
The contents of the document are:
-) The first chapter might be of less interest as it gives only an
overview on SQL.
-) The second chapter gives a description on much of PostgreSQL's
features (like user defined types etc. and how to use these features)
-) The third chapter starts with an overview of PostgreSQL's internal
structure with focus on the stages a query has to pass (i.e. parser,
planner/optimizer, executor). Then a detailed description of the
implementation of the Having clause and the Intersect/Except logic is
given.
Originally I worked on v6.3.2 but never found time enough to prepare
and post a patch. Now I applied the changes to v6.4 to get Intersect
and Except working with the new version. Chapter 3 of my documentation
deals with the changes against v6.3.2, so keep that in mind when
comparing the parts of the code printed there with the patched sources
of v6.4.
Here are some remarks on the patch. There are some things that have
still to be done but at the moment I don't have time to do them
myself. (I'm doing my military service at the moment) Sorry for that
:-(
-) I used a rewrite technique for the implementation of the Except/Intersect
logic which rewrites the query to a semantically equivalent query before
it is handed to the rewrite system (for views, rules etc.), planner,
executor etc.
-) In v6.3.2 the types of the attributes of two select statements
connected by the UNION keyword had to match 100%. In v6.4 the types
only need to be familiar (i.e. int and float can be mixed). Since this
feature did not exist when I worked on Intersect/Except it
does not work correctly for Except/Intersect queries WHEN USED IN
COMBINATION WITH UNIONS! (i.e. sometimes the wrong type is used for the
resulting table. This is because until now the types of the attributes of
the first select statement have been used for the resulting table.
When Intersects and/or Excepts are used in combination with Unions it
might happen, that the first select statement of the original query
appears at another position in the query which will be executed. The reason
for this is the technique used for the implementation of
Except/Intersect which does a query rewrite!)
NOTE: It is NOT broken for pure UNION queries and pure INTERSECT/EXCEPT
queries!!!
-) I had to add the field intersect_clause to some data structures
but did not find time to implement printfuncs for the new field.
This does NOT break the debug modes but when an Except/Intersect
is used the query debug output will be the already rewritten query.
-) Massive changes to the grammar rules for SELECT and INSERT statements
have been necessary (see comments in gram.y and documentation for
deatails) in order to be able to use mixed queries like
(SELECT ... UNION (SELECT ... EXCEPT SELECT)) INTERSECT SELECT...;
-) When using UNION/EXCEPT/INTERSECT you will get:
NOTICE: equal: "Don't know if nodes of type xxx are equal".
I did not have time to add comparsion support for all the needed nodes,
but the default behaviour of the function equal met my requirements.
I did not dare to supress this message!
That's the reason why the regression test for union will fail: These
messages are also included in the union.out file!
-) Somebody of you changed the union_planner() function for v6.4
(I copied the targetlist to new_tlist and that was removed and
replaced by a cleanup of the original targetlist). These chnages
violated some having queries executed against views so I changed
it back again. I did not have time to examine the differences between the
two versions but now it works :-)
If you want to find out, try the file queries/view_having.sql on
both versions and compare the results . Two queries won't produce a
correct result with your version.
regards
Stefan
1999-01-18 01:10:17 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :limitOffset */
|
1998-10-22 15:52:24 +02:00
|
|
|
local_node->limitOffset = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :limitCount */
|
1998-10-22 15:52:24 +02:00
|
|
|
local_node->limitCount = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :setOperations */
|
2000-10-05 21:11:39 +02:00
|
|
|
local_node->setOperations = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :resultRelations */
|
2000-11-12 01:37:02 +01:00
|
|
|
local_node->resultRelations = toIntList(nodeRead(true));
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1998-01-06 19:53:02 +01:00
|
|
|
}
|
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
/* ----------------
|
|
|
|
* _readNotifyStmt
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static NotifyStmt *
|
|
|
|
_readNotifyStmt(void)
|
|
|
|
{
|
|
|
|
NotifyStmt *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(NotifyStmt);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* skip :relation */
|
|
|
|
local_node->relation = nodeRead(true);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
1998-01-06 19:53:02 +01:00
|
|
|
/* ----------------
|
1998-01-07 00:19:49 +01:00
|
|
|
* _readSortClause
|
1998-01-06 19:53:02 +01:00
|
|
|
* ----------------
|
|
|
|
*/
|
1998-01-07 00:19:49 +01:00
|
|
|
static SortClause *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readSortClause(void)
|
1998-01-06 19:53:02 +01:00
|
|
|
{
|
1998-01-07 00:19:49 +01:00
|
|
|
SortClause *local_node;
|
1998-01-06 19:53:02 +01:00
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
1998-01-07 00:19:49 +01:00
|
|
|
local_node = makeNode(SortClause);
|
1998-01-06 19:53:02 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :tleSortGroupRef */
|
|
|
|
token = pg_strtok(&length); /* get tleSortGroupRef */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->tleSortGroupRef = atoui(token);
|
1998-01-06 19:53:02 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :sortop */
|
|
|
|
token = pg_strtok(&length); /* get sortop */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->sortop = atooid(token);
|
1998-01-06 19:53:02 +01:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1998-01-07 00:19:49 +01:00
|
|
|
}
|
1998-01-06 19:53:02 +01:00
|
|
|
|
1998-01-07 00:19:49 +01:00
|
|
|
/* ----------------
|
|
|
|
* _readGroupClause
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static GroupClause *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readGroupClause(void)
|
1998-01-07 00:19:49 +01:00
|
|
|
{
|
|
|
|
GroupClause *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(GroupClause);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :tleSortGroupRef */
|
|
|
|
token = pg_strtok(&length); /* get tleSortGroupRef */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->tleSortGroupRef = atoui(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip :sortop */
|
|
|
|
token = pg_strtok(&length); /* get sortop */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->sortop = atooid(token);
|
1999-05-12 17:02:39 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-10-05 21:11:39 +02:00
|
|
|
/* ----------------
|
|
|
|
* _readSetOperationStmt
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static SetOperationStmt *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readSetOperationStmt(void)
|
2000-10-05 21:11:39 +02:00
|
|
|
{
|
|
|
|
SetOperationStmt *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(SetOperationStmt);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :op */
|
|
|
|
token = pg_strtok(&length); /* get op */
|
2000-10-05 21:11:39 +02:00
|
|
|
local_node->op = (SetOperation) atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :all */
|
|
|
|
token = pg_strtok(&length); /* get all */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->all = strtobool(token);
|
2000-10-05 21:11:39 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :larg */
|
2000-10-05 21:11:39 +02:00
|
|
|
local_node->larg = nodeRead(true); /* get larg */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :rarg */
|
2000-10-05 21:11:39 +02:00
|
|
|
local_node->rarg = nodeRead(true); /* get rarg */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :colTypes */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->colTypes = toOidList(nodeRead(true));
|
2000-10-05 21:11:39 +02:00
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _getPlan
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_getPlan(Plan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* first token is :startup_cost */
|
|
|
|
token = pg_strtok(&length); /* next is the actual cost */
|
2000-02-15 21:49:31 +01:00
|
|
|
node->startup_cost = (Cost) atof(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip the :total_cost */
|
|
|
|
token = pg_strtok(&length); /* next is the actual cost */
|
2000-02-15 21:49:31 +01:00
|
|
|
node->total_cost = (Cost) atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip the :rows */
|
|
|
|
token = pg_strtok(&length); /* get the plan_rows */
|
2000-01-09 01:26:47 +01:00
|
|
|
node->plan_rows = atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip the :width */
|
|
|
|
token = pg_strtok(&length); /* get the plan_width */
|
1997-09-07 07:04:48 +02:00
|
|
|
node->plan_width = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :qptargetlist */
|
1997-09-07 07:04:48 +02:00
|
|
|
node->targetlist = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :qpqual */
|
1997-09-07 07:04:48 +02:00
|
|
|
node->qual = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :lefttree */
|
1997-09-07 07:04:48 +02:00
|
|
|
node->lefttree = (Plan *) nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :righttree */
|
1997-09-07 07:04:48 +02:00
|
|
|
node->righttree = (Plan *) nodeRead(true);
|
|
|
|
|
2000-11-12 01:37:02 +01:00
|
|
|
node->state = (EState *) NULL; /* never read in */
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
return;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Stuff from plannodes.h
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readPlan
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Plan *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readPlan(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Plan *local_node;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Plan);
|
|
|
|
|
|
|
|
_getPlan(local_node);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readResult
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Result *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readResult(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Result *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Result);
|
|
|
|
|
|
|
|
_getPlan((Plan *) local_node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :resconstantqual */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->resconstantqual = nodeRead(true); /* now read it */
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readAppend
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Append is a subclass of Plan.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
static Append *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readAppend(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Append *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Append);
|
|
|
|
|
|
|
|
_getPlan((Plan *) local_node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :appendplans */
|
1998-07-15 16:54:39 +02:00
|
|
|
local_node->appendplans = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :isTarget */
|
|
|
|
token = pg_strtok(&length); /* get isTarget */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->isTarget = strtobool(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _getJoin
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_getJoin(Join *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-09-12 23:07:18 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
_getPlan((Plan *) node);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip the :jointype */
|
|
|
|
token = pg_strtok(&length); /* get the jointype */
|
2000-09-12 23:07:18 +02:00
|
|
|
node->jointype = (JoinType) atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip the :joinqual */
|
2000-09-12 23:07:18 +02:00
|
|
|
node->joinqual = nodeRead(true); /* get the joinqual */
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readJoin
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Join is a subclass of Plan
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Join *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readJoin(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Join *local_node;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Join);
|
|
|
|
|
|
|
|
_getJoin(local_node);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readNestLoop
|
|
|
|
*
|
|
|
|
* NestLoop is a subclass of Join
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
static NestLoop *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readNestLoop(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
NestLoop *local_node;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(NestLoop);
|
|
|
|
|
|
|
|
_getJoin((Join *) local_node);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readMergeJoin
|
|
|
|
*
|
|
|
|
* MergeJoin is a subclass of Join
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static MergeJoin *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readMergeJoin(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
MergeJoin *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(MergeJoin);
|
|
|
|
|
|
|
|
_getJoin((Join *) local_node);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :mergeclauses */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->mergeclauses = nodeRead(true); /* now read it */
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readHashJoin
|
|
|
|
*
|
|
|
|
* HashJoin is a subclass of Join.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static HashJoin *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readHashJoin(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
HashJoin *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(HashJoin);
|
|
|
|
|
|
|
|
_getJoin((Join *) local_node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :hashclauses */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->hashclauses = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :hashjoinop */
|
|
|
|
token = pg_strtok(&length); /* get hashjoinop */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->hashjoinop = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _getScan
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-09-12 23:07:18 +02:00
|
|
|
* Scan is a subclass of Plan.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Scan gets its own get function since stuff inherits it.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
static void
|
1997-09-08 23:56:23 +02:00
|
|
|
_getScan(Scan *node)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
_getPlan((Plan *) node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :scanrelid */
|
|
|
|
token = pg_strtok(&length); /* get scanrelid */
|
2001-01-08 01:31:43 +01:00
|
|
|
node->scanrelid = atoui(token);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readScan
|
|
|
|
*
|
2000-09-12 23:07:18 +02:00
|
|
|
* Scan is a subclass of Plan.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Scan *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readScan(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Scan *local_node;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Scan);
|
|
|
|
|
|
|
|
_getScan(local_node);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readSeqScan
|
|
|
|
*
|
|
|
|
* SeqScan is a subclass of Scan
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static SeqScan *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readSeqScan(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
SeqScan *local_node;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(SeqScan);
|
|
|
|
|
|
|
|
_getScan((Scan *) local_node);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readIndexScan
|
|
|
|
*
|
|
|
|
* IndexScan is a subclass of Scan
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static IndexScan *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readIndexScan(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
IndexScan *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(IndexScan);
|
|
|
|
|
|
|
|
_getScan((Scan *) local_node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :indxid */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->indxid = toOidList(nodeRead(true)); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :indxqual */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->indxqual = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :indxqualorig */
|
1999-05-25 18:15:34 +02:00
|
|
|
local_node->indxqualorig = nodeRead(true); /* now read it */
|
1998-11-22 11:48:45 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :indxorderdir */
|
|
|
|
token = pg_strtok(&length); /* get indxorderdir */
|
1999-08-09 08:20:27 +02:00
|
|
|
local_node->indxorderdir = atoi(token);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1999-11-23 21:07:06 +01:00
|
|
|
/* ----------------
|
|
|
|
* _readTidScan
|
|
|
|
*
|
|
|
|
* TidScan is a subclass of Scan
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static TidScan *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readTidScan(void)
|
1999-11-23 21:07:06 +01:00
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
TidScan *local_node;
|
1999-11-23 21:07:06 +01:00
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(TidScan);
|
|
|
|
|
|
|
|
_getScan((Scan *) local_node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :needrescan */
|
|
|
|
token = pg_strtok(&length); /* get needrescan */
|
1999-11-23 21:07:06 +01:00
|
|
|
local_node->needRescan = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :tideval */
|
2000-04-12 19:17:23 +02:00
|
|
|
local_node->tideval = nodeRead(true); /* now read it */
|
1999-11-23 21:07:06 +01:00
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
/* ----------------
|
|
|
|
* _readSubqueryScan
|
|
|
|
*
|
|
|
|
* SubqueryScan is a subclass of Scan
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static SubqueryScan *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readSubqueryScan(void)
|
2000-09-29 20:21:41 +02:00
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
SubqueryScan *local_node;
|
2000-09-29 20:21:41 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(SubqueryScan);
|
|
|
|
|
|
|
|
_getScan((Scan *) local_node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :subplan */
|
|
|
|
local_node->subplan = nodeRead(true); /* now read it */
|
2000-09-29 20:21:41 +02:00
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
2002-05-12 22:10:05 +02:00
|
|
|
/* ----------------
|
|
|
|
* _readFunctionScan
|
|
|
|
*
|
|
|
|
* FunctionScan is a subclass of Scan
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static FunctionScan *
|
|
|
|
_readFunctionScan(void)
|
|
|
|
{
|
|
|
|
FunctionScan *local_node;
|
|
|
|
|
|
|
|
local_node = makeNode(FunctionScan);
|
|
|
|
|
|
|
|
_getScan((Scan *) local_node);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readSort
|
|
|
|
*
|
2000-06-19 00:44:35 +02:00
|
|
|
* Sort is a subclass of Plan
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Sort *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readSort(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Sort *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Sort);
|
|
|
|
|
|
|
|
_getPlan((Plan *) local_node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :keycount */
|
|
|
|
token = pg_strtok(&length); /* get keycount */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->keycount = atoi(token);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-09-08 04:41:22 +02:00
|
|
|
static Agg *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readAgg(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Agg *local_node;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Agg);
|
|
|
|
_getPlan((Plan *) local_node);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readHash
|
|
|
|
*
|
2000-06-19 00:44:35 +02:00
|
|
|
* Hash is a subclass of Plan
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Hash *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readHash(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Hash *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Hash);
|
|
|
|
|
|
|
|
_getPlan((Plan *) local_node);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :hashkey */
|
2000-07-12 04:37:39 +02:00
|
|
|
local_node->hashkey = nodeRead(true);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* Stuff from primnodes.h.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readResdom
|
|
|
|
*
|
|
|
|
* Resdom is a subclass of Node
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Resdom *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readResdom(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Resdom *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Resdom);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :resno */
|
|
|
|
token = pg_strtok(&length); /* get resno */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->resno = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :restype */
|
|
|
|
token = pg_strtok(&length); /* get restype */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->restype = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :restypmod */
|
|
|
|
token = pg_strtok(&length); /* get restypmod */
|
1998-02-10 05:02:59 +01:00
|
|
|
local_node->restypmod = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :resname */
|
|
|
|
token = pg_strtok(&length); /* get the name */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->resname = nullable_string(token, length);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :reskey */
|
|
|
|
token = pg_strtok(&length); /* get reskey */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->reskey = atoui(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :reskeyop */
|
|
|
|
token = pg_strtok(&length); /* get reskeyop */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->reskeyop = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :ressortgroupref */
|
|
|
|
token = pg_strtok(&length); /* get ressortgroupref */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->ressortgroupref = atoui(token);
|
1999-05-12 17:02:39 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :resjunk */
|
|
|
|
token = pg_strtok(&length); /* get resjunk */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->resjunk = strtobool(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readExpr
|
|
|
|
*
|
|
|
|
* Expr is a subclass of Node
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Expr *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readExpr(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Expr *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Expr);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :typeOid */
|
|
|
|
token = pg_strtok(&length); /* get typeOid */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->typeOid = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :opType */
|
|
|
|
token = pg_strtok(&length); /* get opType */
|
2001-01-08 01:31:43 +01:00
|
|
|
if (strncmp(token, "op", 2) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->opType = OP_EXPR;
|
2002-07-04 17:24:11 +02:00
|
|
|
else if (strncmp(token, "distinct", 8) == 0)
|
|
|
|
local_node->opType = DISTINCT_EXPR;
|
2001-01-08 01:31:43 +01:00
|
|
|
else if (strncmp(token, "func", 4) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->opType = FUNC_EXPR;
|
2001-01-08 01:31:43 +01:00
|
|
|
else if (strncmp(token, "or", 2) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->opType = OR_EXPR;
|
2001-01-08 01:31:43 +01:00
|
|
|
else if (strncmp(token, "and", 3) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->opType = AND_EXPR;
|
2001-01-08 01:31:43 +01:00
|
|
|
else if (strncmp(token, "not", 3) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->opType = NOT_EXPR;
|
2001-01-08 01:31:43 +01:00
|
|
|
else if (strncmp(token, "subp", 4) == 0)
|
1998-02-13 04:27:47 +01:00
|
|
|
local_node->opType = SUBPLAN_EXPR;
|
2000-01-14 01:53:21 +01:00
|
|
|
else
|
2001-01-08 01:31:43 +01:00
|
|
|
elog(ERROR, "_readExpr: unknown opType \"%.*s\"", length, token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :oper */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->oper = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :args */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->args = nodeRead(true); /* now read it */
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1998-12-14 01:02:17 +01:00
|
|
|
/* ----------------
|
|
|
|
* _readCaseExpr
|
|
|
|
*
|
|
|
|
* CaseExpr is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static CaseExpr *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readCaseExpr(void)
|
1998-12-14 01:02:17 +01:00
|
|
|
{
|
|
|
|
CaseExpr *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(CaseExpr);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :casetype */
|
|
|
|
token = pg_strtok(&length); /* get casetype */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->casetype = atooid(token);
|
2000-06-16 07:27:03 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :arg */
|
2000-06-16 07:27:03 +02:00
|
|
|
local_node->arg = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :args */
|
1998-12-14 01:02:17 +01:00
|
|
|
local_node->args = nodeRead(true);
|
2000-06-16 07:27:03 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :defresult */
|
1998-12-14 01:02:17 +01:00
|
|
|
local_node->defresult = nodeRead(true);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
|
|
|
* _readCaseWhen
|
|
|
|
*
|
|
|
|
* CaseWhen is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static CaseWhen *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readCaseWhen(void)
|
1998-12-14 01:02:17 +01:00
|
|
|
{
|
|
|
|
CaseWhen *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(CaseWhen);
|
|
|
|
|
|
|
|
local_node->expr = nodeRead(true);
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :then */
|
1998-12-14 01:02:17 +01:00
|
|
|
local_node->result = nodeRead(true);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
2001-06-20 00:39:12 +02:00
|
|
|
/* ----------------
|
|
|
|
* _readNullTest
|
|
|
|
*
|
|
|
|
* NullTest is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static NullTest *
|
|
|
|
_readNullTest(void)
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
NullTest *local_node;
|
|
|
|
char *token;
|
2001-06-20 00:39:12 +02:00
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(NullTest);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :arg */
|
|
|
|
local_node->arg = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :nulltesttype */
|
|
|
|
token = pg_strtok(&length); /* get nulltesttype */
|
|
|
|
local_node->nulltesttype = (NullTestType) atoi(token);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
|
|
|
* _readBooleanTest
|
|
|
|
*
|
|
|
|
* BooleanTest is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static BooleanTest *
|
|
|
|
_readBooleanTest(void)
|
|
|
|
{
|
2001-10-25 07:50:21 +02:00
|
|
|
BooleanTest *local_node;
|
|
|
|
char *token;
|
2001-06-20 00:39:12 +02:00
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(BooleanTest);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :arg */
|
|
|
|
local_node->arg = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :booltesttype */
|
|
|
|
token = pg_strtok(&length); /* get booltesttype */
|
|
|
|
local_node->booltesttype = (BoolTestType) atoi(token);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readVar
|
|
|
|
*
|
|
|
|
* Var is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Var *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readVar(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Var *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Var);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :varno */
|
|
|
|
token = pg_strtok(&length); /* get varno */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->varno = atoui(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :varattno */
|
|
|
|
token = pg_strtok(&length); /* get varattno */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->varattno = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :vartype */
|
|
|
|
token = pg_strtok(&length); /* get vartype */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->vartype = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :vartypmod */
|
|
|
|
token = pg_strtok(&length); /* get vartypmod */
|
1998-02-10 17:04:38 +01:00
|
|
|
local_node->vartypmod = atoi(token);
|
1998-02-10 05:02:59 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :varlevelsup */
|
|
|
|
token = pg_strtok(&length); /* get varlevelsup */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->varlevelsup = atoui(token);
|
1998-01-20 23:12:17 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :varnoold */
|
|
|
|
token = pg_strtok(&length); /* get varnoold */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->varnoold = atoui(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :varoattno */
|
|
|
|
token = pg_strtok(&length); /* eat :varoattno */
|
2000-06-16 07:27:03 +02:00
|
|
|
local_node->varoattno = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
|
|
|
* _readArrayRef
|
|
|
|
*
|
|
|
|
* ArrayRef is a subclass of Expr
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static ArrayRef *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readArrayRef(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
ArrayRef *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(ArrayRef);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :refelemtype */
|
|
|
|
token = pg_strtok(&length); /* get refelemtype */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->refelemtype = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :refattrlength */
|
|
|
|
token = pg_strtok(&length); /* get refattrlength */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->refattrlength = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :refelemlength */
|
|
|
|
token = pg_strtok(&length); /* get refelemlength */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->refelemlength = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :refelembyval */
|
|
|
|
token = pg_strtok(&length); /* get refelembyval */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->refelembyval = strtobool(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :refupperindex */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->refupperindexpr = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :reflowerindex */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->reflowerindexpr = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :refexpr */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->refexpr = nodeRead(true);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :refassgnexpr */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->refassgnexpr = nodeRead(true);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readConst
|
|
|
|
*
|
|
|
|
* Const is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Const *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readConst(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Const *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Const);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :consttype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->consttype = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :constlen */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->constlen = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :constbyval */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->constbyval = strtobool(token);
|
2001-01-07 02:08:48 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :constisnull */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->constisnull = strtobool(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :constvalue */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
if (local_node->constisnull)
|
|
|
|
{
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* skip "NIL" */
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
else
|
2001-01-07 02:08:48 +01:00
|
|
|
local_node->constvalue = readDatum(local_node->constbyval);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readFunc
|
|
|
|
*
|
|
|
|
* Func is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Func *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readFunc(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Func *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Func);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :funcid */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->funcid = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-05-13 01:43:04 +02:00
|
|
|
token = pg_strtok(&length); /* get :funcresulttype */
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* now read it */
|
2002-05-13 01:43:04 +02:00
|
|
|
local_node->funcresulttype = atooid(token);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* get :funcretset */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
|
|
|
local_node->funcretset = strtobool(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-08-08 17:43:12 +02:00
|
|
|
local_node->func_fcache = NULL;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readOper
|
|
|
|
*
|
|
|
|
* Oper is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Oper *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readOper(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Oper *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Oper);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :opno */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->opno = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :opid */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->opid = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :opresulttype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->opresulttype = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-05-13 01:43:04 +02:00
|
|
|
token = pg_strtok(&length); /* get :opretset */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
|
|
|
local_node->opretset = strtobool(token);
|
|
|
|
|
2000-08-08 17:43:12 +02:00
|
|
|
local_node->op_fcache = NULL;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readParam
|
|
|
|
*
|
|
|
|
* Param is a subclass of Expr
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Param *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readParam(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Param *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Param);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :paramkind */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->paramkind = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :paramid */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->paramid = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :paramname */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->paramname = nullable_string(token, length);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :paramtype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->paramtype = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-05-12 09:17:23 +02:00
|
|
|
/* ----------------
|
1999-01-24 01:28:37 +01:00
|
|
|
* _readAggref
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1999-01-24 01:28:37 +01:00
|
|
|
* Aggref is a subclass of Node
|
1997-05-12 09:17:23 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1999-01-24 01:28:37 +01:00
|
|
|
static Aggref *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readAggref(void)
|
1997-05-12 09:17:23 +02:00
|
|
|
{
|
1999-01-24 01:28:37 +01:00
|
|
|
Aggref *local_node;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-01-24 01:28:37 +01:00
|
|
|
local_node = makeNode(Aggref);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2002-04-11 22:00:18 +02:00
|
|
|
token = pg_strtok(&length); /* eat :aggfnoid */
|
|
|
|
token = pg_strtok(&length); /* get aggfnoid */
|
|
|
|
local_node->aggfnoid = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :aggtype */
|
|
|
|
token = pg_strtok(&length); /* get aggtype */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->aggtype = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :target */
|
1998-01-06 19:53:02 +01:00
|
|
|
local_node->target = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :aggstar */
|
|
|
|
token = pg_strtok(&length); /* get aggstar */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->aggstar = strtobool(token);
|
1999-12-13 02:27:21 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :aggdistinct */
|
|
|
|
token = pg_strtok(&length); /* get aggdistinct */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->aggdistinct = strtobool(token);
|
1999-12-13 02:27:21 +01:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1997-05-12 09:17:23 +02:00
|
|
|
}
|
|
|
|
|
1998-01-17 05:53:46 +01:00
|
|
|
/* ----------------
|
|
|
|
* _readSubLink
|
|
|
|
*
|
|
|
|
* SubLink is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static SubLink *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readSubLink(void)
|
1998-01-17 05:53:46 +01:00
|
|
|
{
|
1998-02-26 05:46:47 +01:00
|
|
|
SubLink *local_node;
|
1998-01-17 05:53:46 +01:00
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(SubLink);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :subLinkType */
|
|
|
|
token = pg_strtok(&length); /* get subLinkType */
|
1998-01-17 05:53:46 +01:00
|
|
|
local_node->subLinkType = atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :useor */
|
|
|
|
token = pg_strtok(&length); /* get useor */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->useor = strtobool(token);
|
1998-01-17 05:53:46 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :lefthand */
|
1998-01-17 05:53:46 +01:00
|
|
|
local_node->lefthand = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :oper */
|
1998-02-26 05:46:47 +01:00
|
|
|
local_node->oper = nodeRead(true); /* now read it */
|
1998-01-17 05:53:46 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :subselect */
|
1998-01-17 05:53:46 +01:00
|
|
|
local_node->subselect = nodeRead(true); /* now read it */
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1998-01-17 05:53:46 +01:00
|
|
|
}
|
|
|
|
|
2000-08-08 17:43:12 +02:00
|
|
|
/* ----------------
|
|
|
|
* _readFieldSelect
|
|
|
|
*
|
|
|
|
* FieldSelect is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static FieldSelect *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readFieldSelect(void)
|
2000-08-08 17:43:12 +02:00
|
|
|
{
|
|
|
|
FieldSelect *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(FieldSelect);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :arg */
|
2000-08-08 17:43:12 +02:00
|
|
|
local_node->arg = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :fieldnum */
|
|
|
|
token = pg_strtok(&length); /* get fieldnum */
|
2000-08-08 17:43:12 +02:00
|
|
|
local_node->fieldnum = (AttrNumber) atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :resulttype */
|
|
|
|
token = pg_strtok(&length); /* get resulttype */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->resulttype = atooid(token);
|
2000-08-08 17:43:12 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :resulttypmod */
|
|
|
|
token = pg_strtok(&length); /* get resulttypmod */
|
2000-08-08 17:43:12 +02:00
|
|
|
local_node->resulttypmod = atoi(token);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
2000-02-20 22:32:16 +01:00
|
|
|
/* ----------------
|
|
|
|
* _readRelabelType
|
|
|
|
*
|
|
|
|
* RelabelType is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static RelabelType *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readRelabelType(void)
|
2000-02-20 22:32:16 +01:00
|
|
|
{
|
|
|
|
RelabelType *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(RelabelType);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :arg */
|
2000-02-20 22:32:16 +01:00
|
|
|
local_node->arg = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :resulttype */
|
|
|
|
token = pg_strtok(&length); /* get resulttype */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->resulttype = atooid(token);
|
2000-02-20 22:32:16 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :resulttypmod */
|
|
|
|
token = pg_strtok(&length); /* get resulttypmod */
|
2000-02-20 22:32:16 +01:00
|
|
|
local_node->resulttypmod = atoi(token);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
2000-09-12 23:07:18 +02:00
|
|
|
/* ----------------
|
|
|
|
* _readRangeTblRef
|
|
|
|
*
|
|
|
|
* RangeTblRef is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static RangeTblRef *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readRangeTblRef(void)
|
2000-09-12 23:07:18 +02:00
|
|
|
{
|
|
|
|
RangeTblRef *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(RangeTblRef);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get rtindex */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->rtindex = atoi(token);
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
2000-09-29 20:21:41 +02:00
|
|
|
/* ----------------
|
|
|
|
* _readFromExpr
|
|
|
|
*
|
|
|
|
* FromExpr is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static FromExpr *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readFromExpr(void)
|
2000-09-29 20:21:41 +02:00
|
|
|
{
|
|
|
|
FromExpr *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(FromExpr);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :fromlist */
|
|
|
|
local_node->fromlist = nodeRead(true); /* now read it */
|
2000-09-29 20:21:41 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :quals */
|
|
|
|
local_node->quals = nodeRead(true); /* now read it */
|
2000-09-29 20:21:41 +02:00
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
2000-09-12 23:07:18 +02:00
|
|
|
/* ----------------
|
|
|
|
* _readJoinExpr
|
|
|
|
*
|
|
|
|
* JoinExpr is a subclass of Node
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static JoinExpr *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readJoinExpr(void)
|
2000-09-12 23:07:18 +02:00
|
|
|
{
|
|
|
|
JoinExpr *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(JoinExpr);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :jointype */
|
|
|
|
token = pg_strtok(&length); /* get jointype */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->jointype = (JoinType) atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :isNatural */
|
2002-03-12 01:52:10 +01:00
|
|
|
token = pg_strtok(&length); /* get isNatural */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->isNatural = strtobool(token);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :larg */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->larg = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :rarg */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->rarg = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :using */
|
|
|
|
local_node->using = nodeRead(true); /* now read it */
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :quals */
|
|
|
|
local_node->quals = nodeRead(true); /* now read it */
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :alias */
|
|
|
|
local_node->alias = nodeRead(true); /* now read it */
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2002-03-12 01:52:10 +01:00
|
|
|
token = pg_strtok(&length); /* eat :rtindex */
|
|
|
|
token = pg_strtok(&length); /* get rtindex */
|
|
|
|
local_node->rtindex = atoi(token);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readTargetEntry
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static TargetEntry *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readTargetEntry(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
TargetEntry *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node = makeNode(TargetEntry);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :resdom */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->resdom = nodeRead(true); /* now read it */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :expr */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->expr = nodeRead(true); /* now read it */
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
static RangeVar *
|
|
|
|
_readRangeVar(void)
|
2000-02-15 04:38:29 +01:00
|
|
|
{
|
2002-03-21 17:02:16 +01:00
|
|
|
RangeVar *local_node;
|
2000-02-15 04:38:29 +01:00
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
local_node = makeNode(RangeVar);
|
2000-02-15 04:38:29 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
local_node->catalogname = NULL; /* not currently saved in output format */
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :relation */
|
|
|
|
token = pg_strtok(&length); /* get schemaname */
|
|
|
|
local_node->schemaname = nullable_string(token, length);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat "." */
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get relname */
|
2002-03-21 17:02:16 +01:00
|
|
|
local_node->relname = nullable_string(token, length);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :inhopt */
|
|
|
|
token = pg_strtok(&length); /* get inhopt */
|
|
|
|
local_node->inhOpt = (InhOption) atoi(token);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :istemp */
|
|
|
|
token = pg_strtok(&length); /* get istemp */
|
|
|
|
local_node->istemp = strtobool(token);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :alias */
|
|
|
|
local_node->alias = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ColumnRef *
|
|
|
|
_readColumnRef(void)
|
|
|
|
{
|
|
|
|
ColumnRef *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(ColumnRef);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :fields */
|
|
|
|
local_node->fields = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :indirection */
|
|
|
|
local_node->indirection = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ExprFieldSelect *
|
|
|
|
_readExprFieldSelect(void)
|
|
|
|
{
|
|
|
|
ExprFieldSelect *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(ExprFieldSelect);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :arg */
|
|
|
|
local_node->arg = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :fields */
|
|
|
|
local_node->fields = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :indirection */
|
|
|
|
local_node->indirection = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Alias *
|
|
|
|
_readAlias(void)
|
|
|
|
{
|
|
|
|
Alias *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(Alias);
|
|
|
|
|
|
|
|
token = pg_strtok(&length); /* eat :aliasname */
|
|
|
|
token = pg_strtok(&length); /* get aliasname */
|
|
|
|
local_node->aliasname = debackslash(token, length);
|
2000-02-15 04:38:29 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
token = pg_strtok(&length); /* eat :colnames */
|
|
|
|
local_node->colnames = nodeRead(true); /* now read it */
|
2000-02-15 04:38:29 +01:00
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------
|
1998-01-06 19:53:02 +01:00
|
|
|
* _readRangeTblEntry
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static RangeTblEntry *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readRangeTblEntry(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
RangeTblEntry *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node = makeNode(RangeTblEntry);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :alias */
|
|
|
|
local_node->alias = nodeRead(true); /* now read it */
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :eref */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->eref = nodeRead(true); /* now read it */
|
|
|
|
|
2002-03-22 03:56:37 +01:00
|
|
|
token = pg_strtok(&length); /* eat :rtekind */
|
|
|
|
token = pg_strtok(&length); /* get rtekind */
|
|
|
|
local_node->rtekind = (RTEKind) atoi(token);
|
|
|
|
|
|
|
|
switch (local_node->rtekind)
|
|
|
|
{
|
|
|
|
case RTE_RELATION:
|
|
|
|
case RTE_SPECIAL:
|
|
|
|
token = pg_strtok(&length); /* eat :relid */
|
|
|
|
token = pg_strtok(&length); /* get :relid */
|
|
|
|
local_node->relid = atooid(token);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RTE_SUBQUERY:
|
|
|
|
token = pg_strtok(&length); /* eat :subquery */
|
|
|
|
local_node->subquery = nodeRead(true); /* now read it */
|
|
|
|
break;
|
|
|
|
|
2002-05-12 22:10:05 +02:00
|
|
|
case RTE_FUNCTION:
|
|
|
|
token = pg_strtok(&length); /* eat :funcexpr */
|
|
|
|
local_node->funcexpr = nodeRead(true); /* now read it */
|
|
|
|
break;
|
|
|
|
|
2002-03-22 03:56:37 +01:00
|
|
|
case RTE_JOIN:
|
|
|
|
token = pg_strtok(&length); /* eat :jointype */
|
|
|
|
token = pg_strtok(&length); /* get jointype */
|
|
|
|
local_node->jointype = (JoinType) atoi(token);
|
|
|
|
|
2002-04-28 21:54:29 +02:00
|
|
|
token = pg_strtok(&length); /* eat :joinaliasvars */
|
|
|
|
local_node->joinaliasvars = nodeRead(true); /* now read it */
|
2002-03-22 03:56:37 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
elog(ERROR, "bogus rte kind %d", (int) local_node->rtekind);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :inh */
|
|
|
|
token = pg_strtok(&length); /* get :inh */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->inh = strtobool(token);
|
1998-02-21 19:17:58 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :inFromCl */
|
|
|
|
token = pg_strtok(&length); /* get :inFromCl */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->inFromCl = strtobool(token);
|
1998-02-21 19:17:58 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :checkForRead */
|
|
|
|
token = pg_strtok(&length); /* get :checkForRead */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->checkForRead = strtobool(token);
|
1999-01-21 17:08:55 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :checkForWrite */
|
|
|
|
token = pg_strtok(&length); /* get :checkForWrite */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->checkForWrite = strtobool(token);
|
1999-01-21 17:08:55 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* eat :checkAsUser */
|
|
|
|
token = pg_strtok(&length); /* get :checkAsUser */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->checkAsUser = atooid(token);
|
1999-01-21 17:08:55 +01:00
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readPath
|
|
|
|
*
|
|
|
|
* Path is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Path *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readPath(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Path *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(Path);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathtype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->pathtype = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :startup_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->startup_cost = (Cost) atof(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :total_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->total_cost = (Cost) atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathkeys */
|
1999-05-25 18:15:34 +02:00
|
|
|
local_node->pathkeys = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readIndexPath
|
|
|
|
*
|
|
|
|
* IndexPath is a subclass of Path.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static IndexPath *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readIndexPath(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
IndexPath *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(IndexPath);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathtype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->path.pathtype = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :startup_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->path.startup_cost = (Cost) atof(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :total_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->path.total_cost = (Cost) atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathkeys */
|
1999-05-25 18:15:34 +02:00
|
|
|
local_node->path.pathkeys = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-05-20 22:28:20 +02:00
|
|
|
token = pg_strtok(&length); /* get :indexinfo */
|
|
|
|
local_node->indexinfo = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :indexqual */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->indexqual = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :indexscandir */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->indexscandir = (ScanDirection) atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :joinrelids */
|
1999-08-16 04:17:58 +02:00
|
|
|
local_node->joinrelids = toIntList(nodeRead(true));
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :alljoinquals */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->alljoinquals = strtobool(token);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :rows */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-03-22 23:08:35 +01:00
|
|
|
local_node->rows = atof(token);
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1999-11-23 21:07:06 +01:00
|
|
|
/* ----------------
|
|
|
|
* _readTidPath
|
|
|
|
*
|
|
|
|
* TidPath is a subclass of Path.
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static TidPath *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readTidPath(void)
|
1999-11-23 21:07:06 +01:00
|
|
|
{
|
2000-04-12 19:17:23 +02:00
|
|
|
TidPath *local_node;
|
1999-11-23 21:07:06 +01:00
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(TidPath);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathtype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->path.pathtype = atoi(token);
|
1999-11-23 21:07:06 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :startup_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->path.startup_cost = (Cost) atof(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :total_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->path.total_cost = (Cost) atof(token);
|
1999-11-23 21:07:06 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathkeys */
|
1999-11-23 21:07:06 +01:00
|
|
|
local_node->path.pathkeys = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :tideval */
|
2000-04-12 19:17:23 +02:00
|
|
|
local_node->tideval = nodeRead(true); /* now read it */
|
1999-11-23 21:07:06 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :unjoined_relids */
|
1999-11-23 21:07:06 +01:00
|
|
|
local_node->unjoined_relids = toIntList(nodeRead(true));
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
2000-11-12 01:37:02 +01:00
|
|
|
/* ----------------
|
|
|
|
* _readAppendPath
|
|
|
|
*
|
|
|
|
* AppendPath is a subclass of Path.
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static AppendPath *
|
|
|
|
_readAppendPath(void)
|
|
|
|
{
|
|
|
|
AppendPath *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
|
|
|
|
local_node = makeNode(AppendPath);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathtype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->path.pathtype = atoi(token);
|
2000-11-12 01:37:02 +01:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :startup_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-11-12 01:37:02 +01:00
|
|
|
local_node->path.startup_cost = (Cost) atof(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :total_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-11-12 01:37:02 +01:00
|
|
|
local_node->path.total_cost = (Cost) atof(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathkeys */
|
2000-11-12 01:37:02 +01:00
|
|
|
local_node->path.pathkeys = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :subpaths */
|
2000-11-12 01:37:02 +01:00
|
|
|
local_node->subpaths = nodeRead(true); /* now read it */
|
|
|
|
|
|
|
|
return local_node;
|
|
|
|
}
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* ----------------
|
1999-02-12 07:43:53 +01:00
|
|
|
* _readNestPath
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1999-02-12 07:43:53 +01:00
|
|
|
* NestPath is a subclass of Path
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1999-02-12 07:43:53 +01:00
|
|
|
static NestPath *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readNestPath(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-02-12 07:43:53 +01:00
|
|
|
NestPath *local_node;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-02-12 07:43:53 +01:00
|
|
|
local_node = makeNode(NestPath);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathtype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->path.pathtype = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :startup_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->path.startup_cost = (Cost) atof(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :total_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->path.total_cost = (Cost) atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathkeys */
|
1999-05-25 18:15:34 +02:00
|
|
|
local_node->path.pathkeys = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :jointype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->jointype = (JoinType) atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :outerjoinpath */
|
2000-02-07 05:41:04 +01:00
|
|
|
local_node->outerjoinpath = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :innerjoinpath */
|
2000-02-07 05:41:04 +01:00
|
|
|
local_node->innerjoinpath = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :joinrestrictinfo */
|
|
|
|
local_node->joinrestrictinfo = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readMergePath
|
|
|
|
*
|
1999-02-12 07:43:53 +01:00
|
|
|
* MergePath is a subclass of NestPath.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static MergePath *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readMergePath(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
MergePath *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(MergePath);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathtype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->jpath.path.pathtype = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :startup_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->jpath.path.startup_cost = (Cost) atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :total_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->jpath.path.total_cost = (Cost) atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathkeys */
|
1999-05-25 18:15:34 +02:00
|
|
|
local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :jointype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->jpath.jointype = (JoinType) atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :outerjoinpath */
|
2000-04-12 19:17:23 +02:00
|
|
|
local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :innerjoinpath */
|
2000-04-12 19:17:23 +02:00
|
|
|
local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :joinrestrictinfo */
|
|
|
|
local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :path_mergeclauses */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->path_mergeclauses = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :outersortkeys */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->outersortkeys = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :innersortkeys */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->innersortkeys = nodeRead(true); /* now read it */
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* _readHashPath
|
|
|
|
*
|
1999-02-12 07:43:53 +01:00
|
|
|
* HashPath is a subclass of NestPath.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static HashPath *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readHashPath(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
HashPath *local_node;
|
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
local_node = makeNode(HashPath);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathtype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->jpath.path.pathtype = atoi(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :startup_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->jpath.path.startup_cost = (Cost) atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :total_cost */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-02-15 21:49:31 +01:00
|
|
|
local_node->jpath.path.total_cost = (Cost) atof(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :pathkeys */
|
1999-05-25 18:15:34 +02:00
|
|
|
local_node->jpath.path.pathkeys = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :jointype */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2000-09-12 23:07:18 +02:00
|
|
|
local_node->jpath.jointype = (JoinType) atoi(token);
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :outerjoinpath */
|
2000-04-12 19:17:23 +02:00
|
|
|
local_node->jpath.outerjoinpath = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :innerjoinpath */
|
2000-04-12 19:17:23 +02:00
|
|
|
local_node->jpath.innerjoinpath = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :joinrestrictinfo */
|
|
|
|
local_node->jpath.joinrestrictinfo = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :path_hashclauses */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->path_hashclauses = nodeRead(true); /* now read it */
|
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1999-08-16 04:17:58 +02:00
|
|
|
* _readPathKeyItem
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1999-08-16 04:17:58 +02:00
|
|
|
* PathKeyItem is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1999-08-16 04:17:58 +02:00
|
|
|
static PathKeyItem *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readPathKeyItem(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-08-16 04:17:58 +02:00
|
|
|
PathKeyItem *local_node;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-08-16 04:17:58 +02:00
|
|
|
local_node = makeNode(PathKeyItem);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :sortop */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->sortop = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :key */
|
1999-08-16 04:17:58 +02:00
|
|
|
local_node->key = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1999-02-03 21:15:53 +01:00
|
|
|
* _readRestrictInfo
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1999-02-03 21:15:53 +01:00
|
|
|
* RestrictInfo is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1999-02-03 21:15:53 +01:00
|
|
|
static RestrictInfo *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readRestrictInfo(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-02-03 21:15:53 +01:00
|
|
|
RestrictInfo *local_node;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1999-02-03 21:15:53 +01:00
|
|
|
local_node = makeNode(RestrictInfo);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :clause */
|
1997-09-07 07:04:48 +02:00
|
|
|
local_node->clause = nodeRead(true); /* now read it */
|
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :ispusheddown */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->ispusheddown = strtobool(token);
|
2000-09-12 23:07:18 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :subclauseindices */
|
1999-08-16 04:17:58 +02:00
|
|
|
local_node->subclauseindices = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :mergejoinoperator */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->mergejoinoperator = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :left_sortop */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->left_sortop = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :right_sortop */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->right_sortop = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :hashjoinoperator */
|
|
|
|
token = pg_strtok(&length); /* now read it */
|
2001-01-08 01:31:43 +01:00
|
|
|
local_node->hashjoinoperator = atooid(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-12-13 00:33:34 +01:00
|
|
|
/* eval_cost is not part of saved representation; compute on first use */
|
|
|
|
local_node->eval_cost = -1;
|
2001-06-05 07:26:05 +02:00
|
|
|
/* ditto for this_selec */
|
|
|
|
local_node->this_selec = -1;
|
2002-03-01 07:01:20 +01:00
|
|
|
/* ditto for cached pathkeys, selectivity, bucketsize */
|
2000-12-14 23:30:45 +01:00
|
|
|
local_node->left_pathkey = NIL;
|
|
|
|
local_node->right_pathkey = NIL;
|
2002-03-01 07:01:20 +01:00
|
|
|
local_node->left_mergescansel = -1;
|
|
|
|
local_node->right_mergescansel = -1;
|
2001-05-07 02:43:27 +02:00
|
|
|
local_node->left_bucketsize = -1;
|
|
|
|
local_node->right_bucketsize = -1;
|
2000-12-13 00:33:34 +01:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------
|
1998-09-01 05:29:17 +02:00
|
|
|
* _readJoinInfo()
|
1997-09-07 07:04:48 +02:00
|
|
|
*
|
1998-09-01 05:29:17 +02:00
|
|
|
* JoinInfo is a subclass of Node.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1998-09-01 05:29:17 +02:00
|
|
|
static JoinInfo *
|
2000-10-23 00:15:13 +02:00
|
|
|
_readJoinInfo(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
JoinInfo *local_node;
|
1997-09-08 04:41:22 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
local_node = makeNode(JoinInfo);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :unjoined_relids */
|
1999-05-25 18:15:34 +02:00
|
|
|
local_node->unjoined_relids = toIntList(nodeRead(true)); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-03-22 05:01:46 +01:00
|
|
|
token = pg_strtok(&length); /* get :jinfo_restrictinfo */
|
1999-05-25 18:15:34 +02:00
|
|
|
local_node->jinfo_restrictinfo = nodeRead(true); /* now read it */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return local_node;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* parsePlanString
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* Given a character string containing a plan, parsePlanString sets up the
|
|
|
|
* plan structure representing that plan.
|
|
|
|
*
|
2001-01-07 02:08:48 +01:00
|
|
|
* The string to be read must already have been loaded into pg_strtok().
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1998-02-26 05:46:47 +01:00
|
|
|
Node *
|
1996-11-10 04:06:38 +01:00
|
|
|
parsePlanString(void)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
char *token;
|
|
|
|
int length;
|
|
|
|
void *return_value = NULL;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-01-07 02:08:48 +01:00
|
|
|
token = pg_strtok(&length);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-01-14 01:53:21 +01:00
|
|
|
if (length == 4 && strncmp(token, "PLAN", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readPlan();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 6 && strncmp(token, "RESULT", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readResult();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 6 && strncmp(token, "APPEND", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readAppend();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "JOIN", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readJoin();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 8 && strncmp(token, "NESTLOOP", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readNestLoop();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 9 && strncmp(token, "MERGEJOIN", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readMergeJoin();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 8 && strncmp(token, "HASHJOIN", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readHashJoin();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "SCAN", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readScan();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 7 && strncmp(token, "SEQSCAN", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readSeqScan();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 9 && strncmp(token, "INDEXSCAN", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readIndexScan();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 7 && strncmp(token, "TIDSCAN", length) == 0)
|
1999-11-23 21:07:06 +01:00
|
|
|
return_value = _readTidScan();
|
2000-09-29 20:21:41 +02:00
|
|
|
else if (length == 12 && strncmp(token, "SUBQUERYSCAN", length) == 0)
|
|
|
|
return_value = _readSubqueryScan();
|
2002-05-12 22:10:05 +02:00
|
|
|
else if (length == 12 && strncmp(token, "FUNCTIONSCAN", length) == 0)
|
|
|
|
return_value = _readFunctionScan();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "SORT", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readSort();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 6 && strncmp(token, "AGGREG", length) == 0)
|
1999-01-24 01:28:37 +01:00
|
|
|
return_value = _readAggref();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 7 && strncmp(token, "SUBLINK", length) == 0)
|
1998-01-17 05:53:46 +01:00
|
|
|
return_value = _readSubLink();
|
2000-08-08 17:43:12 +02:00
|
|
|
else if (length == 11 && strncmp(token, "FIELDSELECT", length) == 0)
|
|
|
|
return_value = _readFieldSelect();
|
2000-02-20 22:32:16 +01:00
|
|
|
else if (length == 11 && strncmp(token, "RELABELTYPE", length) == 0)
|
|
|
|
return_value = _readRelabelType();
|
2000-09-12 23:07:18 +02:00
|
|
|
else if (length == 11 && strncmp(token, "RANGETBLREF", length) == 0)
|
|
|
|
return_value = _readRangeTblRef();
|
2000-09-29 20:21:41 +02:00
|
|
|
else if (length == 8 && strncmp(token, "FROMEXPR", length) == 0)
|
|
|
|
return_value = _readFromExpr();
|
2000-09-12 23:07:18 +02:00
|
|
|
else if (length == 8 && strncmp(token, "JOINEXPR", length) == 0)
|
|
|
|
return_value = _readJoinExpr();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 3 && strncmp(token, "AGG", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readAgg();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "HASH", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readHash();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 6 && strncmp(token, "RESDOM", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readResdom();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "EXPR", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readExpr();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 8 && strncmp(token, "ARRAYREF", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readArrayRef();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 3 && strncmp(token, "VAR", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readVar();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 5 && strncmp(token, "CONST", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readConst();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "FUNC", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readFunc();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "OPER", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readOper();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 5 && strncmp(token, "PARAM", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readParam();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 11 && strncmp(token, "TARGETENTRY", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readTargetEntry();
|
2002-03-21 17:02:16 +01:00
|
|
|
else if (length == 8 && strncmp(token, "RANGEVAR", length) == 0)
|
|
|
|
return_value = _readRangeVar();
|
|
|
|
else if (length == 9 && strncmp(token, "COLUMNREF", length) == 0)
|
|
|
|
return_value = _readColumnRef();
|
|
|
|
else if (length == 15 && strncmp(token, "EXPRFIELDSELECT", length) == 0)
|
|
|
|
return_value = _readExprFieldSelect();
|
|
|
|
else if (length == 5 && strncmp(token, "ALIAS", length) == 0)
|
|
|
|
return_value = _readAlias();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 3 && strncmp(token, "RTE", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readRangeTblEntry();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "PATH", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readPath();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 9 && strncmp(token, "INDEXPATH", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readIndexPath();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 7 && strncmp(token, "TIDPATH", length) == 0)
|
1999-11-23 21:07:06 +01:00
|
|
|
return_value = _readTidPath();
|
2000-11-12 01:37:02 +01:00
|
|
|
else if (length == 10 && strncmp(token, "APPENDPATH", length) == 0)
|
|
|
|
return_value = _readAppendPath();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 8 && strncmp(token, "NESTPATH", length) == 0)
|
1999-02-12 07:43:53 +01:00
|
|
|
return_value = _readNestPath();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 9 && strncmp(token, "MERGEPATH", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readMergePath();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 8 && strncmp(token, "HASHPATH", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readHashPath();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 11 && strncmp(token, "PATHKEYITEM", length) == 0)
|
1999-08-16 04:17:58 +02:00
|
|
|
return_value = _readPathKeyItem();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 12 && strncmp(token, "RESTRICTINFO", length) == 0)
|
1999-02-03 21:15:53 +01:00
|
|
|
return_value = _readRestrictInfo();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 8 && strncmp(token, "JOININFO", length) == 0)
|
1998-09-01 05:29:17 +02:00
|
|
|
return_value = _readJoinInfo();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 5 && strncmp(token, "QUERY", length) == 0)
|
1997-09-07 07:04:48 +02:00
|
|
|
return_value = _readQuery();
|
2002-03-21 17:02:16 +01:00
|
|
|
else if (length == 6 && strncmp(token, "NOTIFY", length) == 0)
|
|
|
|
return_value = _readNotifyStmt();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 10 && strncmp(token, "SORTCLAUSE", length) == 0)
|
1998-01-07 00:19:49 +01:00
|
|
|
return_value = _readSortClause();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 11 && strncmp(token, "GROUPCLAUSE", length) == 0)
|
1998-01-07 00:19:49 +01:00
|
|
|
return_value = _readGroupClause();
|
2000-10-05 21:11:39 +02:00
|
|
|
else if (length == 16 && strncmp(token, "SETOPERATIONSTMT", length) == 0)
|
|
|
|
return_value = _readSetOperationStmt();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "CASE", length) == 0)
|
1998-12-14 01:02:17 +01:00
|
|
|
return_value = _readCaseExpr();
|
2000-01-14 01:53:21 +01:00
|
|
|
else if (length == 4 && strncmp(token, "WHEN", length) == 0)
|
1998-12-14 01:02:17 +01:00
|
|
|
return_value = _readCaseWhen();
|
2001-06-20 00:39:12 +02:00
|
|
|
else if (length == 8 && strncmp(token, "NULLTEST", length) == 0)
|
|
|
|
return_value = _readNullTest();
|
|
|
|
else if (length == 11 && strncmp(token, "BOOLEANTEST", length) == 0)
|
|
|
|
return_value = _readBooleanTest();
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
2000-09-29 20:21:41 +02:00
|
|
|
elog(ERROR, "badly formatted planstring \"%.10s\"...", token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return (Node *) return_value;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* readDatum
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2001-01-07 02:08:48 +01:00
|
|
|
* Given a string representation of a constant, recreate the appropriate
|
|
|
|
* Datum. The string representation embeds length info, but not byValue,
|
|
|
|
* so we must be told that.
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
static Datum
|
2001-01-07 02:08:48 +01:00
|
|
|
readDatum(bool typbyval)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2001-01-08 01:31:43 +01:00
|
|
|
Size length,
|
|
|
|
i;
|
1997-09-08 04:41:22 +02:00
|
|
|
int tokenLength;
|
|
|
|
char *token;
|
|
|
|
Datum res;
|
|
|
|
char *s;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* read the actual length of the value
|
|
|
|
*/
|
2001-01-07 02:08:48 +01:00
|
|
|
token = pg_strtok(&tokenLength);
|
2001-01-08 01:31:43 +01:00
|
|
|
length = atoui(token);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-07-03 18:52:48 +02:00
|
|
|
token = pg_strtok(&tokenLength); /* read the '[' */
|
|
|
|
if (token == NULL || token[0] != '[')
|
|
|
|
elog(ERROR, "readDatum: expected '%s', got '%s'; length = %lu",
|
|
|
|
"[", token ? (const char *) token : "[NULL]",
|
|
|
|
(unsigned long) length);
|
2001-01-07 02:08:48 +01:00
|
|
|
|
|
|
|
if (typbyval)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2001-01-08 01:31:43 +01:00
|
|
|
if (length > (Size) sizeof(Datum))
|
2001-02-12 22:03:03 +01:00
|
|
|
elog(ERROR, "readDatum: byval & length = %lu",
|
|
|
|
(unsigned long) length);
|
2000-01-14 01:53:21 +01:00
|
|
|
res = (Datum) 0;
|
1997-09-07 07:04:48 +02:00
|
|
|
s = (char *) (&res);
|
2001-01-08 01:31:43 +01:00
|
|
|
for (i = 0; i < (Size) sizeof(Datum); i++)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2001-01-07 02:08:48 +01:00
|
|
|
token = pg_strtok(&tokenLength);
|
1997-09-07 07:04:48 +02:00
|
|
|
s[i] = (char) atoi(token);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (length <= 0)
|
2000-01-14 01:53:21 +01:00
|
|
|
res = (Datum) NULL;
|
|
|
|
else
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
|
|
|
s = (char *) palloc(length);
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
{
|
2001-01-07 02:08:48 +01:00
|
|
|
token = pg_strtok(&tokenLength);
|
1997-09-07 07:04:48 +02:00
|
|
|
s[i] = (char) atoi(token);
|
|
|
|
}
|
|
|
|
res = PointerGetDatum(s);
|
|
|
|
}
|
|
|
|
|
2001-07-03 18:52:48 +02:00
|
|
|
token = pg_strtok(&tokenLength); /* read the ']' */
|
2001-01-07 02:08:48 +01:00
|
|
|
if (token == NULL || token[0] != ']')
|
2001-07-03 18:52:48 +02:00
|
|
|
elog(ERROR, "readDatum: expected '%s', got '%s'; length = %lu",
|
|
|
|
"]", token ? (const char *) token : "[NULL]",
|
2001-02-12 22:03:03 +01:00
|
|
|
(unsigned long) length);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return res;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|