Added patch by Bernd Helmle that adds a low level
authorMichael Meskes
Fri, 18 Sep 2009 13:13:32 +0000 (13:13 +0000)
committerMichael Meskes
Fri, 18 Sep 2009 13:13:32 +0000 (13:13 +0000)
function that returns the current transaction status.

doc/src/sgml/ecpg.sgml
src/interfaces/ecpg/ecpglib/exports.txt
src/interfaces/ecpg/ecpglib/misc.c
src/interfaces/ecpg/include/ecpglib.h

index 4a22adbe838fd9860fa9e1dbdc55ac619e52ec44..34989f1dfacf5fc56f59469a9bc886e1b5735ce8 100644 (file)
@@ -1,4 +1,4 @@
-
+
 
 
  <application>ECPG</application> - Embedded <acronym>SQL</acronym> in C
@@ -4753,6 +4753,31 @@ ECPG = ecpg
     
    
 
+   
+     
+       ECPGget_PGconn(const char *connection_name)
+        returns the library database connection handle identified by the given name.
+       If connection_name is set to NULL, the current
+       connection handle is returned. If no connection handle can be identified, the function returns 
+       NULL. The returned connection handle can be used to call any other functions
+       from libpq, if necessary.
+     
+     
+     
+       It is a bad idea to manipulate database connection handles made from ecpg directly
+       with libpq routines.
+     
+     
+   
+
+   
+     
+       ECPGtransactionStatus(const char *connection_name)
+       returns the current transaction status of the given connection identified by connection_name.
+       See  and libpq's PQtransactionStatus() for details about the returned status codes.
+     
+   
+
    
     
      ECPGstatus(int lineno,
index 23f4733c4a5948b07941e010e98d5709826c5cb9..c63994ff11bbe358d67790dd4bc1a4a9e4f6406f 100644 (file)
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/exports.txt,v 1.5 2008/03/25 12:45:25 meskes Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/exports.txt,v 1.6 2009/09/18 13:13:32 meskes Exp $
 # Functions to be exported by ecpglib DLL
 ECPGallocate_desc                1
 ECPGconnect                      2
@@ -26,3 +26,4 @@ ECPGstatus                       23
 ECPGtrans                        24
 sqlprint                         25
 ECPGget_PGconn          26
+ECPGtransactionStatus      27
index f70e3734ba5f24d959256711874e3b830bc4ee70..fafe9aceba8bee51b789b65621624c5715b656be 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.51 2009/09/03 09:09:01 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.52 2009/09/18 13:13:32 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -170,6 +170,21 @@ ECPGstatus(int lineno, const char *connection_name)
    return (true);
 }
 
+PGTransactionStatusType
+ECPGtransactionStatus(const char *connection_name)
+{
+   const struct connection *con;
+
+   con = ecpg_get_connection(connection_name);
+   if (con == NULL) {
+       /* transaction status is unknown */
+       return PQTRANS_UNKNOWN;
+   }
+
+   return PQtransactionStatus(con->connection);
+
+}
+
 bool
 ECPGtrans(int lineno, const char *connection_name, const char *transaction)
 {
index eb7c5f863707b65d1771b7c6c2df50c502bff4a2..bbb817830510648d282dea1b8ecf64d8cabfb422 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * this is a small part of c.h since we don't want to leak all postgres
  * definitions into ecpg programs
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.79 2009/06/11 14:49:13 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.80 2009/09/18 13:13:32 meskes Exp $
  */
 
 #ifndef _ECPGLIB_H
@@ -59,7 +59,7 @@ bool      ECPGdeallocate(int, int, const char *, const char *);
 bool       ECPGdeallocate_all(int, int, const char *);
 char      *ECPGprepared_statement(const char *, const char *, int);
 PGconn    *ECPGget_PGconn(const char *);
-
+PGTransactionStatusType ECPGtransactionStatus(const char *);
 
 char      *ECPGerrmsg(void);