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.114 2005/05/11 06:24:50 neilc Exp $
11+ * $PostgreSQL: pgsql/src/backend/access/gist/gist.c,v 1.115 2005/05/15 04:08:29 neilc Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
2525
2626#undef GIST_PAGEADDITEM
2727
28- #define ATTSIZE (datum ,TupDesc ,i ,isnull ) \
28+ #define ATTSIZE (datum ,TupDesc ,i ,isnull ) \
2929( \
30- ( isnull ) ? 0 : \
30+ (isnull) ? 0 : \
3131att_addlength(0, (TupDesc)->attrs[(i)-1]->attlen, (datum)) \
3232)
3333
4545 * and gistadjsubkey only
4646 */
4747#define FILLITEM (evp ,isnullkey ,okey ,okeyb ,rkey ,rkeyb ) do { \
48- if ( isnullkey ) { \
49- gistentryinit((evp), rkey, r, NULL, \
50- (OffsetNumber) 0, rkeyb, FALSE); \
48+ if (isnullkey) { \
49+ gistentryinit((evp), rkey, r, NULL, \
50+ (OffsetNumber) 0, rkeyb, FALSE); \
5151} else { \
52- gistentryinit((evp), okey, r, NULL, \
53- (OffsetNumber) 0, okeyb, FALSE); \
52+ gistentryinit((evp), okey, r, NULL, \
53+ (OffsetNumber) 0, okeyb, FALSE); \
5454} \
5555} while(0)
5656
@@ -87,8 +87,7 @@ static OffsetNumber gistwritebuffer(Relation r,
8787IndexTuple * itup ,
8888int len ,
8989OffsetNumber off );
90- static int gistnospace (Page page ,
91- IndexTuple * itvec ,int len );
90+ static bool gistnospace (Page page ,IndexTuple * itvec ,int len );
9291static IndexTuple * gistreadbuffer (Buffer buffer ,int * len );
9392static IndexTuple * gistjoinvector (
9493IndexTuple * itvec ,int * len ,
@@ -107,14 +106,13 @@ static void gistadjsubkey(Relation r,
107106GIST_SPLITVEC * v ,
108107GISTSTATE * giststate );
109108static IndexTuple gistFormTuple (GISTSTATE * giststate ,
110- Relation r ,Datum attdata [] ,int datumsize [] ,bool isnull [] );
109+ Relation r ,Datum * attdata ,int * datumsize ,bool * isnull );
111110static IndexTuple * gistSplit (Relation r ,
112111Buffer buffer ,
113112IndexTuple * itup ,
114113int * len ,
115114GISTSTATE * giststate );
116- static void gistnewroot (Relation r ,
117- IndexTuple * itup ,int len );
115+ static void gistnewroot (Relation r ,IndexTuple * itup ,int len );
118116static void GISTInitBuffer (Buffer b ,uint32 f );
119117static OffsetNumber gistchoose (Relation r ,Page p ,
120118IndexTuple it ,
@@ -131,8 +129,8 @@ static void gistcentryinit(GISTSTATE *giststate, int nkey,
131129OffsetNumber o ,int b ,bool l ,bool isNull );
132130static void gistDeCompressAtt (GISTSTATE * giststate ,Relation r ,
133131IndexTuple tuple ,Page p ,OffsetNumber o ,
134- GISTENTRY attdata [] ,bool decompvec [] ,bool isnull [] );
135- static void gistFreeAtt (Relation r ,GISTENTRY attdata [] ,bool decompvec [] );
132+ GISTENTRY * attdata ,bool * decompvec ,bool * isnull );
133+ static void gistFreeAtt (Relation r ,GISTENTRY * attdata ,bool * decompvec );
136134static void gistpenalty (GISTSTATE * giststate ,int attno ,
137135GISTENTRY * key1 ,bool isNull1 ,
138136GISTENTRY * key2 ,bool isNull2 ,
@@ -503,7 +501,7 @@ gistlayerinsert(Relation r, BlockNumber blkno,
503501}
504502else
505503{
506- /*enogth space */
504+ /*enough space */
507505OffsetNumber off ,
508506l ;
509507
@@ -577,7 +575,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup,
577575/*
578576 * Check space for itup vector on page
579577 */
580- static int
578+ static bool
581579gistnospace (Page page ,IndexTuple * itvec ,int len )
582580{
583581unsignedint size = 0 ;
@@ -934,7 +932,7 @@ gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITV
934932}
935933
936934/*
937- * find group in vector withequial value
935+ * find group in vector withequal value
938936 */
939937static int
940938gistfindgroup (GISTSTATE * giststate ,GISTENTRY * valvec ,GIST_SPLITVEC * spl )
@@ -949,7 +947,6 @@ gistfindgroup(GISTSTATE *giststate, GISTENTRY *valvec, GIST_SPLITVEC *spl)
949947 * first key is always not null (see gistinsert), so we may not check
950948 * for nulls
951949 */
952-
953950for (i = 0 ;i < spl -> spl_nleft ;i ++ )
954951{
955952if (spl -> spl_idgrp [spl -> spl_left [i ]])
@@ -1007,8 +1004,7 @@ gistadjsubkey(Relation r,
10071004IndexTuple * itup ,/* contains compressed entry */
10081005int * len ,
10091006GIST_SPLITVEC * v ,
1010- GISTSTATE * giststate
1011- )
1007+ GISTSTATE * giststate )
10121008{
10131009int curlen ;
10141010OffsetNumber * curwpos ;
@@ -1400,8 +1396,8 @@ GISTInitBuffer(Buffer b, uint32 f)
14001396
14011397
14021398/*
1403- * * find entry with lowest penalty
1404- */
1399+ * find entry with lowest penalty
1400+ */
14051401static OffsetNumber
14061402gistchoose (Relation r ,Page p ,IndexTuple it ,/* it has compressed entry */
14071403GISTSTATE * giststate )
@@ -1643,12 +1639,12 @@ freeGISTstate(GISTSTATE *giststate)
16431639
16441640#ifdef GIST_PAGEADDITEM
16451641/*
1646- * * Given an IndexTuple to be inserted on a page, this routine replaces
1647- * * the key with another key, which may involve generating a new IndexTuple
1648- * * if the sizes don't match or if the null status changes.
1649- * *
1650- * * XXX this only works for a single-column index tuple!
1651- */
1642+ * Given an IndexTuple to be inserted on a page, this routine replaces
1643+ * the key with another key, which may involve generating a new IndexTuple
1644+ * if the sizes don't match or if the null status changes.
1645+ *
1646+ * XXX this only works for a single-column index tuple!
1647+ */
16521648static IndexTuple
16531649gist_tuple_replacekey (Relation r ,GISTENTRY entry ,IndexTuple t )
16541650{
@@ -1690,8 +1686,8 @@ gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t)
16901686#endif
16911687
16921688/*
1693- * * initialize a GiST entry with a decompressed version of key
1694- */
1689+ * initialize a GiST entry with a decompressed version of key
1690+ */
16951691void
16961692gistdentryinit (GISTSTATE * giststate ,int nkey ,GISTENTRY * e ,
16971693Datum k ,Relation r ,Page pg ,OffsetNumber o ,
@@ -1719,8 +1715,8 @@ gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
17191715
17201716
17211717/*
1722- * * initialize a GiST entry with a compressed version of key
1723- */
1718+ * initialize a GiST entry with a compressed version of key
1719+ */
17241720static void
17251721gistcentryinit (GISTSTATE * giststate ,int nkey ,
17261722GISTENTRY * e ,Datum k ,Relation r ,
@@ -1790,7 +1786,7 @@ gistFormTuple(GISTSTATE *giststate, Relation r,
17901786
17911787static void
17921788gistDeCompressAtt (GISTSTATE * giststate ,Relation r ,IndexTuple tuple ,Page p ,
1793- OffsetNumber o ,GISTENTRY attdata [] ,bool decompvec [] ,bool isnull [] )
1789+ OffsetNumber o ,GISTENTRY * attdata ,bool * decompvec ,bool * isnull )
17941790{
17951791int i ;
17961792Datum datum ;
@@ -1814,7 +1810,7 @@ gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p,
18141810}
18151811
18161812static void
1817- gistFreeAtt (Relation r ,GISTENTRY attdata [] ,bool decompvec [] )
1813+ gistFreeAtt (Relation r ,GISTENTRY * attdata ,bool * decompvec )
18181814{
18191815int i ;
18201816