yohgaki Sun Sep 29 23:51:54 2002 EDT Modified files: /php4/ext/pgsql pgsql.c Log: Improve error message. Fix proto. Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.218 php4/ext/pgsql/pgsql.c:1.219 --- php4/ext/pgsql/pgsql.c:1.218 Wed Sep 4 18:25:13 2002 +++ php4/ext/pgsql/pgsql.c Sun Sep 29 23:51:54 2002 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.218 2002/09/04 22:25:13 yohgaki Exp $ */ +/* $Id: pgsql.c,v 1.219 2002/09/30 03:51:54 yohgaki Exp $ */ #include <stdlib.h> @@ -2296,7 +2296,7 @@ } /* }}} */ -/* {{{ proto array pg_copy_to(int connection, string table_name [, string delimiter [, string null_as]]) +/* {{{ proto array pg_copy_to(resource connection, string table_name [, string +delimiter [, string null_as]]) Copy table to array */ PHP_FUNCTION(pg_copy_to) { @@ -2357,7 +2357,7 @@ while (!copydone) { if ((ret = PQgetline(pgsql, copybuf, COPYBUFSIZ))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, +E_WARNING, "getline failed: %s", PQerrorMessage(pgsql)); RETURN_FALSE; } @@ -2391,7 +2391,7 @@ } } if (PQendcopy(pgsql)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, +"endcopy failed: %s", PQerrorMessage(pgsql)); RETURN_FALSE; } while ((pgsql_result = PQgetResult(pgsql))) { @@ -2404,14 +2404,14 @@ break; default: PQclear(pgsql_result); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "COPY command +failed: %s", PQerrorMessage(pgsql)); RETURN_FALSE; break; } } /* }}} */ -/* {{{ proto bool pg_copy_from(int connection, string table_name , array rows [, string delimiter [, string null_as]]) +/* {{{ proto bool pg_copy_from(resource connection, string table_name , array rows [, +string delimiter [, string null_as]]) Copy table from array */ PHP_FUNCTION(pg_copy_from) { @@ -2468,21 +2468,22 @@ convert_to_string_ex(tmp); query = (char *)emalloc(Z_STRLEN_PP(tmp) +2); strcpy(query, Z_STRVAL_PP(tmp)); - if(*(query+Z_STRLEN_PP(tmp)-1) != '\n') strcat(query, "\n"); + if(*(query+Z_STRLEN_PP(tmp)-1) != '\n') + strcat(query, "\n"); if (PQputline(pgsql, query)) { efree(query); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, +E_WARNING, "copy failed: %s", PQerrorMessage(pgsql)); RETURN_FALSE; } efree(query); zend_hash_move_forward_ex(Z_ARRVAL_P(pg_rows), &pos); } - if (PQputline(pgsql, "\\.\n")) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql)); + if (PQputline(pgsql, "\\.\n") == EOF) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, +"putline failed: %s", PQerrorMessage(pgsql)); RETURN_FALSE; } if (PQendcopy(pgsql)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, +"endcopy failed: %s", PQerrorMessage(pgsql)); RETURN_FALSE; } while ((pgsql_result = PQgetResult(pgsql))) { @@ -2496,7 +2497,7 @@ break; default: PQclear(pgsql_result); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "COPY command +failed: %s", PQerrorMessage(pgsql)); RETURN_FALSE; break; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php