Permalink
Browse files

[Pg] implement ping

also add a fairly trivial test
  • Loading branch information...
1 parent 424924e commit 20cfae1f3e7e499bed497ad2063f7adffafe283a @moritz moritz committed Apr 27, 2012
Showing with 11 additions and 9 deletions.
  1. +4 −8 lib/MiniDBD/Pg.pm6
  2. +7 −1 t/99-common.pl6
View
@@ -17,14 +17,6 @@ sub PQprepare (OpaquePointer $conn, Str $statement_name, Str $query, Int $n_para
is native('libpq')
{ ... }
-# PGresult *PQexecPrepared(PGconn *conn,
-# const char *stmtName,
-# int nParams,
-# const char * const *paramValues,
-# const int *paramLengths,
-# const int *paramFormats,
-# int resultFormat);
-#
sub PQexecPrepared(
OpaquePointer $conn,
Str $statement_name,
@@ -416,6 +408,10 @@ class MiniDBD::Pg::Connection does MiniDBD::Connection {
PQexec($!pg_conn, "ROLLBACK");
$.in_transaction = 0;
}
+
+ method ping {
+ PQstatus($!pg_conn) == CONNECTION_OK
+ }
}
class MiniDBD::Pg:auth<mberends>:ver<0.0.1> {
View
@@ -5,7 +5,7 @@
#use Test; # "use" dies in a runtime eval
#use MiniDBI;
diag "Testing MiniDBD::$*mdriver";
-plan 32;
+plan 33;
# Verify that the driver loads before attempting a connect
my $drh = MiniDBI.install_driver($*mdriver);
@@ -152,6 +152,12 @@ if 'fetchrow_arrayref' eq any ($sth.^methods) {
# Drop the table when finished, and disconnect
ok $dbh.do("DROP TABLE nom"), "final cleanup";
+if $dbh.can('ping') {
+ ok $dbh.ping, '.ping is true on a working DB handle';
+}
+else {
+ skip('ping not implemented', 1);
+}
ok $dbh.disconnect, "disconnect";
# Return an unabiguous sign of successful completion

0 comments on commit 20cfae1

Please sign in to comment.