On Fri, 06 Nov 2009 15:31:42 -0800, Bryce Nesbitt wrote: > Here's the one line patch, consistent with upstream > http://rt.cpan.org/Public/Bug/Display.html?id=39390 > Plus an addition to the test harness which I highly encourage you to > raft along.
Thanks alot, your help is much appreciated! After fiddling a bit with the wrapped lines in the mail I got the patch applied now (and I had to change some whitespace in t/06bytea.t to make t/99_perlcritic.t pass :)). For reference I'm attaching it in unified diff format again. I'm going to contact the release team now about the inclusion in a Lenny point release. Cheers, gregor -- .''`. http://info.comodo.priv.at/ -- GPG Key IDs: 0x00F3CFE4, 0x8649AA06 : :' : Debian GNU/Linux user, admin, & developer - http://www.debian.org/ `. `' Member of VIBE!AT, SPI Inc., fellow of FSFE | http://got.to/quote/ `- NP: Lenny Kravitz: Black Velveteen
Index: t/06bytea.t =================================================================== --- t/06bytea.t (revision 46899) +++ t/06bytea.t (working copy) @@ -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'); @@ -28,6 +28,7 @@ my ($sth, $t); +################################################################# $sth = $dbh->prepare(q{INSERT INTO dbd_pg_test (id,bytetest) VALUES (?,?)}); $t='bytea insert test with string containing null and backslashes'; @@ -40,6 +41,15 @@ $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 +61,16 @@ $byte = $sth->fetchall_arrayref()->[0][0]; is ($byte, '\'', $t); +$t='compare binary data in bytea row 403'; +$sth->execute(403); +($binary_in) = $sth->fetchrow_array(); +ok ($binary_in eq $binary_out, $t); +$t='compare binary data in bytea row 404'; +$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 }); Index: quote.c =================================================================== --- quote.c (revision 46899) +++ quote.c (working copy) @@ -205,7 +205,7 @@ *result++ = '\\'; } else if (*string < 0x20 || *string > 0x7e) { - (void) snprintf((char *)result, 6, "\\\\%03o", *string++); + (void) snprintf((char *)result, 6, "\\\\%03o", (unsigned char)*string++); result += 5; } else {
signature.asc
Description: Digital signature