mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
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:
parent
33766e680d
commit
276fc7ce82
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* 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,
|
||||
IndexTuple *itup,
|
||||
int len,
|
||||
OffsetNumber off,
|
||||
GISTSTATE *giststate);
|
||||
OffsetNumber off);
|
||||
static int gistnospace(Page page,
|
||||
IndexTuple *itvec, int len);
|
||||
static IndexTuple *gistreadbuffer(Relation r,
|
||||
Buffer buffer, int *len);
|
||||
static IndexTuple *gistreadbuffer(Buffer buffer, int *len);
|
||||
static IndexTuple *gistjoinvector(
|
||||
IndexTuple *itvec, int *len,
|
||||
IndexTuple *additvec, int addlen);
|
||||
@ -117,7 +115,7 @@ static IndexTuple *gistSplit(Relation r,
|
||||
int *len,
|
||||
GISTSTATE *giststate,
|
||||
InsertIndexResult *res);
|
||||
static void gistnewroot(GISTSTATE *giststate, Relation r,
|
||||
static void gistnewroot(Relation r,
|
||||
IndexTuple *itup, int len);
|
||||
static void GISTInitBuffer(Buffer b, uint32 f);
|
||||
static OffsetNumber gistchoose(Relation r, Page p,
|
||||
@ -359,11 +357,11 @@ gistinsert(PG_FUNCTION_ARGS)
|
||||
|
||||
#ifdef GIST_PAGEADDITEM
|
||||
/*
|
||||
** 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
|
||||
** that knowledge (some compression routines may want to fish around
|
||||
** on the page, for example, or do something special for leaf nodes.)
|
||||
*/
|
||||
* 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
|
||||
* that knowledge (some compression routines may want to fish around
|
||||
* on the page, for example, or do something special for leaf nodes.)
|
||||
*/
|
||||
static OffsetNumber
|
||||
gistPageAddItem(GISTSTATE *giststate,
|
||||
Relation r,
|
||||
@ -425,7 +423,7 @@ gistdoinsert(Relation r,
|
||||
|
||||
ret = gistlayerinsert(r, GISTP_ROOT, &instup, &len, res, giststate);
|
||||
if (ret & SPLITED)
|
||||
gistnewroot(giststate, r, instup, len);
|
||||
gistnewroot(r, instup, len);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
pfree(instup[i]);
|
||||
@ -452,7 +450,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
|
||||
if (!(opaque->flags & F_LEAF))
|
||||
{
|
||||
/* internal page, so we must walk on tree */
|
||||
/* len IS equial 1 */
|
||||
/* len IS equal 1 */
|
||||
ItemId iid;
|
||||
BlockNumber nblkno;
|
||||
ItemPointerData oldtid;
|
||||
@ -509,7 +507,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
|
||||
oldlen;
|
||||
|
||||
ret |= SPLITED;
|
||||
itvec = gistreadbuffer(r, buffer, &tlen);
|
||||
itvec = gistreadbuffer(buffer, &tlen);
|
||||
itvec = gistjoinvector(itvec, &tlen, (*itup), *len);
|
||||
oldlen = *len;
|
||||
newitup = gistSplit(r, buffer, itvec, &tlen, giststate,
|
||||
@ -534,7 +532,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
|
||||
FirstOffsetNumber
|
||||
:
|
||||
OffsetNumberNext(PageGetMaxOffsetNumber(page));
|
||||
l = gistwritebuffer(r, page, (*itup), *len, off, giststate);
|
||||
l = gistwritebuffer(r, page, (*itup), *len, off);
|
||||
WriteBuffer(buffer);
|
||||
|
||||
/*
|
||||
@ -570,7 +568,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
|
||||
*/
|
||||
static OffsetNumber
|
||||
gistwritebuffer(Relation r, Page page, IndexTuple *itup,
|
||||
int len, OffsetNumber off, GISTSTATE *giststate)
|
||||
int len, OffsetNumber off)
|
||||
{
|
||||
OffsetNumber l = InvalidOffsetNumber;
|
||||
int i;
|
||||
@ -609,7 +607,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup,
|
||||
static int
|
||||
gistnospace(Page page, IndexTuple *itvec, int len)
|
||||
{
|
||||
int size = 0;
|
||||
unsigned int size = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
@ -622,7 +620,7 @@ gistnospace(Page page, IndexTuple *itvec, int len)
|
||||
* Read buffer into itup vector
|
||||
*/
|
||||
static IndexTuple *
|
||||
gistreadbuffer(Relation r, Buffer buffer, int *len /* out */ )
|
||||
gistreadbuffer(Buffer buffer, int *len /* out */ )
|
||||
{
|
||||
OffsetNumber i,
|
||||
maxoff;
|
||||
@ -1365,7 +1363,7 @@ gistSplit(Relation r,
|
||||
{
|
||||
OffsetNumber l;
|
||||
|
||||
l = gistwritebuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber, giststate);
|
||||
l = gistwritebuffer(r, right, rvectup, v.spl_nright, FirstOffsetNumber);
|
||||
WriteBuffer(rightbuf);
|
||||
|
||||
if (res)
|
||||
@ -1398,7 +1396,7 @@ gistSplit(Relation r,
|
||||
{
|
||||
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)
|
||||
PageRestoreTempPage(left, p);
|
||||
|
||||
@ -1428,7 +1426,7 @@ gistSplit(Relation r,
|
||||
}
|
||||
|
||||
static void
|
||||
gistnewroot(GISTSTATE *giststate, Relation r, IndexTuple *itup, int len)
|
||||
gistnewroot(Relation r, IndexTuple *itup, int len)
|
||||
{
|
||||
Buffer b;
|
||||
Page p;
|
||||
@ -1437,7 +1435,7 @@ gistnewroot(GISTSTATE *giststate, Relation r, IndexTuple *itup, int len)
|
||||
GISTInitBuffer(b, 0);
|
||||
p = BufferGetPage(b);
|
||||
|
||||
gistwritebuffer(r, p, itup, len, FirstOffsetNumber, giststate);
|
||||
gistwritebuffer(r, p, itup, len, FirstOffsetNumber);
|
||||
WriteBuffer(b);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* 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 gistnext(IndexScanDesc s, ScanDirection dir);
|
||||
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,
|
||||
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 */
|
||||
static bool
|
||||
gistindex_keytest(IndexTuple tuple,
|
||||
TupleDesc tupdesc,
|
||||
int scanKeySize,
|
||||
ScanKey key,
|
||||
GISTSTATE *giststate,
|
||||
@ -314,7 +313,6 @@ gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir)
|
||||
{
|
||||
it = (IndexTuple) PageGetItem(p, PageGetItemId(p, n));
|
||||
if (gistindex_keytest(it,
|
||||
RelationGetDescr(s->relation),
|
||||
s->numberOfKeys, s->keyData, giststate,
|
||||
s->relation, p, n))
|
||||
break;
|
||||
|
@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* 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 gistadjone(IndexScanDesc s, int op, BlockNumber blkno,
|
||||
OffsetNumber offnum);
|
||||
static void adjuststack(GISTSTACK *stk, BlockNumber blkno,
|
||||
OffsetNumber offnum);
|
||||
static void adjuststack(GISTSTACK *stk, BlockNumber blkno);
|
||||
static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
|
||||
int op, BlockNumber blkno, OffsetNumber offnum);
|
||||
|
||||
@ -340,8 +339,8 @@ gistadjone(IndexScanDesc s,
|
||||
|
||||
if (op == GISTOP_SPLIT)
|
||||
{
|
||||
adjuststack(so->s_stack, blkno, offnum);
|
||||
adjuststack(so->s_markstk, blkno, offnum);
|
||||
adjuststack(so->s_stack, blkno);
|
||||
adjuststack(so->s_markstk, blkno);
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,8 +427,7 @@ adjustiptr(IndexScanDesc s,
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
adjuststack(GISTSTACK *stk,
|
||||
BlockNumber blkno,
|
||||
OffsetNumber offnum)
|
||||
BlockNumber blkno)
|
||||
{
|
||||
while (stk != (GISTSTACK *) NULL)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* 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 rtadjone(IndexScanDesc s, int op, BlockNumber blkno,
|
||||
OffsetNumber offnum);
|
||||
static void adjuststack(RTSTACK *stk, BlockNumber blkno,
|
||||
OffsetNumber offnum);
|
||||
static void adjuststack(RTSTACK *stk, BlockNumber blkno);
|
||||
static void adjustiptr(IndexScanDesc s, ItemPointer iptr,
|
||||
int op, BlockNumber blkno, OffsetNumber offnum);
|
||||
|
||||
@ -337,8 +336,8 @@ rtadjone(IndexScanDesc s,
|
||||
|
||||
if (op == RTOP_SPLIT)
|
||||
{
|
||||
adjuststack(so->s_stack, blkno, offnum);
|
||||
adjuststack(so->s_markstk, blkno, offnum);
|
||||
adjuststack(so->s_stack, blkno);
|
||||
adjuststack(so->s_markstk, blkno);
|
||||
}
|
||||
}
|
||||
|
||||
@ -425,8 +424,7 @@ adjustiptr(IndexScanDesc s,
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
adjuststack(RTSTACK *stk,
|
||||
BlockNumber blkno,
|
||||
OffsetNumber offnum)
|
||||
BlockNumber blkno)
|
||||
{
|
||||
while (stk != (RTSTACK *) NULL)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user