]> granicus.if.org Git - postgresql/commitdiff
Fixes:
authorMarc G. Fournier <scrappy@hub.org>
Tue, 6 Aug 1996 16:27:59 +0000 (16:27 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Tue, 6 Aug 1996 16:27:59 +0000 (16:27 +0000)
While a normal SELECT statement can contain a GROUP BY clause, a cursor
declaration cannot. This was not the case in PG-1.0. Was there a good
reason why this was changed? Are cursors being phased out? Is there any way
to get data with just a SELECT (and without a DECLARE CURSOR ...)?

The patch below seems to fix things. If anyone can see a problem with it,
please let me know. Thanks.

Submitted by:  David Smith <dasmith@perseus.tufts.edu>

src/backend/nodes/parsenodes.h
src/backend/parser/analyze.c
src/backend/parser/gram.y

index bc994bb1a0a679170127a4aa6b2f0386670eda42..ff5baea9f1b61c2ca4dd715e1a4e255964db63c1 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parsenodes.h,v 1.1.1.1 1996/07/09 06:21:33 scrappy Exp $
+ * $Id: parsenodes.h,v 1.2 1996/08/06 16:27:48 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -462,6 +462,7 @@ typedef struct CursorStmt {
     List               *targetList;    /* the target list (of ResTarget) */
     List               *fromClause;    /* the from clause */
     Node               *whereClause;   /* qualifications */
+    List              *groupClause;   /* group by clause */
     List               *orderClause;   /* sort clause (a list of SortBy's) */
 } CursorStmt;    
 
index cba2e2119949538ad20fcde395689c52439ccc4a..a99bd780fa6a99394bb9238d4634cee8f8329a58 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.3 1996/07/20 07:58:04 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.4 1996/08/06 16:27:56 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -509,6 +509,10 @@ transformCursorStmt(ParseState *pstate, CursorStmt *stmt)
     qry->sortClause = transformSortClause(stmt->orderClause,
                                          qry->targetList,
                                          qry->uniqueFlag);
+    /* fix group by clause */
+    qry->groupClause = transformGroupClause(pstate,
+                                          stmt->groupClause);
+
     qry->rtable = pstate->p_rtable;
 
     if (pstate->p_numAgg > 0)
index 4fbfbbc8aea69b7c901dfea72497ea5422b10000..a40a2caff88b10e0a402834c804654c21bedfd8c 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.2 1996/07/23 02:23:33 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.3 1996/08/06 16:27:59 scrappy Exp $
  *
  * HISTORY
  *    AUTHOR           DATE            MAJOR EVENT
@@ -1349,7 +1349,7 @@ ReplaceStmt:  UPDATE relation_name
 
 CursorStmt:  DECLARE name opt_binary CURSOR FOR 
             SELECT opt_unique res_target_list2 
-            from_clause where_clause sort_clause
+            from_clause where_clause group_clause sort_clause
                {
                    CursorStmt *n = makeNode(CursorStmt);
 
@@ -1370,7 +1370,8 @@ CursorStmt:  DECLARE name opt_binary CURSOR FOR
                    n->targetList = $8;
                    n->fromClause = $9;
                    n->whereClause = $10;
-                   n->orderClause = $11;
+                   n->groupClause = $11;
+                   n->orderClause = $12;
                    $$ = (Node *)n;
                }
        ;