]> granicus.if.org Git - php/commitdiff
Properly detect when the copy command fails
authorEdin Kadribasic <edink@php.net>
Tue, 5 Jul 2005 14:49:22 +0000 (14:49 +0000)
committerEdin Kadribasic <edink@php.net>
Tue, 5 Jul 2005 14:49:22 +0000 (14:49 +0000)
ext/pgsql/pgsql.c

index ec863185e8b0fde3744ab8cdb3e66c03155eb471..61cd2175785e4449ed9be17770eab7400f0daf70 100644 (file)
@@ -3327,6 +3327,7 @@ PHP_FUNCTION(pg_copy_from)
        switch (status) {
                case PGRES_COPY_IN:
                        if (pgsql_result) {
+                               int command_failed = 0;
                                PQclear(pgsql_result);
                                zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pg_rows), &pos);
 #if HAVE_PQPUTCOPYDATA
@@ -3373,8 +3374,15 @@ PHP_FUNCTION(pg_copy_from)
                                }
 #endif
                                while ((pgsql_result = PQgetResult(pgsql))) {
+                                       if (PGRES_COMMAND_OK != PQresultStatus(pgsql_result)) {
+                                               PHP_PQ_ERROR("Copy command failed: %s", pgsql);
+                                               command_failed = 1;
+                                       }
                                        PQclear(pgsql_result);
                                }
+                               if (command_failed) {
+                                       RETURN_FALSE;
+                               }
                        } else {
                                PQclear(pgsql_result);
                                RETURN_FALSE;