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

Commit 276fc7c

Browse files
committed
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
1 parent 33766e6 commit 276fc7c

File tree

4 files changed

+32
-40
lines changed

4 files changed

+32
-40
lines changed

src/backend/access/gist/gist.c

Lines changed: 20 additions & 22 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-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.89 2002/03/02 21:39:16 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.90 2002/03/05 05:30:31 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -87,12 +87,10 @@ static OffsetNumber gistwritebuffer(Relation r,
8787
Page page,
8888
IndexTuple *itup,
8989
int len,
90-
OffsetNumber off,
91-
GISTSTATE *giststate);
90+
OffsetNumber off);
9291
static int gistnospace(Page page,
9392
IndexTuple *itvec, int len);
94-
static IndexTuple *gistreadbuffer(Relation r,
95-
Buffer buffer, int *len);
93+
static IndexTuple *gistreadbuffer(Buffer buffer, int *len);
9694
static IndexTuple *gistjoinvector(
9795
IndexTuple *itvec, int *len,
9896
IndexTuple *additvec, int addlen);
@@ -117,7 +115,7 @@ static IndexTuple *gistSplit(Relation r,
117115
int *len,
118116
GISTSTATE *giststate,
119117
InsertIndexResult *res);
120-
static void gistnewroot(GISTSTATE *giststate, Relation r,
118+
static void gistnewroot(Relation r,
121119
IndexTuple *itup, int len);
122120
static void GISTInitBuffer(Buffer b, uint32 f);
123121
static OffsetNumber gistchoose(Relation r, Page p,
@@ -359,11 +357,11 @@ gistinsert(PG_FUNCTION_ARGS)
359357

360358
#ifdef GIST_PAGEADDITEM
361359
/*
362-
** Take a compressed entry, and install it on a page. Since we now know
363-
** where the entry will live, we decompress it and recompress it using
364-
** that knowledge (some compression routines may want to fish around
365-
** on the page, for example, or do something special for leaf nodes.)
366-
*/
360+
* Take a compressed entry, and install it on a page. Since we now know
361+
* where the entry will live, we decompress it and recompress it using
362+
* that knowledge (some compression routines may want to fish around
363+
* on the page, for example, or do something special for leaf nodes.)
364+
*/
367365
static OffsetNumber
368366
gistPageAddItem(GISTSTATE *giststate,
369367
Relation r,
@@ -425,7 +423,7 @@ gistdoinsert(Relation r,
425423

426424
ret = gistlayerinsert(r, GISTP_ROOT, &instup, &len, res, giststate);
427425
if (ret & SPLITED)
428-
gistnewroot(giststate, r, instup, len);
426+
gistnewroot(r, instup, len);
429427

430428
for (i = 0; i < len; i++)
431429
pfree(instup[i]);
@@ -452,7 +450,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
452450
if (!(opaque->flags & F_LEAF))
453451
{
454452
/* internal page, so we must walk on tree */
455-
/* len IS equial 1 */
453+
/* len IS equal 1 */
456454
ItemId iid;
457455
BlockNumber nblkno;
458456
ItemPointerData oldtid;
@@ -509,7 +507,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
509507
oldlen;
510508

511509
ret |= SPLITED;
512-
itvec = gistreadbuffer(r, buffer, &tlen);
510+
itvec = gistreadbuffer(buffer, &tlen);
513511
itvec = gistjoinvector(itvec, &tlen, (*itup), *len);
514512
oldlen = *len;
515513
newitup = gistSplit(r, buffer, itvec, &tlen, giststate,
@@ -534,7 +532,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
534532
FirstOffsetNumber
535533
:
536534
OffsetNumberNext(PageGetMaxOffsetNumber(page));
537-
l = gistwritebuffer(r, page, (*itup), *len, off, giststate);
535+
l = gistwritebuffer(r, page, (*itup), *len, off);
538536
WriteBuffer(buffer);
539537

540538
/*
@@ -570,7 +568,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
570568
*/
571569
static OffsetNumber
572570
gistwritebuffer(Relation r, Page page, IndexTuple *itup,
573-
int len, OffsetNumber off, GISTSTATE *giststate)
571+
int len, OffsetNumber off)
574572
{
575573
OffsetNumber l = InvalidOffsetNumber;
576574
int i;
@@ -609,7 +607,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup,
609607
static int
610608
gistnospace(Page page, IndexTuple *itvec, int len)
611609
{
612-
int size = 0;
610+
unsigned int size = 0;
613611
int i;
614612

615613
for (i = 0; i < len; i++)
@@ -622,7 +620,7 @@ gistnospace(Page page, IndexTuple *itvec, int len)
622620
* Read buffer into itup vector
623621
*/
624622
static IndexTuple *
625-
gistreadbuffer(Relation r, Buffer buffer, int *len /* out */ )
623+
gistreadbuffer(Buffer buffer, int *len /* out */ )
626624
{
627625
OffsetNumber i,
628626
maxoff;
@@ -1365,7 +1363,7 @@ gistSplit(Relation r,
13651363
{
13661364
OffsetNumber l;
13671365

1368-
l = gistwritebuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber, giststate);
1366+
l = gistwritebuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber);
13691367
WriteBuffer(rightbuf);
13701368

13711369
if (res)
@@ -1398,7 +1396,7 @@ gistSplit(Relation r,
13981396
{
13991397
OffsetNumber l;
14001398

1401-
l = gistwritebuffer(r, left, lvectup, v.spl_nleft, FirstOffsetNumber, giststate);
1399+
l = gistwritebuffer(r, left, lvectup, v.spl_nleft, FirstOffsetNumber);
14021400
if (BufferGetBlockNumber(buffer) != GISTP_ROOT)
14031401
PageRestoreTempPage(left, p);
14041402

@@ -1428,7 +1426,7 @@ gistSplit(Relation r,
14281426
}
14291427

14301428
static void
1431-
gistnewroot(GISTSTATE *giststate, Relation r, IndexTuple *itup, int len)
1429+
gistnewroot(Relation r, IndexTuple *itup, int len)
14321430
{
14331431
Buffer b;
14341432
Page p;
@@ -1437,7 +1435,7 @@ gistnewroot(GISTSTATE *giststate, Relation r, IndexTuple *itup, int len)
14371435
GISTInitBuffer(b, 0);
14381436
p = BufferGetPage(b);
14391437

1440-
gistwritebuffer(r, p, itup, len, FirstOffsetNumber, giststate);
1438+
gistwritebuffer(r, p, itup, len, FirstOffsetNumber);
14411439
WriteBuffer(b);
14421440
}
14431441

src/backend/access/gist/gistget.c

Lines changed: 2 additions & 4 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-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.31 2001/10/25 05:49:20 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.32 2002/03/05 05:30:31 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -24,7 +24,7 @@ static RetrieveIndexResult gistscancache(IndexScanDesc s, ScanDirection dir);
2424
static RetrieveIndexResult gistfirst(IndexScanDesc s, ScanDirection dir);
2525
static RetrieveIndexResult gistnext(IndexScanDesc s, ScanDirection dir);
2626
static ItemPointer gistheapptr(Relation r, ItemPointer itemp);
27-
static bool gistindex_keytest(IndexTuple tuple, TupleDesc tupdesc,
27+
static bool gistindex_keytest(IndexTuple tuple,
2828
int scanKeySize, ScanKey key, GISTSTATE *giststate,
2929
Relation r, Page p, OffsetNumber offset);
3030

@@ -219,7 +219,6 @@ gistnext(IndexScanDesc s, ScanDirection dir)
219219
/* Similar to index_keytest, but decompresses the key in the IndexTuple */
220220
static bool
221221
gistindex_keytest(IndexTuple tuple,
222-
TupleDesc tupdesc,
223222
int scanKeySize,
224223
ScanKey key,
225224
GISTSTATE *giststate,
@@ -314,7 +313,6 @@ gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
314313
{
315314
it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
316315
if (gistindex_keytest(it,
317-
RelationGetDescr(s->relation),
318316
s->numberOfKeys, s->keyData, giststate,
319317
s->relation, p, n))
320318
break;

src/backend/access/gist/gistscan.c

Lines changed: 5 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-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.40 2001/10/25 05:49:20 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistscan.c,v 1.41 2002/03/05 05:30:35 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -24,8 +24,7 @@ static void gistregscan(IndexScanDesc s);
2424
static void gistdropscan(IndexScanDesc s);
2525
static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
2626
OffsetNumber offnum);
27-
static void adjuststack(GISTSTACK *stk, BlockNumber blkno,
28-
OffsetNumber offnum);
27+
static void adjuststack(GISTSTACK *stk, BlockNumber blkno);
2928
static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
3029
int op, BlockNumber blkno, OffsetNumber offnum);
3130

@@ -340,8 +339,8 @@ gistadjone(IndexScanDesc s,
340339

341340
if (op == GISTOP_SPLIT)
342341
{
343-
adjuststack(so->s_stack, blkno, offnum);
344-
adjuststack(so->s_markstk, blkno, offnum);
342+
adjuststack(so->s_stack, blkno);
343+
adjuststack(so->s_markstk, blkno);
345344
}
346345
}
347346

@@ -428,8 +427,7 @@ adjustiptr(IndexScanDesc s,
428427
/*ARGSUSED*/
429428
static void
430429
adjuststack(GISTSTACK *stk,
431-
BlockNumber blkno,
432-
OffsetNumber offnum)
430+
BlockNumber blkno)
433431
{
434432
while (stk != (GISTSTACK *) NULL)
435433
{

src/backend/access/rtree/rtscan.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.39 2001/10/25 05:49:21 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.40 2002/03/05 05:30:40 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -25,8 +25,7 @@ static void rtregscan(IndexScanDesc s);
2525
static void rtdropscan(IndexScanDesc s);
2626
static void rtadjone(IndexScanDesc s, int op, BlockNumber blkno,
2727
OffsetNumber offnum);
28-
static void adjuststack(RTSTACK *stk, BlockNumber blkno,
29-
OffsetNumber offnum);
28+
static void adjuststack(RTSTACK *stk, BlockNumber blkno);
3029
static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
3130
int op, BlockNumber blkno, OffsetNumber offnum);
3231

@@ -337,8 +336,8 @@ rtadjone(IndexScanDesc s,
337336

338337
if (op == RTOP_SPLIT)
339338
{
340-
adjuststack(so->s_stack, blkno, offnum);
341-
adjuststack(so->s_markstk, blkno, offnum);
339+
adjuststack(so->s_stack, blkno);
340+
adjuststack(so->s_markstk, blkno);
342341
}
343342
}
344343

@@ -425,8 +424,7 @@ adjustiptr(IndexScanDesc s,
425424
/*ARGSUSED*/
426425
static void
427426
adjuststack(RTSTACK *stk,
428-
BlockNumber blkno,
429-
OffsetNumber offnum)
427+
BlockNumber blkno)
430428
{
431429
while (stk != (RTSTACK *) NULL)
432430
{

0 commit comments

Comments
 (0)