88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.154 2002/02/19 20:11:12 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.155 2002/02/26 22:47:04 tgl Exp $
1212 *
1313 * NOTES
1414 * The PerformAddAttribute() code, like most of the relation
@@ -89,16 +89,25 @@ PortalCleanup(Portal portal)
8989MemoryContextSwitchTo (oldcontext );
9090}
9191
92- /* --------------------------------
93- *PerformPortalFetch
94- * --------------------------------
92+
93+ /*
94+ * PerformPortalFetch
95+ *
96+ *name: name of portal
97+ *forward: forward or backward fetch?
98+ *count: # of tuples to fetch (0 implies all)
99+ *dest: where to send results
100+ *completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE
101+ *in which to store a command completion status string.
102+ *
103+ * completionTag may be NULL if caller doesn't want a status string.
95104 */
96105void
97106PerformPortalFetch (char * name ,
98107bool forward ,
99108int count ,
100- char * tag ,
101- CommandDest dest )
109+ CommandDest dest ,
110+ char * completionTag )
102111{
103112Portal portal ;
104113QueryDesc * queryDesc ;
@@ -107,6 +116,10 @@ PerformPortalFetch(char *name,
107116CommandId savedId ;
108117bool temp_desc = false;
109118
119+ /* initialize completion status in case of early exit */
120+ if (completionTag )
121+ strcpy (completionTag , (dest == None ) ?"MOVE 0" :"FETCH 0" );
122+
110123/*
111124 * sanity checks
112125 */
@@ -167,7 +180,7 @@ PerformPortalFetch(char *name,
167180 * relations */
168181 false,/* this is a portal fetch, not a "retrieve
169182 * portal" */
170- tag ,
183+ NULL , /* not used */
171184queryDesc -> dest );
172185
173186/*
@@ -193,16 +206,15 @@ PerformPortalFetch(char *name,
193206{
194207ExecutorRun (queryDesc ,estate ,EXEC_FOR , (long )count );
195208
196- /*
197- * I use CMD_UPDATE, because no CMD_MOVE or the like exists,
198- * and I would like to provide the same kind of info as
199- * CMD_UPDATE
200- */
201- UpdateCommandInfo (CMD_UPDATE ,0 ,estate -> es_processed );
202209if (estate -> es_processed > 0 )
203210portal -> atStart = false;/* OK to back up now */
204211if (count <=0 || (int )estate -> es_processed < count )
205212portal -> atEnd = true;/* we retrieved 'em all */
213+
214+ if (completionTag )
215+ snprintf (completionTag ,COMPLETION_TAG_BUFSIZE ,"%s %u" ,
216+ (dest == None ) ?"MOVE" :"FETCH" ,
217+ estate -> es_processed );
206218}
207219}
208220else
@@ -211,16 +223,15 @@ PerformPortalFetch(char *name,
211223{
212224ExecutorRun (queryDesc ,estate ,EXEC_BACK , (long )count );
213225
214- /*
215- * I use CMD_UPDATE, because no CMD_MOVE or the like exists,
216- * and I would like to provide the same kind of info as
217- * CMD_UPDATE
218- */
219- UpdateCommandInfo (CMD_UPDATE ,0 ,estate -> es_processed );
220226if (estate -> es_processed > 0 )
221227portal -> atEnd = false;/* OK to go forward now */
222228if (count <=0 || (int )estate -> es_processed < count )
223229portal -> atStart = true;/* we retrieved 'em all */
230+
231+ if (completionTag )
232+ snprintf (completionTag ,COMPLETION_TAG_BUFSIZE ,"%s %u" ,
233+ (dest == None ) ?"MOVE" :"FETCH" ,
234+ estate -> es_processed );
224235}
225236}
226237
@@ -236,11 +247,6 @@ PerformPortalFetch(char *name,
236247pfree (queryDesc );
237248
238249MemoryContextSwitchTo (oldcontext );
239-
240- /*
241- * Note: the "end-of-command" tag is returned by higher-level utility
242- * code
243- */
244250}
245251
246252/* --------------------------------