statement.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/statement.c b/statement.c index e7f816f..4867eda 100644 --- a/statement.c +++ b/statement.c @@ -296,7 +296,10 @@ PGAPI_FreeStmt(HSTMT hstmt, if (stmt->execute_parent) stmt->execute_parent->execute_delegate = NULL; /* Destroy the statement and free any results, cursors, etc. */ - SC_Destructor(stmt); + //SC_Destructor(stmt); + /*if the connection was give up,return SQL_ERROR.*/ + if(SC_Destructor(stmt) == FALSE) + return SQL_ERROR; } else if (fOption == SQL_UNBIND) SC_unbind_cols(stmt); @@ -477,6 +480,7 @@ SC_Constructor(ConnectionClass *conn) char SC_Destructor(StatementClass *self) { + char cRet = TRUE; CSTR func = "SC_Destructor"; QResultClass *res = SC_get_Result(self); @@ -498,6 +502,13 @@ SC_Destructor(StatementClass *self) SC_initialize_stmts(self, TRUE); + + if(self->hdbc && !self->hdbc->pqconn) + { + SC_set_error(self, STMT_COMMUNICATION_ERROR, "connection error.", func); + cRet = FALSE; + } + /* Free the parsed table information */ SC_initialize_cols_info(self, FALSE, TRUE); @@ -524,8 +535,8 @@ SC_Destructor(StatementClass *self) free(self); MYLOG(0, "leaving\n"); - - return TRUE; + + return cRet; } void