tony2001 Fri Oct 6 12:46:08 2006 UTC
Modified files:
/php-src/ext/oci8 oci8_statement.c
Log:
fix PECL bug #8816 (issue in php_oci_statement_fetch with more than one
piecewise column)
patch by jeff at badtz-maru dot com
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.29&r2=1.30&diff_format=u
Index: php-src/ext/oci8/oci8_statement.c
diff -u php-src/ext/oci8/oci8_statement.c:1.29
php-src/ext/oci8/oci8_statement.c:1.30
--- php-src/ext/oci8/oci8_statement.c:1.29 Tue Sep 12 11:42:25 2006
+++ php-src/ext/oci8/oci8_statement.c Fri Oct 6 12:46:08 2006
@@ -25,7 +25,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: oci8_statement.c,v 1.29 2006/09/12 11:42:25 tony2001 Exp $ */
+/* $Id: oci8_statement.c,v 1.30 2006/10/06 12:46:08 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
@@ -155,6 +155,11 @@
int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC)
{
int i;
+ void *handlepp;
+ ub4 typep, iterp, idxp;
+ ub1 in_outp, piecep;
+ zend_bool piecewisecols = 0;
+
php_oci_out_column *column;
PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtFetch, (statement->stmt,
statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT));
@@ -186,42 +191,63 @@
column = php_oci_statement_get_column(statement, i + 1, NULL, 0
TSRMLS_CC);
if (column->piecewise) {
column->retlen4 = 0;
+ piecewisecols = 1;
}
}
while (statement->errcode == OCI_NEED_DATA) {
- for (i = 0; i < statement->ncolumns; i++) {
- column = php_oci_statement_get_column(statement, i + 1,
NULL, 0 TSRMLS_CC);
- if (column->piecewise) {
- if (!column->data) {
- column->data = (text *)
emalloc(PHP_OCI_PIECE_SIZE);
- } else {
- column->data = erealloc(column->data,
column->retlen4 + PHP_OCI_PIECE_SIZE);
- }
-
- column->cb_retlen = PHP_OCI_PIECE_SIZE;
+ if (piecewisecols) {
+ PHP_OCI_CALL_RETURN(statement->errcode,
+ OCIStmtGetPieceInfo,
+ (
+ statement->stmt,
+ statement->err,
+ &handlepp,
+ &typep,
+ &in_outp,
+ &iterp,
+ &idxp,
+ &piecep
+ )
+ );
+
+ /* scan through our columns for a piecewise column with
a matching handle */
+ for (i = 0; i < statement->ncolumns; i++) {
+ column =
php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC);
+ if (column->piecewise && handlepp ==
column->oci_define) {
+ if (!column->data) {
+ column->data = (text *)
ecalloc(1, PHP_OCI_PIECE_SIZE + 1);
+ } else {
+ column->data =
erealloc(column->data, column->retlen4 + PHP_OCI_PIECE_SIZE + 1);
+ memset(column->data +
column->retlen4, 0, PHP_OCI_PIECE_SIZE + 1);
+ }
+ column->cb_retlen = PHP_OCI_PIECE_SIZE;
- PHP_OCI_CALL(OCIStmtSetPieceInfo,
- (
- (void *) column->oci_define,
- OCI_HTYPE_DEFINE,
- statement->err,
- ((char*)column->data) +
column->retlen4,
- &(column->cb_retlen),
- OCI_NEXT_PIECE,
- &column->indicator,
- &column->retcode
- )
- );
+ /* and instruct fetch to fetch waiting
piece into our buffer */
+ PHP_OCI_CALL(OCIStmtSetPieceInfo,
+ (
+ (void *)
column->oci_define,
+ OCI_HTYPE_DEFINE,
+ statement->err,
+ ((char*)column->data) +
column->retlen4,
+ &(column->cb_retlen),
+ piecep,
+ &column->indicator,
+ &column->retcode
+ )
+ );
+ }
}
}
PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtFetch,
(statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT));
- for (i = 0; i < statement->ncolumns; i++) {
- column = php_oci_statement_get_column(statement, i + 1,
NULL, 0 TSRMLS_CC);
- if (column && column->piecewise) {
- column->retlen4 += column->cb_retlen;
+ if (piecewisecols) {
+ for (i = 0; i < statement->ncolumns; i++) {
+ column =
php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC);
+ if (column && column->piecewise && handlepp ==
column->oci_define) {
+ column->retlen4 += column->cb_retlen;
+ }
}
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php