cvs: php4 /ext/oci8 oci8.c php_oci8.h

From: Date: Fri, 08 Feb 2002 18:50:12 +0000
Subject: cvs: php4 /ext/oci8 oci8.c php_oci8.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-9325@lists.php.net to get a copy of this message
thies Fri Feb 8 13:50:12 2002 EDT Modified files: /php4/ext/oci8 oci8.c php_oci8.h Log: - got rid of unneded calls to OCIAttrGet when reexecuting the same query - only invalidate the define list after all rows from a REFCORSOR are read, "normal" corsors will now remember their column defines. this means that ocigetcolumn[name|type|..] will from now on work even after the result set has been read. Index: php4/ext/oci8/oci8.c diff -u php4/ext/oci8/oci8.c:1.166 php4/ext/oci8/oci8.c:1.167 --- php4/ext/oci8/oci8.c:1.166 Wed Jan 30 02:41:04 2002 +++ php4/ext/oci8/oci8.c Fri Feb 8 13:50:12 2002 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.166 2002/01/30 07:41:04 thies Exp $ */ +/* $Id: oci8.c,v 1.167 2002/02/08 18:50:12 thies Exp $ */ /* TODO list: * @@ -49,6 +49,9 @@ * - delay OCIInitialize() as far as we can. * - add PHP Array <-> OCICollection conversion * - add Collection iterator object for INDEX BY tables + * - make auto-rollabck only happen if we have an outstanding transaction + * - implement ocidisconnect + * - add bind patch */ /* {{{ includes & stuff */ @@ -630,7 +633,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.166 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.167 $"); #ifndef PHP_WIN32 php_info_print_table_row(2, "Oracle Version", PHP_OCI8_VERSION ); php_info_print_table_row(2, "Compile-time ORACLE_HOME", PHP_OCI8_DIR ); @@ -1407,7 +1410,6 @@ text *colname; ub4 counter; ub2 define_type; - ub2 stmttype; ub4 iters; ub4 colcount; ub2 dynamic; @@ -1417,21 +1419,24 @@ sword error; TSRMLS_FETCH(); - CALL_OCI_RETURN(error, OCIAttrGet( - (dvoid *)statement->pStmt, - OCI_HTYPE_STMT, - (ub2 *)&stmttype, - (ub4 *)0, - OCI_ATTR_STMT_TYPE, - statement->pError)); + if (! statement->stmttype) { + CALL_OCI_RETURN(error, OCIAttrGet( + (dvoid *)statement->pStmt, + OCI_HTYPE_STMT, + (ub2 *)&statement->stmttype, + (ub4 *)0, + OCI_ATTR_STMT_TYPE, + statement->pError)); - statement->error = oci_error(statement->pError, "OCIAttrGet OCI_HTYPE_STMT/OCI_ATTR_STMT_TYPE", error); - if (statement->error) { - oci_handle_error(statement->conn, statement->error); - return 0; + statement->error = oci_error(statement->pError, "OCIAttrGet OCI_HTYPE_STMT/OCI_ATTR_STMT_TYPE", error); + + if (statement->error) { + oci_handle_error(statement->conn, statement->error); + return 0; + } } - if (stmttype == OCI_STMT_SELECT) { + if (statement->stmttype == OCI_STMT_SELECT) { iters = 0; } else { iters = 1; @@ -1467,9 +1472,9 @@ } } - if (stmttype == OCI_STMT_SELECT && (statement->executed == 0)) { + if ((statement->stmttype == OCI_STMT_SELECT) && (statement->executed == 0)) { /* we only need to do the define step is this very statement is executed the first time! */ - statement->executed++; + statement->executed = 1; ALLOC_HASHTABLE(statement->columns); zend_hash_init(statement->columns, 13, NULL, _oci_column_hash_dtor, 0); @@ -1728,6 +1733,7 @@ zend_hash_apply(statement->columns, (apply_func_t) _oci_column_pre_fetch TSRMLS_CC); } + CALL_OCI_RETURN(statement->error, OCIStmtFetch( statement->pStmt, statement->pError, @@ -1736,14 +1742,16 @@ OCI_DEFAULT)); if ((statement->error == OCI_NO_DATA) || (nrows == 0)) { - /* XXX this is needed for REFCURSORS! */ - if (statement->columns) { - zend_hash_destroy(statement->columns); - efree(statement->columns); - statement->columns = 0; - statement->ncolumns = 0; + if (statement->last_query == 0) { + /* reset define-list for refcursosrs */ + if (statement->columns) { + zend_hash_destroy(statement->columns); + efree(statement->columns); + statement->columns = 0; + statement->ncolumns = 0; + } + statement->executed = 0; } - statement->executed = 0; statement->error = 0; /* OCI_NO_DATA is NO error for us!!! */ Index: php4/ext/oci8/php_oci8.h diff -u php4/ext/oci8/php_oci8.h:1.21 php4/ext/oci8/php_oci8.h:1.22 --- php4/ext/oci8/php_oci8.h:1.21 Tue Dec 11 10:29:59 2001 +++ php4/ext/oci8/php_oci8.h Fri Feb 8 13:50:12 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_oci8.h,v 1.21 2001/12/11 15:29:59 sebastian Exp $ */ +/* $Id: php_oci8.h,v 1.22 2002/02/08 18:50:12 thies Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_H @@ -118,6 +118,7 @@ HashTable *defines; int ncolumns; int executed; + ub2 stmttype; } oci_statement; typedef struct {

« previous php.cvs (#9325) next »