Обсуждение: dedebugging and a functions that just don't work on debian flavour

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

dedebugging and a functions that just don't work on debian flavour

От
Ivan Sergio Borgonovo
Дата:
I wrote a function that turns tsvectors into tsqueries.
I can't see any evident error and actually the function return the
expected results but just for a strange set of queries. Otherwise it
causes tsqueryout to exit with errors when the result is returned.

It seems that tsqueryout is running beyond what it should and most
likely it could be some dirty memory/allocation issue.
(ERROR:  unrecognized operator type: or ERROR:  stack depth limit
exceeded)

The queries that succede and the one that fail belong to a pretty
curious set:

SUCCEDE:
select tsvector_to_tsquery(ft1idx, '|', 'ABCD', 22::smallint) from catalog_items limit 2; -- q1

select itemid, tsvector_to_tsquery(ft1idx, '|', 'ABCD', 22::smallint) from catalog_items; -- q2

select tsvector_to_tsquery(ft1idx, '|', 'ABCD', 22::smallint) from catalog_items where itemid=10 or itemid=15 or
itemid=27;-- q3
 

select tsvector_to_tsquery(ft1idx, '|', 'ABCD', 22::smallint) from catalog_items order by random() limit 3; -- q4

FAIL:
select tsvector_to_tsquery(ft1idx, '|', 'ABCD', 22::smallint) from catalog_items limit 3; -- q5

If I compile my function with -O0 all queries succeed.

Then I created a table
create table tsvectors(i serial, tsv tsvector);
in the same DB of catalog_items and filled it with some data.
Length of tsvector is similar, just catalog_items contains more
fields and records.
All queries above succeeded.

I then compiled from scratch postgresql with default configure
options, loaded the whole DB containing catalog_items and no errors.

Then I looked into configure options used by debian, copied nearly
all with the exception of tcl stuff and rpath, compiled once more...
tested my function and no error.

I've no idea what to do next other than asking if someone can give a
look to the code and check my comprehension of what a tsquery should
be in memory.

http://www.webthatworks.it/d1/files/ts_utilities.tar.bz2

thanks

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



Re: dedebugging and a functions that just don't work on debian flavour

От
Robert Haas
Дата:
On Sun, Feb 28, 2010 at 8:43 AM, Ivan Sergio Borgonovo
<mail@webthatworks.it> wrote:
> I've no idea what to do next other than asking if someone can give a
> look to the code and check my comprehension of what a tsquery should
> be in memory.

Have you tried valgrind?

...Robert


Re: dedebugging and a functions that just don't work on debian flavour

От
Ivan Sergio Borgonovo
Дата:
On Sun, 28 Feb 2010 23:02:39 -0500
Robert Haas <robertmhaas@gmail.com> wrote:

> On Sun, Feb 28, 2010 at 8:43 AM, Ivan Sergio Borgonovo
> <mail@webthatworks.it> wrote:
> > I've no idea what to do next other than asking if someone can
> > give a look to the code and check my comprehension of what a
> > tsquery should be in memory.

> Have you tried valgrind?

It was something related to my misinterpretation on how a tsquery is
built.

operand.length is the length of the cstring *excluding* the \0.
I was mislead by the fact that in tsvector there are no ending \0
while in tsquery there are.

It still need more extensive testing but I think I got it working.

Once I'm sure I got it I'll make the polished source available and
write some docs for all the poor guys like me willing to start to
write extensions ;)

thanks to everybody for the patience.

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it