From: | Adrian Schreyer <ams214(at)cam(dot)ac(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Weird problems with C extension and bytea as input type |
Date: | 2011-03-22 13:22:23 |
Message-ID: | AANLkTimvAfX9G5jzhm=eMdDOBBYDJcPdM_SVnbuWbS_7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I have a weird problem with my custom functions (written in C,C++)
that use bytea as input type (cstring works fine). The functions will
work as expected if they are the only function that uses the bytea
column in a query; as soon as there is a second function using the
same column, the C function will return one of the following: an empty
cstring, a substring of the bytea or the correct cstring. Based on
these symptoms I assume there is something fundamental that I do wrong
(or that is missing) with handling the bytea pointer.
In one specific example, the bytea contains a binary file format that
the function converts into a string format. I convert the bytea to a
C++ string with string(VARDATA(b), VARSIZE(b)-VARHDRSZ).
bytea *b = PG_GETARG_BYTEA_P(0);
char *ism;
ism = function(b);
PG_RETURN_CSTRING(ism);
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-03-22 15:03:43 | Re: share directory on windows |
Previous Message | Voils, Steven M | 2011-03-22 12:05:54 | Re: Primary key vs unique index |