Author: turnstep
Date: Thu Dec 17 07:17:47 2009
New Revision: 13669

Modified:
   DBD-Pg/trunk/Changes
   DBD-Pg/trunk/t/06bytea.t

Log:
Put in a test for high-bit characters in bytea handling.


Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes        (original)
+++ DBD-Pg/trunk/Changes        Thu Dec 17 07:17:47 2009
@@ -1,5 +1,7 @@
 ('GSM' is Greg Sabino Mullane, [email protected])
 
+ - Put in a test for high-bit characters in bytea handling.
+   [Bryce Nesbitt] (see also CPAN bug #39390)
 
  - Better SQLSTATE code on connection failure (CPAN bug #52863)
    [Chris Travers with help from Andrew Gierth]

Modified: DBD-Pg/trunk/t/06bytea.t
==============================================================================
--- DBD-Pg/trunk/t/06bytea.t    (original)
+++ DBD-Pg/trunk/t/06bytea.t    Thu Dec 17 07:17:47 2009
@@ -17,7 +17,7 @@
 if (! defined $dbh) {
        plan skip_all => 'Connection to database failed, cannot continue 
testing';
 }
-plan tests => 7;
+plan tests => 11;
 
 isnt ($dbh, undef, 'Connect to database for bytea testing');
 
@@ -40,6 +40,14 @@
 $t='bytea (second) insert test with string containing a single quote';
 ok ($sth->execute(402, '\''), $t);
 
+my ($binary_in, $binary_out);
+$t='store binary data in BYTEA column';
+for(my $i=0; $i<256; $i++) { $binary_out .= chr($i); }
+$sth->{pg_server_prepare} = 0;
+ok ($sth->execute(403, $binary_out), $t);
+$sth->{pg_server_prepare} = 1;
+ok ($sth->execute(404, $binary_out), $t);
+
 $t='Received correct text from BYTEA column with backslashes';
 $sth = $dbh->prepare(q{SELECT bytetest FROM dbd_pg_test WHERE id=?});
 $sth->execute(400);
@@ -51,6 +59,14 @@
 $byte = $sth->fetchall_arrayref()->[0][0];
 is ($byte, '\'', $t);
 
+$t='Ensure proper handling of high bit characters';
+$sth->execute(403);
+($binary_in) = $sth->fetchrow_array();
+ok( $binary_in eq $binary_out, $t );
+$sth->execute(404);
+($binary_in) = $sth->fetchrow_array();
+ok( $binary_in eq $binary_out, $t );
+
 $t='quote properly handles bytea strings';
 my $string = "abc\123\\def\0ghi";
 my $result = $dbh->quote($string, { pg_type => PG_BYTEA });

Reply via email to