Ok, Thanks for that. Script works great.
Here's bt I get:
#0 0xb7ef26a4 in ?? ()
#1 0xb7cae460 in _IO_list_all () from /lib/tls/libc.so.6
#2 0xb7ef2ea8 in ?? ()
#3 0x00000000 in ?? ()
#4 0x0844bebc in ?? ()
#5 0x00000000 in ?? ()
#6 0xb7cadff4 in ?? () from /lib/tls/libc.so.6
#7 0xb7cadff4 in ?? () from /lib/tls/libc.so.6
#8 0x08432746 in ?? ()
#9 0xbfc24eb0 in ?? ()
#10 0xbfc252d4 in ?? ()
#11 0xbfc24fd4 in ?? ()
#12 0xbfc24fb0 in ?? ()
#13 0x0844bebc in ?? ()
#14 0x00000000 in ?? ()
#15 0xbfc24cd0 in ?? ()
#16 0xb7cadff4 in ?? () from /lib/tls/libc.so.6
#17 0xbfc24fb0 in ?? ()
#18 0xbfc24fd4 in ?? ()
#19 0xbfc24ef8 in ?? ()
#20 0x082c0b1d in FunctionCall3 (flinfo=0xbfc24cf0, arg1=3083469667,
arg2=3083469667, arg3=3083469667) at fmgr.c:1179
#21 0x082c0b1d in FunctionCall3 (flinfo=0xbfc260e4, arg1=3217183444,
arg2=3217182676, arg3=3217182640) at fmgr.c:1179
#22 0x0808730d in gistpenalty (giststate=0xbfc254e4, attno=0, key1=0xbfc252d4,
isNull1=0 '\0', key2=0xbfc24fd4, isNull2=0 '\0',
penalty=0xbfc24fb0) at gistutil.c:821
#23 0x080868fd in gistchoose (r=0xb710039c, p=0xb739b0a0 "", it=0x844beb4,
giststate=0xbfc254e4) at gistutil.c:688
I guess, what's important is #22 with two keys, both NOT nulls.
It's not a secret how my _penalty function is defined:
CREATE OR REPLACE FUNCTION enum_penalty( internal, internal, internal)
RETURNS internal
AS 'enum2916', 'enum_penalty'
LANGUAGE C STRICT;
and in C it looks like that:
PG_FUNCTION_INFO_V1(enum_penalty);
Datum enum_penalty(PG_FUNCTION_ARGS)
{
GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0);
GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
float *result = (float *) PG_GETARG_POINTER(2);
struct enumNumber *key;
struct enumNumber* ud;
float tmp1, tmp2;
ud = (struct enumNumber*) DatumGetPointer(origentry->key);
key = (struct enumNumber*) DatumGetPointer(newentry->key);
tmp2 = ((float)ud->eStart)*(1.5*(float)ud->percent);
tmp1 = ((float)key->eStart)*(1.5*(float)key->percent);
*result = tmp1 - tmp2;
PG_RETURN_POINTER(result);
}
for whatever reason here origentry->key is NULL.
--
GJ