Author: turnstep
Date: Tue Apr 6 09:03:43 2010
New Revision: 13888
Modified:
DBD-Pg/trunk/t/03dbmethod.t
DBD-Pg/trunk/t/12placeholders.t
DBD-Pg/trunk/t/dbdpg_test_setup.pl
Log:
Testing tweaks to support 7.4 (even though we don't officially support it, it's nice to at least get the tests working)
Modified: DBD-Pg/trunk/t/03dbmethod.t
==============================================================================
--- DBD-Pg/trunk/t/03dbmethod.t (original)
+++ DBD-Pg/trunk/t/03dbmethod.t Tue Apr 6 09:03:43 2010
@@ -1427,6 +1427,9 @@
if ($pglibversion < 80400) {
skip ('Cannot test pg_lo_import_with_oid unless compiled against 8.4 or better server', 5);
}
+ if ($pgversion < 80000) {
+ skip ('Cannot test pg_lo_import_with_oid against old versions of Postgres', 5);
+ }
$t='DB handle method "pg_lo_import_with_oid" works with high number';
my $highnumber = 345167;
Modified: DBD-Pg/trunk/t/12placeholders.t
==============================================================================
--- DBD-Pg/trunk/t/12placeholders.t (original)
+++ DBD-Pg/trunk/t/12placeholders.t Tue Apr 6 09:03:43 2010
@@ -506,6 +506,9 @@
};
is ($@, q{}, $t);
+SKIP: {
+ skip 'Cannot run some quote tests on very old versions of Postgres', 14 if $pgversion < 80000;
+
$t='Prepare works with placeholders after double slashes';
eval {
$dbh->do(q{CREATE OPERATOR // ( PROCEDURE=bit, LEFTARG=int, RIGHTARG=int )});
@@ -544,6 +547,8 @@
is ($@, q{}, $t);
}
+}
+
SKIP: {
skip 'Cannot run backslash_quote test on Postgres < 8.2', 1 if $pgversion < 80200;
Modified: DBD-Pg/trunk/t/dbdpg_test_setup.pl
==============================================================================
--- DBD-Pg/trunk/t/dbdpg_test_setup.pl (original)
+++ DBD-Pg/trunk/t/dbdpg_test_setup.pl Tue Apr 6 09:03:43 2010
@@ -63,7 +63,8 @@
## We'll try various ways to get to a database to test with
## First, check to see if we've been here before and left directions
- my ($testdsn,$testuser,$helpconnect,$su,$uid,$testdir,$pg_ctl,$initdb,$error) = get_test_settings();
+ my ($testdsn,$testuser,$helpconnect,$su,$uid,$testdir,$pg_ctl,$initdb,$error,$version)
+ = get_test_settings();
## Did we fail last time? Fail this time too, but quicker!
if ($testdsn =~ /FAIL!/) {
@@ -131,6 +132,9 @@
}
}
$option = q{-o '-k socket'};
+ if ($version < 8.0) {
+ $option = q{-o '-k dbdpg_test_database/data/socket'};
+ }
}
my $COM = qq{$pg_ctl $option -l $testdir/dbdpg_test.logfile -D $testdir/data start};
if ($su) {
@@ -245,10 +249,11 @@
$ENV{LANG} = 'C';
$info = '';
eval {
- $info = qx{$initdb --help 2>&1};
+ $info = qx{$initdb --version 2>&1};
};
last GETHANDLE if $@; ## Fail - initdb bad
- if (!defined $info or ($info !~ /\@postgresql\.org/ and $info !~ /run as root/)) {
+ $version = 0;
+ if (!defined $info or ($info !~ /(Postgres)/i and $info !~ /run as root/)) {
if (defined $info) {
if ($info !~ /\w/) {
$@ = 'initdb not found: cannot run full tests without a Postgres database';
@@ -265,6 +270,9 @@
}
last GETHANDLE; ## Fail - initdb bad
}
+ elsif ($info =~ /(\d+\.\d+)\.\d+/) {
+ $version = $1;
+ }
## Make sure pg_ctl is available as well before we go further
if (! -e $pg_ctl) {
@@ -401,8 +409,13 @@
print $cfh "\n\n## DBD::Pg testing parameters\n";
print $cfh "port=$testport\n";
print $cfh "max_connections=4\n";
- print $cfh "log_statement = 'all'\n";
- print $cfh "log_line_prefix = '%m [%p] '\n";
+ if ($version >= 8.0) {
+ print $cfh "log_statement = 'all'\n";
+ print $cfh "log_line_prefix = '%m [%p] '\n";
+ }
+ else {
+ print $cfh "silent_mode = true\n";
+ }
print $cfh "log_min_messages = 'DEBUG1'\n";
print $cfh "listen_addresses='127.0.0.1'\n" if $^O =~ /Win32/;
print $cfh "\n";
@@ -426,6 +439,9 @@
}
}
$option = q{-o '-k socket'};
+ if ($version < 8.0) {
+ $option = q{-o '-k dbdpg_test_database/data/socket'};
+ }
}
my $COM = qq{$pg_ctl $option -l $testdir/dbdpg_test.logfile -D $testdir/data start};
$olddir = getcwd;
@@ -453,6 +469,7 @@
else {
$testdsn .= ";host=$testdir/data/socket";
}
+
my $loop = 1;
STARTUP: {
eval {
@@ -461,7 +478,22 @@
};
## Regardless of the error, try again.
## We used to check the message, but LANG problems may complicate that.
+
if ($@) {
+ if ($@ =~ /database "postgres" does not exist/) {
+ ## Old server, so let's create a postgres database manually
+ sleep 2;
+ (my $tempdsn = $testdsn) =~ s/postgres/template1/;
+ eval {
+ $dbh = DBI->connect($tempdsn, $testuser, '',
+ {RaiseError => 1, PrintError => 0, AutoCommit => 1});
+ };
+ $dbh->do('CREATE DATABASE postgres');
+ $dbh->disconnect();
+ if ($@) {
+ die "Could not connect: $@\n";
+ }
+ }
if ($loop++ < 5) {
sleep 1;
redo STARTUP;
@@ -483,6 +515,7 @@
print $fh "## Helpconnect: $helpconnect\n";
print $fh "## pg_ctl: $pg_ctl\n";
print $fh "## initdb: $initdb\n";
+ print $fh "## Version: $version\n";
if ($connerror) {
print $fh "## DSN: FAIL!\n";
print $fh "## ERROR: $connerror\n";
@@ -601,7 +634,7 @@
($pg_ctl = $ENV{PGINITDB}) =~ s/initdb/pg_ctl/;
}
my ($testdsn, $testuser, $testdir, $error) = ('','','','?');
- my ($helpconnect, $su, $uid, $initdb) = (0,'','','default');
+ my ($helpconnect, $su, $uid, $initdb, $version) = (0,'','','default',0);
my $inerror = 0;
if (-e $helpfile) {
open $fh, '<', $helpfile or die qq{Could not open "$helpfile": $!\n};
@@ -618,6 +651,7 @@
/pg_ctl: (.+)/ and $pg_ctl = $1;
/initdb: (.+)/ and $initdb = $1;
/ERROR: (.+)/ and $error = $1 and $inerror = 1;
+ /Version: (.+)/ and $version = $1;
}
close $fh or die qq{Could not close "$helpfile": $!\n};
}
@@ -627,7 +661,7 @@
$testdir = "$dir/dbdpg_test_database";
}
- return $testdsn, $testuser, $helpconnect, $su, $uid, $testdir, $pg_ctl, $initdb, $error;
+ return $testdsn, $testuser, $helpconnect, $su, $uid, $testdir, $pg_ctl, $initdb, $error, $version;
} ## end of get_test_settings
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.