Revise recent lost connection check.
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sun, 5 Mar 2017 13:26:53 +0000 (22:26 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Tue, 7 Mar 2017 04:37:39 +0000 (13:37 +0900)
Check the lost connection
1. at the beginning of ODBC APIs.
2. at the beginning of FE-BE communications using extended protocol.

execute.c
odbcapi.c
odbcapi30.c
odbcapi30w.c
odbcapiw.c
statement.c
statement.h

index d568219dd0aea72eaea630c5f1cd4a843cf4ea38..da8f81e83bec8669b7b392c0131b674a4aaca8fb 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -594,6 +594,11 @@ SetStatementSvp(StatementClass *stmt)
    QResultClass *res;
    RETCODE ret = SQL_SUCCESS_WITH_INFO;
 
+   if (NULL == conn->pqconn)
+   {
+       SC_set_error(stmt, STMT_COMMUNICATION_ERROR, "The connection has been lost", __FUNCTION__);
+       return SQL_ERROR;
+   }
    if (CC_is_in_error_trans(conn))
        return ret;
 
index ca2ce313b391a8bba9ede648d285d54df69b701c..dff253933b92af345dc437d3a075d18c69af4663 100644 (file)
--- a/odbcapi.c
+++ b/odbcapi.c
 #include "qresult.h"
 #include "loadlib.h"
 
+BOOL   SC_connection_lost_check(StatementClass *stmt, const char *funcname)
+{
+   ConnectionClass *conn = SC_get_conn(stmt);
+   char    message[64];
+
+   if (NULL != conn->pqconn)
+       return  FALSE;
+   SC_clear_error(stmt);
+   snprintf(message, sizeof(message), "%s unable due to the connection lost", funcname);
+   SC_set_error(stmt, STMT_COMMUNICATION_ERROR, message, funcname);
+   return TRUE;
+}
+
 RETCODE        SQL_API
 SQLBindCol(HSTMT StatementHandle,
           SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
@@ -64,6 +77,8 @@ SQLCancel(HSTMT StatementHandle)
    mylog("[SQLCancel]");
    /* Not that neither ENTER_STMT_CS nor StartRollbackState is called */
    /* SC_clear_error((StatementClass *) StatementHandle); maybe this neither */
+   if (SC_connection_lost_check((StatementClass *) StatementHandle, __FUNCTION__))
+       return SQL_ERROR;
    return PGAPI_Cancel(StatementHandle);
 }
 
@@ -90,6 +105,9 @@ SQLColumns(HSTMT StatementHandle,
    UWORD   flag    = PODBC_SEARCH_PUBLIC_SCHEMA;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -241,6 +259,9 @@ SQLDescribeCol(HSTMT StatementHandle,
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("[SQLDescribeCol]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -282,6 +303,9 @@ SQLExecDirect(HSTMT StatementHandle,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    flag |= PODBC_WITH_HOLD;
@@ -306,6 +330,9 @@ SQLExecute(HSTMT StatementHandle)
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    flag |= PODBC_WITH_HOLD;
@@ -333,11 +360,14 @@ SQLFetch(HSTMT StatementHandle)
    SQLUSMALLINT *rowStatusArray = irdopts->rowStatusArray;
    SQLULEN *pcRow = irdopts->rowsFetched;
 
+   mylog("[[%s]]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
 
-   mylog("[[%s]]", func);
    ret = PGAPI_ExtendedFetch(StatementHandle, SQL_FETCH_NEXT, 0,
                               pcRow, rowStatusArray, 0, ardopts->size_of_rowset);
    stmt->transition_status = STMT_TRANSITION_FETCH_SCROLL;
@@ -416,6 +446,9 @@ SQLGetData(HSTMT StatementHandle,
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("[SQLGetData]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -475,6 +508,9 @@ SQLGetTypeInfo(HSTMT StatementHandle,
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check((StatementClass *) StatementHandle, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    if (SC_opencheck(stmt, func))
@@ -497,6 +533,9 @@ SQLNumResultCols(HSTMT StatementHandle,
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("[SQLNumResultCols]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -514,6 +553,9 @@ SQLParamData(HSTMT StatementHandle,
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("[SQLParamData]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    ret = PGAPI_ParamData(StatementHandle, Value);
@@ -531,6 +573,9 @@ SQLPrepare(HSTMT StatementHandle,
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("[SQLPrepare]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    if (SC_opencheck(stmt, func))
@@ -553,6 +598,9 @@ SQLPutData(HSTMT StatementHandle,
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("[SQLPutData]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    ret = PGAPI_PutData(StatementHandle, Data, StrLen_or_Ind);
@@ -569,6 +617,9 @@ SQLRowCount(HSTMT StatementHandle,
    StatementClass *stmt = (StatementClass *) StatementHandle;
 
    mylog("[SQLRowCount]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -629,6 +680,9 @@ SQLSpecialColumns(HSTMT StatementHandle,
    SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -692,6 +746,9 @@ SQLStatistics(HSTMT StatementHandle,
    SQLCHAR *ctName = CatalogName, *scName = SchemaName, *tbName = TableName;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -756,6 +813,9 @@ SQLTables(HSTMT StatementHandle,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -828,6 +888,9 @@ SQLColumnPrivileges(HSTMT hstmt,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -899,6 +962,9 @@ SQLDescribeParam(HSTMT hstmt,
    StatementClass *stmt = (StatementClass *) hstmt;
 
    mylog("[SQLDescribeParam]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -924,6 +990,9 @@ SQLExtendedFetch(HSTMT hstmt,
    StatementClass *stmt = (StatementClass *) hstmt;
 
    mylog("[SQLExtendedFetch]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -967,6 +1036,9 @@ SQLForeignKeys(HSTMT hstmt,
        *fkscName = szFkSchemaName, *fktbName = szFkTableName;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -1048,6 +1120,9 @@ SQLMoreResults(HSTMT hstmt)
    StatementClass *stmt = (StatementClass *) hstmt;
 
    mylog("[SQLMoreResults]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -1086,6 +1161,9 @@ SQLNumParams(HSTMT hstmt,
    StatementClass *stmt = (StatementClass *) hstmt;
 
    mylog("[SQLNumParams]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -1111,6 +1189,9 @@ SQLPrimaryKeys(HSTMT hstmt,
        *tbName = szTableName;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -1178,6 +1259,9 @@ SQLProcedureColumns(HSTMT hstmt,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -1254,6 +1338,9 @@ SQLProcedures(HSTMT hstmt,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -1315,6 +1402,9 @@ SQLSetPos(HSTMT hstmt,
    StatementClass *stmt = (StatementClass *) hstmt;
 
    mylog("[SQLSetPos]");
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -1341,6 +1431,9 @@ SQLTablePrivileges(HSTMT hstmt,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
index 468882304394d693853adc7ee17e7855c6cdde4e..9b41104c0ac9bc5caedb0a304e60b79171e50ed8 100644 (file)
@@ -103,6 +103,9 @@ SQLCloseCursor(HSTMT StatementHandle)
    RETCODE ret;
 
    mylog("[[%s]]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -132,6 +135,9 @@ SQLColAttribute(SQLHSTMT StatementHandle,
    StatementClass  *stmt = (StatementClass *) StatementHandle;
 
    mylog("[[%s]]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -200,6 +206,9 @@ SQLFetchScroll(HSTMT StatementHandle,
    SQLLEN  bkmarkoff = 0;
 
    mylog("[[%s]] %d,%d\n", func, FetchOrientation, FetchOffset);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
@@ -674,6 +683,9 @@ SQLBulkOperations(HSTMT hstmt, SQLSMALLINT operation)
    CSTR func = "SQLBulkOperations";
    StatementClass  *stmt = (StatementClass *) hstmt;
 
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    mylog("[[%s]] Handle=%p %d\n", func, hstmt, operation);
    SC_clear_error(stmt);
index 9126971bbef9af53159715b0833e63414f123ee9..25606312d60d0271fbb4ed32cf7732acfb78cef7 100644 (file)
@@ -288,6 +288,9 @@ SQLColAttributeW(SQLHSTMT   hstmt,
         char    *rgbD = NULL, *rgbDt;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
index 7bd1ec725f0efe86f18586c5bdc03bfb5c2eb9f1..96d7cf4705527338a46e9d2bb566caa7da93f2f6 100644 (file)
@@ -42,6 +42,9 @@ SQLColumnsW(HSTMT StatementHandle,
    UWORD   flag = PODBC_SEARCH_PUBLIC_SCHEMA;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
@@ -259,6 +262,9 @@ SQLDescribeColW(HSTMT StatementHandle,
    char    *clName = NULL, *clNamet = NULL;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    buflen = 0;
    if (BufferLength > 0)
        buflen = BufferLength * 3;
@@ -318,6 +324,9 @@ SQLExecDirectW(HSTMT StatementHandle,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE);
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
@@ -420,6 +429,9 @@ SQLPrepareW(HSTMT StatementHandle,
    SQLLEN  slen;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE);
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
@@ -475,6 +487,9 @@ SQLSpecialColumnsW(HSTMT StatementHandle,
    BOOL lower_id;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
@@ -518,6 +533,9 @@ SQLStatisticsW(HSTMT StatementHandle,
    BOOL lower_id;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
@@ -562,6 +580,9 @@ SQLTablesW(HSTMT StatementHandle,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(CatalogName, NameLength1, &nmlen1, lower_id);
@@ -615,6 +636,9 @@ SQLColumnPrivilegesW(HSTMT          hstmt,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
@@ -672,6 +696,9 @@ SQLForeignKeysW(HSTMT           hstmt,
    BOOL    lower_id;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(szPkCatalogName, cbPkCatalogName, &nmlen1, lower_id);
@@ -789,6 +816,9 @@ SQLPrimaryKeysW(HSTMT           hstmt,
    BOOL    lower_id;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
@@ -888,6 +918,9 @@ SQLProceduresW(HSTMT        hstmt,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
@@ -936,6 +969,9 @@ SQLTablePrivilegesW(HSTMT           hstmt,
    UWORD   flag = 0;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    conn = SC_get_conn(stmt);
    lower_id = SC_is_lower_case(stmt, conn);
    ctName = ucs2_to_utf8(szCatalogName, cbCatalogName, &nmlen1, lower_id);
@@ -974,6 +1010,9 @@ SQLGetTypeInfoW(SQLHSTMT   StatementHandle,
    StatementClass * stmt = (StatementClass *) StatementHandle;
 
    mylog("[%s]", func);
+   if (SC_connection_lost_check(stmt, __FUNCTION__))
+       return SQL_ERROR;
+
    ENTER_STMT_CS(stmt);
    SC_clear_error(stmt);
    StartRollbackState(stmt);
index bfcecab5a59e50b4d073084e32a457ee8b115b4b..991cfcf7e5e31b0cb755320b9d6d8bd612f9bab9 100644 (file)
 
 #include "pgapifunc.h"
 
-#define STMT_LOST_GEXIT(stmt) \
-do { \
-   ConnectionClass *conn = SC_get_conn(stmt); \
-        if (NULL == conn->pqconn) \
-        { \
-                SC_set_error((stmt), STMT_COMMUNICATION_ERROR, "The connection has been lost", __FUNCTION__); \
-                goto cleanup; \
-        } \
-   break; \
-} while (1)
 
 /* Map sql commands to statement types */
 static const struct
@@ -776,11 +766,6 @@ BOOL   SC_opencheck(StatementClass *self, const char *func)
            return TRUE;
        }
    }
-   if (CC_not_connected((ConnectionClass *) SC_get_conn(self)))
-   {
-       SC_set_error(self, STMT_SEQUENCE_ERROR, "The connection has been lost", func);
-       return TRUE;
-   }
 
    return  FALSE;
 }
@@ -2357,6 +2342,11 @@ RequestStart(StatementClass *stmt, ConnectionClass *conn, const char *func)
    if (conn->asdum)
        CALL_IsolateDtcConn(conn, TRUE);
 #endif /* _HANDLE_ENLIST_IN_DTC_ */
+   if (NULL == conn->pqconn)
+        {
+       SC_set_error(stmt, STMT_COMMUNICATION_ERROR, "The connection has been lost", __FUNCTION__);
+       return SQL_ERROR;
+   }
    if (SC_accessed_db(stmt))
        return TRUE;
    if (SQL_ERROR == SetStatementSvp(stmt))
@@ -2364,7 +2354,7 @@ RequestStart(StatementClass *stmt, ConnectionClass *conn, const char *func)
        char    emsg[128];
 
        snprintf(emsg, sizeof(emsg), "internal savepoint error in %s", func);
-       SC_set_error(stmt, STMT_INTERNAL_ERROR, emsg, func);
+       SC_set_error_if_not_set(stmt, STMT_INTERNAL_ERROR, emsg, func);
        return FALSE;
    }
 
@@ -2408,7 +2398,7 @@ libpq_bind_and_exec(StatementClass *stmt)
    {
        if (SQL_ERROR == SetStatementSvp(stmt))
        {
-           SC_set_error(stmt, STMT_INTERNAL_ERROR, "internal savepoint error in build_libpq_bind_params", func);
+           SC_set_error_if_not_set(stmt, STMT_INTERNAL_ERROR, "internal savepoint error in build_libpq_bind_params", func);
            return NULL;
        }
    }
@@ -2450,7 +2440,6 @@ libpq_bind_and_exec(StatementClass *stmt)
        }
 
        pstmt = stmt->processed_statements;
-       STMT_LOST_GEXIT(stmt);
        pgres = PQexecParams(conn->pqconn,
                             pstmt->query,
                             nParams,
@@ -2474,7 +2463,6 @@ libpq_bind_and_exec(StatementClass *stmt)
        plan_name = stmt->plan_name ? stmt->plan_name : "";
 
        /* already prepared */
-       STMT_LOST_GEXIT(stmt);
        pgres = PQexecPrepared(conn->pqconn,
                               plan_name,   /* portal name == plan name */
                               nParams,
@@ -2679,7 +2667,6 @@ mylog("sta_pidx=%d end_pidx=%d num_p=%d\n", sta_pidx, end_pidx, num_params);
        conn->unnamed_prepared_stmt = NULL;
 
    /* Prepare */
-   STMT_LOST_GEXIT(stmt);
    pgres = PQprepare(conn->pqconn, plan_name, query, num_params, paramTypes);
    if (PQresultStatus(pgres) != PGRES_COMMAND_OK)
    {
@@ -2759,7 +2746,6 @@ ParseAndDescribeWithLibpq(StatementClass *stmt, const char *plan_name,
    /* Describe */
    mylog("%s: describing plan_name=%s\n", func, plan_name);
 
-   STMT_LOST_GEXIT(stmt);
    pgres = PQdescribePrepared(conn->pqconn, plan_name);
    switch (PQresultStatus(pgres))
    {
index 803b20fa5e3b65c688a18075ea166327cf2c181a..1e11e3a972bb65089a92d00f7710934943385b11 100644 (file)
@@ -530,6 +530,8 @@ BOOL    SC_SetExecuting(StatementClass *self, BOOL on);
 BOOL   SC_SetCancelRequest(StatementClass *self);
 BOOL   SC_AcceptedCancelRequest(const StatementClass *self);
 
+BOOL   SC_connection_lost_check(StatementClass *stmt, const char *funcname);
+
 int        enqueueNeedDataCallback(StatementClass *self, NeedDataCallfunc, void *);
 RETCODE        dequeueNeedDataCallback(RETCODE, StatementClass *self);
 void       cancelNeedDataState(StatementClass *self);