Re: selfmade datatype in C and server-crash

Поиск
Список
Период
Сортировка
От Markus Schulz
Тема Re: selfmade datatype in C and server-crash
Дата
Msg-id 200510051444.53118.msc@antzsystem.de
обсуждение исходный текст
Ответ на Re: selfmade datatype in C and server-crash  (Markus Schulz <msc@antzsystem.de>)
Список pgsql-general
Now i have debugged the _first_ "Insert" Statement in my etextin
function cause i got a NULL value for inputText on second insert.
now etextin function looks like:
Datum
etextin(PG_FUNCTION_ARGS)
{
    char       *inputText = PG_GETARG_CSTRING(0);
    text       *result;
    int         len=0;

    if(!inputText)
            return CStringGetDatum("");//only for testing purpose
    /* verify encoding */
    len = strlen(inputText);
    pg_verifymbstr(inputText, len, false);

    result = (text *) palloc(len + VARHDRSZ);
    VARATT_SIZEP(result) = len + VARHDRSZ;

    memcpy(VARDATA(result), inputText, len);

    PG_RETURN_TEXT_P(result);
}


debug:(SQL=insert into test ( var1) values ('aiksnd');)

(gdb) break new_types.c:26
Breakpoint 1 at 0x40ffe888: file new_types.c, line 26.
(gdb) cont
Continuing.

Breakpoint 1, etextin (fcinfo=0x8332c90) at new_types.c:26
26              if(!inputText)
(gdb) display inputText
1: inputText = 0x8332c90 "@-3\b\020"

this looks weird to me. The content should be "aiksnd" or i'm wrong?

i think i have missed some precondition but don't know which.


With this additional if(!inputText) condition inserts don't crash
anymore. But each select on the table crashs now.


Markus Schulz

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

Предыдущее
От: Douglas McNaught
Дата:
Сообщение: Re: Or selection on index versus union
Следующее
От: Robert Osowiecki
Дата:
Сообщение: Cast to integer