Re: PATCH: CITEXT 2.0 v3

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема Re: PATCH: CITEXT 2.0 v3
Дата
Msg-id 27083F56-6EEA-47BB-ABA5-E905D27AC713@kineticode.com
обсуждение исходный текст
Ответ на Re: PATCH: CITEXT 2.0 v3  (Zdenek Kotala <Zdenek.Kotala@Sun.COM>)
Ответы Re: PATCH: CITEXT 2.0 v3  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: PATCH: CITEXT 2.0 v3  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: PATCH: CITEXT 2.0 v3  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: PATCH: CITEXT 2.0 v3  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Jul 11, 2008, at 13:02, Zdenek Kotala wrote:

>> Thank you, Zdenek. Have you had a chance to try citext yet? Or did
>> you just read the source?
>
> I tested version two on Solaris/SPARC and Sun studio compiler. I
> checked last version  only quickly (comparing your changes).

Thanks.

I just updated my performance test script (attached) by increasing the
number of rows tested by an order of magnitude. So now it creates
1,000,000 rows, queries them, adds indexes, and then queries them
again. Unfortunately, CITEXT seems to have a memory leak somewhere,
because when I index the CITEXT column, it fails with "ERROR:  out of
memory". So obviously something's not getting cleaned up. Here's the
btree indexing function:

Datum
citext_cmp(PG_FUNCTION_ARGS)
{
     text *left  = PG_GETARG_TEXT_PP(0);
     text *right = PG_GETARG_TEXT_PP(1);
     int32 result;

     result = citextcmp(left, right);

     PG_FREE_IF_COPY(left, 0);
     PG_FREE_IF_COPY(right, 1);

     PG_RETURN_INT32(result);
}

And here's citextcmp():

citextcmp (text *left, text *right)
{
     char *lcstr, *rcstr;
     int   result;

     lcstr = str_tolower(VARDATA_ANY(left), VARSIZE_ANY_EXHDR(left));
     rcstr = str_tolower(VARDATA_ANY(right), VARSIZE_ANY_EXHDR(right));

     result = varstr_cmp(
         lcstr,
         VARSIZE_ANY_EXHDR(left),
         rcstr,
         VARSIZE_ANY_EXHDR(right)
     );

     pfree(lcstr);
     pfree(rcstr);
     return result;
}

Can anyone see where I'm failing to free up memory? Might it be in
some other function?

Thanks!

David





Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Vacuuming leaked temp tables (once again)
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: [PATCHES] GIN improvements