Improve Travis setup
[m6w6/ext-pq] / src / php_pqcur.c
index afaa6b36529b31657019c377cf1d2aacf6067d7f..1ff10da22c5e9d103a2b0dc2aeacaa30a669efee 100644 (file)
@@ -31,7 +31,7 @@ static HashTable php_pqcur_object_prophandlers;
 
 static void cur_close(php_pqcur_object_t *obj TSRMLS_DC)
 {
-       if (obj->intern->open) {
+       if (obj->intern->open && obj->intern->conn->intern) {
                PGresult *res;
                smart_str cmd = {0};
 
@@ -79,8 +79,10 @@ static void cur_fetch_or_move(INTERNAL_FUNCTION_PARAMETERS, const char *action,
 
                                if (!rc) {
                                        throw_exce(EX_IO TSRMLS_CC, "Failed to %s cursor (%s)", *action == 'f' ? "fetch from" : "move in", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
+#if HAVE_PQSETSINGLEROWMODE
                                } else if (obj->intern->conn->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn->intern->conn)) {
                                        throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
+#endif
                                } else {
                                        php_pq_callback_recurse(&obj->intern->conn->intern->onevent, &resolver TSRMLS_CC);
                                        obj->intern->conn->intern->poller = PQconsumeInput;