8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.141 2000/02/24 04:34:38 inoue Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.142 2000/03/08 23:41:00 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -144,6 +144,7 @@ PortalVariableMemory CommonSpecialPortalGetMemory(void)
144
144
{
145
145
return PortalGetVariableMemory (vc_portal );
146
146
}
147
+
147
148
bool CommonSpecialPortalIsOpen (void )
148
149
{
149
150
return CommonSpecialPortalInUse ;
153
154
vacuum (char * vacrel , bool verbose , bool analyze , List * va_spec )
154
155
{
155
156
NameData VacRel ;
157
+ Name VacRelName ;
156
158
PortalVariableMemory pmem ;
157
159
MemoryContext old ;
158
160
List * le ;
@@ -173,17 +175,22 @@ vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
173
175
if (IsTransactionBlock ())
174
176
elog (ERROR , "VACUUM cannot run inside a BEGIN/END block" );
175
177
176
- /* initialize vacuum cleaner, particularly vc_portal */
177
- vc_init ();
178
-
179
178
if (verbose )
180
179
MESSAGE_LEVEL = NOTICE ;
181
180
else
182
181
MESSAGE_LEVEL = DEBUG ;
183
182
184
- /* vacrel gets de-allocated on transaction commit, so copy it */
183
+ /* Create special portal for cross-transaction storage */
184
+ CommonSpecialPortalOpen ();
185
+
186
+ /* vacrel gets de-allocated on xact commit, so copy it to safe storage */
185
187
if (vacrel )
186
- strcpy (NameStr (VacRel ), vacrel );
188
+ {
189
+ namestrcpy (& VacRel , vacrel );
190
+ VacRelName = & VacRel ;
191
+ }
192
+ else
193
+ VacRelName = NULL ;
187
194
188
195
/* must also copy the column list, if any, to safe storage */
189
196
pmem = CommonSpecialPortalGetMemory ();
@@ -196,11 +203,18 @@ vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
196
203
}
197
204
MemoryContextSwitchTo (old );
198
205
206
+ /*
207
+ * Start up the vacuum cleaner.
208
+ *
209
+ * NOTE: since this commits the current transaction, the memory holding
210
+ * any passed-in parameters gets freed here. We must have already copied
211
+ * pass-by-reference parameters to safe storage. Don't make me fix this
212
+ * again!
213
+ */
214
+ vc_init ();
215
+
199
216
/* vacuum the database */
200
- if (vacrel )
201
- vc_vacuum (& VacRel , analyze , va_cols );
202
- else
203
- vc_vacuum (NULL , analyze , NIL );
217
+ vc_vacuum (VacRelName , analyze , va_cols );
204
218
205
219
/* clean up */
206
220
vc_shutdown ();
@@ -229,8 +243,6 @@ vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
229
243
static void
230
244
vc_init ()
231
245
{
232
- CommonSpecialPortalOpen ();
233
-
234
246
/* matches the StartTransaction in PostgresMain() */
235
247
CommitTransactionCommand ();
236
248
}
@@ -252,6 +264,7 @@ vc_shutdown()
252
264
*/
253
265
unlink (RELCACHE_INIT_FILENAME );
254
266
267
+ /* Clean up working storage */
255
268
CommonSpecialPortalClose ();
256
269
257
270
/* matches the CommitTransaction in PostgresMain() */
0 commit comments