cvs: php-src(PHP_5_2) /ext/oci8 oci8_statement.c php_oci8_int.h

From: Date: Thu, 01 Mar 2007 22:27:44 +0000
Subject: cvs: php-src(PHP_5_2) /ext/oci8 oci8_statement.c php_oci8_int.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-43337@lists.php.net to get a copy of this message
tony2001 Thu Mar 1 22:27:44 2007 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/oci8 oci8_statement.c php_oci8_int.h Log: allocate descriptors dynamically http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.7.2.14.2.22&r2=1.7.2.14.2.23&diff_format=u Index: php-src/ext/oci8/oci8_statement.c diff -u php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.22 php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.23 --- php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.22 Wed Jan 31 13:55:43 2007 +++ php-src/ext/oci8/oci8_statement.c Thu Mar 1 22:27:44 2007 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8_statement.c,v 1.7.2.14.2.22 2007/01/31 13:55:43 tony2001 Exp $ */ +/* $Id: oci8_statement.c,v 1.7.2.14.2.23 2007/03/01 22:27:44 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H @@ -314,6 +314,77 @@ } /* }}} */ +/* php_oci_define_callback() {{{ */ +sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **bufpp, ub4 **alenpp, ub1 *piecep, dvoid **indpp, ub2 **rcpp) +{ + php_oci_out_column *outcol = (php_oci_out_column *)ctx; + + if (!outcol) { + TSRMLS_FETCH(); + + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid context pointer value"); + return OCI_ERROR; + } + + switch(outcol->data_type) { + case SQLT_RSET: { + php_oci_statement *nested_stmt; + TSRMLS_FETCH(); + + nested_stmt = php_oci_statement_create(outcol->statement->connection, NULL, 0 TSRMLS_CC); + if (!nested_stmt) { + return OCI_ERROR; + } + zend_list_addref(outcol->statement->id); + outcol->nested_statement = nested_stmt; + outcol->stmtid = nested_stmt->id; + + *bufpp = nested_stmt->stmt; + *alenpp = &(outcol->retlen4); + *piecep = OCI_ONE_PIECE; + *indpp = &(outcol->indicator); + *rcpp = &(outcol->retcode); + return OCI_CONTINUE; + } + break; + case SQLT_RDD: + case SQLT_BLOB: + case SQLT_CLOB: + case SQLT_BFILE: { + php_oci_descriptor *descr; + int dtype; + TSRMLS_FETCH(); + + if (outcol->data_type == SQLT_BFILE) { + dtype = OCI_DTYPE_FILE; + } else if (outcol->data_type == SQLT_RDD ) { + dtype = OCI_DTYPE_ROWID; + } else { + dtype = OCI_DTYPE_LOB; + } + + descr = php_oci_lob_create(outcol->statement->connection, dtype TSRMLS_CC); + if (!descr) { + return OCI_ERROR; + } + zend_list_addref(outcol->statement->id); + outcol->descid = descr->id; + descr->charset_form = outcol->charset_form; + + *bufpp = descr->descriptor; + *alenpp = &(outcol->retlen4); + *piecep = OCI_ONE_PIECE; + *indpp = &(outcol->indicator); + *rcpp = &(outcol->retcode); + + return OCI_CONTINUE; + } + break; + } + return OCI_ERROR; +} +/* }}} */ + /* {{{ php_oci_statement_execute() Execute statement */ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) @@ -327,9 +398,7 @@ ub4 iters; ub4 colcount; ub2 dynamic; - int dtype; dvoid *buf; - php_oci_descriptor *descr; switch (mode) { case OCI_COMMIT_ON_SUCCESS: @@ -417,8 +486,6 @@ return 1; } - outcol->statement = statement; - /* get column */ PHP_OCI_CALL_RETURN(statement->errcode, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)&param, counter)); @@ -516,45 +583,25 @@ buf = 0; switch (outcol->data_type) { case SQLT_RSET: - outcol->statement = php_oci_statement_create(statement->connection, NULL, 0 TSRMLS_CC); - outcol->stmtid = outcol->statement->id; - outcol->statement->nested = 1; + outcol->statement = statement; /* parent handle */ define_type = SQLT_RSET; outcol->is_cursor = 1; outcol->storage_size4 = -1; outcol->retlen = -1; - dynamic = OCI_DEFAULT; - buf = &(outcol->statement->stmt); - zend_list_addref(statement->id); + dynamic = OCI_DYNAMIC_FETCH; break; case SQLT_RDD: /* ROWID */ case SQLT_BLOB: /* binary LOB */ case SQLT_CLOB: /* character LOB */ case SQLT_BFILE: /* binary file LOB */ + outcol->statement = statement; /* parent handle */ + define_type = outcol->data_type; outcol->is_descr = 1; outcol->storage_size4 = -1; - dynamic = OCI_DEFAULT; - - if (outcol->data_type == SQLT_BFILE) { - dtype = OCI_DTYPE_FILE; - } else if (outcol->data_type == SQLT_RDD ) { - dtype = OCI_DTYPE_ROWID; - } else { - dtype = OCI_DTYPE_LOB; - } - - descr = php_oci_lob_create(statement->connection, dtype TSRMLS_CC); - if (!descr) { - efree(outcol->name); - return 1; - } - outcol->descid = descr->id; - buf = &(descr->descriptor); - descr->charset_form = outcol->charset_form; - /* descr->charset_id = outcol->charset_id; */ + dynamic = OCI_DYNAMIC_FETCH; break; case SQLT_LNG: @@ -643,6 +690,26 @@ PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 0; } + + /* additional OCIDefineDynamic() call */ + switch (outcol->data_type) { + case SQLT_RSET: + case SQLT_RDD: + case SQLT_BLOB: + case SQLT_CLOB: + case SQLT_BFILE: + PHP_OCI_CALL_RETURN(statement->errcode, + OCIDefineDynamic, + ( + outcol->oci_define, + statement->err, + (dvoid *)outcol, + php_oci_define_callback + ) + ); + + break; + } } } http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.11.2.6.2.16&r2=1.11.2.6.2.17&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.16 php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.17 --- php-src/ext/oci8/php_oci8_int.h:1.11.2.6.2.16 Tue Feb 13 20:19:56 2007 +++ php-src/ext/oci8/php_oci8_int.h Thu Mar 1 22:27:44 2007 @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_oci8_int.h,v 1.11.2.6.2.16 2007/02/13 20:19:56 tony2001 Exp $ */ +/* $Id: php_oci8_int.h,v 1.11.2.6.2.17 2007/03/01 22:27:44 tony2001 Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -194,7 +194,8 @@ } php_oci_bind; /* }}} */ typedef struct { /* php_oci_out_column {{{ */ - php_oci_statement *statement; /* statement handle. used when fetching REFCURSORS */ + php_oci_statement *statement; /* statement handle. used when fetching REFCURSORS */ + php_oci_statement *nested_statement; /* statement handle. used when fetching REFCURSORS */ OCIDefine *oci_define; /* define handle */ char *name; /* column name */ ub4 name_len; /* column name length */

« previous php.cvs (#43337) next »