From 663379deda26233a1ef2059d2ce7aac68ace064e Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Fri, 18 Sep 2009 13:13:32 +0000 Subject: Added patch by Bernd Helmle that adds a low level function that returns the current transaction status. --- doc/src/sgml/ecpg.sgml | 33 +++++++++++++++++++++++++++++---- src/interfaces/ecpg/ecpglib/exports.txt | 1 + src/interfaces/ecpg/ecpglib/misc.c | 15 +++++++++++++++ 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); dtcvasc - Parses a timestamp from its textual representation in ANSI standard + Parses a timestamp from its textual representation into a timestamp variable. int dtcvasc(char *str, timestamp *ts); @@ -3087,7 +3087,7 @@ int dtcvasc(char *str, timestamp *ts); dtcvfmtasc - 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. 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 (ts) and the string that should hold the result of the operation output). It converts ts to its - textual representation in the ANSI SQL standard which is defined to + textual representation according to the SQL standard, which is be YYYY-MM-DD HH:MM:SS. @@ -3187,7 +3187,7 @@ int intoasc(interval *i, char *str); The function receives a pointer to the interval variable to convert (i) and the string that should hold the result of the operation str). It converts i to its - textual representation in the ANSI SQL standard which is defined to + textual representation according to the SQL standard, which is be YYYY-MM-DD HH:MM:SS. @@ -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, 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); -- cgit v1.2.3