we found a problem in GiST with massive insert/update operations

with many NULLs ( inserting of NULL into indexed field cause
ERROR: MemoryContextAlloc: invalid request size)
As a workaround 'vacuum analyze' could be used.

This patch resolves the problem, please upply to 7.1.1 sources and
current cvs tree.

Oleg Bartunov
This commit is contained in:
Bruce Momjian 2001-05-15 14:14:49 +00:00
parent 3848a14ed7
commit d0e1091cfd
2 changed files with 18 additions and 11 deletions

View File

@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.75 2001/05/15 03:49:34 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.76 2001/05/15 14:14:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -1199,13 +1199,17 @@ gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r,
gistentryinit(*e, pr, r, pg, o, b, l);
if (giststate->haskeytype)
{
dep = (GISTENTRY *)
DatumGetPointer(FunctionCall1(&giststate->decompressFn,
if ( b ) {
dep = (GISTENTRY *)
DatumGetPointer(FunctionCall1(&giststate->decompressFn,
PointerGetDatum(e)));
gistentryinit(*e, dep->pred, dep->rel, dep->page, dep->offset, dep->bytes,
gistentryinit(*e, dep->pred, dep->rel, dep->page, dep->offset, dep->bytes,
dep->leafkey);
if (dep != e)
pfree(dep);
if (dep != e)
pfree(dep);
} else {
gistentryinit(*e, (char*)NULL, r, pg, o, 0, l);
}
}
}

View File

@ -241,16 +241,16 @@ gistindex_keytest(IndexTuple tuple,
1,
tupdesc,
&isNull);
gistdentryinit(giststate, &de, (char *) datum, r, p, offset,
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE);
if (isNull)
if (isNull || IndexTupleSize(tuple) == sizeof(IndexTupleData) )
{
/* XXX eventually should check if SK_ISNULL */
return false;
}
gistdentryinit(giststate, &de, (char *) datum, r, p, offset,
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE);
if (key[0].sk_flags & SK_COMMUTE)
{
test = FunctionCall3(&key[0].sk_func,
@ -266,6 +266,9 @@ gistindex_keytest(IndexTuple tuple,
ObjectIdGetDatum(key[0].sk_procedure));
}
if ( (char*)de.pred != (char*)datum )
if ( de.pred ) pfree( de.pred );
if (DatumGetBool(test) == !!(key[0].sk_flags & SK_NEGATE))
return false;