Author: turnstep
Date: Wed Apr 30 15:39:27 2008
New Revision: 11156
Modified:
DBD-Pg/trunk/Changes
DBD-Pg/trunk/dbdimp.c
DBD-Pg/trunk/t/07copy.t
Log:
Fix for bug #35556: Calling pg_getcopydata into a new var segfaults.
Thanks to David Harris for finding this and supplying a fix.
Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes (original)
+++ DBD-Pg/trunk/Changes Wed Apr 30 15:39:27 2008
@@ -1,7 +1,9 @@
('GSM' is Greg Sabino Mullane, [EMAIL PROTECTED])
-2.6.2
+2.6.2 Released April 30, 2008
+ - Fix coredump when pg_getcopydata copies 0 rows into a
+ freshly created var. (CPAN bug #35556) [David Harris]
- Allow 'make test' create a test database from scratch if
if it can't find an existing one to use. [GSM]
Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c (original)
+++ DBD-Pg/trunk/dbdimp.c Wed Apr 30 15:39:27 2008
@@ -3653,7 +3653,7 @@
else if (-1 == copystatus) {
PGresult * result;
ExecStatusType status;
- SvCUR_set(dataline, 0);
+ sv_setpv(dataline, "");
imp_dbh->copystate=0;
TRACE_PQGETRESULT;
result = PQgetResult(imp_dbh->conn);
Modified: DBD-Pg/trunk/t/07copy.t
==============================================================================
--- DBD-Pg/trunk/t/07copy.t (original)
+++ DBD-Pg/trunk/t/07copy.t Wed Apr 30 15:39:27 2008
@@ -13,7 +13,7 @@
my $dbh = connect_database();
if (defined $dbh) {
- plan tests => 54;
+ plan tests => 55;
}
else {
plan skip_all => 'Connection to database failed, cannot continue
testing';
@@ -302,6 +302,14 @@
};
is($@, q{}, $t);
+$t=q{pg_getcopydata works when pulling from an empty table into an empty var};
+$dbh->do("COPY (SELECT 1 FROM pg_class LIMIT 0) TO STDOUT");
+eval {
+ my $newvar;
+ $dbh->pg_getcopydata($newvar);
+};
+is($@, q{}, $t);
+
#
# Make sure rollback and commit reset our internal copystate tracking
#