From afd25b61a4d667f08b7ffcf310905cd758637736 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Thu, 23 Nov 2006 15:23:10 +0000 Subject: [PATCH] fix oci_bind_array_by_name() with SQLT_ODT type fix tests --- ext/oci8/oci8_statement.c | 21 ++++++++++++++++----- ext/oci8/tests/array_bind_001.phpt | 9 +++++++++ ext/oci8/tests/array_bind_003.phpt | 13 +++++++++++++ ext/oci8/tests/array_bind_date.phpt | 14 ++++++++++++++ ext/oci8/tests/array_bind_date1.phpt | 14 ++++++++++++++ 5 files changed, 66 insertions(+), 5 deletions(-) diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 36be4dc016..ee2b8b3222 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -802,7 +802,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) } else { zstr tmp; tmp.s = buff; - ZVAL_TEXTL(*entry, tmp, buff_len, 1); + ZVAL_TEXTL(*entry, tmp, TEXT_CHARS(buff_len), 1); } zend_hash_move_forward(hash); } else { @@ -813,7 +813,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) php_oci_error(connection->err, connection->errcode TSRMLS_CC); add_next_index_null(bind->zval); } else { - add_next_index_textl(bind->zval, tmp, buff_len, 1); + add_next_index_textl(bind->zval, tmp, TEXT_CHARS(buff_len), 1); } } } @@ -1523,8 +1523,12 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p } if ((i < bind->array.current_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) { - convert_to_string_ex(entry); - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, 0, NULL, 0, &oci_date)); + convert_to_text_ex(entry); + if (UG(unicode)) { + PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (text *)Z_UNIVAL_PP(entry).s, UBYTES(Z_UNILEN_PP(entry)), NULL, 0, NULL, 0, &oci_date)); + } else { + PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, 0, NULL, 0, &oci_date)); + } if (connection->errcode != OCI_SUCCESS) { /* failed to convert string to date */ @@ -1538,7 +1542,14 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p ((OCIDate *)bind->array.elements)[i] = oci_date; zend_hash_move_forward(hash); } else { - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, "01-JAN-00", sizeof("01-JAN-00")-1, NULL, 0, NULL, 0, &oci_date)); + + if (UG(unicode)) { + UChar *tmp = USTR_MAKE("01-JAN-00"); + PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (text *)tmp, UBYTES(sizeof("01-JAN-00")-1), NULL, 0, NULL, 0, &oci_date)); + efree(tmp); + } else { + PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, "01-JAN-00", sizeof("01-JAN-00")-1, NULL, 0, NULL, 0, &oci_date)); + } if (connection->errcode != OCI_SUCCESS) { /* failed to convert string to date */ diff --git a/ext/oci8/tests/array_bind_001.phpt b/ext/oci8/tests/array_bind_001.phpt index 1310325ad4..6fa0d11050 100644 --- a/ext/oci8/tests/array_bind_001.phpt +++ b/ext/oci8/tests/array_bind_001.phpt @@ -67,3 +67,12 @@ array(1) { string(0) "" } Done +--UEXPECTF-- +Warning: oci_bind_array_by_name(): OCI-21560: argument 3 is null, invalid, or out of range in %s on line %d + +Warning: oci_execute(): ORA-01008: not all variables bound in %s on line %d +array(1) { + [0]=> + unicode(0) "" +} +Done diff --git a/ext/oci8/tests/array_bind_003.phpt b/ext/oci8/tests/array_bind_003.phpt index 497e46e496..f1218ca231 100644 --- a/ext/oci8/tests/array_bind_003.phpt +++ b/ext/oci8/tests/array_bind_003.phpt @@ -71,3 +71,16 @@ array(4) { string(9) "26-OCT-17" } Done +--UEXPECTF-- +Warning: oci_execute(): OCI_NO_DATA in %s on line %d +array(4) { + [0]=> + unicode(9) "06-DEC-05" + [1]=> + unicode(9) "10-DEC-80" + [2]=> + unicode(9) "21-AUG-91" + [3]=> + unicode(9) "26-OCT-17" +} +Done diff --git a/ext/oci8/tests/array_bind_date.phpt b/ext/oci8/tests/array_bind_date.phpt index 63da558f91..5c2f5dae87 100644 --- a/ext/oci8/tests/array_bind_date.phpt +++ b/ext/oci8/tests/array_bind_date.phpt @@ -72,3 +72,17 @@ array(5) { string(9) "06-DEC-05" } Done +--UEXPECT-- +array(5) { + [0]=> + unicode(9) "05-NOV-05" + [1]=> + unicode(9) "26-OCT-17" + [2]=> + unicode(9) "21-AUG-91" + [3]=> + unicode(9) "10-DEC-80" + [4]=> + unicode(9) "06-DEC-05" +} +Done diff --git a/ext/oci8/tests/array_bind_date1.phpt b/ext/oci8/tests/array_bind_date1.phpt index ebf767570b..21725d40f9 100644 --- a/ext/oci8/tests/array_bind_date1.phpt +++ b/ext/oci8/tests/array_bind_date1.phpt @@ -72,3 +72,17 @@ array(5) { string(9) "06-DEC-05" } Done +--UEXPECT-- +array(5) { + [0]=> + unicode(9) "05-NOV-05" + [1]=> + unicode(9) "26-OCT-17" + [2]=> + unicode(9) "21-AUG-91" + [3]=> + unicode(9) "10-DEC-80" + [4]=> + unicode(9) "06-DEC-05" +} +Done -- 2.50.1