Re: runtime error on SPGIST, needed help

Поиск
Список
Период
Сортировка
Искать

Re: runtime error on SPGIST, needed help

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Simone Campora"  writes:
> I first want to implement it and to make it works, like this:

> SPGIST_FUNCTION(pquad_equals_op)
> {
>     elog (NOTICE, "1");

>     Point *p1 = (Point *)PG_GETARG_POINTER(0);
>     Point *p2 = (Point *)PG_GETARG_POINTER(1);

>     elog (NOTICE, "2");

(1) are you sure this function is marked as being V1 calling convention?
Maybe "SPGIST_FUNCTION" takes care of that for you but I don't know.

(2) since you neither marked it STRICT nor defended against nulls in the
function body, I'd fully expect a crash on a null input ... does that
table contain any null points?

> Could anyone suggest me a good runtime debugger for that purpose?

Any C debugger should work fine.  gdb and ddd are the most common
tools around this project, I think.
		regards, tom lane

runtime error on SPGIST, needed help

От:
"Simone Campora" <simone.campora@gmail.com>
Дата:

Hello to all of you! I'm new of this newsletter but I hope that this is the good place to send this help request!
I'm a student and I'm developing a quadtree index using postgresql 8.0.15 under Linux Ubuntu  7.10 Gusty Gibbon, but I have the following problem:

I downloaded the GIST extension SPGIST from the website http://www.cs.purdue.edu/spgist/

and I tried to modify some C functions used by the operators (for instance the == used between Point and Point)

here there is a function in the ./spgist-pquad/spgist_pquad.cc that is:

SPGIST_FUNCTION(pquad_equals_op) 
{
        PG_RETURN_BOOL(true);
}

That is the one that is used by the operator == defined as follows:

CREATE OR REPLACE FUNCTION pquad_equals_op(point,point) RETURNS bool AS '/usr/local/lib/libspgist_pquad' LANGUAGE 'C';
CREATE OPERATOR == ( LEFTARG = point, RIGHTARG = point, PROCEDURE = pquad_equals_op, RESTRICT = eqsel, JOIN = eqjoinsel);

I first want to implement it and to make it works, like this:

SPGIST_FUNCTION(pquad_equals_op) 
{
    elog (NOTICE, "1");

    Point *p1 = (Point *)PG_GETARG_POINTER(0);
    Point *p2 = (Point *)PG_GETARG_POINTER(1);

    elog (NOTICE, "2");

    if((p1->x == p2->x) && (p1->y == p2->y))
    {
        PG_RETURN_BOOL(true);
    }
    else
    {
        PG_RETURN_BOOL(false);
    }
 
}

I can compile it without problem but when I use that operator in a sql query like:

select * from tablepoints  p1 where p1.point == '(1,1)';

then the process simply crash by signal 11 and without any useful feedback on the motivation (it just prints out the notice "1" and "2").
Is that an already known problem? Honestly I found it very hard to discover the problem and I still don't have a solution.



Could anyone suggest me a good runtime debugger for that purpose?

Thanks to all of you!!

Simone



--
Campora Simone,
________________________
School of computer science
Swiss Federal Institute of Technology, Lausanne
EPFL

E-MAIL: simone.campora@gmail.com
             simone.campora@epfl.ch

WWW: www.simonecampora.com

MOBILE:  +41 762 563466
               +39 347 8036605

SKYPE: sim0ne.

Re: runtime error on SPGIST, needed help

От:
"Simone Campora" <simone.campora@gmail.com>
Дата:
Hello and really thanks for the answer, I found the solution for the problem also thanks to the gdb debugger. My problem was a SegmentationFault runtime error due to a little tricky:

the function SPGIST_FUNCTION(pquad_equals_op) is defined as follows

#define SPGIST_FUNCTION(name) extern "C" Datum name(PG_FUNCTION_ARGS)
 
 
extern "C" {
PG_FUNCTION_INFO_V1(pquad_consistent);
PG_FUNCTION_INFO_V1(pquad_nn_consistent);
PG_FUNCTION_INFO_V1(pquad_penalty);
PG_FUNCTION_INFO_V1(pquad_checkinternalsplit);
PG_FUNCTION_INFO_V1(pquad_picksplit);
PG_FUNCTION_INFO_V1(pquad_childbp);
PG_FUNCTION_INFO_V1(pquad_keylen);
PG_FUNCTION_INFO_V1(pquad_check);
PG_FUNCTION_INFO_V1(pquad_printpred);
PG_FUNCTION_INFO_V1(pquad_getpred);
PG_FUNCTION_INFO_V1(pquad_getparam);
PG_FUNCTION_INFO_V1(pquad_inside_op);
PG_FUNCTION_INFO_V1(pquad_check_chaining); 
}

but as you can see, this "C" lacks the row

PG_FUNCTION_INFO_V1(pquad_equals_op);

that's why it was not working... I didn't noticed it because as far as I don't access any pointer's argument, I don't get any error back! (I really don't know why, is it maybe because of some default setting?)

Anyway thanks again to all!

Simone



On 12/04/2008, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Simone Campora" <simone.campora@gmail.com> writes:
> I first want to implement it and to make it works, like this:

> SPGIST_FUNCTION(pquad_equals_op)
> {
>     elog (NOTICE, "1");

>     Point *p1 = (Point *)PG_GETARG_POINTER(0);
>     Point *p2 = (Point *)PG_GETARG_POINTER(1);

>     elog (NOTICE, "2");


(1) are you sure this function is marked as being V1 calling convention?
Maybe "SPGIST_FUNCTION" takes care of that for you but I don't know.

(2) since you neither marked it STRICT nor defended against nulls in the
function body, I'd fully expect a crash on a null input ... does that
table contain any null points?


> Could anyone suggest me a good runtime debugger for that purpose?


Any C debugger should work fine.  gdb and ddd are the most common
tools around this project, I think.

                        regards, tom lane



--
Campora Simone,
________________________
School of computer science
Swiss Federal Institute of Technology, Lausanne
EPFL

E-MAIL: simone.campora@gmail.com
             simone.campora@epfl.ch

WWW: www.simonecampora.com

MOBILE:  +41 762 563466
               +39 347 8036605

SKYPE: sim0ne.
FAQ