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.