Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 116179
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 3.5.0_1
Fixed in: 3.6.0



Subject: Tests skipped with: invalid connection option "client_encoding"
When building DBD-Pg-3.5.3 against postgresql-8.4.20, tests are skipped because a connection to server fails and the first one is: $ prove -b t/01connect.t t/01connect.t .. # # DBI Version 1.636 # DBD::Pg Version 3.4.1 # Perl Version 5.20.1 # OS linux # PostgreSQL (compiled) ? # PostgreSQL (target) ? # PostgreSQL (reported) ? # Default port ? # DBI_DSN ? # DBI_USER <not set> # Test schema dbd_pg_testschema # LANG en_US.UTF-8 # Adjusted: initdb # Error was: invalid connection option "client_encoding" at t/dbdpg_test_setup.pl line 555. t/01connect.t .. skipped: Connection to database failed, cannot continue testing Files=1, Tests=0, 0 wallclock secs ( 0.03 usr 0.02 sys + 0.09 cusr 0.02 csys = 0.16 CPU) Result: NOTESTS DBD-Pg-3.4.2 works fine. First affected version is 3.5.0_1. I identified the culprit. It's commit: commit 581465d505988d26d44c62bf7d2ebc38aa93d2ba Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Date: Thu Sep 4 17:46:18 2014 +0100 Force client_encoding=utf8 in tests Some tests were doing SET NAMES 'UTF8' for the non-ASCII bits, while others were doing nothing and hoping, so just be consistent and use UTF8 throughout. Somebody reported the same issue to mailing <http://comments.gmane.org/gmane.comp.db.postgresql.dbdpg/2889> without relevant response. Is the client_encoding option supported by postgresql-8.4.20? (The server comes from RHEL-6.)
From: ppisar [...] redhat.com
Dne Pá 15.čec.2016 09:09:41, ppisar napsal(a): Show quoted text
> When building DBD-Pg-3.5.3 against postgresql-8.4.20, tests are > skipped because a connection to server fails and the first one is: >
[...] Show quoted text
> # Error was: invalid connection option "client_encoding" at > t/dbdpg_test_setup.pl line 555.
Attached patch allows the tests to fully pass against postgresql-8.4.20 as well as postgresql-9.5.3. It looks like the 8.4.20 does not yet support client_encoding option in a connect string as it's implemented there like <https://github.com/postgres/postgres/commit/02e14562a>.
Subject: DBD-Pg-3.5.3-compatible-client_encoding-against-postgresql-8.4.patch
From 9e845bf5c026ed6f131e7fd6c169f849e1369d2f Mon Sep 17 00:00:00 2001 From: Pavel Raiskup <praiskup@redhat.com> Date: Fri, 15 Jul 2016 21:00:03 +0200 Subject: [PATCH] compatible 'client_encoding' against postgresql 8.4 --- t/02attribs.t | 4 ++-- t/dbdpg_test_setup.pl | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/t/02attribs.t b/t/02attribs.t index 9547d27..2d09372 100644 --- a/t/02attribs.t +++ b/t/02attribs.t @@ -1100,7 +1100,7 @@ is ($attrib, 'st', $t); # Need a separate connection to keep the output size down # -my $dbh4 = connect_database({quickreturn => 1}); +my $dbh4 = connect_database({quickreturn => 2}); $t='Database handle attribute "ChildHandles" is an empty list on startup'; $attrib = $dbh4->{ChildHandles}; @@ -1273,7 +1273,7 @@ if ($client_level ne 'error') { # $t='Database handle attribute "ErrCount" starts out at 0'; -$dbh4 = connect_database({quickreturn => 1}); +$dbh4 = connect_database({quickreturn => 2}); is ($dbh4->{ErrCount}, 0, $t); $t='Database handle attribute "ErrCount" is incremented with set_err()'; diff --git a/t/dbdpg_test_setup.pl b/t/dbdpg_test_setup.pl index 275e801..053b077 100644 --- a/t/dbdpg_test_setup.pl +++ b/t/dbdpg_test_setup.pl @@ -235,10 +235,6 @@ version: $version $testuser = 'postgres'; } - # non-ASCII parts of the tests assume UTF8 - $testdsn =~ s/;?\bclient_encoding=[^;]+//; - $testdsn .= ';client_encoding=utf8'; - ## From here on out, we don't return directly, but save it first GETHANDLE: { eval { @@ -554,7 +550,7 @@ version: $version } ## Attempt to connect to this server - $testdsn = "dbi:Pg:dbname=postgres;client_encoding=utf8;port=$testport"; + $testdsn = "dbi:Pg:dbname=postgres;port=$testport"; if ($^O =~ /Win32/) { $testdsn .= ';host=localhost'; } @@ -651,6 +647,11 @@ version: $version $debug and diag "Got a database handle ($dbh)"; + if (!$arg->{quickreturn} or 1 != $arg->{quickreturn}) { + ## non-ASCII parts of the tests assume UTF8 + $dbh->do('SET client_encoding = utf8'); + } + if ($arg->{quickreturn}) { $debug and diag 'Returning via quickreturn'; return $helpconnect, '', $dbh; -- 2.7.4
Thank you, applied in 1dcdca7400c5b0bc3c6bf351cc402332562a0a25
Resolved in version 3.6.0