Thread: PG 7.4 beta 2: COPY IN, arrays, and double quotes bug.

PG 7.4 beta 2: COPY IN, arrays, and double quotes bug.

From
Bertrand Petit
Date:
I spoted a trouble with the HEAD taged PG version CVS updated
on the 4th of september.

    During a COPY FROM stdin query involving a VARCHAR[] column I
experienced troubles with values containing an escaped double quote.
The query was expressed like this on the application side:

"COPY my_table "
"(..., attribs) "
"FROM stdin WITH DELIMITER '\\t'"

One of the attribs value is piped to the backend as {"3/4\""}, this is
how the array appears on the wire, and PG rejected it with the
following message, as submited to syslog:

postgres[90257]: [51-1] ERROR:  malformed array literal: "{"3/4""}"


    Regards,
    Bertrand.



P.S.: despites that this PG vresion was CVS updated after the release
of beta 2, it still identifies itself as beta1:

=> select version();
                                version
------------------------------------------------------------------------
 PostgreSQL 7.4beta1 on i386-unknown-freebsd4.5, compiled by GCC 2.95.3
(1 row)

When PG is compiled from a CVS working directory tree, it would be
nice if the output of the version() function could include a latest
update timestamp and maybe a list of the sticky tags.

--
%!PS
297.6 420.9 translate 90 rotate 0 setgray gsave 0 1 1{pop 0 180 moveto 100
180 170 100 170 -10 curveto 180 -9 180 -9 190 -10 curveto 190 100 100 180
0 180 curveto fill 180 rotate}for grestore/Bookman-LightItalic findfont
240 scalefont setfont -151.536392 -63.7998886 moveto (bp)show showpage

Re: PG 7.4 beta 2: COPY IN, arrays, and double quotes bug.

From
Tom Lane
Date:
Bertrand Petit <pgsql-bugs@phoe.frmug.org> writes:
> One of the attribs value is piped to the backend as {"3/4\""}, this is
> how the array appears on the wire, and PG rejected it with the
> following message, as submited to syslog:

> postgres[90257]: [51-1] ERROR:  malformed array literal: "{"3/4""}"

Seems like a client-side quoting bug to me.  Backslashes have to be
doubled at the sending end, because COPY itself will do one level of
backslash processing.

If the client-side code is ours, then it's our problem, but you did not
say what you are using...

> P.S.: despites that this PG vresion was CVS updated after the release
> of beta 2, it still identifies itself as beta1:

Sounds like you didn't re-run configure after updating.  I doubt that
affects the COPY issue above, but it surely might cause some other
problems.  My invariable procedure for updating from CVS is a complete
rebuild:
        make distclean
        cvs update
        configure
        make
This costs a few machine cycles but I figure that's cheap compared to my
time puzzling out meaningless failures.

            regards, tom lane