The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 18
META.yml 33
Makefile.PL 22
Pg.pm 5454
README 22
SIGNATURE 1515
dbdimp.c 45
lib/Bundle/DBD/Pg.pm 11
quote.c 22
t/02attribs.t 05
t/03dbmethod.t 229
t/09arrays.t 04
t/99_spellcheck.t 21
13 files changed (This is a version diff) 88131
@@ -1,6 +1,13 @@
 ('GSM' is Greg Sabino Mullane, greg@turnstep.com)
 
-2.10.5 Released September 16, 2008
+2.10.6 Released September 19, 2008
+
+	- Correctly quote all bytea characters. (CPAN bug #39390) [Rod Taylor]
+	- Prevent core dump when checking $dbh->{standard_conforming_strings}
+		on older servers. [GSM]
+	- Skip unicode tests if server is set to 'LATIN1' [GSM]
+
+2.10.5 Released September 16, 2008 (subversion r11800)
 
 	- Fix SIGNATURE file
 
@@ -1,6 +1,6 @@
 --- #YAML:1.1
 name                        : DBD-Pg
-version                     : 2.10.5
+version                     : 2.10.6
 abstract                    : DBI PostgreSQL interface
 author:              
   - Greg Sabino Mullane <greg@turnstep.com>
@@ -38,10 +38,10 @@ recommends:
 provides:
   DBD::Pg:
     file                    : Pg.pm
-    version                 : 2.10.5
+    version                 : 2.10.6
   Bundle::DBD::Pg:
     file                    : lib/Bundle/DBD/Pg.pm
-    version                 : 2.10.5
+    version                 : 2.10.6
 
 keywords:
   - Postgres
@@ -1,4 +1,4 @@
-# $Id: Makefile.PL 11798 2008-09-16 15:38:17Z turnstep $
+# $Id: Makefile.PL 11803 2008-09-17 22:02:51Z turnstep $
 
 use ExtUtils::MakeMaker;
 use Config;
@@ -7,7 +7,7 @@ use warnings;
 use 5.006001;
 
 ## No version.pm for this one, as the prereqs are not loaded yet.
-my $VERSION = '2.10.5';
+my $VERSION = '2.10.6';
 
 my $lib;
 BEGIN {
@@ -1,5 +1,5 @@
 #  -*-cperl-*-
-#  $Id: Pg.pm 11798 2008-09-16 15:38:17Z turnstep $
+#  $Id: Pg.pm 11806 2008-09-17 22:22:54Z turnstep $
 #
 #  Copyright (c) 2002-2008 Greg Sabino Mullane and others: see the Changes file
 #  Portions Copyright (c) 2002 Jeffrey W. Baker
@@ -17,7 +17,7 @@ use 5.006001;
 {
 	package DBD::Pg;
 
-	use version; our $VERSION = qv('2.10.5');
+	use version; our $VERSION = qv('2.10.6');
 
 	use DBI ();
 	use DynaLoader ();
@@ -1703,7 +1703,7 @@ DBD::Pg - PostgreSQL database driver for the DBI module
 
 =head1 VERSION
 
-This documents version 2.10.5 of the DBD::Pg module
+This documents version 2.10.6 of the DBD::Pg module
 
 =head1 DESCRIPTION
 
@@ -2243,15 +2243,15 @@ Implemented by DBI, no driver-specific impact.
 Returns C<dr> for a driver handle, C<db> for a database handle, and C<st> for a statement handle. 
 Should be rarely needed.
 
-=head3 B<LongReadLen> (integer, inherited)
+=head3 B<LongReadLen>
 
 Not used by DBD::Pg
 
-=head3 B<LongTruncOk> (boolean, inherited)
+=head3 B<LongTruncOk>
 
 Not used by DBD::Pg
 
-=head3 B<CompatMode> (boolean, inherited)
+=head3 B<CompatMode>
 
 Not used by DBD::Pg
 
@@ -2420,7 +2420,7 @@ You can force DBD::Pg to send your query directly to the server by adding
 the L</pg_direct> attribute to your prepare call. This is not recommended,
 but is added just in case you need it.
 
-=head3 B<Placeholders>
+=head4 B<Placeholders>
 
 There are three types of placeholders that can be used in DBD::Pg. The first is
 the "question mark" type, in which each placeholder is represented by a single
@@ -2623,6 +2623,47 @@ If the script exits before disconnect is called (or, more precisely, if the data
 referenced by anything), then the database handle's DESTROY method will call the rollback() and disconnect() 
 methods automatically. It is best to explicitly disconnect rather than rely on this behavior.
 
+=head3 B<quote>
+
+  $rv = $dbh->quote($value, $data_type);
+
+This module implements its own C<quote> method. For simple string types, both backslashes 
+and single quotes are doubled. You may also quote arrayrefs and receive a string 
+suitable for passing into Postgres array columns.
+
+If the value contains backslashes, and the server is version 8.1 or higher, 
+then the escaped string syntax will be used (which places a capital E before 
+the first single quote). This syntax is always used when quoting bytea values 
+on servers 8.1 and higher.
+
+The C<data_type> argument is optional and should be one of the type constants 
+exported by DBD::Pg (such as PG_BYTEA). In addition to string, bytea, char, bool, 
+and other standard types, the following geometric types are supported: point, line, 
+lseg, box, path, polygon, and circle (PG_POINT, PG_LINE, PG_LSEG, PG_BOX, 
+PG_POLYGON, and PG_CIRCLE respectively).
+
+B<NOTE:> The undocumented (and invalid) support for the C<SQL_BINARY> data
+type is officially deprecated. Use C<PG_BYTEA> with C<bind_param()> instead:
+
+  $rv = $sth->bind_param($param_num, $bind_value,
+                         { pg_type => PG_BYTEA });
+
+=head3 B<quote_identifier>
+
+  $string = $dbh->quote_identifier( $name );
+  $string = $dbh->quote_identifier( undef, $schema, $table);
+
+Returns a quoted version of the supplied string, which is commonly a schema, 
+table, or column name. The three argument form will return the schema and 
+the table together, separated by a dot. Examples:
+
+  print $dbh->quote_identifier('grapefruit'); ## Prints: "grapefruit"
+
+  print $dbh->quote_identifier('juicy fruit'); ## Prints: "juicy fruit"
+
+  print $dbh->quote_identifier(undef, 'public', 'pg_proc');
+  ## Prints: "public"."pg_proc"
+
 =head3 B<pg_notifies>
 
   $ret = $dbh->pg_notifies;
@@ -2911,47 +2952,6 @@ according to the following table:
 Returns a list of hash references holding information about one or more variants of $data_type. 
 See the DBI documentation for more details.
 
-=head3 B<quote>
-
-  $rv = $dbh->quote($value, $data_type);
-
-This module implements its own C<quote> method. For simple string types, both backslashes 
-and single quotes are doubled. You may also quote arrayrefs and receive a string 
-suitable for passing into Postgres array columns.
-
-If the value contains backslashes, and the server is version 8.1 or higher, 
-then the escaped string syntax will be used (which places a capital E before 
-the first single quote). This syntax is always used when quoting bytea values 
-on servers 8.1 and higher.
-
-The C<data_type> argument is optional and should be one of the type constants 
-exported by DBD::Pg (such as PG_BYTEA). In addition to string, bytea, char, bool, 
-and other standard types, the following geometric types are supported: point, line, 
-lseg, box, path, polygon, and circle (PG_POINT, PG_LINE, PG_LSEG, PG_BOX, 
-PG_POLYGON, and PG_CIRCLE respectively).
-
-B<NOTE:> The undocumented (and invalid) support for the C<SQL_BINARY> data
-type is officially deprecated. Use C<PG_BYTEA> with C<bind_param()> instead:
-
-  $rv = $sth->bind_param($param_num, $bind_value,
-                         { pg_type => PG_BYTEA });
-
-=head3 B<quote_identifier>
-
-  $string = $dbh->quote_identifier( $name );
-  $string = $dbh->quote_identifier( undef, $schema, $table);
-
-Returns a quoted version of the supplied string, which is commonly a schema, 
-table, or column name. The three argument form will return the schema and 
-the table together, separated by a dot. Examples:
-
-  print $dbh->quote_identifier('grapefruit'); ## Prints: "grapefruit"
-
-  print $dbh->quote_identifier('juicy fruit'); ## Prints: "juicy fruit"
-
-  print $dbh->quote_identifier(undef, 'public', 'pg_proc');
-  ## Prints: "public"."pg_proc"
-
 =head3 B<pg_server_trace>
 
   $dbh->pg_server_trace($filehandle);
@@ -3149,7 +3149,7 @@ backend server process handling the connection.
 DBD::Pg specific attribute. Default is off. If true, then the L</prepare> method will 
 immediately prepare commands, rather than waiting until the first execute.
 
-=head3 B<pg_expand_array> (boolean, read-only)
+=head3 B<pg_expand_array> (boolean)
 
 DBD::Pg specific attribute. Defaults to false. If false, arrays returned from the server will 
 not be changed into a Perl arrayref, but remain as a string.
@@ -3175,7 +3175,7 @@ Constant to be used for the mode in L</lo_creat> and L</lo_open>.
 
 Constant to be used for the mode in L</lo_creat> and L</lo_open>.
 
-=head3 B<Driver> (handle)
+=head3 B<Driver> (handle, read-only)
 
 Holds the handle of the parent driver. The only recommended use for this is to find the name 
 of the driver using:
@@ -3188,9 +3188,9 @@ DBD::Pg specific attribute. Returns the version of the PostgreSQL server.
 If DBD::Pg is unable to figure out the version, it will return a "0". Otherwise,
 a "3" is returned.
 
-=head3 B<RowCacheSize> (integer)
+=head3 B<RowCacheSize>
 
-Not used for DBD::Pg
+Not used by DBD::Pg
 
 =head1 DBI STATEMENT HANDLE OBJECTS
 
@@ -3703,11 +3703,11 @@ on L</Asynchronous Constants> for more information.
 
 Not used by DBD::Pg
 
-=head3 B<RowCache> (integer, read-only)
+=head3 B<RowCache>
 
 Not used by DBD::Pg
 
-=head3 B<CursorName> (string, read-only)
+=head3 B<CursorName>
 
 Not used by DBD::Pg. See the note about L</Cursors> elsewhere in this document.
 
@@ -1,12 +1,12 @@
 
 DBD::Pg  --  the DBI PostgreSQL interface for Perl
 
-# $Id: README 11798 2008-09-16 15:38:17Z turnstep $
+# $Id: README 11803 2008-09-17 22:02:51Z turnstep $
 
 DESCRIPTION:
 ------------
 
-This is version 2.10.5 of DBD::Pg, the Perl interface to Postgres using DBI. 
+This is version 2.10.6 of DBD::Pg, the Perl interface to Postgres using DBI. 
 The web site for this interface, and the latest version, can be found at:
 
 	http://search.cpan.org/dist/DBD-Pg/
@@ -15,41 +15,41 @@ not run its Makefile.PL or Build.PL.
 Hash: RIPEMD160
 
 SHA1 14d7a3c7a0b0497e4ab463b67850bd5e1f70409d .perlcriticrc
-SHA1 a8c228dece4d35ac6b1480daade898612176e65c Changes
+SHA1 a83dc346eeb9fdcdadc901061c651d32abc88d75 Changes
 SHA1 4d91c71e5dbb19ece1505ab75c36d00a744bb076 MANIFEST
 SHA1 22055b195f5cf15d7909e8a08468e617f46154e7 MANIFEST.SKIP
-SHA1 2d51a4a17f8533f50228d5aee5c12f7e8273ff1a META.yml
-SHA1 9e85dd278bf84e97fe012537198b3ef36f229488 Makefile.PL
+SHA1 d95d5380fd3d79e11987b82064c817770c9b3aa6 META.yml
+SHA1 56f3ade7a370cc8a7def08c454b6b77743df26de Makefile.PL
 SHA1 c51356c52c139265e20a2ad33bc8d3ee04f6ff48 Pg.h
-SHA1 7a651bb36b7f4bf75c88f0ad68bdd8dc4bfce69f Pg.pm
+SHA1 d9863b63a025c1554d2e1d7335260e3f9a3fad5c Pg.pm
 SHA1 caf6c843024b2853bc2460c60f9c667f9150cbd4 Pg.xs
-SHA1 7033f02e84f71f6a7be1527b5c2c623b5a74af5c README
+SHA1 356be150aff2608f6b87505eed03b37b984ca541 README
 SHA1 c6d2633bdb72186bfb2887d6a1efab3a06f44cbd README.dev
 SHA1 968d5fad61bce160b31a9cb1a21dd240b9df930f README.win32
 SHA1 cb3078ec98906fc6381ca0af9e146e2d8b4176c6 TODO
-SHA1 9f62d36a36b23819316112e853f142bd8bfefafc dbdimp.c
+SHA1 de56b7328d402a3ba32431b97410d401aedc7f45 dbdimp.c
 SHA1 e079dca9f560b265daba52e7daee42e1a17184bb dbdimp.h
 SHA1 6c33bcf138e577722283bef02fceb8cbce4d100d dbivport.h
-SHA1 8065710e31f61f0227044cb0f880d133a1588770 lib/Bundle/DBD/Pg.pm
-SHA1 76a2c65c065a93775ceadf933a5d38bb25c8afa4 quote.c
+SHA1 6a3c7c46fc7db7e76c7333026bf714e1458137fb lib/Bundle/DBD/Pg.pm
+SHA1 dbe8b0bd24538a61d4c617848e7fca27fd4ea3eb quote.c
 SHA1 0a1fdd0406c5c367a9aba366d1d35cfa8d5272ae quote.h
 SHA1 93aa7e8cae0a361d1e6163dea0281ebff41f3c5f t/00-signature.t
 SHA1 073baf503a601ceeb49516d61bd275f0c1e51563 t/00basic.t
 SHA1 e5c88f4796bed486507104d3a751315995c77b94 t/01connect.t
 SHA1 ec842e6aaf11d6a55809318d69bd11ce8245092f t/01constants.t
-SHA1 806b8b7dfac746f8d4624a61cd0de387baa206ee t/02attribs.t
-SHA1 0d0a07674d2c493601a6807d22c2c8f2bdbbcd91 t/03dbmethod.t
+SHA1 73c4d8f20e828885828505f8266629af4f2e8ae9 t/02attribs.t
+SHA1 790f36471738f6b701e86654f8cd0ffafce03f0b t/03dbmethod.t
 SHA1 7ce47f4163e23b3f3df589487707257f5158001a t/03smethod.t
 SHA1 910d6c2234d77a74a49cf189b6c799e13bf75280 t/04misc.t
 SHA1 ee7ecab04b202d5cd8816fbb8c2703971161dd53 t/06bytea.t
 SHA1 2aac29d06766d0edbf0848c433c2ff837908e6ea t/07copy.t
 SHA1 1413c886eaf1714db1cf8abfb989dabfd86dee87 t/08async.t
-SHA1 acfbfcdbbf4f285b068da11c1031d0afc1c365b5 t/09arrays.t
+SHA1 5027751944bdca8f0fe63c20c790c4c3beccf433 t/09arrays.t
 SHA1 ee401c485a5c6f36844268eac0e95485359790bf t/12placeholders.t
 SHA1 85b5df8ef0c78b1d2d0018d874c62af7ef01a28f t/20savepoints.t
 SHA1 3bfb78b128724d3badf19ec4db8c1674543c557e t/99_perlcritic.t
 SHA1 9f94e06ec6b6a27512f1f4c638635e4095ae6be7 t/99_pod.t
-SHA1 e538f970e7609cdbd9aa25917b0b578b31970b29 t/99_spellcheck.t
+SHA1 29ee4d1ebb593b2148e2b50f75e55c7c4b8ee376 t/99_spellcheck.t
 SHA1 ace40437561196dc6a08b5e725de35aed0e9902c t/99_yaml.t
 SHA1 60031c2db489d77291078ab6a418723e1a35f137 t/99cleanup.t
 SHA1 1ecceecf54ab48affeae320e0cd8dfbcacfd51d5 t/dbdpg_test_setup.pl
@@ -65,7 +65,7 @@ SHA1 01c443add5e4541921943d361025d3e82e9bc7d0 types.h
 SHA1 f07cd5ecaeb854c81ceb9206364979cf607e6546 win32.mak
 -----BEGIN PGP SIGNATURE-----
 
-iEYEAREDAAYFAkjP07QACgkQvJuQZxSWSsgmfgCcC3tGAPI0UxImLBXnPQ23HlDE
-UTwAn1JXnCU31ik1uVrJGplXsAvgPVM+
-=roW2
+iEYEAREDAAYFAkjTqRQACgkQvJuQZxSWSshUHQCgrdRP5fxrnfWKeGBUpLP084l0
+r+YAni9pa97s07shGU5LGSjiTUmOeZnO
+=lkDO
 -----END PGP SIGNATURE-----
@@ -1,6 +1,6 @@
 /*
 
-  $Id: dbdimp.c 11673 2008-08-23 22:11:15Z turnstep $
+  $Id: dbdimp.c 11818 2008-09-18 19:10:13Z turnstep $
 
   Copyright (c) 2002-2008 Greg Sabino Mullane and others: see the Changes file
   Portions Copyright (c) 2002 Jeffrey W. Baker
@@ -623,7 +623,7 @@ SV * dbd_db_FETCH_attrib (SV * dbh, imp_dbh_t * imp_dbh, SV * keysv)
 	SV *   retsv = Nullsv;
 	
 	if (TSTART) TRC(DBILOGFP, "%sBegin dbd_db_FETCH (key: %s)\n", THEADER, dbh ? key : key);
-	
+
 	switch (kl) {
 
 	case 5: /* pg_db */
@@ -743,8 +743,9 @@ SV * dbd_db_FETCH_attrib (SV * dbh, imp_dbh_t * imp_dbh, SV * keysv)
 	case 30: /* pg_standard_conforming_strings */
 
 		if (strEQ("pg_standard_conforming_strings", key)) {
-			TRACE_PQPARAMETERSTATUS;
-			retsv = newSVpv(PQparameterStatus(imp_dbh->conn,"standard_conforming_strings"),0);
+			if (NULL != PQparameterStatus(imp_dbh->conn, "standard_conforming_strings")) {
+				retsv = newSVpv(PQparameterStatus(imp_dbh->conn,"standard_conforming_strings"),0);
+			}
 		}
 		break;
 
@@ -4,7 +4,7 @@ package Bundle::DBD::Pg;
 use strict;
 use warnings;
 
-$VERSION = '2.10.5';
+$VERSION = '2.10.6';
 
 1;
 
@@ -1,6 +1,6 @@
 /*
 
-   $Id: quote.c 11220 2008-05-09 02:14:39Z turnstep $
+   $Id: quote.c 11819 2008-09-18 19:10:52Z turnstep $
 
    Copyright (c) 2003-2008 Greg Sabino Mullane and others: see the Changes file
 
@@ -205,7 +205,7 @@ char * quote_bytea(char *string, STRLEN len, STRLEN *retlen, int estring)
 			*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 {
@@ -411,6 +411,11 @@ if ($old_encoding ne 'UTF8') {
 SKIP: {
 	eval { require Encode; };
 	skip ('Encode module is needed for unicode tests', 5) if $@;
+
+	my $server_encoding = $dbh->selectall_arrayref('SHOW server_encoding')->[0][0];
+	skip ('Cannot test unicode with a LATIN1 database', 5)
+		if $server_encoding eq 'LATIN1';
+
 	my $SQL = 'SELECT id, pname FROM dbd_pg_test WHERE id = ?';
 	my $sth = $dbh->prepare($SQL);
 	$sth->execute(1);
@@ -26,7 +26,7 @@ my $dbh = connect_database();
 if (! defined $dbh) {
 	plan skip_all => 'Connection to database failed, cannot continue testing';
 }
-plan tests => 224;
+plan tests => 479;
 
 isnt ($dbh, undef, 'Connect to database for database handle method testing');
 
@@ -633,6 +633,8 @@ is_deeply (\@result, $expected, $t);
 # Test of the "statistics_info" database handle method
 #
 
+SKIP: {
+
 $dbh->{private_dbdpg}{version} >= 80000
 	or skip ('Server must be version 8.0 or higher to test database handle method "statistics_info"', 10);
 
@@ -745,7 +747,7 @@ $dbh->do("DROP TABLE $table3");
 $dbh->do("DROP TABLE $table2");
 $dbh->do("DROP TABLE $table1");
 
-## end of statistics_info tests
+} ## end of statistics_info tests
 
 
 #
@@ -1115,6 +1117,31 @@ my $foo;
 $t='DB handle method "quote" works with a supplied data type argument';
 is ($dbh->quote(1, 4), 1, $t);
 
+## Test bytea quoting
+my $scs = $dbh->{pg_standard_conforming_strings};
+for my $byteval (1 .. 255) {
+	my $byte = chr($byteval);
+	$result = $dbh->quote($byte, { pg_type => PG_BYTEA });
+	if ($byteval < 32 or $byteval >= 127) {
+		$expected = $scs
+			? sprintf q{E'\\\\%03o'}, $byteval
+				: sprintf q{'\\\\%03o'}, $byteval;
+	}
+	else {
+		$expected = $scs
+			? sprintf q{E'%s'}, $byte
+				: sprintf q{'%s'}, $byte;
+	}
+	if ($byte eq '\\') {
+		$expected =~ s{\\}{\\\\\\\\};
+	}
+	elsif ($byte eq q{'}) {
+		$expected = $scs ? q{E''''} : q{''''};
+	}
+	$t = qq{Byte value $byteval quotes to $expected};
+	is ($result, $expected, $t);
+}
+
 ## Various backslash tests
 $t='DB handle method "quote" works properly with backslashes';
 my $E = $pgversion >= 80100 ? q{E} : q{};
@@ -499,6 +499,10 @@ SKIP: {
 	eval { require Encode; };
 	skip ('Encode module is needed for unicode tests', 14) if $@;
 
+	my $server_encoding = $dbh->selectall_arrayref('SHOW server_encoding')->[0][0];
+	skip ('Cannot test unicode with a LATIN1 database', 14)
+		if $server_encoding eq 'LATIN1';
+
 	$t='String should be UTF-8';
 	local $dbh->{pg_enable_utf8} = 1;
 	my $utf8_str = chr(0x100).'dam'; # LATIN CAPITAL LETTER A WITH MACRON
@@ -483,6 +483,7 @@ txn
 typename
 uid
 undef
+unicode
 unix
 UNKNOWNOID
 userid
@@ -556,7 +557,6 @@ yml
 ## TODO:
 struct
 hashrefs
-unicode
 
 ## README.dev:
 DProf
@@ -799,7 +799,6 @@ encodings
 lc
 msg
 uc
-unicode
 
 ## t/03smethod.t:
 ArrayTupleFetch