[GENERAL] PQexec(), what should I do for the "NULL in command" problem?

2007-11-12 Thread jason
Hello: As you know the interface of PQexec(): PGresult *PQexec(PGconn *conn, const char *command); "command" contains some SQL statements. But there exist "\0" in some data filed, and I found PQexec() failed on such situation. Something like this: PQexec(conn, "INSERT INTO ('t', 'abc\0

Re: [GENERAL] PQexec(), what should I do for the "NULL in command" problem?

2007-11-12 Thread Martijn van Oosterhout
On Thu, Nov 08, 2007 at 06:39:23PM -0800, jason wrote: > As you know the interface of PQexec(): > PGresult *PQexec(PGconn *conn, const char *command); > > "command" contains some SQL statements. > > But there exist "\0" in some data filed, and I found PQexec() failed > on such situation. Two wa

Re: [GENERAL] PQexec(), what should I do for the "NULL in command" problem?

2007-11-12 Thread yang zhenyu
On Nov 12, 2007 11:13 PM, Martijn van Oosterhout <[EMAIL PROTECTED]> wrote: > On Thu, Nov 08, 2007 at 06:39:23PM -0800, jason wrote: > > As you know the interface of PQexec(): > > PGresult *PQexec(PGconn *conn, const char *command); > > > > "command" contains some SQL statements. > > > > But there

Re: [GENERAL] PQexec(), what should I do for the "NULL in command" problem?

2007-11-12 Thread Martijn van Oosterhout
On Tue, Nov 13, 2007 at 10:52:09AM +0800, yang zhenyu wrote: > > > But there exist "\0" in some data filed, and I found PQexec() failed > > > on such situation. > > Thanks for reply :-) > But would you please give me more details or some references? > > > Two ways: > > - out of line parameters >

Re: [GENERAL] PQexec(), what should I do for the "NULL in command" problem?

2007-11-13 Thread yang zhenyu
> > > - 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,