From: Edin Kadribasic Date: Tue, 5 Jul 2005 14:49:22 +0000 (+0000) Subject: Properly detect when the copy command fails X-Git-Tag: php-5.1.0b3~178 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=312a8eede3b76a5389832021a7c8483050d9271e;p=php Properly detect when the copy command fails --- diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index ec863185e8..61cd217578 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -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;