mirror of
https://github.com/postgres/postgres.git
synced 2025-07-23 03:21:12 +03:00
Re-implement LIMIT/OFFSET as a plan node type, instead of a hack in
ExecutorRun. This allows LIMIT to work in a view. Also, LIMIT in a cursor declaration will behave in a reasonable fashion, whereas before it was overridden by the FETCH count.
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.126 2000/10/18 16:16:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.127 2000/10/26 21:35:47 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -592,6 +592,31 @@ _copySetOp(SetOp *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* _copyLimit
|
||||
* ----------------
|
||||
*/
|
||||
static Limit *
|
||||
_copyLimit(Limit *from)
|
||||
{
|
||||
Limit *newnode = makeNode(Limit);
|
||||
|
||||
/* ----------------
|
||||
* copy node superclass fields
|
||||
* ----------------
|
||||
*/
|
||||
CopyPlanFields((Plan *) from, (Plan *) newnode);
|
||||
|
||||
/* ----------------
|
||||
* copy remainder of node
|
||||
* ----------------
|
||||
*/
|
||||
Node_Copy(from, newnode, limitOffset);
|
||||
Node_Copy(from, newnode, limitCount);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* _copyHash
|
||||
* ----------------
|
||||
@ -2567,6 +2592,9 @@ copyObject(void *from)
|
||||
case T_SetOp:
|
||||
retval = _copySetOp(from);
|
||||
break;
|
||||
case T_Limit:
|
||||
retval = _copyLimit(from);
|
||||
break;
|
||||
case T_Hash:
|
||||
retval = _copyHash(from);
|
||||
break;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.128 2000/10/05 19:11:27 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.129 2000/10/26 21:35:48 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||
@ -623,6 +623,18 @@ _outSetOp(StringInfo str, SetOp *node)
|
||||
(int) node->flagColIdx);
|
||||
}
|
||||
|
||||
static void
|
||||
_outLimit(StringInfo str, Limit *node)
|
||||
{
|
||||
appendStringInfo(str, " LIMIT ");
|
||||
_outPlanInfo(str, (Plan *) node);
|
||||
|
||||
appendStringInfo(str, " :limitOffset ");
|
||||
_outNode(str, node->limitOffset);
|
||||
appendStringInfo(str, " :limitCount ");
|
||||
_outNode(str, node->limitCount);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hash is a subclass of Plan
|
||||
*/
|
||||
@ -1559,6 +1571,9 @@ _outNode(StringInfo str, void *obj)
|
||||
case T_SetOp:
|
||||
_outSetOp(str, obj);
|
||||
break;
|
||||
case T_Limit:
|
||||
_outLimit(str, obj);
|
||||
break;
|
||||
case T_Hash:
|
||||
_outHash(str, obj);
|
||||
break;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.44 2000/10/22 22:14:54 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.45 2000/10/26 21:35:48 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -324,6 +324,8 @@ plannode_type(Plan *p)
|
||||
return "UNIQUE";
|
||||
case T_SetOp:
|
||||
return "SETOP";
|
||||
case T_Limit:
|
||||
return "LIMIT";
|
||||
case T_Hash:
|
||||
return "HASH";
|
||||
case T_Group:
|
||||
|
Reference in New Issue
Block a user