Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 20435
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.49
Fixed in: 2.0.0



Subject: New COPY support breaks old idiom
I'm upgrading DBD::Pg from 1.32 to 1.49 and my existing code is breaking due to the new COPY support methods not allowing the old idiom for copying to work. With 1.32 the code did this: $dbh->do("COPY $table ( $fields ) FROM STDIN"); $dbh->func($line, "putline"); $dbh->func("\\.\n", "putline"); $dbh->func("endcopy"); But that code no longer works. DBD::Pg 1.49 complains "Must call pg_endcopy before issuing more commands". But pg_endcopy() was added in 1.41 and I need to support earlier versions. This is problematic as there's now no cross-version compatible way to copy a table (if there is, please let me know). We are experiencing a similar problem with $dbh->do("ROLLBACK TO SAVEPOINT $savepoint_name"); DBD::Pg 1.32 complains that we're trying to do a ROLLBACK via do() and should instead use the method. It doesn't understand we're doing a different kind of rollback and 1.32 has no savepoint methods. I'm glad to see this "helpful" check has been removed in 1.49. It would be nice if these sorts of "helpful" checks were turned from errors into warnings and the old idioms be allowed to work in the new versions to facilitate upgrades.
On Wed Jul 12 14:08:17 2006, MSCHWERN wrote: Show quoted text
> But that code no longer works. DBD::Pg 1.49 complains "Must call > pg_endcopy before issuing more commands".
The problem was the behavior of getline() changed, as reported in [rt.cpan.org 20447]. The existing code works just fine as long as the change to getline() is taken into account. The error message could be better.
The old COPY functions are deprecated as of 2.0.0, due to a change in the underlying Postgres library, libpq. We now use pg_getcopydata, pg_putcopydata, and pg_putcopyend. Hopefully, these will behave better and certainly have an easier API than the old ones. Marking as "resolved" as rt.cpan.org does not really have a "does not apply due to API change, but may still be an issue in older versions" field. :)