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

Commit 8fa393a

Browse files
committed
Minor cleanup of GiST code, for readability.
Remove the gistcentryinit function, inlining the relevant part of it into the only caller.
1 parent bed756a commit 8fa393a

File tree

2 files changed

+16
-40
lines changed

2 files changed

+16
-40
lines changed

src/backend/access/gist/gistutil.c

+15-35
Original file line numberDiff line numberDiff line change
@@ -558,61 +558,41 @@ gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
558558
gistentryinit(*e, (Datum) 0, r, pg, o, l);
559559
}
560560

561-
562-
/*
563-
* initialize a GiST entry with a compressed version of key
564-
*/
565-
void
566-
gistcentryinit(GISTSTATE *giststate, int nkey,
567-
GISTENTRY *e, Datum k, Relation r,
568-
Page pg, OffsetNumber o, bool l, bool isNull)
569-
{
570-
if (!isNull)
571-
{
572-
GISTENTRY *cep;
573-
574-
gistentryinit(*e, k, r, pg, o, l);
575-
cep = (GISTENTRY *)
576-
DatumGetPointer(FunctionCall1Coll(&giststate->compressFn[nkey],
577-
giststate->supportCollation[nkey],
578-
PointerGetDatum(e)));
579-
/* compressFn may just return the given pointer */
580-
if (cep != e)
581-
gistentryinit(*e, cep->key, cep->rel, cep->page, cep->offset,
582-
cep->leafkey);
583-
}
584-
else
585-
gistentryinit(*e, (Datum) 0, r, pg, o, l);
586-
}
587-
588561
IndexTuple
589562
gistFormTuple(GISTSTATE *giststate, Relation r,
590-
Datum attdata[], bool isnull[], bool newValues)
563+
Datum attdata[], bool isnull[], bool isleaf)
591564
{
592-
GISTENTRY centry[INDEX_MAX_KEYS];
593565
Datum compatt[INDEX_MAX_KEYS];
594566
int i;
595567
IndexTuple res;
596568

569+
/*
570+
* Call the compress method on each attribute.
571+
*/
597572
for (i = 0; i < r->rd_att->natts; i++)
598573
{
599574
if (isnull[i])
600575
compatt[i] = (Datum) 0;
601576
else
602577
{
603-
gistcentryinit(giststate, i, &centry[i], attdata[i],
604-
r, NULL, (OffsetNumber) 0,
605-
newValues,
606-
FALSE);
607-
compatt[i] = centry[i].key;
578+
GISTENTRY centry;
579+
GISTENTRY *cep;
580+
581+
gistentryinit(centry, attdata[i], r, NULL, (OffsetNumber) 0,
582+
isleaf);
583+
cep = (GISTENTRY *)
584+
DatumGetPointer(FunctionCall1Coll(&giststate->compressFn[i],
585+
giststate->supportCollation[i],
586+
PointerGetDatum(&centry)));
587+
compatt[i] = cep->key;
608588
}
609589
}
610590

611591
res = index_form_tuple(giststate->tupdesc, compatt, isnull);
612592

613593
/*
614594
* The offset number on tuples on internal pages is unused. For historical
615-
* reasons, it is set 0xffff.
595+
* reasons, it is set to 0xffff.
616596
*/
617597
ItemPointerSetOffsetNumber(&(res->t_tid), 0xffff);
618598
return res;

src/include/access/gist_private.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,11 @@ extern IndexTuple gistgetadjusted(Relation r,
485485
IndexTuple addtup,
486486
GISTSTATE *giststate);
487487
extern IndexTuple gistFormTuple(GISTSTATE *giststate,
488-
Relation r, Datum *attdata, bool *isnull, bool newValues);
488+
Relation r, Datum *attdata, bool *isnull, bool isleaf);
489489

490490
extern OffsetNumber gistchoose(Relation r, Page p,
491491
IndexTuple it,
492492
GISTSTATE *giststate);
493-
extern void gistcentryinit(GISTSTATE *giststate, int nkey,
494-
GISTENTRY *e, Datum k,
495-
Relation r, Page pg,
496-
OffsetNumber o, bool l, bool isNull);
497493

498494
extern void GISTInitBuffer(Buffer b, uint32 f);
499495
extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,

0 commit comments

Comments
 (0)