Commit 3b6f3d changed the results of regression tests. Put back to set error messages...
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Thu, 27 Oct 2016 03:44:41 +0000 (12:44 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sat, 29 Oct 2016 06:04:42 +0000 (15:04 +0900)
statement.c

index 6df9c1741ac4efb1b381356a53f911c9c8c03fce..a8b17b19560b2d56c4c99e0f47e1763164cb426f 100644 (file)
@@ -2935,6 +2935,18 @@ BOOL SC_AcceptedCancelRequest(const StatementClass *self)
    return shouldCancel;
 }
 
+static void
+SC_set_error_if_not_set(StatementClass *self, int errornumber, const char *errmsg, const char *func)
+{
+   if (SC_get_errormsg(self) <= 0)
+   {
+       if (!SC_get_errormsg(self))
+           SC_set_errornumber(self, errornumber);
+       else
+           SC_set_error(self, errornumber, errmsg, func);
+   }
+}
+
 static void
 SC_set_errorinfo(StatementClass *self, QResultClass *res)
 {
@@ -2942,23 +2954,23 @@ SC_set_errorinfo(StatementClass *self, QResultClass *res)
 
    if (conn->status == CONN_NOT_CONNECTED || conn->status == CONN_DOWN)
    {
-       SC_set_error(self, STMT_COMMUNICATION_ERROR, "The connection has been lost", __FUNCTION__);
+       SC_set_error_if_not_set(self, STMT_COMMUNICATION_ERROR, "The connection has been lost", __FUNCTION__);
        return;
    }
 
    switch (QR_get_rstatus(res))
    {
        case PORES_NO_MEMORY_ERROR:
-           SC_set_error(self, STMT_NO_MEMORY_ERROR, "memory allocation error???", __FUNCTION__);
+           SC_set_error_if_not_set(self, STMT_NO_MEMORY_ERROR, "memory allocation error???", __FUNCTION__);
            break;
        case PORES_BAD_RESPONSE:
-           SC_set_error(self, STMT_COMMUNICATION_ERROR, "communication error occured", __FUNCTION__);
+           SC_set_error_if_not_set(self, STMT_COMMUNICATION_ERROR, "communication error occured", __FUNCTION__);
            break;
        case PORES_INTERNAL_ERROR:
-           SC_set_error(self, STMT_INTERNAL_ERROR, "Internal error fetching next row", __FUNCTION__);
+           SC_set_error_if_not_set(self, STMT_INTERNAL_ERROR, "Internal error fetching next row", __FUNCTION__);
            break;
        default:
-           SC_set_error(self, STMT_EXEC_ERROR, "Error fetching next row", __FUNCTION__);
+           SC_set_error_if_not_set(self, STMT_EXEC_ERROR, "Error fetching next row", __FUNCTION__);
            break;
    }
 }