Skip to content

Commit 88b49cd

Browse files
committed
Code cleanup. gistfillbuffer accepts InvalidOffsetNumber.
1 parent 365205d commit 88b49cd

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

src/backend/access/gist/gist.c

Lines changed: 5 additions & 10 deletions
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.122 2005/06/27 12:45:21 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.123 2005/06/28 15:51:00 teodor Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -421,13 +421,10 @@ gistplacetopage(GISTInsertState *state, GISTSTATE *giststate) {
421421
else
422422
{
423423
/* enough space */
424-
OffsetNumber l, off;
425424
XLogRecPtr oldlsn;
426425

427-
off = ( PageIsEmpty(state->stack->page) ) ?
428-
FirstOffsetNumber : OffsetNumberNext(PageGetMaxOffsetNumber(state->stack->page));
429-
430-
l = gistfillbuffer(state->r, state->stack->page, state->itup, state->ituplen, off);
426+
gistfillbuffer(state->r, state->stack->page, state->itup, state->ituplen, InvalidOffsetNumber);
427+
431428
oldlsn = PageGetLSN(state->stack->page);
432429
if ( !state->r->rd_istemp ) {
433430
OffsetNumber noffs=0, offs[ MAXALIGN( sizeof(OffsetNumber) ) / sizeof(OffsetNumber) ];
@@ -999,10 +996,9 @@ gistSplit(Relation r,
999996
}
1000997
else
1001998
{
1002-
OffsetNumber l;
1003999
char *ptr;
10041000

1005-
l = gistfillbuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber);
1001+
gistfillbuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber);
10061002
/* XLOG stuff */
10071003
ROTATEDIST(*dist);
10081004
(*dist)->block.blkno = BufferGetBlockNumber(rightbuf);
@@ -1035,10 +1031,9 @@ gistSplit(Relation r,
10351031
}
10361032
else
10371033
{
1038-
OffsetNumber l;
10391034
char *ptr;
10401035

1041-
l = gistfillbuffer(r, left, lvectup, v.spl_nleft, FirstOffsetNumber);
1036+
gistfillbuffer(r, left, lvectup, v.spl_nleft, FirstOffsetNumber);
10421037
/* XLOG stuff */
10431038
ROTATEDIST(*dist);
10441039
(*dist)->block.blkno = BufferGetBlockNumber(leftbuf);

src/backend/access/gist/gistutil.c

Lines changed: 5 additions & 1 deletion
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/gistutil.c,v 1.3 2005/06/27 12:45:22 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistutil.c,v 1.4 2005/06/28 15:51:00 teodor Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include "postgres.h"
@@ -62,6 +62,10 @@ gistfillbuffer(Relation r, Page page, IndexTuple *itup,
6262
OffsetNumber l = InvalidOffsetNumber;
6363
int i;
6464

65+
if ( off == InvalidOffsetNumber )
66+
off = ( PageIsEmpty(page) ) ? FirstOffsetNumber :
67+
OffsetNumberNext(PageGetMaxOffsetNumber(page));
68+
6569
for (i = 0; i < len; i++)
6670
{
6771
l = PageAddItem(page, (Item) itup[i], IndexTupleSize(itup[i]),

src/backend/access/gist/gistvacuum.c

Lines changed: 2 additions & 7 deletions
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.3 2005/06/27 12:45:22 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.4 2005/06/28 15:51:00 teodor Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -199,12 +199,7 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
199199
needunion = false; /* gistSplit already forms unions */
200200
} else {
201201
/* enough free space */
202-
OffsetNumber off = (PageIsEmpty(page)) ?
203-
FirstOffsetNumber
204-
:
205-
OffsetNumberNext(PageGetMaxOffsetNumber(page));
206-
207-
gistfillbuffer(gv->index, page, addon, curlenaddon, off);
202+
gistfillbuffer(gv->index, page, addon, curlenaddon, InvalidOffsetNumber);
208203
}
209204
}
210205
}

src/backend/access/gist/gistxlog.c

Lines changed: 4 additions & 12 deletions
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/gistxlog.c,v 1.4 2005/06/27 12:45:22 teodor Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.5 2005/06/28 15:51:00 teodor Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include "postgres.h"
@@ -198,14 +198,8 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) {
198198
}
199199

200200
/* add tuples */
201-
if ( xlrec.len > 0 ) {
202-
OffsetNumber off = (PageIsEmpty(page)) ?
203-
FirstOffsetNumber
204-
:
205-
OffsetNumberNext(PageGetMaxOffsetNumber(page));
206-
207-
gistfillbuffer(reln, page, xlrec.itup, xlrec.len, off);
208-
}
201+
if ( xlrec.len > 0 )
202+
gistfillbuffer(reln, page, xlrec.itup, xlrec.len, InvalidOffsetNumber);
209203

210204
/* special case: leafpage, nothing to insert, nothing to delete, then
211205
vacuum marks page */
@@ -623,9 +617,7 @@ gistContinueInsert(gistIncompleteInsert *insert) {
623617
}
624618
}
625619
} else
626-
gistfillbuffer( index, pages[numbuffer-1], itup, lenitup,
627-
(PageIsEmpty(pages[numbuffer-1])) ?
628-
FirstOffsetNumber : OffsetNumberNext(PageGetMaxOffsetNumber(pages[numbuffer-1])) );
620+
gistfillbuffer( index, pages[numbuffer-1], itup, lenitup, InvalidOffsetNumber);
629621

630622
lenitup=numbuffer;
631623
for(j=0;j<numbuffer;j++) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy