I was digging through the GiST code, and figured I'd fix up some of the

"bad smell" in that code. Stuff like function parameters that aren't
used, typos in the comments, comparison between signed and unsigned
ints, etc.

Attached is a pretty trivial patch; it compiles, but beyond that
completely untested. Unless anyone sees any problems, please apply for
7.3.

Neil Conway
This commit is contained in:
Bruce Momjian 2002-03-05 05:30:40 +00:00
parent 33766e680d
commit 276fc7ce82
4 changed files with 32 additions and 40 deletions

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.89 2002/03/02 21:39:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.90 2002/03/05 05:30:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -87,12 +87,10 @@ static OffsetNumber gistwritebuffer(Relation r,
Page page, Page page,
IndexTuple *itup, IndexTuple *itup,
int len, int len,
OffsetNumber off, OffsetNumber off);
GISTSTATE *giststate);
static int gistnospace(Page page, static int gistnospace(Page page,
IndexTuple *itvec, int len); IndexTuple *itvec, int len);
static IndexTuple *gistreadbuffer(Relation r, static IndexTuple *gistreadbuffer(Buffer buffer, int *len);
Buffer buffer, int *len);
static IndexTuple *gistjoinvector( static IndexTuple *gistjoinvector(
IndexTuple *itvec, int *len, IndexTuple *itvec, int *len,
IndexTuple *additvec, int addlen); IndexTuple *additvec, int addlen);
@ -117,7 +115,7 @@ static IndexTuple *gistSplit(Relation r,
int *len, int *len,
GISTSTATE *giststate, GISTSTATE *giststate,
InsertIndexResult *res); InsertIndexResult *res);
static void gistnewroot(GISTSTATE *giststate, Relation r, static void gistnewroot(Relation r,
IndexTuple *itup, int len); IndexTuple *itup, int len);
static void GISTInitBuffer(Buffer b, uint32 f); static void GISTInitBuffer(Buffer b, uint32 f);
static OffsetNumber gistchoose(Relation r, Page p, static OffsetNumber gistchoose(Relation r, Page p,
@ -359,11 +357,11 @@ gistinsert(PG_FUNCTION_ARGS)
#ifdef GIST_PAGEADDITEM #ifdef GIST_PAGEADDITEM
/* /*
** Take a compressed entry, and install it on a page. Since we now know * Take a compressed entry, and install it on a page. Since we now know
** where the entry will live, we decompress it and recompress it using * where the entry will live, we decompress it and recompress it using
** that knowledge (some compression routines may want to fish around * that knowledge (some compression routines may want to fish around
** on the page, for example, or do something special for leaf nodes.) * on the page, for example, or do something special for leaf nodes.)
*/ */
static OffsetNumber static OffsetNumber
gistPageAddItem(GISTSTATE *giststate, gistPageAddItem(GISTSTATE *giststate,
Relation r, Relation r,
@ -425,7 +423,7 @@ gistdoinsert(Relation r,
ret = gistlayerinsert(r, GISTP_ROOT, &instup, &len, res, giststate); ret = gistlayerinsert(r, GISTP_ROOT, &instup, &len, res, giststate);
if (ret & SPLITED) if (ret & SPLITED)
gistnewroot(giststate, r, instup, len); gistnewroot(r, instup, len);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
pfree(instup[i]); pfree(instup[i]);
@ -452,7 +450,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
if (!(opaque->flags & F_LEAF)) if (!(opaque->flags & F_LEAF))
{ {
/* internal page, so we must walk on tree */ /* internal page, so we must walk on tree */
/* len IS equial 1 */ /* len IS equal 1 */
ItemId iid; ItemId iid;
BlockNumber nblkno; BlockNumber nblkno;
ItemPointerData oldtid; ItemPointerData oldtid;
@ -509,7 +507,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
oldlen; oldlen;
ret |= SPLITED; ret |= SPLITED;
itvec = gistreadbuffer(r, buffer, &tlen); itvec = gistreadbuffer(buffer, &tlen);
itvec = gistjoinvector(itvec, &tlen, (*itup), *len); itvec = gistjoinvector(itvec, &tlen, (*itup), *len);
oldlen = *len; oldlen = *len;
newitup = gistSplit(r, buffer, itvec, &tlen, giststate, newitup = gistSplit(r, buffer, itvec, &tlen, giststate,
@ -534,7 +532,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
FirstOffsetNumber FirstOffsetNumber
: :
OffsetNumberNext(PageGetMaxOffsetNumber(page)); OffsetNumberNext(PageGetMaxOffsetNumber(page));
l = gistwritebuffer(r, page, (*itup), *len, off, giststate); l = gistwritebuffer(r, page, (*itup), *len, off);
WriteBuffer(buffer); WriteBuffer(buffer);
/* /*
@ -570,7 +568,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
*/ */
static OffsetNumber static OffsetNumber
gistwritebuffer(Relation r, Page page, IndexTuple *itup, gistwritebuffer(Relation r, Page page, IndexTuple *itup,
int len, OffsetNumber off, GISTSTATE *giststate) int len, OffsetNumber off)
{ {
OffsetNumber l = InvalidOffsetNumber; OffsetNumber l = InvalidOffsetNumber;
int i; int i;
@ -609,7 +607,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup,
static int static int
gistnospace(Page page, IndexTuple *itvec, int len) gistnospace(Page page, IndexTuple *itvec, int len)
{ {
int size = 0; unsigned int size = 0;
int i; int i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
@ -622,7 +620,7 @@ gistnospace(Page page, IndexTuple *itvec, int len)
* Read buffer into itup vector * Read buffer into itup vector
*/ */
static IndexTuple * static IndexTuple *
gistreadbuffer(Relation r, Buffer buffer, int *len /* out */ ) gistreadbuffer(Buffer buffer, int *len /* out */ )
{ {
OffsetNumber i, OffsetNumber i,
maxoff; maxoff;
@ -1365,7 +1363,7 @@ gistSplit(Relation r,
{ {
OffsetNumber l; OffsetNumber l;
l = gistwritebuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber, giststate); l = gistwritebuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber);
WriteBuffer(rightbuf); WriteBuffer(rightbuf);
if (res) if (res)
@ -1398,7 +1396,7 @@ gistSplit(Relation r,
{ {
OffsetNumber l; OffsetNumber l;
l = gistwritebuffer(r, left, lvectup, v.spl_nleft, FirstOffsetNumber, giststate); l = gistwritebuffer(r, left, lvectup, v.spl_nleft, FirstOffsetNumber);
if (BufferGetBlockNumber(buffer) != GISTP_ROOT) if (BufferGetBlockNumber(buffer) != GISTP_ROOT)
PageRestoreTempPage(left, p); PageRestoreTempPage(left, p);
@ -1428,7 +1426,7 @@ gistSplit(Relation r,
} }
static void static void
gistnewroot(GISTSTATE *giststate, Relation r, IndexTuple *itup, int len) gistnewroot(Relation r, IndexTuple *itup, int len)
{ {
Buffer b; Buffer b;
Page p; Page p;
@ -1437,7 +1435,7 @@ gistnewroot(GISTSTATE *giststate, Relation r, IndexTuple *itup, int len)
GISTInitBuffer(b, 0); GISTInitBuffer(b, 0);
p = BufferGetPage(b); p = BufferGetPage(b);
gistwritebuffer(r, p, itup, len, FirstOffsetNumber, giststate); gistwritebuffer(r, p, itup, len, FirstOffsetNumber);
WriteBuffer(b); WriteBuffer(b);
} }

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.31 2001/10/25 05:49:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.32 2002/03/05 05:30:31 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -24,7 +24,7 @@ static RetrieveIndexResult gistscancache(IndexScanDesc s, ScanDirection dir);
static RetrieveIndexResult gistfirst(IndexScanDesc s, ScanDirection dir); static RetrieveIndexResult gistfirst(IndexScanDesc s, ScanDirection dir);
static RetrieveIndexResult gistnext(IndexScanDesc s, ScanDirection dir); static RetrieveIndexResult gistnext(IndexScanDesc s, ScanDirection dir);
static ItemPointer gistheapptr(Relation r, ItemPointer itemp); static ItemPointer gistheapptr(Relation r, ItemPointer itemp);
static bool gistindex_keytest(IndexTuple tuple, TupleDesc tupdesc, static bool gistindex_keytest(IndexTuple tuple,
int scanKeySize, ScanKey key, GISTSTATE *giststate, int scanKeySize, ScanKey key, GISTSTATE *giststate,
Relation r, Page p, OffsetNumber offset); Relation r, Page p, OffsetNumber offset);
@ -219,7 +219,6 @@ gistnext(IndexScanDesc s, ScanDirection dir)
/* Similar to index_keytest, but decompresses the key in the IndexTuple */ /* Similar to index_keytest, but decompresses the key in the IndexTuple */
static bool static bool
gistindex_keytest(IndexTuple tuple, gistindex_keytest(IndexTuple tuple,
TupleDesc tupdesc,
int scanKeySize, int scanKeySize,
ScanKey key, ScanKey key,
GISTSTATE *giststate, GISTSTATE *giststate,
@ -314,7 +313,6 @@ gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
{ {
it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n)); it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
if (gistindex_keytest(it, if (gistindex_keytest(it,
RelationGetDescr(s->relation),
s->numberOfKeys, s->keyData, giststate, s->numberOfKeys, s->keyData, giststate,
s->relation, p, n)) s->relation, p, n))
break; break;

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.40 2001/10/25 05:49:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.41 2002/03/05 05:30:35 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -24,8 +24,7 @@ static void gistregscan(IndexScanDesc s);
static void gistdropscan(IndexScanDesc s); static void gistdropscan(IndexScanDesc s);
static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno, static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
OffsetNumber offnum); OffsetNumber offnum);
static void adjuststack(GISTSTACK *stk, BlockNumber blkno, static void adjuststack(GISTSTACK *stk, BlockNumber blkno);
OffsetNumber offnum);
static void adjustiptr(IndexScanDesc s, ItemPointer iptr, static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
int op, BlockNumber blkno, OffsetNumber offnum); int op, BlockNumber blkno, OffsetNumber offnum);
@ -340,8 +339,8 @@ gistadjone(IndexScanDesc s,
if (op == GISTOP_SPLIT) if (op == GISTOP_SPLIT)
{ {
adjuststack(so->s_stack, blkno, offnum); adjuststack(so->s_stack, blkno);
adjuststack(so->s_markstk, blkno, offnum); adjuststack(so->s_markstk, blkno);
} }
} }
@ -428,8 +427,7 @@ adjustiptr(IndexScanDesc s,
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
adjuststack(GISTSTACK *stk, adjuststack(GISTSTACK *stk,
BlockNumber blkno, BlockNumber blkno)
OffsetNumber offnum)
{ {
while (stk != (GISTSTACK *) NULL) while (stk != (GISTSTACK *) NULL)
{ {

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.39 2001/10/25 05:49:21 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.40 2002/03/05 05:30:40 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -25,8 +25,7 @@ static void rtregscan(IndexScanDesc s);
static void rtdropscan(IndexScanDesc s); static void rtdropscan(IndexScanDesc s);
static void rtadjone(IndexScanDesc s, int op, BlockNumber blkno, static void rtadjone(IndexScanDesc s, int op, BlockNumber blkno,
OffsetNumber offnum); OffsetNumber offnum);
static void adjuststack(RTSTACK *stk, BlockNumber blkno, static void adjuststack(RTSTACK *stk, BlockNumber blkno);
OffsetNumber offnum);
static void adjustiptr(IndexScanDesc s, ItemPointer iptr, static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
int op, BlockNumber blkno, OffsetNumber offnum); int op, BlockNumber blkno, OffsetNumber offnum);
@ -337,8 +336,8 @@ rtadjone(IndexScanDesc s,
if (op == RTOP_SPLIT) if (op == RTOP_SPLIT)
{ {
adjuststack(so->s_stack, blkno, offnum); adjuststack(so->s_stack, blkno);
adjuststack(so->s_markstk, blkno, offnum); adjuststack(so->s_markstk, blkno);
} }
} }
@ -425,8 +424,7 @@ adjustiptr(IndexScanDesc s,
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
adjuststack(RTSTACK *stk, adjuststack(RTSTACK *stk,
BlockNumber blkno, BlockNumber blkno)
OffsetNumber offnum)
{ {
while (stk != (RTSTACK *) NULL) while (stk != (RTSTACK *) NULL)
{ {