8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.4 2005/06/28 15:51:00 teodor Exp $
11
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.5 2005/06/29 14:06:14 teodor Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -52,7 +52,7 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
52
52
int lenaddon = 4 , curlenaddon = 0 , ntodelete = 0 ;
53
53
IndexTuple idxtuple , * addon = NULL ;
54
54
bool needwrite = false;
55
- OffsetNumber * todelete = NULL ;
55
+ OffsetNumber todelete [ BLCKSZ / SizeOfIptrData ] ;
56
56
ItemPointerData * completed = NULL ;
57
57
int ncompleted = 0 , lencompleted = 16 ;
58
58
@@ -67,7 +67,6 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
67
67
GistClearTuplesDeleted (page );
68
68
}
69
69
} else {
70
- todelete = (OffsetNumber * )palloc ( MAXALIGN (sizeof (OffsetNumber )* (maxoff + 1 )) );
71
70
completed = (ItemPointerData * )palloc ( sizeof (ItemPointerData )* lencompleted );
72
71
addon = (IndexTuple * )palloc (sizeof (IndexTuple )* lenaddon );
73
72
@@ -143,16 +142,14 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
143
142
XLogRecPtr recptr ;
144
143
XLogRecData * rdata ;
145
144
ItemPointerData key ; /* set key for incomplete insert */
145
+ char * xlinfo ;
146
146
147
147
ItemPointerSet (& key , blkno , TUPLE_IS_VALID );
148
148
149
- oldCtx = MemoryContextSwitchTo (gv -> opCtx );
150
-
151
149
rdata = formSplitRdata (gv -> index -> rd_node , blkno ,
152
150
& key , dist );
151
+ xlinfo = rdata -> data ;
153
152
154
- MemoryContextSwitchTo (oldCtx );
155
-
156
153
START_CRIT_SECTION ();
157
154
158
155
recptr = XLogInsert (RM_GIST_ID , XLOG_GIST_PAGE_SPLIT , rdata );
@@ -164,6 +161,8 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
164
161
}
165
162
166
163
END_CRIT_SECTION ();
164
+ pfree ( xlinfo );
165
+ pfree ( rdata );
167
166
} else {
168
167
ptr = dist ;
169
168
while (ptr ) {
@@ -267,7 +266,6 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
267
266
for (i = 0 ;i < curlenaddon ;i ++ )
268
267
pfree ( addon [i ] );
269
268
if (addon ) pfree (addon );
270
- if (todelete ) pfree (todelete );
271
269
if (completed ) pfree (completed );
272
270
return res ;
273
271
}
@@ -442,7 +440,7 @@ gistbulkdelete(PG_FUNCTION_ARGS) {
442
440
page = (Page ) BufferGetPage (buffer );
443
441
444
442
if ( GistPageIsLeaf (page ) ) {
445
- OffsetNumber * todelete = NULL ;
443
+ OffsetNumber todelete [ BLCKSZ / SizeOfIptrData ] ;
446
444
int ntodelete = 0 ;
447
445
448
446
LockBuffer (buffer , GIST_UNLOCK );
@@ -462,7 +460,6 @@ gistbulkdelete(PG_FUNCTION_ARGS) {
462
460
pushStackIfSplited (page , stack );
463
461
464
462
maxoff = PageGetMaxOffsetNumber (page );
465
- todelete = (OffsetNumber * )palloc ( MAXALIGN (sizeof (OffsetNumber )* (maxoff + 1 )) );
466
463
467
464
for (i = FirstOffsetNumber ;i <=maxoff ;i = OffsetNumberNext (i )) {
468
465
iid = PageGetItemId (page , i );
@@ -502,8 +499,6 @@ gistbulkdelete(PG_FUNCTION_ARGS) {
502
499
PageSetLSN (page , XLogRecPtrForTemp );
503
500
WriteNoReleaseBuffer ( buffer );
504
501
}
505
-
506
- pfree ( todelete );
507
502
} else {
508
503
/* check for split proceeded after look at parent */
509
504
pushStackIfSplited (page , stack );
0 commit comments