PHP 4.0 Bug #6219 Updated: PQendcopy /PQputline missing

From: Date: Tue, 12 Sep 2000 03:40:38 +0000
Subject: PHP 4.0 Bug #6219 Updated: PQendcopy /PQputline missing
Groups: php.dev 
Request: Send a blank email to php-dev+get-32926@lists.php.net to get a copy of this message
ID: 6219 Updated by: derick Reported By: dirk@rackspace.com Status: Closed Bug Type: Feature/Change Request Assigned To: Comments: Added in CVS Previous Comments: --------------------------------------------------------------------------- [2000-08-21 10:45:21] dirk@rackspace.com Sorry nothing seemed to happen to this patch while it was under the postgresql. --------------------------------------------------------------------------- [2000-08-17 12:18:46] dirk@rackspace.com The Postgres module seems to be missing all the copy functions. I needed the PQendcopy / PQputline. I haven't writted PQgetline. I'm not sure what the normal procedure is for submitting code to PHP (first time for me) This is mostly based on the existing postgresql code. I have included a patch to add these to the current version of php4. I'm using this patch actively , but I wouldn't mind some help testing it. Please consider this for inclusion into the code base. --- php-4.0.1pl2/ext/pgsql/pgsql.c Tue Jun 27 08:26:04 2000 +++ php-4.0.1pl2/ext/pgsql/pgsql.c.dirk Wed Aug 9 10:33:29 2000 @@ -74,6 +74,8 @@ PHP_FE(pg_loreadall, NULL) PHP_FE(pg_loimport, NULL) PHP_FE(pg_loexport, NULL) + PHP_FE(pg_putline, NULL) + PHP_FE(pg_endcopy, NULL) {NULL, NULL, NULL} }; @@ -636,7 +638,91 @@ } } /* }}} */ +/* {{{ proto int pg_endcopy([int connection,]) + Sync with backend. Completes the Copy command*/ +PHP_FUNCTION(pg_endcopy) +{ + zval **query, **pgsql_link; + int id = -1; + PGconn *pgsql; + int result = 0; + ExecStatusType status; + pgsql_result_handle *pg_result; + PGLS_FETCH(); + + switch(ZEND_NUM_ARGS()) { + case 1: + if (zend_get_parameters_ex(1, &query)==FAILURE) { + RETURN_FALSE; + } + id = PGG(default_link); + break; + case 2: + if (zend_get_parameters_ex(2, &pgsql_link, &query)==FAILURE) { + RETURN_FALSE; + } + break; + default: + WRONG_PARAM_COUNT; + break; + } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); + + convert_to_string_ex(query); + result = PQendcopy(pgsql); + +/* if (result!=0) + { + php_error(E_WARNING, "PostgreSQL query failed: %s", PQerrorMessage(pgsql)); + RETURN_FALSE; + } */ + RETURN_FALSE; +} +/* }}} */ +/* {{{ proto int pg_putline([int connection,] string query) + Send null-terminated string to backend server*/ +PHP_FUNCTION(pg_putline) +{ + zval **query, **pgsql_link; + int id = -1; + PGconn *pgsql; + int result = 0; + ExecStatusType status; + pgsql_result_handle *pg_result; + PGLS_FETCH(); + + switch(ZEND_NUM_ARGS()) { + case 1: + if (zend_get_parameters_ex(1, &query)==FAILURE) { + RETURN_FALSE; + } + id = PGG(default_link); + break; + case 2: + if (zend_get_parameters_ex(2, &pgsql_link, &query)==FAILURE) { + RETURN_FALSE; + } + break; + default: + WRONG_PARAM_COUNT; + break; + } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); + + convert_to_string_ex(query); + result = PQputline(pgsql, Z_STRVAL_PP(query)); + + if (result==EOF) + { + php_error(E_WARNING, "PostgreSQL query failed: %s", PQerrorMessage(pgsql)); + RETURN_FALSE; + } + RETURN_FALSE; +} +/* }}} */ #define PHP_PG_NUM_ROWS 1 #define PHP_PG_NUM_FIELDS 2 #define PHP_PG_CMD_TUPLES 3 --- php-4.0.1pl2/ext/pgsql/php_pgsql.h Sat Jun 10 03:47:57 2000 +++ php-4.0.1pl2/ext/pgsql/php_pgsql.h.dirk Wed Aug 9 10:33:29 2000 @@ -85,6 +85,8 @@ PHP_FUNCTION(pg_loreadall); PHP_FUNCTION(pg_loimport); PHP_FUNCTION(pg_loexport); +PHP_FUNCTION(pg_putline); +PHP_FUNCTION(pg_endcopy); void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent); int php_pgsql_get_default_link(INTERNAL_FUNCTION_PARAMETERS); --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6219

« previous php.dev (#32926) next »