Re: making tsearch2 dictionaries - Mailing list pgsql-general

From Teodor Sigaev
Subject Re: making tsearch2 dictionaries
Date
Msg-id 4030EB2E.7080608@sigaev.ru
Whole thread Raw
In response to Re: making tsearch2 dictionaries  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: making tsearch2 dictionaries  (Ben <bench@silentmedia.com>)
List pgsql-general
Excuse me, but I was too brief.
I mean your lexize method of dictionary should return pointer to array with 3
elements:
first should points to "one" C-string, second - to "hundred" C-string and 3rd is
NULL.
Array and C-strings should be palloc'ed in short-lived context, because it's
lives during parse text only.




Tom Lane wrote:
> Ben <bench@silentmedia.com> writes:
>
>>Okay, so I was actually able to answer this question on my own, in a
>>manner of speaking. It seems the way to do this is to merely return a
>>larger char** array, with one element for each word. But I was having
>>trouble with postgres crashing, because (I think) it tries to free each
>>element independently before using all of them. I had set each element
>>to a different null-terminated chunk of the same palloc'd memory
>>segment. Having never written C stored procs before, I take it that's
>>bad practice?
>
>
> Given Teodor's response, I think the issue is probably that you were
> palloc'ing in too short-lived a context.  But whatever the problem is,
> you'll narrow it down a lot faster if you build with --enable-cassert.
> I wouldn't ever recommend trying to debug C functions without that.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html

--
Teodor Sigaev                                  E-mail: teodor@sigaev.ru

pgsql-general by date:

Previous
From: Karam Chand
Date:
Subject: PGSQL C API()
Next
From: "Vidyasagara Guntaka"
Date:
Subject: Replication in postgresql