|
Home > Archive > PostgreSQL Hacks > October 2005 > _penalty gist method invoked with one key NULL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
_penalty gist method invoked with one key NULL
|
|
| Grzegorz Piotr Jaskiewicz 2005-10-27, 5:29 pm |
| As in subject.
What it does, it gets through picksplit, I return good values, valid unions,
etc. Than (I guess) postgres is trying to insert another value in tree, hence
penalty is called. Why one of the values penalty is called with is NULL, and
I have no idea if that's valid.
From all the examples available in contrib dir, I can deduct that it shouldn't
happend.
Now question, how shall I debug postgres in this case?
can I just run postgres, in non forking mode, on gdb?
I am running psql with all commands required to create new type, functions,
operators, and gist. So there must be separate connection available for that.
Thanks.
--
GJ
Binary system, you're either 1 or 0...
dead or alive ;)
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly
| |
| Tom Lane 2005-10-27, 5:29 pm |
| Grzegorz Piotr Jaskiewicz <gj@pointblue.com.pl> writes:
> can I just run postgres, in non forking mode, on gdb?
Just start a normal session and then attach to the backend process with
gdb in a separate window. There's no reason to fool with a standalone
backend for 99.99% of debugging problems. With a regular session, you
can use psql to input the SQL commands, which is MUCH friendlier than a
standalone backend, and you can run additional sessions in case you'd
like to examine the state of the database while you've got your debug
backend pinned down someplace.
I tend to use the attached script so that I don't even need to manually
discover the PID to attach to, assuming there's only one backend running
(else it shows me all the plausible candidates to attach to).
Dunno about the gist-specific issue, Oleg or Teodor will have to answer
that.
regards, tom lane
#!/bin/sh
# Usage: gdblive
# tee /dev/tty is for user to see the set of procs considered
PROCS=`ps auxww | \
grep postgres: | \
grep -v -e 'grep postgres:' -e 'postgres: stats' -e 'postgres: writer' -e 'postgres: archiver' -e 'postgres: logger' | \
tee /dev/tty | \
awk '{print $2}'`
if [ `echo "$PROCS" | wc -w` -eq 1 ]
then
exec gdb $PGINSTROOT/bin/postgres -silent "$PROCS"
else
exec gdb $PGINSTROOT/bin/postgres -silent
fi
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
| |
|
| 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=0xbfc254e
4, 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_FUNC
TION_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(orig
entry->key);
key = (struct enumNumber*) DatumGetPointer(newe
ntry->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(re
sult);
}
for whatever reason here origentry->key is NULL.
--
GJ
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
| |
|
|
Breakpoint 1, gistpenalty (giststate=0xbfc254e
4, attno=0, key1=0xbfc252d4,
isNull1=0 '\0', key2=0xbfc24fd4, isNull2=0 '\0',
penalty=0xbfc24fb0) at gistutil.c:821
821 FunctionCall3(&giststate->penaltyFn[attno],
(gdb) p key1
$1 = (GISTENTRY *) 0xbfc252d4
(gdb) p key1->key
$2 = 0
(gdb) p key2->key
$3 = 138721324
Sorry, key1 and key2 are just GISTENTRY pointers.
so, as I can see this is NULL indeed, so my _penalty function is ok.
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly
| |
| Grzegorz Jaskiewicz 2005-10-27, 8:23 pm |
| Seems like decompress and compress were offending here, simply
removing them from gist index create helped.
But, I still get on explain analyze that seqscan was used, rather
than gist. Even tho ~ operator is defined for gist, and that seqscan
is set to false.
On 2005-10-28, at 00:24, gj wrote:
>
>
> Breakpoint 1, gistpenalty (giststate=0xbfc254e
4, attno=0,
> key1=0xbfc252d4,
> isNull1=0 '\0', key2=0xbfc24fd4, isNull2=0 '\0',
> penalty=0xbfc24fb0) at gistutil.c:821
> 821 FunctionCall3(&giststate->penaltyFn[attno],
> (gdb) p key1
> $1 = (GISTENTRY *) 0xbfc252d4
> (gdb) p key1->key
> $2 = 0
> (gdb) p key2->key
> $3 = 138721324
>
>
> Sorry, key1 and key2 are just GISTENTRY pointers.
> so, as I can see this is NULL indeed, so my _penalty function is ok.
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql
.org so that
> your
> message can get through to the mailing list cleanly
>
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
|
|
|
|
|