Author: turnstep
Date: Tue Jan 15 14:01:52 2008
New Revision: 10556

Modified:
   DBD-Pg/trunk/Pg.pm
   DBD-Pg/trunk/Pg.xs
   DBD-Pg/trunk/dbdimp.c
   DBD-Pg/trunk/t/08async.t

Log:
Quick fix to handle case of 7.4 library (no async queries)


Modified: DBD-Pg/trunk/Pg.pm
==============================================================================
--- DBD-Pg/trunk/Pg.pm  (original)
+++ DBD-Pg/trunk/Pg.pm  Tue Jan 15 14:01:52 2008
@@ -3213,7 +3213,8 @@
 
 It is possible to send a query to the backend and have your script do other 
work while the query is 
 running on the backend. Both queries sent by the do() method, and by the 
execute() method can be 
-sent asynchronously. The basic usage is as follows:
+sent asynchronously. (NOTE: This will only work if DBD::Pg has been compiled 
against Postgres libraries 
+of version 8.0 or greater) The basic usage is as follows:
 
   use DBD::Pg ':async';
 

Modified: DBD-Pg/trunk/Pg.xs
==============================================================================
--- DBD-Pg/trunk/Pg.xs  (original)
+++ DBD-Pg/trunk/Pg.xs  Tue Jan 15 14:01:52 2008
@@ -621,6 +621,8 @@
                ST(0) = sv_2mortal( newSViv( type_num ) );
        }
 
+#if PGLIBVERSION >= 80000
+
 void
 pg_result(dbh)
        SV * dbh
@@ -649,6 +651,8 @@
        D_imp_dbh(dbh);
        ST(0) = dbdpg_cancel(dbh, imp_dbh) ? &sv_yes : &sv_no;
 
+#endif
+
 # -- end of DBD::Pg::db
 
 
@@ -679,6 +683,8 @@
        D_imp_sth(sth);
        ST(0) = dbdpg_cancel_sth(sth, imp_sth) ? &sv_yes : &sv_no;
 
+#if PGLIBVERSION >= 80000
+
 void
 pg_result(sth)
        SV * sth
@@ -694,5 +700,7 @@
                else
                        XST_mIV(0, ret);
 
+#endif
+
 
 # end of Pg.xs

Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c       (original)
+++ DBD-Pg/trunk/dbdimp.c       Tue Jan 15 14:01:52 2008
@@ -43,6 +43,21 @@
 int PQserverVersion(const PGconn *a);
 int PQserverVersion(const PGconn *a) { if (!a) return 0; croak ("Called wrong 
PQserverVersion"); }
 
+typedef struct pg_cancel PGcancel;
+int    PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
+int    PQcancel(PGcancel *cancel, char *errbuf, int errbufsize) {
+       croak ("Called wrong PQcancel");
+}
+PGcancel *PQgetCancel(PGconn *conn);
+PGcancel *PQgetCancel(PGconn *conn) {
+       croak ("Called wrong PQgetCancel");
+}
+void PQfreeCancel(PGcancel *cancel);
+void PQfreeCancel(PGcancel *cancel) {
+       croak ("Called wrong PQfreeCancel");
+}
+
+
 #endif
 
 #ifndef PGErrorVerbosity

Modified: DBD-Pg/trunk/t/08async.t
==============================================================================
--- DBD-Pg/trunk/t/08async.t    (original)
+++ DBD-Pg/trunk/t/08async.t    Tue Jan 15 14:01:52 2008
@@ -11,18 +11,22 @@
 require 'dbdpg_test_setup.pl';
 select(($|=1,select(STDERR),$|=1)[1]);
 
-if (defined $ENV{DBI_DSN}) {
+my $dbh = connect_database();
+my $pglibversion = $dbh->{pg_lib_version};
+
+if ($pglibversion < 80000) {
+       plan skip_all => 'Cannot run asynchronous queries with pre-8.0 
libraries.';
+}
+elsif (defined $ENV{DBI_DSN}) {
        plan tests => 66;
 }
 else {
        plan skip_all => 'Cannot run test unless DBI_DSN is defined. See the 
README file';
 }
 
-my $dbh = connect_database();
 ok( defined $dbh, 'Connect to database for async testing');
 
 my ($t,$sth,$count,$res,$expected,@data);
-my $pglibversion = $dbh->{pg_lib_version};
 my $pgversion = $dbh->{pg_server_version};
 my $table = 'dbd_pg_test1';
 

Reply via email to