The failure of libpq_bind_exec() which returns NULL doesn't mean a FATAL error. Also...
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sat, 4 Mar 2017 11:17:09 +0000 (20:17 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Sat, 4 Mar 2017 11:26:58 +0000 (20:26 +0900)
connection.c
connection.h
statement.c

index 62e31320cc60f1a63c23b8dd7ba4c0bb37ca8349..5fd6b8d639cfc748cb5a3f92f988dec126a45d57 100644 (file)
@@ -1413,7 +1413,7 @@ void  CC_on_abort(ConnectionClass *conn, UDWORD opt)
 {
    BOOL    set_no_trans = FALSE;
 
-mylog("CC_on_abort in\n");
+mylog("CC_on_abort in opt=%x\n", opt);
    CONNLOCK_ACQUIRE(conn);
    if (0 != (opt & CONN_DEAD)) /* CONN_DEAD implies NO_TRANS also */
        opt |= NO_TRANS;
index ffa1364567339f8d4e4953aa2b0c3f9ab2fabec0..d4495d3927fbeb775c1372e43169e06b1da9818e 100644 (file)
@@ -87,7 +87,7 @@ enum
 #define CONN_IN_ERROR_BEFORE_IDLE  (1L<<3)
 
 /* not connected yet || already disconnected */
-#define    CC_not_connected(x) (CONN_DOWN == (x)->status || CONN_NOT_CONNECTED == (x)->status)
+#define    CC_not_connected(x) (!(x) || CONN_DOWN == (x)->status || CONN_NOT_CONNECTED == (x)->status)
 
 /* AutoCommit functions */
 #define CC_is_in_autocommit(x)     (x->transact_status & CONN_IN_AUTOCOMMIT)
index 616c9eae9750f53d42a14353cea7f2d9313d23cb..6d66a7537fede39fd3281234b7c96257a6f458cb 100644 (file)
@@ -765,6 +765,11 @@ 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 is closed", func);
+       return TRUE;
+   }
 
    return  FALSE;
 }
@@ -1887,8 +1892,10 @@ SC_execute(StatementClass *self)
        if (!res)
        {
            if (SC_get_errornumber(self) <= 0)
+           {
                SC_set_error(self, STMT_NO_RESPONSE, "Could not receive the response, communication down ??", func);
-           CC_on_abort(conn, CONN_DEAD);
+               CC_on_abort(conn, CONN_DEAD);
+           }
            goto cleanup;
        }
    }