I'm using copy to import a table.  I use PQescapeString() to make
it safe, but it seems to have a problem when there is a ' in it.

The column that is being copy is a varchar.  If the string that
is being copied is the size of the varchar, and the string
contains a ', I get an error that the string is too big for the
varchar.

PQescapeString() turns the ' into a '', which should work I
think, but doesn't.

I'm currently replacing the '' by a \' and that seems to work for
me.


Kurt


Mon, 30 Dec 2002 02:23:36 +0100
Kurt Roeckx <Q@ping.be>
PQescapeString/copy problem.
Kurt Roeckx <Q@ping.be> writes:
> I'm using copy to import a table.  I use PQescapeString() to make
> it safe, but it seems to have a problem when there is a ' in it.

PQescapeString is not designed to escape data for COPY, and will not
do the right thing.  Quoting ' is not needed for COPY; what *is*
needed is quoting \n, \r, and \t (or whatever the column delimiter is).
And of course \.

Perhaps we should offer an alternative routine for quoting COPY data?
It would need to be told what the delimiter is supposed to be ...

			regards, tom lane

Sun, 29 Dec 2002 21:24:02 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: PQescapeString/copy problem. 