Commit d0e1091c authored by Bruce Momjian's avatar Bruce Momjian

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
parent 3848a14e
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * 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,6 +1199,7 @@ gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r, ...@@ -1199,6 +1199,7 @@ gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r,
gistentryinit(*e, pr, r, pg, o, b, l); gistentryinit(*e, pr, r, pg, o, b, l);
if (giststate->haskeytype) if (giststate->haskeytype)
{ {
if ( b ) {
dep = (GISTENTRY *) dep = (GISTENTRY *)
DatumGetPointer(FunctionCall1(&giststate->decompressFn, DatumGetPointer(FunctionCall1(&giststate->decompressFn,
PointerGetDatum(e))); PointerGetDatum(e)));
...@@ -1206,6 +1207,9 @@ gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r, ...@@ -1206,6 +1207,9 @@ gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r,
dep->leafkey); dep->leafkey);
if (dep != e) if (dep != e)
pfree(dep); pfree(dep);
} else {
gistentryinit(*e, (char*)NULL, r, pg, o, 0, l);
}
} }
} }
......
...@@ -241,16 +241,16 @@ gistindex_keytest(IndexTuple tuple, ...@@ -241,16 +241,16 @@ gistindex_keytest(IndexTuple tuple,
1, 1,
tupdesc, tupdesc,
&isNull); &isNull);
gistdentryinit(giststate, &de, (char *) datum, r, p, offset, if (isNull || IndexTupleSize(tuple) == sizeof(IndexTupleData) )
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE);
if (isNull)
{ {
/* XXX eventually should check if SK_ISNULL */ /* XXX eventually should check if SK_ISNULL */
return false; return false;
} }
gistdentryinit(giststate, &de, (char *) datum, r, p, offset,
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE);
if (key[0].sk_flags & SK_COMMUTE) if (key[0].sk_flags & SK_COMMUTE)
{ {
test = FunctionCall3(&key[0].sk_func, test = FunctionCall3(&key[0].sk_func,
...@@ -266,6 +266,9 @@ gistindex_keytest(IndexTuple tuple, ...@@ -266,6 +266,9 @@ gistindex_keytest(IndexTuple tuple,
ObjectIdGetDatum(key[0].sk_procedure)); 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)) if (DatumGetBool(test) == !!(key[0].sk_flags & SK_NEGATE))
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment