postgresql/src/include/nodes/parsenodes.h

975 lines
24 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* parsenodes.h
* definitions for parse tree nodes
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.76 1999/07/15 23:03:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PARSENODES_H
#define PARSENODES_H
#include "nodes/primnodes.h"
/*****************************************************************************
* Query Tree
*****************************************************************************/
/*
* Query -
* all statments are turned into a Query tree (via transformStmt)
* for further processing by the optimizer
* utility statements (i.e. non-optimizable statements)
* have the *utilityStmt field set.
*
* we need the isPortal flag because portal names can be null too; can
* get rid of it if we support CURSOR as a commandType.
*
*/
typedef struct Query
{
NodeTag type;
CmdType commandType; /* select|insert|update|delete|utility */
Node *utilityStmt; /* non-null if this is a non-optimizable
* statement */
int resultRelation; /* target relation (index to rtable) */
char *into; /* portal (cursor) name */
bool isPortal; /* is this a retrieve into portal? */
bool isBinary; /* binary portal? */
bool isTemp; /* is 'into' a temp table? */
bool unionall; /* union without unique sort */
bool hasAggs; /* has aggregates in target list */
bool hasSubLinks; /* has subquery SubLink */
char *uniqueFlag; /* NULL, '*', or Unique attribute name */
List *sortClause; /* a list of SortClause's */
List *rtable; /* list of range table entries */
List *targetList; /* target list (of TargetEntry) */
Node *qual; /* qualifications */
1999-01-21 17:08:55 +01:00
List *rowMark; /* list of RowMark entries */
List *groupClause; /* list of columns to specified in GROUP
* BY */
Node *havingQual; /* qualification of each group */
1999-05-25 18:15:34 +02:00
List *intersectClause;
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
List *unionClause; /* unions are linked under the previous
* query */
1998-10-22 15:52:24 +02:00
Node *limitOffset; /* # of result tuples to skip */
Node *limitCount; /* # of result tuples to return */
1997-12-24 07:06:58 +01:00
/* internal to planner */
List *base_rel_list; /* base relation list */
List *join_rel_list; /* list of relation involved in joins */
} Query;
/*****************************************************************************
* Other Statements (no optimizations required)
*
* Some of them require a little bit of transformation (which is also
* done by transformStmt). The whole structure is then passed on to
* ProcessUtility (by-passing the optimization step) as the utilityStmt
* field in Query.
*****************************************************************************/
/* ----------------------
* Add Column Statement
* ----------------------
*/
typedef struct AddAttrStmt
{
NodeTag type;
char *relname; /* the relation to add attr */
bool inh; /* add recursively to children? */
Node *colDef; /* the attribute definition */
1997-09-08 22:59:27 +02:00
} AddAttrStmt;
/* ----------------------
* Change ACL Statement
* ----------------------
*/
typedef struct ChangeACLStmt
{
NodeTag type;
struct AclItem *aclitem;
unsigned modechg;
List *relNames;
} ChangeACLStmt;
/* ----------------------
* Close Portal Statement
* ----------------------
*/
typedef struct ClosePortalStmt
{
NodeTag type;
char *portalname; /* name of the portal (cursor) */
} ClosePortalStmt;
/* ----------------------
* Copy Statement
* ----------------------
*/
typedef struct CopyStmt
{
NodeTag type;
bool binary; /* is a binary copy? */
char *relname; /* the relation to copy */
bool oids; /* copy oid's? */
int direction; /* TO or FROM */
char *filename; /* if NULL, use stdin/stdout */
char *delimiter; /* delimiter character, \t by default */
} CopyStmt;
/* ----------------------
* Create Table Statement
* ----------------------
*/
typedef struct CreateStmt
{
NodeTag type;
bool istemp; /* is this a temp table? */
char *relname; /* the relation to create */
List *tableElts; /* column definitions list of Column */
List *inhRelnames; /* relations to inherit from list of Value
* (string) */
List *constraints; /* list of constraints (ConstaintDef) */
} CreateStmt;
typedef enum ConstrType /* type of constaints */
{
CONSTR_NULL, CONSTR_NOTNULL, CONSTR_DEFAULT, CONSTR_CHECK, CONSTR_PRIMARY, CONSTR_UNIQUE
} ConstrType;
typedef struct Constraint
{
NodeTag type;
ConstrType contype;
char *name; /* name */
void *def; /* definition */
void *keys; /* list of primary keys */
} Constraint;
1997-08-31 13:43:09 +02:00
/* ----------------------
* Create/Drop TRIGGER Statements
1997-08-31 13:43:09 +02:00
* ----------------------
*/
typedef struct CreateTrigStmt
{
NodeTag type;
char *trigname; /* TRIGGER' name */
char *relname; /* triggered relation */
char *funcname; /* function to call (or NULL) */
List *args; /* list of (T_String) Values or NULL */
bool before; /* BEFORE/AFTER */
bool row; /* ROW/STATEMENT */
char actions[4]; /* Insert, Update, Delete */
char *lang; /* NULL (which means Clanguage) */
char *text; /* AS 'text' */
List *attr; /* UPDATE OF a, b,... (NI) or NULL */
char *when; /* WHEN 'a > 10 ...' (NI) or NULL */
} CreateTrigStmt;
1997-08-31 13:43:09 +02:00
typedef struct DropTrigStmt
{
NodeTag type;
char *trigname; /* TRIGGER' name */
char *relname; /* triggered relation */
} DropTrigStmt;
/* ----------------------
* Create/Drop PROCEDURAL LANGUAGE Statement
* ----------------------
*/
typedef struct CreatePLangStmt
{
NodeTag type;
char *plname; /* PL name */
char *plhandler; /* PL call handler function */
char *plcompiler; /* lancompiler text */
bool pltrusted; /* PL is trusted */
} CreatePLangStmt;
typedef struct DropPLangStmt
{
NodeTag type;
char *plname; /* PL name */
} DropPLangStmt;
1997-08-31 13:43:09 +02:00
/* ----------------------
* Create/Alter/Drop User Statements
* ----------------------
*/
typedef struct CreateUserStmt
{
NodeTag type;
char *user; /* PostgreSQL user login */
char *password; /* PostgreSQL user password */
bool *createdb; /* Can the user create databases? */
bool *createuser; /* Can this user create users? */
List *groupElts; /* The groups the user is a member of */
char *validUntil; /* The time the login is valid until */
} CreateUserStmt;
typedef CreateUserStmt AlterUserStmt;
typedef struct DropUserStmt
{
NodeTag type;
char *user; /* PostgreSQL user login */
} DropUserStmt;
1997-04-02 05:34:46 +02:00
/* ----------------------
* Create SEQUENCE Statement
1997-04-02 05:34:46 +02:00
* ----------------------
*/
typedef struct CreateSeqStmt
{
NodeTag type;
char *seqname; /* the relation to create */
List *options;
} CreateSeqStmt;
1997-04-02 05:34:46 +02:00
/* ----------------------
* Create Version Statement
* ----------------------
*/
typedef struct VersionStmt
{
NodeTag type;
char *relname; /* the new relation */
int direction; /* FORWARD | BACKWARD */
char *fromRelname; /* relation to create a version */
char *date; /* date of the snapshot */
} VersionStmt;
/* ----------------------
* Create {Operator|Type|Aggregate} Statement
* ----------------------
*/
typedef struct DefineStmt
{
NodeTag type;
int defType; /* OPERATOR|P_TYPE|AGGREGATE */
char *defname;
List *definition; /* a list of DefElem */
} DefineStmt;
/* ----------------------
* Drop Table Statement
* ----------------------
*/
typedef struct DestroyStmt
{
NodeTag type;
List *relNames; /* relations to be dropped */
bool sequence;
} DestroyStmt;
/* ----------------------
* Extend Index Statement
* ----------------------
*/
typedef struct ExtendStmt
{
NodeTag type;
char *idxname; /* name of the index */
Node *whereClause; /* qualifications */
List *rangetable; /* range table, filled in by
* transformStmt() */
} ExtendStmt;
/* ----------------------
* Begin Recipe Statement
* ----------------------
*/
typedef struct RecipeStmt
{
NodeTag type;
char *recipeName; /* name of the recipe */
} RecipeStmt;
/* ----------------------
* Fetch Statement
* ----------------------
*/
typedef struct FetchStmt
{
NodeTag type;
int direction; /* FORWARD or BACKWARD */
int howMany; /* amount to fetch ("ALL" --> 0) */
char *portalname; /* name of portal (cursor) */
bool ismove; /* TRUE if MOVE */
} FetchStmt;
/* ----------------------
* Create Index Statement
* ----------------------
*/
typedef struct IndexStmt
{
NodeTag type;
char *idxname; /* name of the index */
char *relname; /* name of relation to index on */
char *accessMethod; /* name of acess methood (eg. btree) */
List *indexParams; /* a list of IndexElem */
List *withClause; /* a list of ParamString */
Node *whereClause; /* qualifications */
List *rangetable; /* range table, filled in by
* transformStmt() */
bool *lossy; /* is index lossy? */
bool unique; /* is index unique? */
bool primary; /* is index on primary key? */
} IndexStmt;
/* ----------------------
* Create Function Statement
* ----------------------
*/
typedef struct ProcedureStmt
{
NodeTag type;
char *funcname; /* name of function to create */
List *defArgs; /* list of definitions a list of strings
* (as Value *) */
Node *returnType; /* the return type (as a string or a
* TypeName (ie.setof) */
List *withClause; /* a list of ParamString */
char *as; /* the SQL statement or filename */
char *language; /* C or SQL */
} ProcedureStmt;
/* ----------------------
* Drop Aggregate Statement
* ----------------------
*/
typedef struct RemoveAggrStmt
{
NodeTag type;
char *aggname; /* aggregate to drop */
char *aggtype; /* for this type */
} RemoveAggrStmt;
/* ----------------------
* Drop Function Statement
* ----------------------
*/
typedef struct RemoveFuncStmt
{
NodeTag type;
char *funcname; /* function to drop */
List *args; /* types of the arguments */
} RemoveFuncStmt;
/* ----------------------
* Drop Operator Statement
* ----------------------
*/
typedef struct RemoveOperStmt
{
NodeTag type;
char *opname; /* operator to drop */
List *args; /* types of the arguments */
} RemoveOperStmt;
/* ----------------------
* Drop {Type|Index|Rule|View} Statement
* ----------------------
*/
typedef struct RemoveStmt
{
NodeTag type;
int removeType; /* P_TYPE|INDEX|RULE|VIEW */
char *name; /* name to drop */
} RemoveStmt;
/* ----------------------
* Alter Table Statement
* ----------------------
*/
typedef struct RenameStmt
{
NodeTag type;
char *relname; /* relation to be altered */
bool inh; /* recursively alter children? */
char *column; /* if NULL, rename the relation name to
* the new name. Otherwise, rename this
* column name. */
char *newname; /* the new name */
} RenameStmt;
/* ----------------------
* Create Rule Statement
* ----------------------
*/
typedef struct RuleStmt
{
NodeTag type;
char *rulename; /* name of the rule */
Node *whereClause; /* qualifications */
CmdType event; /* RETRIEVE */
struct Attr *object; /* object affected */
bool instead; /* is a 'do instead'? */
List *actions; /* the action statements */
} RuleStmt;
/* ----------------------
* Notify Statement
* ----------------------
*/
typedef struct NotifyStmt
{
NodeTag type;
char *relname; /* relation to notify */
} NotifyStmt;
/* ----------------------
* Listen Statement
* ----------------------
*/
typedef struct ListenStmt
{
NodeTag type;
char *relname; /* relation to listen on */
} ListenStmt;
/* ----------------------
* Unlisten Statement
* ----------------------
*/
typedef struct UnlistenStmt
{
NodeTag type;
char *relname; /* relation to unlisten on */
1999-05-26 00:43:53 +02:00
} UnlistenStmt;
/* ----------------------
* {Begin|Abort|End} Transaction Statement
* ----------------------
*/
typedef struct TransactionStmt
{
NodeTag type;
int command; /* BEGIN|END|ABORT */
} TransactionStmt;
/* ----------------------
* Create View Statement
* ----------------------
*/
typedef struct ViewStmt
{
NodeTag type;
char *viewname; /* name of the view */
Query *query; /* the SQL statement */
} ViewStmt;
/* ----------------------
* Load Statement
* ----------------------
*/
typedef struct LoadStmt
{
NodeTag type;
char *filename; /* file to load */
} LoadStmt;
/* ----------------------
* Createdb Statement
* ----------------------
*/
typedef struct CreatedbStmt
{
NodeTag type;
char *dbname; /* database to create */
1997-11-07 07:38:51 +01:00
char *dbpath; /* location of database */
int encoding; /* default encoding (see regex/pg_wchar.h) */
} CreatedbStmt;
/* ----------------------
* Destroydb Statement
* ----------------------
*/
typedef struct DestroydbStmt
{
NodeTag type;
char *dbname; /* database to drop */
} DestroydbStmt;
/* ----------------------
* Cluster Statement (support pbrown's cluster index implementation)
* ----------------------
*/
typedef struct ClusterStmt
{
NodeTag type;
char *relname; /* relation being indexed */
char *indexname; /* original index defined */
} ClusterStmt;
/* ----------------------
* Vacuum Statement
* ----------------------
*/
typedef struct VacuumStmt
{
NodeTag type;
bool verbose; /* print status info */
bool analyze; /* analyze data */
char *vacrel; /* table to vacuum */
List *va_spec; /* columns to analyse */
} VacuumStmt;
/* ----------------------
* Explain Statement
* ----------------------
*/
typedef struct ExplainStmt
{
NodeTag type;
Query *query; /* the query */
bool verbose; /* print plan info */
} ExplainStmt;
/* ----------------------
* Set Statement
* ----------------------
*/
typedef struct VariableSetStmt
{
NodeTag type;
char *name;
char *value;
} VariableSetStmt;
/* ----------------------
* Show Statement
* ----------------------
*/
typedef struct VariableShowStmt
{
NodeTag type;
char *name;
} VariableShowStmt;
/* ----------------------
* Reset Statement
* ----------------------
*/
typedef struct VariableResetStmt
{
NodeTag type;
char *name;
} VariableResetStmt;
/* ----------------------
* LOCK Statement
* ----------------------
*/
typedef struct LockStmt
{
NodeTag type;
char *relname; /* relation to lock */
int mode; /* lock mode */
1999-05-26 00:43:53 +02:00
} LockStmt;
/*****************************************************************************
* Optimizable Statements
*****************************************************************************/
/* ----------------------
* Insert Statement
* ----------------------
*/
1998-01-09 21:06:08 +01:00
typedef struct InsertStmt
{
NodeTag type;
char *relname; /* relation to insert into */
1998-01-11 04:41:57 +01:00
char *unique; /* NULL, '*', or unique attribute name */
List *cols; /* names of the columns */
List *targetList; /* the target list (of ResTarget) */
List *fromClause; /* the from clause */
Node *whereClause; /* qualifications */
1998-01-11 04:41:57 +01:00
List *groupClause; /* group by clause */
Node *havingClause; /* having conditional-expression */
List *unionClause; /* union subselect parameters */
1999-01-21 17:08:55 +01:00
bool unionall; /* union without unique sort */
1999-05-25 18:15:34 +02:00
List *intersectClause;
1999-01-21 17:08:55 +01:00
List *forUpdate; /* FOR UPDATE clause */
1998-01-09 21:06:08 +01:00
} InsertStmt;
/* ----------------------
* Delete Statement
* ----------------------
*/
typedef struct DeleteStmt
{
NodeTag type;
char *relname; /* relation to delete from */
Node *whereClause; /* qualifications */
} DeleteStmt;
/* ----------------------
* Update Statement
* ----------------------
*/
1998-01-09 21:06:08 +01:00
typedef struct UpdateStmt
{
NodeTag type;
char *relname; /* relation to update */
List *targetList; /* the target list (of ResTarget) */
Node *whereClause; /* qualifications */
List *fromClause; /* the from clause */
1998-01-09 21:06:08 +01:00
} UpdateStmt;
/* ----------------------
* Select Statement
* ----------------------
*/
1998-01-09 21:06:08 +01:00
typedef struct SelectStmt
{
NodeTag type;
char *unique; /* NULL, '*', or unique attribute name */
char *into; /* name of table (for select into table) */
List *targetList; /* the target list (of ResTarget) */
List *fromClause; /* the from clause */
Node *whereClause; /* qualifications */
List *groupClause; /* group by clause */
Node *havingClause; /* having conditional-expression */
1999-01-21 17:08:55 +01:00
List *intersectClause;
List *exceptClause;
List *unionClause; /* union subselect parameters */
List *sortClause; /* sort clause (a list of SortGroupBy's) */
1998-01-10 05:30:11 +01:00
char *portalname; /* the portal (cursor) to create */
bool binary; /* a binary (internal) portal? */
bool istemp; /* into is a temp table */
bool unionall; /* union without unique sort */
1998-10-22 15:52:24 +02:00
Node *limitOffset; /* # of result tuples to skip */
Node *limitCount; /* # of result tuples to return */
1999-01-05 16:46:25 +01:00
List *forUpdate; /* FOR UPDATE clause */
1998-01-09 21:06:08 +01:00
} SelectStmt;
/****************************************************************************
* Supporting data structures for Parse Trees
****************************************************************************/
/*
* TypeName - specifies a type in definitions
*/
typedef struct TypeName
{
NodeTag type;
char *name; /* name of the type */
bool timezone; /* timezone specified? */
bool setof; /* is a set? */
int32 typmod; /* type modifier */
List *arrayBounds; /* array bounds */
} TypeName;
/*
* ParamNo - specifies a parameter reference
*/
typedef struct ParamNo
{
NodeTag type;
int number; /* the number of the parameter */
TypeName *typename; /* the typecast */
List *indirection; /* array references */
} ParamNo;
/*
* A_Expr - binary expressions
*/
typedef struct A_Expr
{
NodeTag type;
int oper; /* type of operation
* {OP,OR,AND,NOT,ISNULL,NOTNULL} */
char *opname; /* name of operator/function */
Node *lexpr; /* left argument */
Node *rexpr; /* right argument */
1997-09-08 22:59:27 +02:00
} A_Expr;
/*
* Attr -
* specifies an Attribute (ie. a Column); could have nested dots or
* array references.
*
*/
typedef struct Attr
{
NodeTag type;
char *relname; /* name of relation (can be "*") */
ParamNo *paramNo; /* or a parameter */
List *attrs; /* attributes (possibly nested); list of
* Values (strings) */
List *indirection; /* array refs (list of A_Indices') */
1997-09-08 22:59:27 +02:00
} Attr;
/*
* A_Const - a constant expression
*/
typedef struct A_Const
{
NodeTag type;
Value val; /* the value (with the tag) */
TypeName *typename; /* typecast */
1997-09-08 22:59:27 +02:00
} A_Const;
1998-12-04 16:34:49 +01:00
/*
* CaseExpr - a CASE expression
*/
typedef struct CaseExpr
{
NodeTag type;
Oid casetype;
Node *arg; /* implicit equality comparison argument */
List *args; /* the arguments (list of WHEN clauses) */
Node *defresult; /* the default result (ELSE clause) */
1999-05-26 00:43:53 +02:00
} CaseExpr;
1998-12-04 16:34:49 +01:00
/*
* CaseWhen - an argument to a CASE expression
*/
typedef struct CaseWhen
{
NodeTag type;
Node *expr; /* comparison expression */
Node *result; /* substitution result */
1999-05-26 00:43:53 +02:00
} CaseWhen;
1998-12-04 16:34:49 +01:00
/*
* ColumnDef - column definition (used in various creates)
*/
typedef struct ColumnDef
{
NodeTag type;
char *colname; /* name of column */
TypeName *typename; /* type of column */
bool is_not_null; /* flag to NOT NULL constraint */
bool is_sequence; /* is a sequence? */
char *defval; /* default value of column */
List *constraints; /* constraints on column */
} ColumnDef;
/*
* Ident -
* an identifier (could be an attribute or a relation name). Depending
* on the context at transformStmt time, the identifier is treated as
* either a relation name (in which case, isRel will be set) or an
* attribute (in which case, it will be transformed into an Attr).
*/
typedef struct Ident
{
NodeTag type;
char *name; /* its name */
List *indirection; /* array references */
bool isRel; /* is a relation - filled in by
* transformExpr() */
} Ident;
/*
* FuncCall - a function/aggregate invocation
*/
typedef struct FuncCall
{
NodeTag type;
char *funcname; /* name of function */
List *args; /* the arguments (list of exprs) */
} FuncCall;
/*
* A_Indices - array reference or bounds ([lidx:uidx] or [uidx])
*/
typedef struct A_Indices
{
NodeTag type;
Node *lidx; /* could be NULL */
Node *uidx;
1997-09-08 22:59:27 +02:00
} A_Indices;
/*
* ResTarget -
* result target (used in target list of pre-transformed Parse trees)
*/
typedef struct ResTarget
{
NodeTag type;
char *name; /* name of the result column */
List *indirection; /* array references */
Node *val; /* the value of the result (A_Expr or
* Attr) (or A_Const) */
} ResTarget;
/*
1998-12-04 16:34:49 +01:00
* ParamString - used in WITH clauses
*/
typedef struct ParamString
{
NodeTag type;
char *name;
char *val;
} ParamString;
/*
* RelExpr - relation expressions
*/
typedef struct RelExpr
{
NodeTag type;
char *relname; /* the relation name */
bool inh; /* inheritance query */
} RelExpr;
/*
1998-12-04 16:34:49 +01:00
* SortGroupBy - for ORDER BY clause
*/
typedef struct SortGroupBy
{
NodeTag type;
char *useOp; /* operator to use */
Node *node; /* Expression */
} SortGroupBy;
/*
1998-12-04 16:34:49 +01:00
* RangeVar - range variable, used in FROM clauses
*/
typedef struct RangeVar
{
NodeTag type;
RelExpr *relExpr; /* the relation expression */
char *name; /* the name to be referenced (optional) */
} RangeVar;
/*
1998-12-04 16:34:49 +01:00
* IndexElem - index parameters (used in CREATE INDEX)
*/
typedef struct IndexElem
{
NodeTag type;
char *name; /* name of index */
List *args; /* if not NULL, function index */
char *class;
TypeName *typename; /* type of index's keys (optional) */
} IndexElem;
/*
* DefElem -
* a definition (used in definition lists in the form of defname = arg)
*/
typedef struct DefElem
{
NodeTag type;
char *defname;
Node *arg; /* a (Value *) or a (TypeName *) */
} DefElem;
/*
* JoinExpr - for JOIN expressions
*/
typedef struct JoinExpr
{
NodeTag type;
int jointype;
RangeVar *larg;
Node *rarg;
List *quals;
1999-05-26 00:43:53 +02:00
} JoinExpr;
/****************************************************************************
* Nodes for a Query tree
****************************************************************************/
/*
* TargetEntry -
* a target entry (used in the transformed target list)
*
* one of resdom or fjoin is not NULL. a target list is
* ((<resdom | fjoin> expr) (<resdom | fjoin> expr) ...)
*/
typedef struct TargetEntry
{
NodeTag type;
Resdom *resdom; /* fjoin overload this to be a list?? */
Fjoin *fjoin;
Node *expr; /* can be a list too */
} TargetEntry;
/*
* RangeTblEntry -
* used in range tables. Some of the following are only used in one of
* the parsing, optimizing, execution stages.
*
* inFromCl marks those range variables that are listed in the from clause.
* In SQL, the targetlist can only refer to range variables listed in the
* from clause but POSTQUEL allows you to refer to tables not specified, in
* which case a range table entry will be generated. We use POSTQUEL
* semantics which is more powerful. However, we need SQL semantics in
* some cases (eg. when expanding a '*')
*/
typedef struct RangeTblEntry
{
NodeTag type;
char *relname; /* real name of the relation */
char *refname; /* the reference name (specified in the
* from clause) */
Oid relid;
bool inh; /* inheritance? */
bool inFromCl; /* comes from From Clause */
bool skipAcl; /* skip ACL check in executor */
} RangeTblEntry;
/*
* SortClause -
* used in the sort clause for retrieves and cursors
*/
typedef struct SortClause
{
NodeTag type;
Resdom *resdom; /* attributes in tlist to be sorted */
Oid opoid; /* sort operators */
} SortClause;
/*
* GroupClause -
* used in the GROUP BY clause
*/
typedef struct GroupClause
{
NodeTag type;
Oid grpOpoid; /* the sort operator to use */
Index tleGroupref; /* reference into targetlist */
} GroupClause;
1999-05-25 18:15:34 +02:00
#define ROW_MARK_FOR_UPDATE (1 << 0)
#define ROW_ACL_FOR_UPDATE (1 << 1)
1999-01-21 17:08:55 +01:00
typedef struct RowMark
{
1999-05-25 18:15:34 +02:00
NodeTag type;
Index rti; /* index in Query->rtable */
bits8 info; /* as above */
1999-05-26 00:43:53 +02:00
} RowMark;
1999-01-21 17:08:55 +01:00
#endif /* PARSENODES_H */