1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

Minor cleanup of GiST code, for readability.

Remove the gistcentryinit function, inlining the relevant part of it into
the only caller.
This commit is contained in:
Heikki Linnakangas
2015-03-26 19:11:54 +02:00
parent bed756a820
commit 8fa393a6d7
2 changed files with 16 additions and 40 deletions

View File

@ -558,53 +558,33 @@ gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
gistentryinit(*e, (Datum) 0, r, pg, o, l); gistentryinit(*e, (Datum) 0, r, pg, o, l);
} }
/*
* initialize a GiST entry with a compressed version of key
*/
void
gistcentryinit(GISTSTATE *giststate, int nkey,
GISTENTRY *e, Datum k, Relation r,
Page pg, OffsetNumber o, bool l, bool isNull)
{
if (!isNull)
{
GISTENTRY *cep;
gistentryinit(*e, k, r, pg, o, l);
cep = (GISTENTRY *)
DatumGetPointer(FunctionCall1Coll(&giststate->compressFn[nkey],
giststate->supportCollation[nkey],
PointerGetDatum(e)));
/* compressFn may just return the given pointer */
if (cep != e)
gistentryinit(*e, cep->key, cep->rel, cep->page, cep->offset,
cep->leafkey);
}
else
gistentryinit(*e, (Datum) 0, r, pg, o, l);
}
IndexTuple IndexTuple
gistFormTuple(GISTSTATE *giststate, Relation r, gistFormTuple(GISTSTATE *giststate, Relation r,
Datum attdata[], bool isnull[], bool newValues) Datum attdata[], bool isnull[], bool isleaf)
{ {
GISTENTRY centry[INDEX_MAX_KEYS];
Datum compatt[INDEX_MAX_KEYS]; Datum compatt[INDEX_MAX_KEYS];
int i; int i;
IndexTuple res; IndexTuple res;
/*
* Call the compress method on each attribute.
*/
for (i = 0; i < r->rd_att->natts; i++) for (i = 0; i < r->rd_att->natts; i++)
{ {
if (isnull[i]) if (isnull[i])
compatt[i] = (Datum) 0; compatt[i] = (Datum) 0;
else else
{ {
gistcentryinit(giststate, i, &centry[i], attdata[i], GISTENTRY centry;
r, NULL, (OffsetNumber) 0, GISTENTRY *cep;
newValues,
FALSE); gistentryinit(centry, attdata[i], r, NULL, (OffsetNumber) 0,
compatt[i] = centry[i].key; isleaf);
cep = (GISTENTRY *)
DatumGetPointer(FunctionCall1Coll(&giststate->compressFn[i],
giststate->supportCollation[i],
PointerGetDatum(&centry)));
compatt[i] = cep->key;
} }
} }
@ -612,7 +592,7 @@ gistFormTuple(GISTSTATE *giststate, Relation r,
/* /*
* The offset number on tuples on internal pages is unused. For historical * The offset number on tuples on internal pages is unused. For historical
* reasons, it is set 0xffff. * reasons, it is set to 0xffff.
*/ */
ItemPointerSetOffsetNumber(&(res->t_tid), 0xffff); ItemPointerSetOffsetNumber(&(res->t_tid), 0xffff);
return res; return res;

View File

@ -485,15 +485,11 @@ extern IndexTuple gistgetadjusted(Relation r,
IndexTuple addtup, IndexTuple addtup,
GISTSTATE *giststate); GISTSTATE *giststate);
extern IndexTuple gistFormTuple(GISTSTATE *giststate, extern IndexTuple gistFormTuple(GISTSTATE *giststate,
Relation r, Datum *attdata, bool *isnull, bool newValues); Relation r, Datum *attdata, bool *isnull, bool isleaf);
extern OffsetNumber gistchoose(Relation r, Page p, extern OffsetNumber gistchoose(Relation r, Page p,
IndexTuple it, IndexTuple it,
GISTSTATE *giststate); GISTSTATE *giststate);
extern void gistcentryinit(GISTSTATE *giststate, int nkey,
GISTENTRY *e, Datum k,
Relation r, Page pg,
OffsetNumber o, bool l, bool isNull);
extern void GISTInitBuffer(Buffer b, uint32 f); extern void GISTInitBuffer(Buffer b, uint32 f);
extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,