Author: turnstep
Date: Wed Jul 22 19:03:42 2009
New Revision: 13106
Modified:
DBD-Pg/trunk/dbdimp.c
DBD-Pg/trunk/t/07copy.t
Log:
Fix up confusing COPY TO / COPY FROM messages.
Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c (original)
+++ DBD-Pg/trunk/dbdimp.c Wed Jul 22 19:03:42 2009
@@ -3695,7 +3695,7 @@
/* We must be in COPY IN state */
if (PGRES_COPY_IN != imp_dbh->copystate)
- croak("pg_putline can only be called directly after issuing a
COPY IN command\n");
+ croak("pg_putline can only be called directly after issuing a
COPY FROM command\n");
TRACE_PQPUTCOPYDATA;
copystatus = PQputCopyData(imp_dbh->conn, buffer, (int)strlen(buffer));
@@ -3733,7 +3733,7 @@
/* We must be in COPY OUT state */
if (PGRES_COPY_OUT != imp_dbh->copystate)
- croak("pg_getline can only be called directly after issuing a
COPY command\n");
+ croak("pg_getline can only be called directly after issuing a
COPY TO command\n");
length = 0; /* Make compilers happy */
TRACE_PQGETCOPYDATA;
@@ -3775,7 +3775,7 @@
/* We must be in COPY OUT state */
if (PGRES_COPY_OUT != imp_dbh->copystate)
- croak("pg_getcopydata can only be called directly after issuing
a COPY FROM command\n");
+ croak("pg_getcopydata can only be called directly after issuing
a COPY TO command\n");
tempbuf = NULL;
@@ -3834,7 +3834,7 @@
/* We must be in COPY IN state */
if (PGRES_COPY_IN != imp_dbh->copystate)
- croak("pg_putcopydata can only be called directly after issuing
a COPY TO command\n");
+ croak("pg_putcopydata can only be called directly after issuing
a COPY FROM command\n");
TRACE_PQPUTCOPYDATA;
copystatus = PQputCopyData
Modified: DBD-Pg/trunk/t/07copy.t
==============================================================================
--- DBD-Pg/trunk/t/07copy.t (original)
+++ DBD-Pg/trunk/t/07copy.t Wed Jul 22 19:03:42 2009
@@ -171,23 +171,23 @@
$dbh->do("DELETE FROM $table");
-$t='pg_putcopydata fails if not after a COPY TO statement';
+$t='pg_putcopydata fails if not after a COPY FROM statement';
eval {
$dbh->pg_putcopydata("pizza\tpie");
};
-like ($@, qr{COPY TO command}, $t);
+like ($@, qr{COPY FROM command}, $t);
$t='pg_getcopydata fails if not after a COPY TO statement';
eval {
$dbh->pg_getcopydata($data[0]);
};
-like ($@, qr{COPY FROM command}, $t);
+like ($@, qr{COPY TO command}, $t);
$t='pg_getcopydata_async fails if not after a COPY TO statement';
eval {
$dbh->pg_getcopydata_async($data[0]);
};
-like ($@, qr{COPY FROM command}, $t);
+like ($@, qr{COPY TO command}, $t);
$t='pg_putcopyend warns but does not die if not after a COPY statement';
eval { require Test::Warn; };
@@ -198,21 +198,21 @@
Test::Warn::warning_like (sub { $dbh->pg_putcopyend(); }, qr/until a
COPY/, $t);
}
-$t='pg_getcopydata does not work if we are using COPY .. FROM';
+$t='pg_getcopydata does not work if we are using COPY .. TO';
$dbh->rollback();
$dbh->do("COPY $table FROM STDIN");
eval {
$dbh->pg_getcopydata($data[0]);
};
-like ($@, qr{COPY FROM command}, $t);
+like ($@, qr{COPY TO command}, $t);
-$t='pg_putcopydata does not work if we are using COPY .. TO';
+$t='pg_putcopydata does not work if we are using COPY .. FROM';
$dbh->rollback();
$dbh->do("COPY $table TO STDOUT");
eval {
$dbh->pg_putcopydata("pizza\tpie");
};
-like ($@, qr{COPY TO command}, $t);
+like ($@, qr{COPY FROM command}, $t);
$t='pg_putcopydata works and returns a 1 on success';
$dbh->rollback();
@@ -234,11 +234,11 @@
};
ok ($@, $t);
-$t='Calling pg_getcopydata gives an error when in the middle of COPY .. FROM';
+$t='Calling pg_getcopydata gives an error when in the middle of COPY .. TO';
eval {
$dbh->pg_getcopydata($data[0]);
};
-like ($@, qr{COPY FROM command}, $t);
+like ($@, qr{COPY TO command}, $t);
$t='Calling do() gives an error when in the middle of COPY .. FROM';
eval {
@@ -265,7 +265,7 @@
eval {
$result = $dbh->pg_putcopydata('root');
};
-like ($@, qr{COPY TO command}, $t);
+like ($@, qr{COPY FROM command}, $t);
$t='Normal queries work after pg_putcopyend is called';
eval {
@@ -306,11 +306,11 @@
};
like ($@, qr{pg_getcopydata}, $t);
-$t='Calling pg_putcopydata gives an errors when in the middle of COPY .. TO';
+$t='Calling pg_putcopydata gives an errors when in the middle of COPY .. FROM';
eval {
$dbh->pg_putcopydata('pie');
};
-like ($@, qr{COPY TO command}, $t);
+like ($@, qr{COPY FROM command}, $t);
$t='pg_getcopydata returns 0 when no more data';
$dbh->pg_getcopydata(\$data[0]);