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

Commit 4523e0b

Browse files
committed
Cleanup, remove unneeded pallocs
1 parent a29d815 commit 4523e0b

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/backend/access/gist/gist.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.123 2005/06/28 15:51:00 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.124 2005/06/29 14:06:14 teodor Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -362,6 +362,7 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate) {
362362
Page page = (Page)BufferGetPage(ptr->buffer);
363363
GistPageGetOpaque(page)->rightlink = ( ptr->next ) ?
364364
ptr->next->block.blkno : InvalidBlockNumber;
365+
GistPageGetOpaque(page)->nsn = PageGetLSN(page);
365366
LockBuffer( ptr->buffer, GIST_UNLOCK );
366367
WriteBuffer(ptr->buffer);
367368
ptr=ptr->next;

src/backend/access/gist/gistvacuum.c

+7-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -52,7 +52,7 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
5252
int lenaddon=4, curlenaddon=0, ntodelete=0;
5353
IndexTuple idxtuple, *addon=NULL;
5454
bool needwrite=false;
55-
OffsetNumber *todelete=NULL;
55+
OffsetNumber todelete[ BLCKSZ/SizeOfIptrData ];
5656
ItemPointerData *completed=NULL;
5757
int ncompleted=0, lencompleted=16;
5858

@@ -67,7 +67,6 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
6767
GistClearTuplesDeleted(page);
6868
}
6969
} else {
70-
todelete = (OffsetNumber*)palloc( MAXALIGN(sizeof(OffsetNumber)*(maxoff+1)) );
7170
completed = (ItemPointerData*)palloc( sizeof(ItemPointerData)*lencompleted );
7271
addon=(IndexTuple*)palloc(sizeof(IndexTuple)*lenaddon);
7372

@@ -143,16 +142,14 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
143142
XLogRecPtr recptr;
144143
XLogRecData *rdata;
145144
ItemPointerData key; /* set key for incomplete insert */
145+
char *xlinfo;
146146

147147
ItemPointerSet(&key, blkno, TUPLE_IS_VALID);
148148

149-
oldCtx = MemoryContextSwitchTo(gv->opCtx);
150-
151149
rdata = formSplitRdata(gv->index->rd_node, blkno,
152150
&key, dist);
151+
xlinfo = rdata->data;
153152

154-
MemoryContextSwitchTo(oldCtx);
155-
156153
START_CRIT_SECTION();
157154

158155
recptr = XLogInsert(RM_GIST_ID, XLOG_GIST_PAGE_SPLIT, rdata);
@@ -164,6 +161,8 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
164161
}
165162

166163
END_CRIT_SECTION();
164+
pfree( xlinfo );
165+
pfree( rdata );
167166
} else {
168167
ptr = dist;
169168
while(ptr) {
@@ -267,7 +266,6 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
267266
for(i=0;i<curlenaddon;i++)
268267
pfree( addon[i] );
269268
if (addon) pfree(addon);
270-
if (todelete) pfree(todelete);
271269
if (completed) pfree(completed);
272270
return res;
273271
}
@@ -442,7 +440,7 @@ gistbulkdelete(PG_FUNCTION_ARGS) {
442440
page = (Page) BufferGetPage(buffer);
443441

444442
if ( GistPageIsLeaf(page) ) {
445-
OffsetNumber *todelete = NULL;
443+
OffsetNumber todelete[BLCKSZ/SizeOfIptrData];
446444
int ntodelete = 0;
447445

448446
LockBuffer(buffer, GIST_UNLOCK);
@@ -462,7 +460,6 @@ gistbulkdelete(PG_FUNCTION_ARGS) {
462460
pushStackIfSplited(page, stack);
463461

464462
maxoff = PageGetMaxOffsetNumber(page);
465-
todelete = (OffsetNumber*)palloc( MAXALIGN(sizeof(OffsetNumber)*(maxoff+1)) );
466463

467464
for(i=FirstOffsetNumber;i<=maxoff;i=OffsetNumberNext(i)) {
468465
iid = PageGetItemId(page, i);
@@ -502,8 +499,6 @@ gistbulkdelete(PG_FUNCTION_ARGS) {
502499
PageSetLSN(page, XLogRecPtrForTemp);
503500
WriteNoReleaseBuffer( buffer );
504501
}
505-
506-
pfree( todelete );
507502
} else {
508503
/* check for split proceeded after look at parent */
509504
pushStackIfSplited(page, stack);

0 commit comments

Comments
 (0)