summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2004-05-10 22:44:49 +0000
committerTom Lane2004-05-10 22:44:49 +0000
commit2f63232d30ca64a8f2684af855230f23a701d371 (patch)
treeb7a7707d1ec9edf368780cd3f4a23755527c5884 /src/include
parent9a939886ac782cfee3cd5fdd1c58689163ed84be (diff)
Promote row expressions to full-fledged citizens of the expression syntax,
rather than allowing them only in a few special cases as before. In particular you can now pass a ROW() construct to a function that accepts a rowtype parameter. Internal generation of RowExprs fixes a number of corner cases that used to not work very well, such as referencing the whole-row result of a JOIN or subquery. This represents a further step in the work I started a month or so back to make rowtype values into first-class citizens.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/executor/executor.h3
-rw-r--r--src/include/nodes/execnodes.h13
-rw-r--r--src/include/nodes/makefuncs.h4
-rw-r--r--src/include/nodes/nodes.h4
-rw-r--r--src/include/nodes/primnodes.h19
-rw-r--r--src/include/optimizer/var.h3
-rw-r--r--src/include/rewrite/rewriteManip.h5
8 files changed, 44 insertions, 11 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 46a8a2d06f3..0e957db82ca 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.228 2004/05/08 21:21:18 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.229 2004/05/10 22:44:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200405081
+#define CATALOG_VERSION_NO 200405101
#endif
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index a3088ca7f62..52873e86469 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.109 2004/04/01 21:28:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.110 2004/05/10 22:44:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -175,6 +175,7 @@ extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate,
TupleDesc tupType);
extern TupleDesc ExecTypeFromTL(List *targetList, bool hasoid);
extern TupleDesc ExecCleanTypeFromTL(List *targetList, bool hasoid);
+extern TupleDesc ExecTypeFromExprList(List *exprList);
extern void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg);
typedef struct TupOutputState
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 8a0fbf7be0f..325bf876800 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.115 2004/04/01 21:28:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.116 2004/05/10 22:44:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -614,6 +614,17 @@ typedef struct ArrayExprState
} ArrayExprState;
/* ----------------
+ * RowExprState node
+ * ----------------
+ */
+typedef struct RowExprState
+{
+ ExprState xprstate;
+ List *args; /* the arguments */
+ TupleDesc tupdesc; /* descriptor for result tuples */
+} RowExprState;
+
+/* ----------------
* CoalesceExprState node
* ----------------
*/
diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h
index 7562e1a82b6..085e76d03bf 100644
--- a/src/include/nodes/makefuncs.h
+++ b/src/include/nodes/makefuncs.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.48 2003/11/29 22:41:06 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/makefuncs.h,v 1.49 2004/05/10 22:44:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,6 +45,8 @@ extern Const *makeConst(Oid consttype,
extern Const *makeNullConst(Oid consttype);
+extern Node *makeBoolConst(bool value, bool isnull);
+
extern Expr *makeBoolExpr(BoolExprType boolop, List *args);
extern Alias *makeAlias(const char *aliasname, List *colnames);
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index a776607ec66..20c1b08f5c5 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.153 2004/05/05 04:48:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.154 2004/05/10 22:44:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -115,6 +115,7 @@ typedef enum NodeTag
T_CaseWhen,
T_CaseTestExpr,
T_ArrayExpr,
+ T_RowExpr,
T_CoalesceExpr,
T_NullIfExpr,
T_NullTest,
@@ -145,6 +146,7 @@ typedef enum NodeTag
T_CaseExprState,
T_CaseWhenState,
T_ArrayExprState,
+ T_RowExprState,
T_CoalesceExprState,
T_CoerceToDomainState,
T_DomainConstraintState,
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 567310fa1c3..d5819eab7bb 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.97 2004/04/01 21:28:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.98 2004/05/10 22:44:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -633,6 +633,23 @@ typedef struct ArrayExpr
} ArrayExpr;
/*
+ * RowExpr - a ROW() expression
+ */
+typedef struct RowExpr
+{
+ Expr xpr;
+ List *args; /* the fields */
+ Oid row_typeid; /* RECORDOID or a composite type's ID */
+ /*
+ * Note: we deliberately do NOT store a typmod. Although a typmod
+ * will be associated with specific RECORD types at runtime, it will
+ * differ for different backends, and so cannot safely be stored in
+ * stored parsetrees. We must assume typmod -1 for a RowExpr node.
+ */
+ CoercionForm row_format; /* how to display this node */
+} RowExpr;
+
+/*
* CoalesceExpr - a COALESCE expression
*/
typedef struct CoalesceExpr
diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h
index 087489a0a75..0f0920d0639 100644
--- a/src/include/optimizer/var.h
+++ b/src/include/optimizer/var.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/optimizer/var.h,v 1.29 2003/11/29 22:41:07 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/optimizer/var.h,v 1.30 2004/05/10 22:44:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,7 +20,6 @@
extern Relids pull_varnos(Node *node);
extern bool contain_var_reference(Node *node, int varno, int varattno,
int levelsup);
-extern bool contain_whole_tuple_var(Node *node, int varno, int levelsup);
extern bool contain_var_clause(Node *node);
extern bool contain_vars_of_level(Node *node, int levelsup);
extern bool contain_vars_above_level(Node *node, int levelsup);
diff --git a/src/include/rewrite/rewriteManip.h b/src/include/rewrite/rewriteManip.h
index d2c694bb4b2..ce4702de35b 100644
--- a/src/include/rewrite/rewriteManip.h
+++ b/src/include/rewrite/rewriteManip.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/rewrite/rewriteManip.h,v 1.34 2003/11/29 22:41:11 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/rewrite/rewriteManip.h,v 1.35 2004/05/10 22:44:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -38,6 +38,7 @@ extern bool checkExprHasAggs(Node *node);
extern bool checkExprHasSubLink(Node *node);
extern Node *ResolveNew(Node *node, int target_varno, int sublevels_up,
- List *targetlist, int event, int update_varno);
+ RangeTblEntry *target_rte,
+ List *targetlist, int event, int update_varno);
#endif /* REWRITEMANIP_H */