Re: Problems converting between C string and Datum - Mailing list pgsql-general

From Tom Lane
Subject Re: Problems converting between C string and Datum
Date
Msg-id 11671.1158774071@sss.pgh.pa.us
Whole thread Raw
In response to Problems converting between C string and Datum  ("Jack Orenstein" <jack.orenstein@gmail.com>)
List pgsql-general
"Jack Orenstein" <jack.orenstein@gmail.com> writes:
> I have a char* which I need as a Datum, for use with a plan returned
> from SPI_prepare, so I'm doing this:

>     char* string;
>     Datum d;
>     ...
>     d = DirectFunctionCall1(textin, CStringGetDatum(string));
>     ...
>     ereport(WARNING, (errmsg("string: %s",
> DatumGetCString(DirectFunctionCall1(textout, d)))));

That looks OK as far as it goes, so I speculate the problem is in
something you didn't show us.

> This crashes doing the ereport:

If you are doing backend C code you should certainly learn how to use
gdb to narrow things down more than that.  A stack trace would be much
more informative than "server closed the connection unexpectedly".

            regards, tom lane

pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: 8.2: select from an INSERT returning?
Next
From: Tom Lane
Date:
Subject: Re: 8.2: select from an INSERT returning?