Added by Bernd Helmle <[email protected]> that adds a low level
authorMichael Meskes <[email protected]>
Fri, 18 Sep 2009 13:13:32 +0000 (13:13 +0000)
committerMichael Meskes <[email protected]>
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 3d005f0f4706faaf707cb25062a179fc93904251..c1f668af42c4db33376eaee3097d2c41509ce29a 100644 (file)
@@ -3062,7 +3062,7 @@ void dtcurrent(timestamp *ts);
       <term><function>dtcvasc</></term>
       <listitem>
        <para>
-        Parses a timestamp from its textual representation in ANSI standard
+        Parses a timestamp from its textual representation
         into a timestamp variable.
 <synopsis>
 int dtcvasc(char *str, timestamp *ts);
@@ -3087,7 +3087,7 @@ int dtcvasc(char *str, timestamp *ts);
       <term><function>dtcvfmtasc</></term>
       <listitem>
        <para>
-        Parses a timestamp from its textual representation in ANSI standard
+        Parses a timestamp from its textual representation
         using a format mask into a timestamp variable.
 <synopsis>
 dtcvfmtasc(char *inbuf, char *fmtstr, timestamp *dtvalue)
@@ -3140,7 +3140,7 @@ int dttoasc(timestamp *ts, char *output);
         The function receives a pointer to the timestamp variable to convert
         (<literal>ts</>) and the string that should hold the result of the
         operation <literal>output</>). It converts <literal>ts</> to its
-        textual representation in the ANSI SQL standard which is defined to
+        textual representation according to the SQL standard, which is
         be <literal>YYYY-MM-DD HH:MM:SS</literal>.
        </para>
        <para>
@@ -3187,7 +3187,7 @@ int intoasc(interval *i, char *str);
         The function receives a pointer to the interval variable to convert
         (<literal>i</>) and the string that should hold the result of the
         operation <literal>str</>). It converts <literal>i</> to its
-        textual representation in the ANSI SQL standard which is defined to
+        textual representation according to the SQL standard, which is
         be <literal>YYYY-MM-DD HH:MM:SS</literal>.
        </para>
        <para>
@@ -4753,6 +4753,31 @@ ECPG = ecpg
     </note>
    </listitem>
 
+   <listitem>
+     <para>
+       <function>ECPGget_PGconn(const char *<replaceable>connection_name</replaceable>)
+       </function> returns the library database connection handle identified by the given name.
+       If <replaceable>connection_name</replaceable> is set to <literal>NULL</literal>, the current
+       connection handle is returned. If no connection handle can be identified, the function returns 
+       <literal>NULL</literal>. The returned connection handle can be used to call any other functions
+       from <application>libpq</application>, if necessary.
+     </para>
+     <note>
+     <para>
+       It is a bad idea to manipulate database connection handles made from <application>ecpg</application> directly
+       with <application>libpq</application> routines.
+     </para>
+     </note>
+   </listitem>
+
+   <listitem>
+     <para>
+       <function>ECPGtransactionStatus(const char *<replaceable>connection_name</replaceable>)</function>
+       returns the current transaction status of the given connection identified by <replaceable>connection_name</replaceable>.
+       See <xref linkend="libpq-status"> and libpq's <function>PQtransactionStatus()</function> for details about the returned status codes.
+     </para>
+   </listitem>
+
    <listitem>
     <para>
      <function>ECPGstatus(int <replaceable>lineno</replaceable>,
index 2c5d2e0e6e4e546f9f271d2f83921cdf3abdff4c..be172cd00c432be370a4188c10a823d268e80d23 100644 (file)
@@ -26,3 +26,4 @@ ECPGstatus                       23
 ECPGtrans                        24
 sqlprint                         25
 ECPGget_PGconn                  26
+ECPGtransactionStatus      27
index 1257e95f4c1d1096491d0c18666d1808c4c39978..0aabbfd6fd1727f8f2a9f5e61174e7ecfd06d09b 100644 (file)
@@ -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 d7110157fd67f7ad8b41f494039784d08e0c0bbe..d218f442d4a7346c283147507084a411af2e67a5 100644 (file)
@@ -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);