From: | Markus Schulz <msc(at)antzsystem(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: selfmade datatype in C and server-crash |
Date: | 2005-10-05 12:44:52 |
Message-ID: | 200510051444.53118.msc@antzsystem.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Osowiecki | 2005-10-05 13:08:33 | Cast to integer |
Previous Message | Douglas McNaught | 2005-10-05 12:11:05 | Re: Or selection on index versus union |