From e529e9fa4449d77127639b073aa2eed386e367b3 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Thu, 13 Feb 2003 05:53:46 +0000
Subject: [PATCH] [ Revert patch ]

> =================================================================
> User interface proposal for multi-row function targetlist entries
> =================================================================
> 1. Only one targetlist entry may return a set.
> 2. Each targetlist item (other than the set returning one) is
>    repeated for each item in the returned set.
>

Having gotten no objections (actually, no response at all), I can only
assume no one had heartburn with this change. The attached patch covers
the first of the two proposals, i.e. restricting the target list to only
one set returning function.

Joe Conway
---
 src/backend/parser/parse_clause.c |  4 ++--
 src/backend/parser/parse_target.c | 24 ++++--------------------
 src/include/parser/parse_target.h |  4 ++--
 3 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 85af5359eaf..a68442b69a9 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.107 2003/02/13 05:06:34 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.108 2003/02/13 05:53:46 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1118,7 +1118,7 @@ findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause)
 	 * 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, NULL);
+	target_result = transformTargetEntry(pstate, node, expr, NULL, true);
 	lappend(tlist, target_result);
 
 	return target_result;
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 0bc5e665d6f..70aaf18ef58 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.96 2003/02/13 05:06:35 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.97 2003/02/13 05:53:46 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -42,16 +42,13 @@ static int	FigureColnameInternal(Node *node, char **name);
  * 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 *retset)
+					 bool resjunk)
 {
 	Oid			type_id;
 	int32		type_mod;
@@ -64,9 +61,6 @@ transformTargetEntry(ParseState *pstate,
 	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);
 
@@ -99,12 +93,10 @@ transformTargetEntry(ParseState *pstate,
 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))
@@ -181,8 +173,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
 														res->val,
 														NULL,
 														res->name,
-														false,
-														&entry_retset));
+														false));
 			}
 		}
 		else if (IsA(res->val, InsertDefault))
@@ -203,16 +194,9 @@ transformTargetList(ParseState *pstate, List *targetlist)
 													res->val,
 													NULL,
 													res->name,
-													false,
-													&entry_retset));
+													false));
 		}
 
-		if (retset && entry_retset)
-			elog(ERROR, "Only one target list entry may return a set result");
-
-		if (entry_retset)
-			retset = true;
-
 		targetlist = lnext(targetlist);
 	}
 
diff --git a/src/include/parser/parse_target.h b/src/include/parser/parse_target.h
index 3fa67cbf41f..b89ed3a30d6 100644
--- a/src/include/parser/parse_target.h
+++ b/src/include/parser/parse_target.h
@@ -7,7 +7,7 @@
  * 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.28 2003/02/13 05:06:35 momjian Exp $
+ * $Id: parse_target.h,v 1.29 2003/02/13 05:53:46 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -20,7 +20,7 @@
 extern List *transformTargetList(ParseState *pstate, List *targetlist);
 extern TargetEntry *transformTargetEntry(ParseState *pstate,
 					 Node *node, Node *expr,
-					 char *colname, bool resjunk, bool *retset);
+					 char *colname, bool resjunk);
 extern void updateTargetListEntry(ParseState *pstate, TargetEntry *tle,
 					  char *colname, int attrno,
 					  List *indirection);
-- 
GitLab