Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitab22b34

Browse files
committed
Fixes:
While a normal SELECT statement can contain a GROUP BY clause, a cursordeclaration cannot. This was not the case in PG-1.0. Was there a goodreason why this was changed? Are cursors being phased out? Is there any wayto 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>
1 parentc4e53a1 commitab22b34

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

‎src/backend/nodes/parsenodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: parsenodes.h,v 1.1.1.1 1996/07/09 06:21:33 scrappy Exp $
9+
* $Id: parsenodes.h,v 1.2 1996/08/06 16:27:48 scrappy Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -462,6 +462,7 @@ typedef struct CursorStmt {
462462
List*targetList;/* the target list (of ResTarget) */
463463
List*fromClause;/* the from clause */
464464
Node*whereClause;/* qualifications */
465+
List*groupClause;/* group by clause */
465466
List*orderClause;/* sort clause (a list of SortBy's) */
466467
}CursorStmt;
467468

‎src/backend/parser/analyze.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.3 1996/07/20 07:58:04 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.4 1996/08/06 16:27:56 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -509,6 +509,10 @@ transformCursorStmt(ParseState *pstate, CursorStmt *stmt)
509509
qry->sortClause=transformSortClause(stmt->orderClause,
510510
qry->targetList,
511511
qry->uniqueFlag);
512+
/* fix group by clause */
513+
qry->groupClause=transformGroupClause(pstate,
514+
stmt->groupClause);
515+
512516
qry->rtable=pstate->p_rtable;
513517

514518
if (pstate->p_numAgg>0)

‎src/backend/parser/gram.y

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.2 1996/07/23 02:23:33 scrappy Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.3 1996/08/06 16:27:59 scrappy Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -1349,7 +1349,7 @@ ReplaceStmt: UPDATE relation_name
13491349

13501350
CursorStmt: DECLARE name opt_binary CURSOR FOR
13511351
SELECT opt_unique res_target_list2
1352-
from_clause where_clause sort_clause
1352+
from_clause where_clausegroup_clausesort_clause
13531353
{
13541354
CursorStmt *n = makeNode(CursorStmt);
13551355

@@ -1370,7 +1370,8 @@ CursorStmt: DECLARE name opt_binary CURSOR FOR
13701370
n->targetList = $8;
13711371
n->fromClause = $9;
13721372
n->whereClause = $10;
1373-
n->orderClause = $11;
1373+
n->groupClause = $11;
1374+
n->orderClause = $12;
13741375
$$ = (Node *)n;
13751376
}
13761377
;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp