[PHP-CVS] cvs: php-src /ext/oci8 oci8_statement.c php_oci8_int.h
sixdMon Mar 9 20:58:13 2009 UTC Modified files: /php-src/ext/oci8 php_oci8_int.h oci8_statement.c Log: Make non-public prototype match the type passed at call http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.48&r2=1.49&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.48 php-src/ext/oci8/php_oci8_int.h:1.49 --- php-src/ext/oci8/php_oci8_int.h:1.48Mon Mar 9 20:07:39 2009 +++ php-src/ext/oci8/php_oci8_int.h Mon Mar 9 20:58:13 2009 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: php_oci8_int.h,v 1.48 2009/03/09 20:07:39 sixd Exp $ */ +/* $Id: php_oci8_int.h,v 1.49 2009/03/09 20:58:13 sixd Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -452,7 +452,7 @@ void php_oci_statement_free (php_oci_statement * TSRMLS_DC); int php_oci_bind_pre_exec(void *data TSRMLS_DC); int php_oci_bind_post_exec(void *data TSRMLS_DC); -int php_oci_bind_by_name(php_oci_statement *, zstr, int, zval*, long, long, zend_uchar TSRMLS_DC); +int php_oci_bind_by_name(php_oci_statement *, zstr, int, zval*, long, ub2, zend_uchar TSRMLS_DC); sb4 php_oci_bind_in_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 *, ub1 *, dvoid **); sb4 php_oci_bind_out_callback(dvoid *, OCIBind *, ub4, ub4, dvoid **, ub4 **, ub1 *, dvoid **, ub2 **); php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAMETERS, int need_data); http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.60&r2=1.61&diff_format=u Index: php-src/ext/oci8/oci8_statement.c diff -u php-src/ext/oci8/oci8_statement.c:1.60 php-src/ext/oci8/oci8_statement.c:1.61 --- php-src/ext/oci8/oci8_statement.c:1.60 Wed Dec 31 11:12:33 2008 +++ php-src/ext/oci8/oci8_statement.c Mon Mar 9 20:58:13 2009 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: oci8_statement.c,v 1.60 2008/12/31 11:12:33 sebastian Exp $ */ +/* $Id: oci8_statement.c,v 1.61 2009/03/09 20:58:13 sixd Exp $ */ #ifdef HAVE_CONFIG_H @@ -918,7 +918,7 @@ /* {{{ php_oci_bind_by_name() Bind zval to the given placeholder */ -int php_oci_bind_by_name(php_oci_statement *statement, zstr name, int name_len, zval* var, long maxlength, long type, zend_uchar uni_type TSRMLS_DC) +int php_oci_bind_by_name(php_oci_statement *statement, zstr name, int name_len, zval* var, long maxlength, ub2 type, zend_uchar uni_type TSRMLS_DC) { php_oci_collection *bind_collection = NULL; php_oci_descriptor *bind_descriptor = NULL; @@ -1020,7 +1020,7 @@ break; default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown or unsupported datatype given: %ld", type); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown or unsupported datatype given: %d", (int) type); return 1; break; } @@ -1053,14 +1053,14 @@ PHP_OCI_CALL_RETURN(statement->errcode, OCIBindByName, ( - statement->stmt,/* statement handle */ - (OCIBind **)&bindp->bind, /* bind hdl (will alloc) */ - statement->err, /* error handle */ - (text*) name.s,/* placeholder name */ - USTR_BYTES(uni_type, name_len), /* placeholder length */ + statement->stmt, /* statement handle */ + (OCIBind **)&bindp->bind,/* bind hdl (will alloc) */ + statement->err, /* error handle */ + (text*) name.s, /* placeholder name */ + USTR_BYTES(uni_type, name_len), /* placeholder length */ (dvoid *)bind_data, /* in/out data */ TEXT_BYTES(value_sz), /* PHP_OCI_MAX_DATA_SIZE, */ /* max size of input/output data */ - (ub2)type, /* in/out data type */ + type, /* in/out data type */ (dvoid *)&bindp->indicator, /* indicator (ignored) */ (ub2 *)0, /* size array (ignored) */ (ub2 *)&bindp->retcode, /* return code (ignored) */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.
[PHP-CVS] cvs: php-src /ext/oci8 oci8_statement.c php_oci8_int.h
tony2001Thu Mar 1 23:28:13 2007 UTC Modified files: /php-src/ext/oci8 oci8_statement.c php_oci8_int.h Log: MFB: allocate and define descriptors dynamically http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.43&r2=1.44&diff_format=u Index: php-src/ext/oci8/oci8_statement.c diff -u php-src/ext/oci8/oci8_statement.c:1.43 php-src/ext/oci8/oci8_statement.c:1.44 --- php-src/ext/oci8/oci8_statement.c:1.43 Wed Jan 31 12:45:56 2007 +++ php-src/ext/oci8/oci8_statement.c Thu Mar 1 23:28:13 2007 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: oci8_statement.c,v 1.43 2007/01/31 12:45:56 tony2001 Exp $ */ +/* $Id: oci8_statement.c,v 1.44 2007/03/01 23:28:13 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H @@ -322,6 +322,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_ZSTR, 0, 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) @@ -335,9 +406,7 @@ ub4 iters; ub4 colcount; ub2 dynamic; - int dtype; dvoid *buf; - php_oci_descriptor *descr; switch (mode) { case OCI_COMMIT_ON_SUCCESS: @@ -425,8 +494,6 @@ return 1; } - outcol->statement = statement; - /* get column */ PHP_OCI_CALL_RETURN(statement->errcode, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)¶m, counter)); @@ -529,45 +596,25 @@ buf = 0; switch (outcol->data_type) { case SQLT_RSE
[PHP-CVS] cvs: php-src /ext/oci8 oci8_statement.c php_oci8_int.h /ext/oci8/tests oci_execute_segfault.phpt
tony2001Wed Jan 31 10:36:20 2007 UTC Modified files: /php-src/ext/oci8 oci8_statement.c php_oci8_int.h /php-src/ext/oci8/tests oci_execute_segfault.phpt Log: fix segfault on re-binding and re-executing a statement improve the test patch by Chris Jones http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.41&r2=1.42&diff_format=u Index: php-src/ext/oci8/oci8_statement.c diff -u php-src/ext/oci8/oci8_statement.c:1.41 php-src/ext/oci8/oci8_statement.c:1.42 --- php-src/ext/oci8/oci8_statement.c:1.41 Thu Jan 11 11:58:34 2007 +++ php-src/ext/oci8/oci8_statement.c Wed Jan 31 10:36:20 2007 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: oci8_statement.c,v 1.41 2007/01/11 11:58:34 tony2001 Exp $ */ +/* $Id: oci8_statement.c,v 1.42 2007/01/31 10:36:20 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H @@ -1147,7 +1147,17 @@ phpbind->out = 1; /* mark as OUT bind */ - if ((Z_TYPE_P(val) == IS_OBJECT) || (Z_TYPE_P(val) == IS_RESOURCE)) { + if (Z_TYPE_P(val) == IS_RESOURCE) { + retval = OCI_CONTINUE; + } else if (Z_TYPE_P(val) == IS_OBJECT) { + if (!phpbind->descriptor) { + return OCI_ERROR; + } + *alenpp = &phpbind->dummy_len; + *bufpp = phpbind->descriptor; + *piecep = OCI_ONE_PIECE; + *rcodepp = &phpbind->retcode; + *indpp = &phpbind->indicator; retval = OCI_CONTINUE; } else { if (UG(unicode)) { http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.29&r2=1.30&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.29 php-src/ext/oci8/php_oci8_int.h:1.30 --- php-src/ext/oci8/php_oci8_int.h:1.29Thu Jan 11 11:26:36 2007 +++ php-src/ext/oci8/php_oci8_int.h Wed Jan 31 10:36:20 2007 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: php_oci8_int.h,v 1.29 2007/01/11 11:26:36 tony2001 Exp $ */ +/* $Id: php_oci8_int.h,v 1.30 2007/01/31 10:36:20 tony2001 Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -199,6 +199,7 @@ sb2 indicator; /* -1 means NULL */ ub2 retcode;/* */ zend_bool out; /* OUT bind or not */ + ub4 dummy_len; /* a dummy var to store alenpp value in bind OUT callback */ } php_oci_bind; /* }}} */ typedef struct { /* php_oci_out_column {{{ */ http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/oci_execute_segfault.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/oci8/tests/oci_execute_segfault.phpt diff -u php-src/ext/oci8/tests/oci_execute_segfault.phpt:1.3 php-src/ext/oci8/tests/oci_execute_segfault.phpt:1.4 --- php-src/ext/oci8/tests/oci_execute_segfault.phpt:1.3Tue Dec 6 19:26:57 2005 +++ php-src/ext/oci8/tests/oci_execute_segfault.phptWed Jan 31 10:36:20 2007 @@ -1,30 +1,54 @@ --TEST-- -oci_execute() segfault after repeated bind +oci_execute() segfault after repeated bind of LOB descriptor --SKIPIF-- --FILE-- save("some text data")); + +oci_bind_by_name($s, ":v_clob", $clob, -1, OCI_B_CLOB); +oci_execute($s, OCI_DEFAULT); +var_dump($clob->save("some more text data")); -$s = oci_parse($c,$ora_sql); -$blob = oci_new_descriptor($c,OCI_D_LOB); -oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); -oci_execute($s); +$query = 'SELECT clob, DBMS_LOB.GETLENGTH(clob) FROM '.$schema.$table_name.' ORDER BY 2'; -oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); -oci_execute($s); +$s = oci_parse ($c, $query); +oci_execute($s, OCI_DEFAULT); + +while ($arr = oci_fetch_assoc($s)) { +$result = $arr['CLOB']->load(); +var_dump($result); +} + +require dirname(__FILE__).'/drop_table.inc'; echo "Done\n"; ?> --EXPECT-- +bool(true) +bool(true) +string(14) "some text data" +string(19) "some more text data" +Done +--UEXPECT-- +bool(true) +bool(true) +unicode(14) "some text data" +unicode(19) "some more text data" Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/oci8 oci8_statement.c php_oci8_int.h
tony2001Fri Nov 10 21:55:05 2006 UTC Modified files: /php-src/ext/oci8 oci8_statement.c php_oci8_int.h Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.34&r2=1.35&diff_format=u Index: php-src/ext/oci8/oci8_statement.c diff -u php-src/ext/oci8/oci8_statement.c:1.34 php-src/ext/oci8/oci8_statement.c:1.35 --- php-src/ext/oci8/oci8_statement.c:1.34 Fri Nov 10 16:56:19 2006 +++ php-src/ext/oci8/oci8_statement.c Fri Nov 10 21:55:05 2006 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: oci8_statement.c,v 1.34 2006/11/10 16:56:19 tony2001 Exp $ */ +/* $Id: oci8_statement.c,v 1.35 2006/11/10 21:55:05 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H @@ -124,7 +124,7 @@ /* {{{ php_oci_statement_set_prefetch() Set prefetch buffer size for the statement (we're assuming that one row is ~1K sized) */ -int php_oci_statement_set_prefetch(php_oci_statement *statement, ub4 size TSRMLS_DC) +int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRMLS_DC) { ub4 prefetch = size * 1024; http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.24&r2=1.25&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.24 php-src/ext/oci8/php_oci8_int.h:1.25 --- php-src/ext/oci8/php_oci8_int.h:1.24Fri Nov 10 16:56:19 2006 +++ php-src/ext/oci8/php_oci8_int.h Fri Nov 10 21:55:05 2006 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: php_oci8_int.h,v 1.24 2006/11/10 16:56:19 tony2001 Exp $ */ +/* $Id: php_oci8_int.h,v 1.25 2006/11/10 21:55:05 tony2001 Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -382,7 +382,7 @@ /* statement related prototypes {{{ */ php_oci_statement * php_oci_statement_create (php_oci_connection *, zstr, int, zend_uchar TSRMLS_DC); -int php_oci_statement_set_prefetch (php_oci_statement *, ub4 TSRMLS_DC); +int php_oci_statement_set_prefetch (php_oci_statement *, long TSRMLS_DC); int php_oci_statement_fetch (php_oci_statement *, ub4 TSRMLS_DC); php_oci_out_column * php_oci_statement_get_column (php_oci_statement *, long, zstr, int TSRMLS_DC); int php_oci_statement_execute (php_oci_statement *, ub4 TSRMLS_DC); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/oci8 oci8_statement.c php_oci8_int.h /ext/oci8/tests bug37581.phpt bug38161.phpt
tony2001Wed Aug 9 12:13:30 2006 UTC Added files: /php-src/ext/oci8/tests bug38161.phpt Modified files: /php-src/ext/oci8 oci8_statement.c php_oci8_int.h /php-src/ext/oci8/tests bug37581.phpt Log: fix #38161 (oci_bind_by_name() returns garbage when Oracle didn't set the variable) http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.22&r2=1.23&diff_format=u Index: php-src/ext/oci8/oci8_statement.c diff -u php-src/ext/oci8/oci8_statement.c:1.22 php-src/ext/oci8/oci8_statement.c:1.23 --- php-src/ext/oci8/oci8_statement.c:1.22 Wed Aug 9 11:48:50 2006 +++ php-src/ext/oci8/oci8_statement.c Wed Aug 9 12:13:30 2006 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: oci8_statement.c,v 1.22 2006/08/09 11:48:50 tony2001 Exp $ */ +/* $Id: oci8_statement.c,v 1.23 2006/08/09 12:13:30 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H @@ -826,9 +826,11 @@ case SQLT_LNG: case SQLT_CHR: /* this is the default case when type was not specified */ - convert_to_string(var); + if (Z_TYPE_P(var) != IS_NULL) { + convert_to_string(var); + } if (maxlength == -1) { - value_sz = Z_STRLEN_P(var); + value_sz = (Z_TYPE_P(var) == IS_STRING) ? Z_STRLEN_P(var) : 0; } else { value_sz = maxlength; @@ -1003,7 +1005,7 @@ zval_dtor(val); Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */ - Z_STRVAL_P(val) = emalloc(Z_STRLEN_P(phpbind->zval)); + Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(phpbind->zval) + 1); /* XXX we assume that zend-zval len has 4 bytes */ *alenpp = (ub4*) &Z_STRLEN_P(phpbind->zval); http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/php_oci8_int.h?r1=1.18&r2=1.19&diff_format=u Index: php-src/ext/oci8/php_oci8_int.h diff -u php-src/ext/oci8/php_oci8_int.h:1.18 php-src/ext/oci8/php_oci8_int.h:1.19 --- php-src/ext/oci8/php_oci8_int.h:1.18Mon Jul 31 10:28:46 2006 +++ php-src/ext/oci8/php_oci8_int.h Wed Aug 9 12:13:30 2006 @@ -25,7 +25,7 @@ +--+ */ -/* $Id: php_oci8_int.h,v 1.18 2006/07/31 10:28:46 tony2001 Exp $ */ +/* $Id: php_oci8_int.h,v 1.19 2006/08/09 12:13:30 tony2001 Exp $ */ #if HAVE_OCI8 # ifndef PHP_OCI8_INT_H @@ -186,7 +186,7 @@ long max_length; long type; } array; - sb2 indicator; /* */ + sb2 indicator; /* -1 means NULL */ ub2 retcode;/* */ } php_oci_bind; /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bug37581.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/oci8/tests/bug37581.phpt diff -u /dev/null php-src/ext/oci8/tests/bug37581.phpt:1.2 --- /dev/null Wed Aug 9 12:13:30 2006 +++ php-src/ext/oci8/tests/bug37581.phptWed Aug 9 12:13:30 2006 @@ -0,0 +1,69 @@ +--TEST-- +Bug #37581 (oci_bind_array_by_name clobbers input array when using SQLT_AFC, AVC) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(5) { + [0]=> + string(1) "A" + [1]=> + string(1) "B" + [2]=> + string(1) "C" + [3]=> + string(1) "D" + [4]=> + string(1) "E" +} +array(5) { + [0]=> + string(1) "A" + [1]=> + string(1) "B" + [2]=> + string(1) "C" + [3]=> + string(1) "D" + [4]=> + string(1) "E" +} +Done http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bug38161.phpt?view=markup&rev=1.1 Index: php-src/ext/oci8/tests/bug38161.phpt +++ php-src/ext/oci8/tests/bug38161.phpt --TEST-- bug #38161 (oci_bind_by_name() returns garbage when Oracle didn't set the variable) --SKIPIF-- --FILE-- --EXPECTF-- NULL int(0) Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php