diff options
| author | Edin Kadribasic <edink@php.net> | 2005-07-05 14:49:22 +0000 |
|---|---|---|
| committer | Edin Kadribasic <edink@php.net> | 2005-07-05 14:49:22 +0000 |
| commit | 312a8eede3b76a5389832021a7c8483050d9271e (patch) | |
| tree | 279317ae4098ad9d62ee88fb5b59de6953faf72e /ext/pgsql/pgsql.c | |
| parent | 43c84919bedaf8663e82e037f395edf68dd5043a (diff) | |
| download | php-git-312a8eede3b76a5389832021a7c8483050d9271e.tar.gz | |
Properly detect when the copy command fails
Diffstat (limited to 'ext/pgsql/pgsql.c')
| -rw-r--r-- | ext/pgsql/pgsql.c | 8 |
1 files changed, 8 insertions, 0 deletions
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; |
