*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.106 2003/02/10 04:44:46 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.107 2003/02/13 05:06:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* the end of the target list. This target is given resjunk = TRUE so
* that it will not be projected into the final tuple.
*/
- target_result = transformTargetEntry(pstate, node, expr, NULL, true);
+ target_result = transformTargetEntry(pstate, node, expr, NULL, true, NULL);
lappend(tlist, target_result);
return target_result;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.95 2003/02/09 06:56:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.96 2003/02/13 05:06:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* colname the column name to be assigned, or NULL if none yet set.
* resjunk true if the target should be marked resjunk, ie, it is not
* wanted in the final projected tuple.
+ * retset if non-NULL, and the entry is a function expression, pass back
+ * expr->funcretset
*/
TargetEntry *
transformTargetEntry(ParseState *pstate,
Node *node,
Node *expr,
char *colname,
- bool resjunk)
+ bool resjunk,
+ bool *retset)
{
Oid type_id;
int32 type_mod;
if (IsA(expr, RangeVar))
elog(ERROR, "You can't use relation names alone in the target list, try relation.*.");
+ if (retset && IsA(expr, FuncExpr))
+ *retset = ((FuncExpr *) expr)->funcretset;
+
type_id = exprType(expr);
type_mod = exprTypmod(expr);
List *
transformTargetList(ParseState *pstate, List *targetlist)
{
+ bool retset = false;
List *p_target = NIL;
while (targetlist != NIL)
{
+ bool entry_retset = false;
ResTarget *res = (ResTarget *) lfirst(targetlist);
if (IsA(res->val, ColumnRef))
res->val,
NULL,
res->name,
- false));
+ false,
+ &entry_retset));
}
}
else if (IsA(res->val, InsertDefault))
res->val,
NULL,
res->name,
- false));
+ false,
+ &entry_retset));
}
+ if (retset && entry_retset)
+ elog(ERROR, "Only one target list entry may return a set result");
+
+ if (entry_retset)
+ retset = true;
+
targetlist = lnext(targetlist);
}
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: parse_target.h,v 1.27 2002/09/18 21:35:24 tgl Exp $
+ * $Id: parse_target.h,v 1.28 2003/02/13 05:06:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern List *transformTargetList(ParseState *pstate, List *targetlist);
extern TargetEntry *transformTargetEntry(ParseState *pstate,
Node *node, Node *expr,
- char *colname, bool resjunk);
+ char *colname, bool resjunk, bool *retset);
extern void updateTargetListEntry(ParseState *pstate, TargetEntry *tle,
char *colname, int attrno,
List *indirection);