diff options
author | Michael Meskes | 2009-09-18 13:13:32 +0000 |
---|---|---|
committer | Michael Meskes | 2009-09-18 13:13:32 +0000 |
commit | 663379deda26233a1ef2059d2ce7aac68ace064e (patch) | |
tree | 2e427ac95ce244c8efd159bd2787491beec38316 | |
parent | c2a12fe29628c8cd50781d02efd4f19199686d88 (diff) |
Added patch by Bernd Helmle <[email protected]> that adds a low level
function that returns the current transaction status.
-rw-r--r-- | doc/src/sgml/ecpg.sgml | 33 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/exports.txt | 1 | ||||
-rw-r--r-- | src/interfaces/ecpg/ecpglib/misc.c | 15 | ||||
-rw-r--r-- | src/interfaces/ecpg/include/ecpglib.h | 2 |
4 files changed, 46 insertions, 5 deletions
diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml index 3d005f0f47..c1f668af42 100644 --- a/doc/src/sgml/ecpg.sgml +++ b/doc/src/sgml/ecpg.sgml @@ -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> @@ -4754,6 +4754,31 @@ ECPG = ecpg </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>, const char* <replaceable>connection_name</replaceable>)</function> diff --git a/src/interfaces/ecpg/ecpglib/exports.txt b/src/interfaces/ecpg/ecpglib/exports.txt index 2c5d2e0e6e..be172cd00c 100644 --- a/src/interfaces/ecpg/ecpglib/exports.txt +++ b/src/interfaces/ecpg/ecpglib/exports.txt @@ -26,3 +26,4 @@ ECPGstatus 23 ECPGtrans 24 sqlprint 25 ECPGget_PGconn 26 +ECPGtransactionStatus 27 diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index 1257e95f4c..0aabbfd6fd 100644 --- a/src/interfaces/ecpg/ecpglib/misc.c +++ b/src/interfaces/ecpg/ecpglib/misc.c @@ -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) { diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h index d7110157fd..d218f442d4 100644 --- a/src/interfaces/ecpg/include/ecpglib.h +++ b/src/interfaces/ecpg/include/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); |