Re: Question about Encoding a Custom Type

Поиск
Список
Период
Сортировка
От David E. Wheeler
Тема Re: Question about Encoding a Custom Type
Дата
Msg-id 9283E9BC-3561-428F-9F15-71461770D501@kineticode.com
обсуждение исходный текст
Ответ на Re: Question about Encoding a Custom Type  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Question about Encoding a Custom Type
Список pgsql-hackers
On Jun 16, 2008, at 13:06, Tom Lane wrote:

> "David E. Wheeler" <david@kineticode.com> writes:
>> What's even weirder is that it can not work and then suddenly work:
>
> Smells like uninitialized-memory problems to me.  Perhaps you are
> miscalculating the length of the input data?

Entirely possible. Here are the two functions in which I calculate size:

char * cilower(text * arg) {    // Do I need to free anything here?    char * str = VARDATA_ANY( arg );
#ifdef USE_WIDE_UPPER_LOWER    // Have wstring_lower() do the work.    return wstring_lower( str );
# else    // Copy the string and process it.    int    inex, len;    char * result;
    index  = 0;    len    = VARSIZE(arg) - VARHDRSZ;    result = (char *) palloc( strlen( str ) + 1 );
    for (index = 0; index <= len; index++) {        result[index] = tolower((unsigned char) str[index] );    }
returnresult;
 
#endif   /* USE_WIDE_UPPER_LOWER */
}

int citextcmp (PG_FUNCTION_ARGS) {    // Could we do away with the varlena struct here?    text * left  =
PG_GETARG_TEXT_P(0);   text * right = PG_GETARG_TEXT_P(1);    char * lstr  = cilower( left );    char * rstr  =
cilower(right );    int    llen  = VARSIZE_ANY_EXHDR(left);    int    rlen  = VARSIZE_ANY_EXHDR(right);    return
varstr_cmp(lstr,llen, rstr, rlen);
 
}

> Are you testing in an --enable-cassert build?  The memory clobber
> stuff can help to make it more obvious where such problems lurk.

I've just recompiled with --enable-cassert and --enable-debug, but got  
no more information when I triggered the error, neither in psql nor in  
the log. :-(

Thanks,

David



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Question about Encoding a Custom Type
Следующее
От: Robert Treat
Дата:
Сообщение: Re: How to Sponsor a Feature