Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5a447b4

Browse files
committed
MOVE implementation.
1 parent 4b9fb26 commit 5a447b4

File tree

3 files changed

+29
-49
lines changed

3 files changed

+29
-49
lines changed

src/backend/commands/command.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.18 1997/09/20 16:14:05 thomas Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.19 1997/09/29 05:56:10 vadim Exp $
1111
*
1212
* NOTES
1313
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -99,7 +99,7 @@ PerformPortalFetch(char *name,
9999
{
100100
Portal portal;
101101
int feature;
102-
QueryDesc *queryDesc;
102+
QueryDesc queryDesc;
103103
MemoryContext context;
104104

105105
/* ----------------
@@ -147,9 +147,11 @@ PerformPortalFetch(char *name,
147147
* tell the destination to prepare to recieve some tuples
148148
* ----------------
149149
*/
150-
queryDesc = PortalGetQueryDesc(portal);
150+
memcpy (&queryDesc, PortalGetQueryDesc(portal), sizeof (queryDesc));
151+
queryDesc.dest = dest;
152+
151153
BeginCommand(name,
152-
queryDesc->operation,
154+
queryDesc.operation,
153155
portal->attinfo, /* QueryDescGetTypeInfo(queryDesc),
154156
* */
155157
false, /* portal fetches don't end up in
@@ -166,7 +168,7 @@ PerformPortalFetch(char *name,
166168
PortalExecutorHeapMemory = (MemoryContext)
167169
PortalGetHeapMemory(portal);
168170

169-
ExecutorRun(queryDesc, PortalGetState(portal), feature, count);
171+
ExecutorRun(&queryDesc, PortalGetState(portal), feature, count);
170172

171173
/* ----------------
172174
* Note: the "end-of-command" tag is returned by higher-level

src/backend/parser/gram.y

Lines changed: 18 additions & 41 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.52 1997/09/26 15:09:11 thomas Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.53 1997/09/29 05:58:12 vadim Exp $
1414
*
1515
* HISTORY
1616
* AUTHOR DATE MAJOR EVENT
@@ -107,7 +107,7 @@ static char *FlattenStringList(List *list);
107107
AddAttrStmt, ClosePortalStmt,
108108
CopyStmt, CreateStmt, CreateSeqStmt, DefineStmt, DestroyStmt,
109109
ExtendStmt, FetchStmt, GrantStmt, CreateTrigStmt, DropTrigStmt,
110-
IndexStmt, MoveStmt, ListenStmt, OptimizableStmt,
110+
IndexStmt, ListenStmt, OptimizableStmt,
111111
ProcedureStmt, PurgeStmt,
112112
RecipeStmt, RemoveAggrStmt, RemoveOperStmt, RemoveFuncStmt, RemoveStmt,
113113
RenameStmt, RevokeStmt, RuleStmt, TransactionStmt, ViewStmt, LoadStmt,
@@ -162,7 +162,7 @@ static char *FlattenStringList(List *list);
162162
%type <ival> copy_dirn, archive_type, OptArchiveType, OptArchiveLocation,
163163
def_type, opt_direction, remove_type, opt_column, event
164164

165-
%type <ival> OptLocation, opt_move_where, fetch_how_many
165+
%type <ival> OptLocation, fetch_how_many
166166

167167
%type <list> OptSeqList
168168
%type <defelt> OptSeqElem
@@ -299,7 +299,6 @@ stmt : AddAttrStmt
299299
| FetchStmt
300300
| GrantStmt
301301
| IndexStmt
302-
| MoveStmt
303302
| ListenStmt
304303
| ProcedureStmt
305304
| PurgeStmt
@@ -995,7 +994,7 @@ DestroyStmt: DROP TABLE relation_name_list
995994
/*****************************************************************************
996995
*
997996
* QUERY:
998-
* fetch [forward | backward] [number | all ] [ in <portalname> ]
997+
* fetch/move [forward | backward] [number | all ] [ in <portalname> ]
999998
*
1000999
*****************************************************************************/
10011000

@@ -1005,6 +1004,16 @@ FetchStmt: FETCH opt_direction fetch_how_many opt_portal_name
10051004
n->direction = $2;
10061005
n->howMany = $3;
10071006
n->portalname = $4;
1007+
n->ismove = false;
1008+
$$ = (Node *)n;
1009+
}
1010+
| MOVE opt_direction fetch_how_many opt_portal_name
1011+
{
1012+
FetchStmt *n = makeNode(FetchStmt);
1013+
n->direction = $2;
1014+
n->howMany = $3;
1015+
n->portalname = $4;
1016+
n->ismove = true;
10081017
$$ = (Node *)n;
10091018
}
10101019
;
@@ -1021,6 +1030,10 @@ fetch_how_many: Iconst
10211030
| /*EMPTY*/ { $$ = 1; /*default*/ }
10221031
;
10231032

1033+
opt_portal_name: IN name { $$ = $2;}
1034+
| /*EMPTY*/ { $$ = NULL; }
1035+
;
1036+
10241037
/*****************************************************************************
10251038
*
10261039
* QUERY:
@@ -1119,42 +1132,6 @@ RevokeStmt: REVOKE privileges ON relation_name_list FROM grantee
11191132
}
11201133
;
11211134

1122-
/*****************************************************************************
1123-
*
1124-
* QUERY:
1125-
* move [<dirn>] [<whereto>] [<portalname>]
1126-
*
1127-
*****************************************************************************/
1128-
1129-
MoveStmt: MOVE opt_direction opt_move_where opt_portal_name
1130-
{
1131-
MoveStmt *n = makeNode(MoveStmt);
1132-
n->direction = $2;
1133-
n->to = FALSE;
1134-
n->where = $3;
1135-
n->portalname = $4;
1136-
$$ = (Node *)n;
1137-
}
1138-
| MOVE opt_direction TO Iconst opt_portal_name
1139-
{
1140-
MoveStmt *n = makeNode(MoveStmt);
1141-
n->direction = $2;
1142-
n->to = TRUE;
1143-
n->where = $4;
1144-
n->portalname = $5;
1145-
$$ = (Node *)n;
1146-
}
1147-
;
1148-
1149-
opt_move_where: Iconst { $$ = $1; }
1150-
| /*EMPTY*/ { $$ = 1; /* default */ }
1151-
;
1152-
1153-
opt_portal_name: IN name { $$ = $2;}
1154-
| /*EMPTY*/ { $$ = NULL; }
1155-
;
1156-
1157-
11581135
/*****************************************************************************
11591136
*
11601137
* QUERY:

src/backend/tcop/utility.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.24 1997/09/08 21:47:58 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.25 1997/09/29 05:59:16 vadim Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -139,7 +139,7 @@ ProcessUtility(Node *parsetree,
139139
bool forward;
140140
int count;
141141

142-
commandTag = "FETCH";
142+
commandTag = (stmt->ismove) ? "MOVE" : "FETCH";
143143
CHECK_IF_ABORTED();
144144

145145
forward = (bool) (stmt->direction == FORWARD);
@@ -149,7 +149,8 @@ ProcessUtility(Node *parsetree,
149149
*/
150150

151151
count = stmt->howMany;
152-
PerformPortalFetch(portalName, forward, count, commandTag, dest);
152+
PerformPortalFetch(portalName, forward, count, commandTag,
153+
(stmt->ismove) ? None : dest); /* /dev/null for MOVE */
153154
}
154155
break;
155156

0 commit comments

Comments
 (0)