Re: PQexec(), what should I do for the "NULL in command" problem? - Mailing list pgsql-general

From yang zhenyu
Subject Re: PQexec(), what should I do for the "NULL in command" problem?
Date
Msg-id 32caccbc0711130230y59bb1841t8713ac6698a53701@mail.gmail.com
Whole thread Raw
In response to Re: PQexec(), what should I do for the "NULL in command" problem?  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
> > > - out of line parameters
> > How to? Is there any function for this? I mean the C interface.
>
> PQexecParams.
>
> > > - escape the nulls, like \0
> > Do you mean this function?
> > #unsigned char *PQescapeBytea(const unsigned char *from,
> > #                              size_t from_length,
> > #                              size_t *to_length);
> >
> > But after the "escape", the data is changed, and it cannot
> > automatically change back when insert them into database.
> > I have to "unescape" it when query. Is this necessary?
>
> True. You should realise that the text data type does not handle
> embedded nulls, that's why the bytea datatype exists. If you don't want
> the full conversion, you'll need to handle your own escaping.
> PostgreSQL is not going return you strings with embedded NULLs...

Thank you very much, I got that :)

Jason

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: PQexec(), what should I do for the "NULL in command" problem?
Next
From: Christian Schröder
Date:
Subject: Re: (Never?) Kill Postmaster?