Search Postgresql Archives

Re: selfmade datatype in C and server-crash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux