From d99f05f1a26aeaf15d1c5c7cbc35580c0e193306 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Fri, 10 Nov 2006 16:56:19 +0000 Subject: [PATCH] add _not yet 100% complete_ Unicode support collections, statements and BLOBs seem to be working ok though there are still some things to be done in order to make oci_bind_array_by_name() work with U-strings Notes: - in Unicode mode OCI8 always speaks to Oracle server using UTF-16, so all the conversions are done by the client lib. This is why character set parameter of oci_connect() and NLS_LANG are ignored in U-mode. - BLOBs and CLOBs behave quite differently in U-mode. Reading data from a CLOB would result in Unicode string, while BLOBs would return binary string. Also, all LOB utilities work with _bytes_ when BLOB is used and _characters_ when it's CLOB. It's not that obvious, but it does make a lot of sense to me. --- ext/oci8/oci8.c | 206 ++++++++++++++---------- ext/oci8/oci8_collection.c | 63 +++++--- ext/oci8/oci8_interface.c | 241 +++++++++++++++++----------- ext/oci8/oci8_lob.c | 137 ++++++++++------ ext/oci8/oci8_statement.c | 217 ++++++++++++++++--------- ext/oci8/php_oci8_int.h | 57 ++++--- ext/oci8/tests/array_bind_005.phpt | 15 ++ ext/oci8/tests/array_bind_008.phpt | 18 +++ ext/oci8/tests/array_bind_010.phpt | 17 +- ext/oci8/tests/bind_long.phpt | 2 +- ext/oci8/tests/bind_long_raw.phpt | 2 +- ext/oci8/tests/bind_raw.phpt | 2 +- ext/oci8/tests/bug27303.phpt | 201 +++++++++++++++++++++++ ext/oci8/tests/bug27303_2.phpt | 201 +++++++++++++++++++++++ ext/oci8/tests/bug27303_4.phpt | 201 +++++++++++++++++++++++ ext/oci8/tests/bug35973.phpt | 11 ++ ext/oci8/tests/bug36096.phpt | 6 + ext/oci8/tests/coll_011.phpt | 6 + ext/oci8/tests/coll_011_func.phpt | 6 + ext/oci8/tests/coll_012.phpt | 5 + ext/oci8/tests/coll_012_func.phpt | 5 + ext/oci8/tests/coll_013.phpt | 5 + ext/oci8/tests/coll_013_func.phpt | 5 + ext/oci8/tests/coll_014.phpt | 5 + ext/oci8/tests/coll_014_func.phpt | 5 + ext/oci8/tests/commit.phpt | 16 +- ext/oci8/tests/commit_old.phpt | 16 +- ext/oci8/tests/cursor_bind.phpt | 21 +++ ext/oci8/tests/cursors.phpt | 4 +- ext/oci8/tests/cursors_old.phpt | 8 +- ext/oci8/tests/define.phpt | 3 + ext/oci8/tests/define1.phpt | 11 ++ ext/oci8/tests/define_old.phpt | 3 + ext/oci8/tests/error.phpt | 12 +- ext/oci8/tests/error1.phpt | 14 -- ext/oci8/tests/error_old.phpt | 12 +- ext/oci8/tests/fetch.phpt | 8 + ext/oci8/tests/fetch_all.phpt | 24 +-- ext/oci8/tests/fetch_array.phpt | 120 +++++++------- ext/oci8/tests/fetch_assoc.phpt | 12 +- ext/oci8/tests/fetch_into.phpt | 12 +- ext/oci8/tests/fetch_into1.phpt | 52 +++--- ext/oci8/tests/fetch_into2.phpt | 22 +++ ext/oci8/tests/fetch_object.phpt | 12 +- ext/oci8/tests/fetch_row.phpt | 38 +++++ ext/oci8/tests/field_funcs.phpt | 49 ++++++ ext/oci8/tests/field_funcs1.phpt | 101 ++++++++++++ ext/oci8/tests/field_funcs_old.phpt | 49 ++++++ ext/oci8/tests/lob_001.phpt | Bin 1562 -> 1570 bytes ext/oci8/tests/lob_002.phpt | 12 +- ext/oci8/tests/lob_003.phpt | Bin 2135 -> 2137 bytes ext/oci8/tests/lob_004.phpt | 4 +- ext/oci8/tests/lob_006.phpt | Bin 2135 -> 2138 bytes ext/oci8/tests/lob_007.phpt | 2 +- ext/oci8/tests/lob_008.phpt | 2 +- ext/oci8/tests/lob_010.phpt | 4 +- ext/oci8/tests/lob_011.phpt | 2 +- ext/oci8/tests/lob_012.phpt | 2 +- ext/oci8/tests/lob_013.phpt | 4 +- ext/oci8/tests/lob_014.phpt | 6 +- ext/oci8/tests/lob_016.phpt | 4 +- ext/oci8/tests/lob_017.phpt | 4 +- ext/oci8/tests/lob_018.phpt | 6 + ext/oci8/tests/lob_019.phpt | Bin 1951 -> 1959 bytes ext/oci8/tests/lob_020.phpt | Bin 2043 -> 2046 bytes ext/oci8/tests/lob_021.phpt | 8 +- ext/oci8/tests/lob_022.phpt | 13 ++ ext/oci8/tests/lob_023.phpt | 37 +++++ ext/oci8/tests/lob_024.phpt | 31 +++- ext/oci8/tests/lob_025.phpt | 36 ++++- ext/oci8/tests/lob_026.phpt | 44 ++++- ext/oci8/tests/lob_temp.phpt | 10 ++ ext/oci8/tests/lob_temp1.phpt | 8 + ext/oci8/tests/pecl_bug8816.phpt | 32 ++++ ext/oci8/tests/serverversion.phpt | 5 + ext/oci8/tests/statement_cache.phpt | 8 +- 76 files changed, 1993 insertions(+), 549 deletions(-) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 39e3c28ee3..5be7991d83 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -762,9 +762,9 @@ void php_oci_define_hash_dtor(void *data) zval_ptr_dtor(&define->zval); - if (define->name) { - efree(define->name); - define->name = NULL; + if (define->name.v) { + efree(define->name.v); + define->name.v = NULL; } } /* }}} */ @@ -813,8 +813,8 @@ void php_oci_column_hash_dtor(void *data) efree(column->data); } - if (column->name) { - efree(column->name); + if (column->name.v) { + efree(column->name.v); } } /* }}} */ @@ -863,7 +863,7 @@ sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC) case OCI_SUCCESS_WITH_INFO: errcode = php_oci_fetch_errmsg(err_p, &errbuf TSRMLS_CC); if (errbuf) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCI_SUCCESS_WITH_INFO: %s", errbuf); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCI_SUCCESS_WITH_INFO: %R", (UG(unicode) ? IS_UNICODE : IS_STRING), errbuf); efree(errbuf); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCI_SUCCESS_WITH_INFO: failed to fetch error message"); @@ -878,7 +878,7 @@ sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC) case OCI_ERROR: errcode = php_oci_fetch_errmsg(err_p, &errbuf TSRMLS_CC); if (errbuf) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errbuf); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%R", (UG(unicode) ? IS_UNICODE : IS_STRING), errbuf); efree(errbuf); } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to fetch error message"); @@ -909,18 +909,26 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC) text tmp_buf[PHP_OCI_ERRBUF_LEN]; tmp_buf[0] = '\0'; - + + memset(tmp_buf, 0, sizeof(tmp_buf)); PHP_OCI_CALL(OCIErrorGet, (error_handle, (ub4)1, NULL, &error_code, tmp_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ERROR)); if (error_code) { - int tmp_buf_len = strlen(tmp_buf); - - if (tmp_buf_len && tmp_buf[tmp_buf_len - 1] == '\n') { - tmp_buf[tmp_buf_len - 1] = '\0'; + int tmp_buf_len; + if (UG(unicode)) { + tmp_buf_len = u_strlen((UChar *)tmp_buf); + if (tmp_buf_len && tmp_buf[UBYTES(tmp_buf_len - 1)] == '\n') { + tmp_buf[UBYTES(tmp_buf_len - 1)] = '\0'; + } + } else { + tmp_buf_len = strlen(tmp_buf); + if (tmp_buf_len && tmp_buf[tmp_buf_len - 1] == '\n') { + tmp_buf[tmp_buf_len - 1] = '\0'; + } } + if (tmp_buf_len && error_buf) { - *error_buf = NULL; - *error_buf = estrndup(tmp_buf, tmp_buf_len); + *error_buf = estrndup(tmp_buf, TEXT_BYTES(tmp_buf_len)); } } return error_code; @@ -929,12 +937,18 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC) #ifdef HAVE_OCI8_ATTR_STATEMENT /* {{{ php_oci_fetch_sqltext_offset() Compute offset in the SQL statement */ -int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, ub2 *error_offset TSRMLS_DC) +int php_oci_fetch_sqltext_offset(php_oci_statement *statement, zstr *sqltext, ub2 *error_offset TSRMLS_DC) { - *sqltext = NULL; + ub4 sqltext_len = 0; + + *sqltext = NULL_ZSTR; *error_offset = 0; - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (text *) sqltext, (ub4 *)0, OCI_ATTR_STATEMENT, statement->err)); + if (UG(unicode)) { + PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (dvoid *) &(sqltext->u), (ub4 *)&sqltext_len, OCI_ATTR_STATEMENT, statement->err)); + } else { + PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (dvoid *) &(sqltext->s), (ub4 *)&sqltext_len, OCI_ATTR_STATEMENT, statement->err)); + } if (statement->errcode != OCI_SUCCESS) { php_oci_error(statement->err, statement->errcode TSRMLS_CC); @@ -956,22 +970,20 @@ int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, u void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclusive) { php_oci_connection *connection; - char *username, *password; - char *dbname = NULL, *charset = NULL; + zstr username, password; + zstr dbname, charset = NULL_ZSTR; int username_len = 0, password_len = 0; int dbname_len = 0, charset_len = 0; + zend_uchar username_type, password_type; + zend_uchar dbname_type, charset_type; long session_mode = OCI_DEFAULT; /* if a fourth parameter is handed over, it is the charset identifier (but is only used in Oracle 9i+) */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|ssl", &username, &username_len, &password, &password_len, &dbname, &dbname_len, &charset, &charset_len, &session_mode) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "TT|TTl", &username, &username_len, &username_type, &password, &password_len, &password_type, &dbname, &dbname_len, &dbname_type, &charset, &charset_len, &charset_type, &session_mode) == FAILURE) { return; } - - if (!charset_len) { - charset = NULL; - } - - connection = php_oci_do_connect_ex(username, username_len, password, password_len, NULL, 0, dbname, dbname_len, charset, session_mode, persistent, exclusive TSRMLS_CC); + + connection = php_oci_do_connect_ex(username, username_len, password, password_len, NULL_ZSTR, 0, dbname, dbname_len, charset, session_mode, persistent, exclusive, username_type TSRMLS_CC); if (!connection) { RETURN_FALSE; @@ -982,7 +994,7 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus /* {{{ php_oci_do_connect_ex() * The real connect function. Allocates all the resources needed, establishes the connection and returns the result handle (or NULL) */ -php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, char *dbname, int dbname_len, char *charset, long session_mode, int persistent, int exclusive TSRMLS_DC) +php_oci_connection *php_oci_do_connect_ex(zstr username, int username_len, zstr password, int password_len, zstr new_password, int new_password_len, zstr dbname, int dbname_len, zstr charset, long session_mode, int persistent, int exclusive, zend_uchar type TSRMLS_DC) { zend_rsrc_list_entry *le; zend_rsrc_list_entry new_le; @@ -1011,17 +1023,17 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char } smart_str_appendl_ex(&hashed_details, "oci8___", sizeof("oci8___") - 1, 0); - smart_str_appendl_ex(&hashed_details, username, username_len, 0); + smart_str_appendl_ex(&hashed_details, username.s, USTR_BYTES(type, username_len), 0); smart_str_appendl_ex(&hashed_details, "__", sizeof("__") - 1, 0); if (password_len) { ulong password_hash; - password_hash = zend_inline_hash_func(password, password_len); + password_hash = zend_u_inline_hash_func(type, password, password_len); smart_str_append_unsigned_ex(&hashed_details, password_hash, 0); } smart_str_appendl_ex(&hashed_details, "__", sizeof("__") - 1, 0); - if (dbname) { - smart_str_appendl_ex(&hashed_details, dbname, dbname_len, 0); + if (dbname_len) { + smart_str_appendl_ex(&hashed_details, dbname.s, USTR_BYTES(type, dbname_len), 0); } smart_str_appendl_ex(&hashed_details, "__", sizeof("__") - 1, 0); @@ -1031,26 +1043,31 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char } #if HAVE_OCI_ENV_NLS_CREATE - if (charset && *charset) { - PHP_OCI_CALL_RETURN(charsetid, OCINlsCharSetNameToId, (OCI_G(env), charset)); - if (!charsetid) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid character set name: %s", charset); - } else { - smart_str_append_unsigned_ex(&hashed_details, charsetid, 0); + if (!UG(unicode)) { + if (charset.s && *charset.s) { + PHP_OCI_CALL_RETURN(charsetid, OCINlsCharSetNameToId, (OCI_G(env), charset.s)); + if (!charsetid) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid character set name: %s", charset.s); + } else { + smart_str_append_unsigned_ex(&hashed_details, charsetid, 0); + } } - } + - /* use NLS_LANG if no or invalid charset specified */ - if (!charsetid) { - size_t rsize = 0; - sword result; + /* use NLS_LANG if no or invalid charset specified */ + + if (!charsetid) { + size_t rsize = 0; + sword result; - PHP_OCI_CALL_RETURN(result, OCINlsEnvironmentVariableGet, (&charsetid_nls_lang, 0, OCI_NLS_CHARSET_ID, 0, &rsize)) - if (result != OCI_SUCCESS) { - charsetid_nls_lang = 0; + PHP_OCI_CALL_RETURN(result, OCINlsEnvironmentVariableGet, (&charsetid_nls_lang, 0, OCI_NLS_CHARSET_ID, 0, &rsize)) + if (result != OCI_SUCCESS) { + charsetid_nls_lang = 0; + } + smart_str_append_unsigned_ex(&hashed_details, charsetid_nls_lang, 0); } - smart_str_append_unsigned_ex(&hashed_details, charsetid_nls_lang, 0); } + #else if (charset && *charset) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Your version of Oracle Client doesn't support setting the charset; bad or no charset conversions may result"); @@ -1065,7 +1082,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char /* make it lowercase */ php_strtolower(hashed_details.c, hashed_details.len); - if (!exclusive && !new_password) { + if (!exclusive && !new_password.v) { zend_bool found = 0; if (persistent && zend_hash_find(&EG(persistent_list), hashed_details.c, hashed_details.len+1, (void **) &le) == SUCCESS) { @@ -1112,7 +1129,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char connection->used_this_request = 1; tmp = (php_oci_connection *)zend_list_find(connection->rsrc_id, &rsrc_type); - if (tmp != NULL && rsrc_type == le_pconnection && strlen(tmp->hash_key) == hashed_details.len && + if (tmp != NULL && rsrc_type == le_pconnection && tmp->hash_key_len == hashed_details.len && memcmp(tmp->hash_key, hashed_details.c, hashed_details.len) == 0 && zend_list_addref(connection->rsrc_id) == SUCCESS) { /* do nothing */ } else { @@ -1165,15 +1182,18 @@ open: if (alloc_non_persistent) { connection = (php_oci_connection *) ecalloc(1, sizeof(php_oci_connection)); connection->hash_key = estrndup(hashed_details.c, hashed_details.len); + connection->hash_key_len = hashed_details.len; connection->is_persistent = 0; } else { connection = (php_oci_connection *) calloc(1, sizeof(php_oci_connection)); connection->hash_key = zend_strndup(hashed_details.c, hashed_details.len); + connection->hash_key_len = hashed_details.len; connection->is_persistent = 1; } } else { connection = (php_oci_connection *) ecalloc(1, sizeof(php_oci_connection)); connection->hash_key = estrndup(hashed_details.c, hashed_details.len); + connection->hash_key_len = hashed_details.len; connection->is_persistent = 0; } @@ -1190,11 +1210,15 @@ open: /* allocate environment handle */ #if HAVE_OCI_ENV_NLS_CREATE #define PHP_OCI_INIT_FUNC_NAME "OCIEnvNlsCreate" - - if (charsetid) { - connection->charset = charsetid; + + if (UG(unicode)) { + connection->charset = OCI_UTF16ID; } else { - connection->charset = charsetid_nls_lang; + if (charsetid) { + connection->charset = charsetid; + } else { + connection->charset = charsetid_nls_lang; + } } /* create an environment using the character set id, Oracle 9i+ ONLY */ @@ -1225,7 +1249,7 @@ open: php_oci_connection_close(connection TSRMLS_CC); return NULL; } - + /* allocate our server handle {{{ */ PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->server), OCI_HTYPE_SERVER, 0, NULL)); @@ -1236,7 +1260,7 @@ open: } /* }}} */ /* attach to the server {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIServerAttach, (connection->server, OCI_G(err), (text*)dbname, dbname_len, (ub4) OCI_DEFAULT)); + PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIServerAttach, (connection->server, OCI_G(err), (text*)dbname.s, USTR_BYTES(type, dbname_len), (ub4) OCI_DEFAULT)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -1273,8 +1297,8 @@ open: } /* }}} */ /* set the username {{{ */ - if (username) { - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) username, (ub4) username_len, (ub4) OCI_ATTR_USERNAME, OCI_G(err))); + if (username.v) { + PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) username.s, (ub4) USTR_BYTES(type, username_len), (ub4) OCI_ATTR_USERNAME, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -1284,8 +1308,8 @@ open: }/* }}} */ /* set the password {{{ */ - if (password) { - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) password, (ub4) password_len, (ub4) OCI_ATTR_PASSWORD, OCI_G(err))); + if (password.v) { + PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) password.s, (ub4) USTR_BYTES(type, password_len), (ub4) OCI_ATTR_PASSWORD, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -1312,9 +1336,9 @@ open: return NULL; } /* }}} */ - if (new_password) { + if (new_password_len) { /* try to change password if new one was provided {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIPasswordChange, (connection->svc, OCI_G(err), (text *)username, username_len, (text *)password, password_len, (text *)new_password, new_password_len, OCI_AUTH)); + PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIPasswordChange, (connection->svc, OCI_G(err), (text *)username.s, USTR_BYTES(type, username_len), (text *)password.s, USTR_BYTES(type, password_len), (text *)new_password.s, USTR_BYTES(type, new_password_len), OCI_AUTH)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -1344,7 +1368,7 @@ open: case OCI_SYSDBA: case OCI_SYSOPER: default: - if (username_len == 1 && username[0] == '/' && password_len == 0) { + if (username_len == 1 && username.s[0] == '/' && password_len == 0) { PHP_OCI_CALL_RETURN(OCI_G(errcode), OCISessionBegin, (connection->svc, OCI_G(err), connection->session, (ub4) OCI_CRED_EXT, (ub4) session_mode)); } else { PHP_OCI_CALL_RETURN(OCI_G(errcode), OCISessionBegin, (connection->svc, OCI_G(err), connection->session, (ub4) OCI_CRED_RDBMS, (ub4) session_mode)); @@ -1387,13 +1411,13 @@ open: new_le.type = le_pconnection; connection->used_this_request = 1; connection->rsrc_id = zend_list_insert(connection, le_pconnection); - zend_hash_update(&EG(persistent_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL); + zend_hash_update(&EG(persistent_list), connection->hash_key, connection->hash_key_len+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL); OCI_G(num_persistent)++; } else if (!exclusive) { connection->rsrc_id = zend_list_insert(connection, le_connection); new_le.ptr = (void *)connection->rsrc_id; new_le.type = le_index_ptr; - zend_hash_update(&EG(regular_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL); + zend_hash_update(&EG(regular_list), connection->hash_key, connection->hash_key_len+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL); OCI_G(num_links)++; } else { connection->rsrc_id = zend_list_insert(connection, le_connection); @@ -1543,9 +1567,9 @@ static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC) /* {{{ php_oci_password_change() Change password for the user with the username given */ -int php_oci_password_change(php_oci_connection *connection, char *user, int user_len, char *pass_old, int pass_old_len, char *pass_new, int pass_new_len TSRMLS_DC) +int php_oci_password_change(php_oci_connection *connection, zstr user, int user_len, zstr pass_old, int pass_old_len, zstr pass_new, int pass_new_len, zend_uchar type TSRMLS_DC) { - PHP_OCI_CALL_RETURN(connection->errcode, OCIPasswordChange, (connection->svc, connection->err, (text *)user, user_len, (text *)pass_old, pass_old_len, (text *)pass_new, pass_new_len, OCI_DEFAULT)); + PHP_OCI_CALL_RETURN(connection->errcode, OCIPasswordChange, (connection->svc, connection->err, (text *)user.s, USTR_BYTES(type, user_len), (text *)pass_old.s, USTR_BYTES(type, pass_old_len), (text *)pass_new.s, USTR_BYTES(type, pass_new_len), OCI_DEFAULT)); if (connection->errcode != OCI_SUCCESS) { php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -1557,9 +1581,9 @@ int php_oci_password_change(php_oci_connection *connection, char *user, int user /* {{{ php_oci_server_get_version() Get Oracle server version */ -int php_oci_server_get_version(php_oci_connection *connection, char **version TSRMLS_DC) +int php_oci_server_get_version(php_oci_connection *connection, zstr *version TSRMLS_DC) { - char version_buff[256]; + char version_buff[512]; PHP_OCI_CALL_RETURN(connection->errcode, OCIServerVersion, (connection->svc, connection->err, (text*)version_buff, sizeof(version_buff), OCI_HTYPE_SVCCTX)); @@ -1568,8 +1592,12 @@ int php_oci_server_get_version(php_oci_connection *connection, char **version TS PHP_OCI_HANDLE_ERROR(connection, connection->errcode); return 1; } - - *version = estrdup(version_buff); + + if (UG(unicode)) { + version->u = eustrdup((UChar *)version_buff); + } else { + version->s = estrdup(version_buff); + } return 0; } /* }}} */ @@ -1580,7 +1608,7 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSR php_oci_descriptor *descriptor; ub4 lob_length; int column_size; - char *lob_buffer; + zstr lob_buffer, zstr_data = (zstr)column->data; if (column->indicator == -1) { /* column is NULL */ ZVAL_NULL(value); @@ -1609,19 +1637,35 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSR } if (column->data_type != SQLT_RDD && (mode & PHP_OCI_RETURN_LOBS)) { + php_oci_lob_type lob_type; /* PHP_OCI_RETURN_LOBS means that we want the content of the LOB back instead of the locator */ if (php_oci_lob_read(descriptor, -1, 0, &lob_buffer, &lob_length TSRMLS_CC)) { ZVAL_FALSE(value); return 1; - } else { - if (lob_length > 0) { - ZVAL_STRINGL(value, lob_buffer, lob_length, 0); - } else { - ZVAL_EMPTY_STRING(value); - } - return 0; } + + if (php_oci_lob_get_type(descriptor, &lob_type TSRMLS_CC) > 0) { + return 1; + } + + switch (lob_type) { + case OCI_IS_CLOB: + if (lob_length > 0) { + ZVAL_TEXTL(value, lob_buffer, TEXT_CHARS(lob_length), 0); + } else { + ZVAL_EMPTY_TEXT(value); + } + break; + case OCI_IS_BLOB: + if (lob_length > 0) { + ZVAL_STRINGL(value, lob_buffer.s, lob_length, 0); + } else { + ZVAL_EMPTY_STRING(value); + } + break; + } + return 0; } else { /* return the locator */ object_init_ex(value, oci_lob_class_entry_ptr); @@ -1644,7 +1688,7 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSR return 0; } - ZVAL_STRINGL(value, column->data, column_size, 1); + ZVAL_TEXTL(value, zstr_data, TEXT_CHARS(column_size), 1); } return 0; } @@ -1711,7 +1755,7 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg for (i = 0; i < statement->ncolumns; i++) { - column = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); + column = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); if (column == NULL) { continue; @@ -1733,7 +1777,7 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg if (fetch_mode & PHP_OCI_NUM) { ZVAL_ADDREF(element); } - add_assoc_zval(return_value, column->name, element); + add_u_assoc_zval(return_value, (UG(unicode) ? IS_UNICODE : IS_STRING), column->name, element); } } else { @@ -1741,7 +1785,7 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg add_index_null(return_value, i); } if (fetch_mode & PHP_OCI_ASSOC) { - add_assoc_null(return_value, column->name); + add_u_assoc_null(return_value, (UG(unicode) ? IS_UNICODE : IS_STRING), column->name); } } } diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c index dbbaff6184..c46c354480 100644 --- a/ext/oci8/oci8_collection.c +++ b/ext/oci8/oci8_collection.c @@ -44,7 +44,7 @@ /* {{{ php_oci_collection_create() Create and return connection handle */ -php_oci_collection * php_oci_collection_create(php_oci_connection* connection, char *tdo, int tdo_len, char *schema, int schema_len TSRMLS_DC) +php_oci_collection * php_oci_collection_create(php_oci_connection* connection, zstr tdo, int tdo_len, zstr schema, int schema_len TSRMLS_DC) { dvoid *dschp1; dvoid *parmp1; @@ -62,10 +62,10 @@ php_oci_collection * php_oci_collection_create(php_oci_connection* connection, c connection->env, connection->err, connection->svc, - (text *) schema, - (ub4) schema_len, - (text *) tdo, - (ub4) tdo_len, + (text *) schema.s, + (ub4) TEXT_BYTES(schema_len), + (text *) tdo.s, + (ub4) TEXT_BYTES(tdo_len), (CONST text *) 0, (ub4) 0, OCI_DURATION_SESSION, @@ -289,14 +289,14 @@ int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC) /* {{{ php_oci_collection_append_date() Append DATE element to the end of the collection (use "DD-MON-YY" format) */ -int php_oci_collection_append_date(php_oci_collection *collection, char *date, int date_len TSRMLS_DC) +int php_oci_collection_append_date(php_oci_collection *collection, zstr date, int date_len TSRMLS_DC) { OCIInd new_index = OCI_IND_NOTNULL; OCIDate oci_date; php_oci_connection *connection = collection->connection; /* format and language are NULLs, so format is "DD-MON-YY" and language is the default language of the session */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, date, date_len, NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, date.s, TEXT_BYTES(date_len), NULL, 0, NULL, 0, &oci_date)); if (connection->errcode != OCI_SUCCESS) { /* failed to convert string to date */ @@ -324,14 +324,18 @@ int php_oci_collection_append_date(php_oci_collection *collection, char *date, i /* {{{ php_oci_collection_append_number() Append NUMBER to the end of the collection */ -int php_oci_collection_append_number(php_oci_collection *collection, char *number, int number_len TSRMLS_DC) +int php_oci_collection_append_number(php_oci_collection *collection, zstr number, int number_len TSRMLS_DC) { OCIInd new_index = OCI_IND_NOTNULL; double element_double; OCINumber oci_number; php_oci_connection *connection = collection->connection; - element_double = zend_strtod(number, NULL); + if (UG(unicode)) { + element_double = zend_u_strtod(number.u, NULL); + } else { + element_double = zend_strtod(number.s, NULL); + } PHP_OCI_CALL_RETURN(connection->errcode, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); @@ -360,13 +364,13 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe /* {{{ php_oci_collection_append_string() Append STRING to the end of the collection */ -int php_oci_collection_append_string(php_oci_collection *collection, char *element, int element_len TSRMLS_DC) +int php_oci_collection_append_string(php_oci_collection *collection, zstr element, int element_len TSRMLS_DC) { OCIInd new_index = OCI_IND_NOTNULL; OCIString *ocistr = (OCIString *)0; php_oci_connection *connection = collection->connection; - PHP_OCI_CALL_RETURN(connection->errcode, OCIStringAssignText, (connection->env, connection->err, element, element_len, &ocistr)); + PHP_OCI_CALL_RETURN(connection->errcode, OCIStringAssignText, (connection->env, connection->err, element.s, TEXT_BYTES(element_len), &ocistr)); if (connection->errcode != OCI_SUCCESS) { php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -393,7 +397,7 @@ int php_oci_collection_append_string(php_oci_collection *collection, char *eleme /* {{{ php_oci_collection_append() Append wrapper. Appends any supported element to the end of the collection */ -int php_oci_collection_append(php_oci_collection *collection, char *element, int element_len TSRMLS_DC) +int php_oci_collection_append(php_oci_collection *collection, zstr element, int element_len TSRMLS_DC) { if (element_len == 0) { return php_oci_collection_append_null(collection TSRMLS_CC); @@ -484,9 +488,14 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z return 1; } - ZVAL_STRINGL(*result_element, buff, buff_len, 1); - Z_STRVAL_P(*result_element)[buff_len] = '\0'; - + if (UG(unicode)) { + ZVAL_UNICODEL(*result_element, (UChar *)buff, TEXT_CHARS(buff_len), 1); + /* Z_UNIVAL_P(*result_element)[buff_len] = 0; XXX */ + } else { + ZVAL_STRINGL(*result_element, buff, buff_len, 1); + Z_STRVAL_P(*result_element)[buff_len] = '\0'; + } + return 0; break; @@ -498,7 +507,11 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z PHP_OCI_CALL_RETURN(str, OCIStringPtr, (connection->env, oci_string)); if (str) { - ZVAL_STRING(*result_element, str, 1); + if (UG(unicode)) { + ZVAL_UNICODE(*result_element, (UChar *)str, 1); + } else { + ZVAL_STRING(*result_element, str, 1); + } } return 0; } @@ -560,14 +573,14 @@ int php_oci_collection_element_set_null(php_oci_collection *collection, long ind /* {{{ php_oci_collection_element_set_date() Change element's value to the given DATE */ -int php_oci_collection_element_set_date(php_oci_collection *collection, long index, char *date, int date_len TSRMLS_DC) +int php_oci_collection_element_set_date(php_oci_collection *collection, long index, zstr date, int date_len TSRMLS_DC) { OCIInd new_index = OCI_IND_NOTNULL; OCIDate oci_date; php_oci_connection *connection = collection->connection; /* format and language are NULLs, so format is "DD-MON-YY" and language is the default language of the session */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, date, date_len, NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, date.s, TEXT_BYTES(date_len), NULL, 0, NULL, 0, &oci_date)); if (connection->errcode != OCI_SUCCESS) { /* failed to convert string to date */ @@ -596,14 +609,18 @@ int php_oci_collection_element_set_date(php_oci_collection *collection, long ind /* {{{ php_oci_collection_element_set_number() Change element's value to the given NUMBER */ -int php_oci_collection_element_set_number(php_oci_collection *collection, long index, char *number, int number_len TSRMLS_DC) +int php_oci_collection_element_set_number(php_oci_collection *collection, long index, zstr number, int number_len TSRMLS_DC) { OCIInd new_index = OCI_IND_NOTNULL; double element_double; OCINumber oci_number; php_oci_connection *connection = collection->connection; - element_double = zend_strtod(number, NULL); + if (UG(unicode)) { + element_double = zend_u_strtod(number.u, NULL); + } else { + element_double = zend_strtod(number.s, NULL); + } PHP_OCI_CALL_RETURN(connection->errcode, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); @@ -633,13 +650,13 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i /* {{{ php_oci_collection_element_set_string() Change element's value to the given string */ -int php_oci_collection_element_set_string(php_oci_collection *collection, long index, char *element, int element_len TSRMLS_DC) +int php_oci_collection_element_set_string(php_oci_collection *collection, long index, zstr element, int element_len TSRMLS_DC) { OCIInd new_index = OCI_IND_NOTNULL; OCIString *ocistr = (OCIString *)0; php_oci_connection *connection = collection->connection; - PHP_OCI_CALL_RETURN(connection->errcode, OCIStringAssignText, (connection->env, connection->err, element, element_len, &ocistr)); + PHP_OCI_CALL_RETURN(connection->errcode, OCIStringAssignText, (connection->env, connection->err, element.s, TEXT_BYTES(element_len), &ocistr)); if (connection->errcode != OCI_SUCCESS) { php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -667,7 +684,7 @@ int php_oci_collection_element_set_string(php_oci_collection *collection, long i /* {{{ php_oci_collection_element_set() Collection element setter */ -int php_oci_collection_element_set(php_oci_collection *collection, long index, char *value, int value_len TSRMLS_DC) +int php_oci_collection_element_set(php_oci_collection *collection, long index, zstr value, int value_len TSRMLS_DC) { if (value_len == 0) { return php_oci_collection_element_set_null(collection, index TSRMLS_CC); diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index bee6971685..e9d3621b7e 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -46,13 +46,14 @@ PHP_FUNCTION(oci_define_by_name) { zval *stmt, *var; - char *name; + zstr name; int name_len; + zend_uchar name_type; long type = SQLT_CHR; php_oci_statement *statement; php_oci_define *define, *tmp_define; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz/|l", &stmt, &name, &name_len, &var, &type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rtz/|l", &stmt, &name, &name_len, &name_type, &var, &type) == FAILURE) { return; } @@ -70,7 +71,7 @@ PHP_FUNCTION(oci_define_by_name) define = ecalloc(1,sizeof(php_oci_define)); - if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void **)&tmp_define) == SUCCESS) { + if (zend_hash_add(statement->defines, name.s, USTR_BYTES(name_type, name_len+1), define, sizeof(php_oci_define), (void **)&tmp_define) == SUCCESS) { efree(define); define = tmp_define; } else { @@ -78,8 +79,14 @@ PHP_FUNCTION(oci_define_by_name) RETURN_FALSE; } - define->name = (text*) estrndup(name, name_len); + if (name_type == IS_UNICODE) { + define->name.u = eustrndup(name.u, name_len); + } else { + define->name.s = estrndup(name.s, name_len); + } + define->name_len = name_len; + define->name_type = name_type; define->type = type; define->zval = var; zval_add_ref(&var); @@ -96,12 +103,13 @@ PHP_FUNCTION(oci_bind_by_name) ub2 bind_type = SQLT_CHR; /* unterminated string */ int name_len; long maxlen = -1, type = 0; - char *name; + zstr name; + zend_uchar name_type; zval *z_statement; zval *bind_var = NULL; php_oci_statement *statement; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz/|ll", &z_statement, &name, &name_len, &bind_var, &maxlen, &type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rtz/|ll", &z_statement, &name, &name_len, &name_type, &bind_var, &maxlen, &type) == FAILURE) { return; } @@ -111,7 +119,7 @@ PHP_FUNCTION(oci_bind_by_name) PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement); - if (php_oci_bind_by_name(statement, name, name_len, bind_var, maxlen, bind_type TSRMLS_CC)) { + if (php_oci_bind_by_name(statement, name, name_len, bind_var, maxlen, bind_type, name_type TSRMLS_CC)) { RETURN_FALSE; } RETURN_TRUE; @@ -126,12 +134,13 @@ PHP_FUNCTION(oci_bind_array_by_name) long max_item_len = -1; long max_array_len = 0; long type = SQLT_AFC; - char *name; + zstr name; + zend_uchar name_type; zval *z_statement; zval *bind_var = NULL; php_oci_statement *statement; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz/l|ll", &z_statement, &name, &name_len, &bind_var, &max_array_len, &max_item_len, &type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rtz/l|ll", &z_statement, &name, &name_len, &name_type, &bind_var, &max_array_len, &max_item_len, &type) == FAILURE) { return; } @@ -146,7 +155,7 @@ PHP_FUNCTION(oci_bind_array_by_name) RETURN_FALSE; } - if (php_oci_bind_array_by_name(statement, name, name_len, bind_var, max_array_len, max_item_len, type TSRMLS_CC)) { + if (php_oci_bind_array_by_name(statement, name, name_len, bind_var, max_array_len, max_item_len, type, name_type TSRMLS_CC)) { RETURN_FALSE; } RETURN_TRUE; @@ -184,18 +193,18 @@ PHP_FUNCTION(oci_lob_save) { zval **tmp, *z_descriptor = getThis(); php_oci_descriptor *descriptor; - char *data; + zstr data; int data_len; + zend_uchar data_type; long offset = 0; ub4 bytes_written; if (getThis()) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|l", &data, &data_len, &data_type, &offset) == FAILURE) { return; } - } - else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &offset) == FAILURE) { + } else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ot|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &data_type, &offset) == FAILURE) { return; } } @@ -211,8 +220,8 @@ PHP_FUNCTION(oci_lob_save) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset parameter must be greater than or equal to 0"); RETURN_FALSE; } - - if (php_oci_lob_write(descriptor, offset, data, data_len, &bytes_written TSRMLS_CC)) { + + if (php_oci_lob_write(descriptor, offset, data, USTR_BYTES(data_type, data_len), &bytes_written TSRMLS_CC)) { RETURN_FALSE; } RETURN_TRUE; @@ -259,8 +268,9 @@ PHP_FUNCTION(oci_lob_load) { zval **tmp, *z_descriptor = getThis(); php_oci_descriptor *descriptor; - char *buffer = NULL; + zstr buffer = NULL_ZSTR; ub4 buffer_len; + php_oci_lob_type lob_type; if (!getThis()) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) { @@ -278,11 +288,24 @@ PHP_FUNCTION(oci_lob_load) if (php_oci_lob_read(descriptor, -1, 0, &buffer, &buffer_len TSRMLS_CC)) { RETURN_FALSE; } - if (buffer_len > 0) { - RETURN_STRINGL(buffer, buffer_len, 0); + + if (php_oci_lob_get_type(descriptor, &lob_type TSRMLS_CC) > 0) { + RETURN_FALSE; } - else { - RETURN_EMPTY_STRING(); + + switch (lob_type) { + case OCI_IS_CLOB: + if (buffer_len > 0) { + RETURN_TEXTL(buffer, TEXT_CHARS(buffer_len), 0); + } + RETURN_EMPTY_TEXT(); + break; + case OCI_IS_BLOB: + if (buffer_len > 0) { + RETURN_STRINGL(buffer.s, buffer_len, 0); + } + RETURN_EMPTY_STRING(); + break; } } /* }}} */ @@ -294,8 +317,9 @@ PHP_FUNCTION(oci_lob_read) zval **tmp, *z_descriptor = getThis(); php_oci_descriptor *descriptor; long length; - char *buffer; + zstr buffer; ub4 buffer_len; + php_oci_lob_type lob_type; if (getThis()) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &length) == FAILURE) { @@ -322,12 +346,25 @@ PHP_FUNCTION(oci_lob_read) if (php_oci_lob_read(descriptor, length, descriptor->lob_current_position, &buffer, &buffer_len TSRMLS_CC)) { RETURN_FALSE; - } - if (buffer_len > 0) { - RETURN_STRINGL(buffer, buffer_len, 0); } - else { - RETURN_EMPTY_STRING(); + + if (php_oci_lob_get_type(descriptor, &lob_type TSRMLS_CC) > 0) { + RETURN_FALSE; + } + + switch (lob_type) { + case OCI_IS_CLOB: + if (buffer_len > 0) { + RETURN_TEXTL(buffer, TEXT_CHARS(buffer_len), 0); + } + RETURN_EMPTY_TEXT(); + break; + case OCI_IS_BLOB: + if (buffer_len > 0) { + RETURN_STRINGL(buffer.s, buffer_len, 0); + } + RETURN_EMPTY_STRING(); + break; } } /* }}} */ @@ -439,7 +476,6 @@ PHP_FUNCTION(oci_lob_seek) PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor); - if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) { RETURN_FALSE; } @@ -449,7 +485,7 @@ PHP_FUNCTION(oci_lob_seek) descriptor->lob_current_position += offset; break; case PHP_OCI_SEEK_END: - if (descriptor->lob_size + offset >= 0) { + if ((descriptor->lob_size + offset) >= 0) { descriptor->lob_current_position = descriptor->lob_size + offset; } else { @@ -458,10 +494,9 @@ PHP_FUNCTION(oci_lob_seek) break; case PHP_OCI_SEEK_SET: default: - descriptor->lob_current_position = (offset > 0) ? offset : 0; + descriptor->lob_current_position = (offset > 0) ? offset : 0; break; } - RETURN_TRUE; } /* }}} */ @@ -503,10 +538,11 @@ PHP_FUNCTION(oci_lob_write) int data_len; long write_len = 0; ub4 bytes_written; - char *data; + zstr data; + zend_uchar data_type; if (getThis()) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &write_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|l", &data, &data_len, &data_type, &write_len) == FAILURE) { return; } @@ -515,7 +551,7 @@ PHP_FUNCTION(oci_lob_write) } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &write_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ot|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &data_type, &write_len) == FAILURE) { return; } @@ -534,8 +570,8 @@ PHP_FUNCTION(oci_lob_write) if (data_len <= 0) { RETURN_LONG(0); } - - if (php_oci_lob_write(descriptor, descriptor->lob_current_position, data, data_len, &bytes_written TSRMLS_CC)) { + + if (php_oci_lob_write(descriptor, descriptor->lob_current_position, data, USTR_BYTES(data_type, data_len), &bytes_written TSRMLS_CC)) { RETURN_FALSE; } RETURN_LONG(bytes_written); @@ -850,11 +886,13 @@ PHP_FUNCTION(oci_lob_export) { zval **tmp, *z_descriptor = getThis(); php_oci_descriptor *descriptor; - char *filename, *buffer; + char *filename; + zstr buffer; int filename_len; long start = -1, length = -1, block_length; php_stream *stream; ub4 lob_length; + php_oci_lob_type lob_type; if (getThis()) { if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &start, &length) == FAILURE) { @@ -920,19 +958,23 @@ PHP_FUNCTION(oci_lob_export) block_length = length; } + if (php_oci_lob_get_type(descriptor, &lob_type TSRMLS_CC)) { + RETURN_FALSE; + } + while(length > 0) { ub4 tmp_bytes_read = 0; if (php_oci_lob_read(descriptor, block_length, start, &buffer, &tmp_bytes_read TSRMLS_CC)) { php_stream_close(stream); RETURN_FALSE; } - if (tmp_bytes_read && !php_stream_write(stream, buffer, tmp_bytes_read)) { + if (tmp_bytes_read && !php_stream_u_write(stream, (lob_type == OCI_IS_CLOB ? IS_UNICODE : IS_STRING), buffer, tmp_bytes_read)) { php_stream_close(stream); - efree(buffer); + efree(buffer.v); RETURN_FALSE; } - if (buffer) { - efree(buffer); + if (buffer.v) { + efree(buffer.v); } length -= tmp_bytes_read; @@ -956,17 +998,18 @@ PHP_FUNCTION(oci_lob_write_temporary) { zval **tmp, *z_descriptor = getThis(); php_oci_descriptor *descriptor; - char *data; + zstr data; int data_len; + zend_uchar data_type; long type = OCI_TEMP_CLOB; if (getThis()) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t|l", &data, &data_len, &data_type, &type) == FAILURE) { return; } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &type) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ot|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &data_type, &type) == FAILURE) { return; } } @@ -978,7 +1021,7 @@ PHP_FUNCTION(oci_lob_write_temporary) PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor); - if (php_oci_lob_write_tmp(descriptor, type, data, data_len TSRMLS_CC)) { + if (php_oci_lob_write_tmp(descriptor, type, data, USTR_BYTES(data_type, data_len) TSRMLS_CC)) { RETURN_FALSE; } RETURN_TRUE; @@ -1099,7 +1142,7 @@ PHP_FUNCTION(oci_field_name) php_oci_out_column *column; if ( ( column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0) ) ) { - RETURN_STRINGL(column->name, column->name_len, 1); + RETURN_TEXTL(column->name, column->name_len, 1); } RETURN_FALSE; } @@ -1163,49 +1206,49 @@ PHP_FUNCTION(oci_field_type) switch (column->data_type) { #ifdef SQLT_TIMESTAMP case SQLT_TIMESTAMP: - RETVAL_STRING("TIMESTAMP",1); + RETVAL_ASCII_STRING("TIMESTAMP", ZSTR_DUPLICATE); break; #endif #ifdef SQLT_TIMESTAMP_TZ case SQLT_TIMESTAMP_TZ: - RETVAL_STRING("TIMESTAMP_TZ",1); + RETVAL_ASCII_STRING("TIMESTAMP_TZ", ZSTR_DUPLICATE); break; #endif case SQLT_DAT: - RETVAL_STRING("DATE",1); + RETVAL_ASCII_STRING("DATE", ZSTR_DUPLICATE); break; case SQLT_NUM: - RETVAL_STRING("NUMBER",1); + RETVAL_ASCII_STRING("NUMBER", ZSTR_DUPLICATE); break; case SQLT_LNG: - RETVAL_STRING("LONG",1); + RETVAL_ASCII_STRING("LONG", ZSTR_DUPLICATE); break; case SQLT_BIN: - RETVAL_STRING("RAW",1); + RETVAL_ASCII_STRING("RAW", ZSTR_DUPLICATE); break; case SQLT_LBI: - RETVAL_STRING("LONG RAW",1); + RETVAL_ASCII_STRING("LONG RAW", ZSTR_DUPLICATE); break; case SQLT_CHR: - RETVAL_STRING("VARCHAR2",1); + RETVAL_ASCII_STRING("VARCHAR2", ZSTR_DUPLICATE); break; case SQLT_RSET: - RETVAL_STRING("REFCURSOR",1); + RETVAL_ASCII_STRING("REFCURSOR", ZSTR_DUPLICATE); break; case SQLT_AFC: - RETVAL_STRING("CHAR",1); + RETVAL_ASCII_STRING("CHAR", ZSTR_DUPLICATE); break; case SQLT_BLOB: - RETVAL_STRING("BLOB",1); + RETVAL_ASCII_STRING("BLOB", ZSTR_DUPLICATE); break; case SQLT_CLOB: - RETVAL_STRING("CLOB",1); + RETVAL_ASCII_STRING("CLOB", ZSTR_DUPLICATE); break; case SQLT_BFILE: - RETVAL_STRING("BFILE",1); + RETVAL_ASCII_STRING("BFILE", ZSTR_DUPLICATE); break; case SQLT_RDD: - RETVAL_STRING("ROWID",1); + RETVAL_ASCII_STRING("ROWID", ZSTR_DUPLICATE); break; default: RETVAL_LONG(column->data_type); @@ -1356,7 +1399,7 @@ PHP_FUNCTION(oci_fetch_all) columns = safe_emalloc(statement->ncolumns, sizeof(php_oci_out_column *), 0); for (i = 0; i < statement->ncolumns; i++) { - columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); + columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); } while (!php_oci_statement_fetch(statement, nrows TSRMLS_CC)) { @@ -1372,7 +1415,7 @@ PHP_FUNCTION(oci_fetch_all) if (flags & PHP_OCI_NUM) { zend_hash_next_index_insert(Z_ARRVAL_P(row), &element, sizeof(zval*), NULL); } else { /* default to ASSOC */ - zend_hash_update(Z_ARRVAL_P(row), columns[ i ]->name, columns[ i ]->name_len+1, &element, sizeof(zval*), NULL); + zend_u_hash_update(Z_ARRVAL_P(row), (UG(unicode) ? IS_UNICODE : IS_STRING), columns[ i ]->name, columns[ i ]->name_len+1, &element, sizeof(zval*), NULL); } } @@ -1392,7 +1435,7 @@ PHP_FUNCTION(oci_fetch_all) if (flags & PHP_OCI_NUM) { for (i = 0; i < statement->ncolumns; i++) { - columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); + columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); MAKE_STD_ZVAL(tmp); array_init(tmp); @@ -1400,11 +1443,11 @@ PHP_FUNCTION(oci_fetch_all) } } else { /* default to ASSOC */ for (i = 0; i < statement->ncolumns; i++) { - columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); + columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); MAKE_STD_ZVAL(tmp); array_init(tmp); - zend_hash_update(Z_ARRVAL_P(array), columns[ i ]->name, columns[ i ]->name_len+1, (void *) &tmp, sizeof(zval*), (void **) &(outarrs[ i ])); + zend_u_hash_update(Z_ARRVAL_P(array), (UG(unicode) ? IS_UNICODE : IS_STRING), columns[ i ]->name, columns[ i ]->name_len+1, (void *) &tmp, sizeof(zval*), (void **) &(outarrs[ i ])); } } @@ -1549,7 +1592,7 @@ PHP_FUNCTION(oci_error) dvoid *errh = NULL; #ifdef HAVE_OCI8_ATTR_STATEMENT ub2 error_offset = 0; - text *sqltext = NULL; + zstr sqltext = NULL_ZSTR; #endif if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &arg) == FAILURE) { @@ -1595,10 +1638,18 @@ PHP_FUNCTION(oci_error) if (errcode) { array_init(return_value); add_assoc_long(return_value, "code", errcode); - add_assoc_string(return_value, "message", (char*) errbuf, 0); + if (UG(unicode)) { + add_assoc_unicode(return_value, "message", (UChar *)errbuf, 0); + } else { + add_assoc_string(return_value, "message", errbuf, 0); + } #ifdef HAVE_OCI8_ATTR_STATEMENT add_assoc_long(return_value, "offset", error_offset); - add_assoc_string(return_value, "sqltext", sqltext ? (char *) sqltext : "", 1); + if (sqltext.v) { + add_assoc_text(return_value, "sqltext", sqltext, 1); + } else { + add_assoc_ascii_string(return_value, "sqltext", "", 1); + } #endif } else { RETURN_FALSE; @@ -1630,16 +1681,17 @@ PHP_FUNCTION(oci_parse) zval *z_connection; php_oci_connection *connection; php_oci_statement *statement; - char *query; + zstr query; + zend_uchar query_type; int query_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &query, &query_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rt", &z_connection, &query, &query_len, &query_type) == FAILURE) { return; } PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - statement = php_oci_statement_create(connection, query, query_len TSRMLS_CC); + statement = php_oci_statement_create(connection, query, query_len, query_type TSRMLS_CC); if (statement) { RETURN_RESOURCE(statement->id); @@ -1674,11 +1726,12 @@ PHP_FUNCTION(oci_set_prefetch) PHP_FUNCTION(oci_password_change) { zval *z_connection; - text *user, *pass_old, *pass_new, *dbname; + zstr user, pass_old, pass_new, dbname; + zend_uchar user_type, pass_old_type, pass_new_type, dbname_type; int user_len, pass_old_len, pass_new_len, dbname_len; php_oci_connection *connection; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &z_connection, &user, &user_len, &pass_old, &pass_old_len, &pass_new, &pass_new_len) == SUCCESS) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rTTT", &z_connection, &user, &user_len, &user_type, &pass_old, &pass_old_len, &pass_old_type, &pass_new, &pass_new_len, &pass_new_type) == SUCCESS) { PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); if (!user_len) { @@ -1694,11 +1747,11 @@ PHP_FUNCTION(oci_password_change) RETURN_FALSE; } - if (php_oci_password_change(connection, user, user_len, pass_old, pass_old_len, pass_new, pass_new_len TSRMLS_CC)) { + if (php_oci_password_change(connection, user, user_len, pass_old, pass_old_len, pass_new, pass_new_len, user_type TSRMLS_CC)) { RETURN_FALSE; } RETURN_TRUE; - } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "ssss", &dbname, &dbname_len, &user, &user_len, &pass_old, &pass_old_len, &pass_new, &pass_new_len) == SUCCESS) { + } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "TTTT", &dbname, &dbname_len, &dbname_type, &user, &user_len, &user_type, &pass_old, &pass_old_len, &pass_old_type, &pass_new, &pass_new_len, &pass_new_type) == SUCCESS) { if (!user_len) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "username cannot be empty"); @@ -1713,7 +1766,7 @@ PHP_FUNCTION(oci_password_change) RETURN_FALSE; } - connection = php_oci_do_connect_ex(user, user_len, pass_old, pass_old_len, pass_new, pass_new_len, dbname, dbname_len, NULL, OCI_DEFAULT, 0, 0 TSRMLS_CC); + connection = php_oci_do_connect_ex(user, user_len, pass_old, pass_old_len, pass_new, pass_new_len, dbname, dbname_len, NULL_ZSTR, OCI_DEFAULT, 0, 0, user_type TSRMLS_CC); if (!connection) { RETURN_FALSE; } @@ -1737,7 +1790,7 @@ PHP_FUNCTION(oci_new_cursor) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - statement = php_oci_statement_create(connection, NULL, 0 TSRMLS_CC); + statement = php_oci_statement_create(connection, NULL_ZSTR, 0, 0 TSRMLS_CC); if (statement) { RETURN_RESOURCE(statement->id); @@ -1768,7 +1821,7 @@ PHP_FUNCTION(oci_server_version) { zval *z_connection; php_oci_connection *connection; - char *version = NULL; + zstr version = NULL_ZSTR; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_connection) == FAILURE) { return; @@ -1780,7 +1833,7 @@ PHP_FUNCTION(oci_server_version) RETURN_FALSE; } - RETURN_STRING(version, 0); + RETURN_TEXT(version, 0); } /* }}} */ @@ -1889,16 +1942,16 @@ PHP_FUNCTION(oci_collection_append) { zval **tmp, *z_collection = getThis(); php_oci_collection *collection; - char *value; + zstr value; int value_len; + zend_uchar value_type; if (getThis()) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "t", &value, &value_len, &value_type) == FAILURE) { return; } - } - else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &z_collection, oci_coll_class_entry_ptr, &value, &value_len) == FAILURE) { + } else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ot", &z_collection, oci_coll_class_entry_ptr, &value, &value_len, &value_type) == FAILURE) { return; } } @@ -2000,15 +2053,15 @@ PHP_FUNCTION(oci_collection_element_assign) php_oci_collection *collection; int value_len; long element_index; - char *value; + zstr value; + zend_uchar value_type; if (getThis()) { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &element_index, &value, &value_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lt", &element_index, &value, &value_len, &value_type) == FAILURE) { return; } - } - else { - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ols", &z_collection, oci_coll_class_entry_ptr, &element_index, &value, &value_len) == FAILURE) { + } else { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Olt", &z_collection, oci_coll_class_entry_ptr, &element_index, &value, &value_len, &value_type) == FAILURE) { return; } } @@ -2123,10 +2176,11 @@ PHP_FUNCTION(oci_new_collection) zval *z_connection; php_oci_connection *connection; php_oci_collection *collection; - char *tdo, *schema = NULL; + zstr tdo, schema = NULL_ZSTR; int tdo_len, schema_len = 0; + zend_uchar tdo_type, schema_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s", &z_connection, &tdo, &tdo_len, &schema, &schema_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rT|T", &z_connection, &tdo, &tdo_len, &tdo_type, &schema, &schema_len, &schema_type) == FAILURE) { return; } @@ -2135,8 +2189,7 @@ PHP_FUNCTION(oci_new_collection) if ( (collection = php_oci_collection_create(connection, tdo, tdo_len, schema, schema_len TSRMLS_CC)) ) { object_init_ex(return_value, oci_coll_class_entry_ptr); add_property_resource(return_value, "collection", collection->id); - } - else { + } else { RETURN_FALSE; } } diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index 39aae293f2..64bb35bf07 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -156,14 +156,20 @@ sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece) { ub4 lenp = (ub4) len; php_oci_lob_ctx *ctx = (php_oci_lob_ctx *)ctxp; + TSRMLS_FETCH(); switch (piece) { case OCI_LAST_PIECE: - *(ctx->lob_data) = erealloc(*(ctx->lob_data), (size_t) (*(ctx->lob_len) + lenp + 1)); + *(ctx->lob_data) = erealloc(*(ctx->lob_data), (size_t) (*(ctx->lob_len) + lenp + TEXT_BYTES(1))); memcpy(*(ctx->lob_data) + *(ctx->lob_len), bufxp, (size_t) lenp); *(ctx->lob_len) += lenp; - *(*(ctx->lob_data) + *(ctx->lob_len)) = 0x00; + + if (UG(unicode)) { + *(*(ctx->lob_data) + *(ctx->lob_len) + 1) = 0; + } + *(*(ctx->lob_data) + *(ctx->lob_len)) = 0; + return OCI_CONTINUE; case OCI_FIRST_PIECE: @@ -173,14 +179,12 @@ sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece) *(ctx->lob_len) += lenp; return OCI_CONTINUE; - default: { - TSRMLS_FETCH(); + default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unexpected LOB piece id received (value:%d)", piece); efree(*(ctx->lob_data)); *(ctx->lob_data) = NULL; *(ctx->lob_len) = 0; return OCI_ERROR; - } } } /* }}} */ @@ -211,27 +215,27 @@ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, l /* {{{ php_oci_lob_read() Read specified portion of the LOB into the buffer */ -int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long initial_offset, char **data, ub4 *data_len TSRMLS_DC) +int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long initial_offset, zstr *data, ub4 *data_len TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; ub4 length = 0; int buffer_size = PHP_OCI_LOB_BUFFER_SIZE; php_oci_lob_ctx ctx; ub1 *bufp; + php_oci_lob_type lob_type; #if defined(HAVE_OCI_LOB_READ2) oraub8 bytes_read, offset = 0; oraub8 requested_len = read_length; /* this is by default */ oraub8 chars_read = 0; - int is_clob = 0; #else int bytes_read, offset = 0; int requested_len = read_length; /* this is by default */ #endif *data_len = 0; - *data = NULL; + *data = NULL_ZSTR; ctx.lob_len = data_len; - ctx.lob_data = data; + ctx.lob_data = &(data->s); if (php_oci_lob_get_length(descriptor, &length TSRMLS_CC)) { return 1; @@ -257,7 +261,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini if (requested_len <= 0) { return 0; } - + offset = initial_offset; if (descriptor->type == OCI_DTYPE_FILE) { @@ -269,24 +273,13 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini return 1; } } -#ifdef HAVE_OCI_LOB_READ2 - else { - ub2 charset_id = 0; - - PHP_OCI_CALL_RETURN(connection->errcode, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id)); - - if (connection->errcode != OCI_SUCCESS) { - php_oci_error(connection->err, connection->errcode TSRMLS_CC); - PHP_OCI_HANDLE_ERROR(connection, connection->errcode); - return 1; - } - if (charset_id > 0) { /* charset_id is always > 0 for [N]CLOBs */ - is_clob = 1; - } + if (php_oci_lob_get_type(descriptor, &lob_type TSRMLS_CC) > 0) { + return 1; } - if (is_clob) { +#ifdef HAVE_OCI_LOB_READ2 + if (lob_type == OCI_IS_CLOB) { chars_read = requested_len; bytes_read = 0; } else { @@ -318,7 +311,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini efree(bufp); - if (is_clob) { + if (lob_type == OCI_IS_CLOB) { offset = descriptor->lob_current_position + chars_read; } else { offset = descriptor->lob_current_position + bytes_read; @@ -348,22 +341,26 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini ); efree(bufp); - offset = descriptor->lob_current_position + bytes_read; + if (!is_clob) { + offset = descriptor->lob_current_position + TEXT_BYTES(bytes_read); + } else { + offset = descriptor->lob_current_position + bytes_read; + } #endif if (connection->errcode != OCI_SUCCESS) { php_oci_error(connection->err, connection->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); - if (*data) { - efree(*data); - *data = NULL; + if (data->s) { + efree(data->s); + *data = NULL_ZSTR; } *data_len = 0; return 1; } - descriptor->lob_current_position = (int)offset; + descriptor->lob_current_position = (offset <= descriptor->lob_size) ? offset : descriptor->lob_size; if (descriptor->type == OCI_DTYPE_FILE) { PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); @@ -371,9 +368,9 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini if (connection->errcode != OCI_SUCCESS) { php_oci_error(connection->err, connection->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); - if (*data) { - efree(*data); - *data = NULL; + if (data->s) { + efree(data->s); + *data = NULL_ZSTR; } *data_len = 0; return 1; @@ -385,18 +382,28 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini /* {{{ php_oci_lob_write() Write data to the LOB */ -int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, int data_len, ub4 *bytes_written TSRMLS_DC) +int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, zstr data, int data_len, ub4 *bytes_written TSRMLS_DC) { OCILobLocator *lob = (OCILobLocator *) descriptor->descriptor; php_oci_connection *connection = (php_oci_connection *) descriptor->connection; ub4 lob_length; + ub4 data_len_out = data_len; + php_oci_lob_type lob_type; *bytes_written = 0; if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) { return 1; } - - if (!data || data_len <= 0) { + + if (php_oci_lob_get_type(descriptor, &lob_type TSRMLS_CC)) { + return 1; + } + + if (lob_type == OCI_IS_CLOB) { + data_len_out = TEXT_CHARS(data_len); + } + + if (!data.v || data_len <= 0) { return 0; } @@ -407,15 +414,15 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i if (offset > descriptor->lob_current_position) { offset = descriptor->lob_current_position; } - + PHP_OCI_CALL_RETURN(connection->errcode, OCILobWrite, ( connection->svc, connection->err, lob, - (ub4 *)&data_len, + (ub4 *)&data_len_out, (ub4) offset + 1, - (dvoid *) data, + (dvoid *) (text *)data.s, (ub4) data_len, OCI_ONE_PIECE, (dvoid *)0, @@ -431,8 +438,8 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i *bytes_written = 0; return 1; } - *bytes_written = data_len; - descriptor->lob_current_position += data_len; + *bytes_written = data_len_out; + descriptor->lob_current_position += data_len_out; if (descriptor->lob_current_position > descriptor->lob_size) { descriptor->lob_size = descriptor->lob_current_position; @@ -779,7 +786,7 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, long length, if (length == -1) { length = lob_length; } - + PHP_OCI_CALL_RETURN(connection->errcode, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, offset+1)); if (connection->errcode != OCI_SUCCESS) { @@ -812,7 +819,7 @@ int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descript /* {{{ php_oci_lob_write_tmp() Create temporary LOB and write data to it */ -int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, ub1 type, char *data, int data_len TSRMLS_DC) +int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, ub1 type, zstr data, int data_len TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; OCILobLocator *lob = descriptor->descriptor; @@ -829,7 +836,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, ub1 type, char *data, break; } - if (!data || data_len <= 0) { + if (!data.v || data_len <= 0) { /* nothing to write, silently fail */ return 1; } @@ -864,4 +871,44 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, ub1 type, char *data, return php_oci_lob_write(descriptor, 0, data, data_len, &bytes_written TSRMLS_CC); } /* }}} */ +int php_oci_lob_get_type(php_oci_descriptor *descriptor, php_oci_lob_type *lob_type TSRMLS_DC) /* {{{ */ +{ + php_oci_connection *connection = descriptor->connection; + + *lob_type = 0; + + if (descriptor->lob_type) { + *lob_type = descriptor->lob_type; + return 0; + } + + if (descriptor->type == OCI_DTYPE_FILE) { + *lob_type = OCI_IS_BLOB; + descriptor->lob_type = OCI_IS_BLOB; + return 0; + } else { + ub2 charset_id = 0; + + PHP_OCI_CALL_RETURN(connection->errcode, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id)); + + if (connection->errcode != OCI_SUCCESS) { + php_oci_error(connection->err, connection->errcode TSRMLS_CC); + PHP_OCI_HANDLE_ERROR(connection, connection->errcode); + return 1; + } + + if (charset_id > 0) { /* charset_id is always > 0 for [N]CLOBs */ + *lob_type = OCI_IS_CLOB; + descriptor->lob_type = OCI_IS_CLOB; + return 0; + } + } + + *lob_type = OCI_IS_BLOB; + descriptor->lob_type = OCI_IS_BLOB; + + return 0; +} +/* }}} */ + #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 8c117ea304..c7c1ff4b21 100644 --- a/ext/oci8/oci8_statement.c +++ b/ext/oci8/oci8_statement.c @@ -43,7 +43,7 @@ /* {{{ php_oci_statement_create() Create statemend handle and allocate necessary resources */ -php_oci_statement *php_oci_statement_create (php_oci_connection *connection, char *query, int query_len TSRMLS_DC) +php_oci_statement *php_oci_statement_create (php_oci_connection *connection, zstr query, int query_len, zend_uchar type TSRMLS_DC) { php_oci_statement *statement; @@ -67,8 +67,8 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha connection->svc, &(statement->stmt), connection->err, - (text *)query, - query_len, + (text *)query.s, + USTR_BYTES(type, query_len), NULL, 0, OCI_NTV_SYNTAX, @@ -95,8 +95,10 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha } } - if (query && query_len) { - statement->last_query = estrndup(query, query_len); + if (query.s && query_len) { + statement->last_query = emalloc(USTR_BYTES(type, query_len + 1)); + memcpy(statement->last_query, query.s, USTR_BYTES(type, query_len)); + statement->last_query[USTR_BYTES(type, query_len)] = '\0'; statement->last_query_len = query_len; } else { @@ -161,8 +163,8 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) ub4 typep, iterp, idxp; ub1 in_outp, piecep; zend_bool piecewisecols = 0; - php_oci_out_column *column; + zstr zstr_data; PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); @@ -190,7 +192,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) /* reset length for all piecewise columns */ for (i = 0; i < statement->ncolumns; i++) { - column = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); + column = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); if (column->piecewise) { column->retlen4 = 0; piecewisecols = 1; @@ -215,12 +217,14 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) /* 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) { + column = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); + if (column->piecewise && handlepp == column->oci_define) { if (!column->data) { - column->data = (text *) ecalloc(1, PHP_OCI_PIECE_SIZE + 1); + zstr_data.v = ecalloc(1, PHP_OCI_PIECE_SIZE + 1); + column->data = zstr_data.v; } else { - column->data = erealloc(column->data, column->retlen4 + PHP_OCI_PIECE_SIZE + 1); + zstr_data.v = erealloc(column->data, column->retlen4 + PHP_OCI_PIECE_SIZE + 1); + column->data = zstr_data.v; } column->cb_retlen = PHP_OCI_PIECE_SIZE; @@ -230,7 +234,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) (void *) column->oci_define, OCI_HTYPE_DEFINE, statement->err, - ((char*)column->data) + column->retlen4, + ((void*)zstr_data.s) + column->retlen4, &(column->cb_retlen), piecep, &column->indicator, @@ -245,7 +249,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) if (piecewisecols) { for (i = 0; i < statement->ncolumns; i++) { - column = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); + column = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); if (column && column->piecewise && handlepp == column->oci_define) { column->retlen4 += column->cb_retlen; } @@ -258,7 +262,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) /* do the stuff needed for OCIDefineByName */ for (i = 0; i < statement->ncolumns; i++) { - column = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); + column = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); if (column == NULL) { continue; } @@ -285,7 +289,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) /* {{{ php_oci_statement_get_column() Get column from the result set */ -php_oci_out_column *php_oci_statement_get_column(php_oci_statement *statement, long column_index, char *column_name, int column_name_len TSRMLS_DC) +php_oci_out_column *php_oci_statement_get_column(php_oci_statement *statement, long column_index, zstr column_name, int column_name_len TSRMLS_DC) { php_oci_out_column *column = NULL; int i; @@ -294,13 +298,17 @@ php_oci_out_column *php_oci_statement_get_column(php_oci_statement *statement, l return NULL; } - if (column_name) { + if (column_name.v != NULL) { for (i = 0; i < statement->ncolumns; i++) { - column = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC); + column = php_oci_statement_get_column(statement, i + 1, NULL_ZSTR, 0 TSRMLS_CC); if (column == NULL) { continue; - } else if (((int) column->name_len == column_name_len) && (!strncmp(column->name, column_name, column_name_len))) { - return column; + } else if ((int) column->name_len == column_name_len) { + if (!UG(unicode) && !strncmp(column->name.s, column_name.s, column_name_len)) { + return column; + } else if (UG(unicode) && !u_strncmp(column->name.u, column_name.u, column_name_len)) { + return column; + } } } } else if (column_index != -1) { @@ -469,7 +477,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } outcol->storage_size4 = outcol->data_size; - outcol->retlen = outcol->data_size; + outcol->retlen = TEXT_CHARS(outcol->data_size); /* get scale of the column */ PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->scale, (dvoid *)0, OCI_ATTR_SCALE, statement->err)); @@ -502,17 +510,22 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); - outcol->name = estrndup((char*) colname, outcol->name_len); + if (UG(unicode)) { + outcol->name_len = TEXT_CHARS(outcol->name_len); + outcol->name.u = eustrndup((UChar*) colname, outcol->name_len); + } else { + outcol->name.s = estrndup((char*) colname, outcol->name_len); + } /* find a user-setted define */ if (statement->defines) { - zend_hash_find(statement->defines,outcol->name,outcol->name_len,(void **) &outcol->define); + zend_hash_find(statement->defines, outcol->name.s, TEXT_BYTES(outcol->name_len+1), (void **) &outcol->define); } buf = 0; switch (outcol->data_type) { case SQLT_RSET: - outcol->statement = php_oci_statement_create(statement->connection, NULL, 0 TSRMLS_CC); + outcol->statement = php_oci_statement_create(statement->connection, NULL_ZSTR, 0, 0 TSRMLS_CC); outcol->stmtid = outcol->statement->id; outcol->statement->nested = 1; @@ -544,7 +557,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) descr = php_oci_lob_create(statement->connection, dtype TSRMLS_CC); if (!descr) { - efree(outcol->name); + efree(outcol->name.v); return 1; } outcol->descid = descr->id; @@ -732,6 +745,14 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) } else if (Z_TYPE_P(bind->zval) == IS_STRING && Z_STRLEN_P(bind->zval) > 0) { Z_STRVAL_P(bind->zval) = erealloc(Z_STRVAL_P(bind->zval), Z_STRLEN_P(bind->zval)+1); Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] = '\0'; + } else if (Z_TYPE_P(bind->zval) == IS_UNICODE && Z_UNILEN_P(bind->zval) > 0) { + if (bind->out) { + /* OCI returns _bytes_ as data length for OUT binds */ + Z_UNILEN_P(bind->zval) = TEXT_CHARS(Z_UNILEN_P(bind->zval)); + } + Z_UNIVAL_P(bind->zval).u = eurealloc(Z_UNIVAL_P(bind->zval).u, Z_UNILEN_P(bind->zval)+1); + Z_UNIVAL_P(bind->zval).s[ TEXT_BYTES(Z_UNILEN_P(bind->zval)) - 1 ] = '\0'; + Z_UNIVAL_P(bind->zval).s[ TEXT_BYTES(Z_UNILEN_P(bind->zval)) ] = '\0'; } else if (Z_TYPE_P(bind->zval) == IS_ARRAY) { int i; zval **entry; @@ -779,16 +800,20 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) php_oci_error(connection->err, connection->errcode TSRMLS_CC); ZVAL_NULL(*entry); } else { - ZVAL_STRINGL(*entry, buff, buff_len, 1); + zstr tmp; + tmp.s = buff; + ZVAL_TEXTL(*entry, tmp, buff_len, 1); } zend_hash_move_forward(hash); } else { + zstr tmp; PHP_OCI_CALL_RETURN(connection->errcode, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); + tmp.s = buff; if (connection->errcode != OCI_SUCCESS) { php_oci_error(connection->err, connection->errcode TSRMLS_CC); add_next_index_null(bind->zval); } else { - add_next_index_stringl(bind->zval, buff, buff_len, 1); + add_next_index_textl(bind->zval, tmp, buff_len, 1); } } } @@ -800,15 +825,20 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) case SQLT_AVC: case SQLT_STR: case SQLT_LVC: - for (i = 0; i < bind->array.current_length; i++) { - /* int curr_element_length = strlen(((text *)bind->array.elements)+i*bind->array.max_length); */ - int curr_element_length = bind->array.element_lengths[i]; - if ((i < bind->array.old_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) { - zval_dtor(*entry); - ZVAL_STRINGL(*entry, ((text *)bind->array.elements)+i*bind->array.max_length, curr_element_length, 1); - zend_hash_move_forward(hash); - } else { - add_next_index_stringl(bind->zval, ((text *)bind->array.elements)+i*bind->array.max_length, curr_element_length, 1); + { + zstr tmp; + for (i = 0; i < bind->array.current_length; i++) { + /* int curr_element_length = strlen(((text *)bind->array.elements)+i*bind->array.max_length); */ + int curr_element_length = bind->array.element_lengths[i]; + if ((i < bind->array.old_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) { + zval_dtor(*entry); + tmp.s = ((text *)bind->array.elements)+i*bind->array.max_length; + ZVAL_TEXTL(*entry, tmp, curr_element_length, 1); + zend_hash_move_forward(hash); + } else { + tmp.s = ((text *)bind->array.elements)+i*bind->array.max_length; + add_next_index_textl(bind->zval, tmp, curr_element_length, 1); + } } } break; @@ -821,7 +851,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) /* {{{ php_oci_bind_by_name() Bind zval to the given placeholder */ -int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval* var, long maxlength, long type TSRMLS_DC) +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) { php_oci_collection *bind_collection = NULL; php_oci_descriptor *bind_descriptor = NULL; @@ -894,10 +924,20 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, case SQLT_CHR: /* this is the default case when type was not specified */ if (Z_TYPE_P(var) != IS_NULL) { - convert_to_string(var); + convert_to_text(var); } if (maxlength == -1) { - value_sz = (Z_TYPE_P(var) == IS_STRING) ? Z_STRLEN_P(var) : 0; + switch (Z_TYPE_P(var)) { + case IS_STRING: + value_sz = Z_STRLEN_P(var); + break; + case IS_UNICODE: + value_sz = Z_UNILEN_P(var); + break; + default: + value_sz = 0; + break; + } } else { value_sz = maxlength; } @@ -930,13 +970,13 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, } memset((void*)&bind,0,sizeof(php_oci_bind)); - if (zend_hash_find(statement->binds, name, name_len + 1, (void **)&old_bind) == SUCCESS) { + if (zend_hash_find(statement->binds, name.s, USTR_BYTES(uni_type, name_len + 1), (void **)&old_bind) == SUCCESS) { bindp = old_bind; if (bindp->zval) { zval_ptr_dtor(&bindp->zval); } } else { - zend_hash_update(statement->binds, name, name_len + 1, &bind, sizeof(php_oci_bind), (void **)&bindp); + zend_hash_update(statement->binds, name.s, USTR_BYTES(uni_type, name_len + 1), &bind, sizeof(php_oci_bind), (void **)&bindp); } bindp->descriptor = oci_desc; @@ -951,10 +991,10 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, statement->stmt, /* statement handle */ (OCIBind **)&bindp->bind, /* bind hdl (will alloc) */ statement->err, /* error handle */ - (text*) name, /* placeholder name */ - name_len, /* placeholder length */ + (text*) name.s, /* placeholder name */ + USTR_BYTES(uni_type, name_len), /* placeholder length */ (dvoid *)bind_data, /* in/out data */ - value_sz, /* PHP_OCI_MAX_DATA_SIZE, */ /* max size of input/output data */ + TEXT_BYTES(value_sz), /* PHP_OCI_MAX_DATA_SIZE, */ /* max size of input/output data */ (ub2)type, /* in/out data type */ (dvoid *)&bindp->indicator, /* indicator (ignored) */ (ub2 *)0, /* size array (ignored) */ @@ -1045,10 +1085,15 @@ sb4 php_oci_bind_in_callback( *indpp = (dvoid *)&phpbind->indicator; } else if ((phpbind->descriptor == 0) && (phpbind->statement == 0)) { /* "normal string bind */ - convert_to_string(val); + convert_to_text(val); - *bufpp = Z_STRVAL_P(val); - *alenp = Z_STRLEN_P(val); + if (UG(unicode)) { + *bufpp = Z_UNIVAL_P(val).v; + *alenp = UBYTES(Z_UNILEN_P(val)); + } else { + *bufpp = Z_STRVAL_P(val); + *alenp = Z_STRLEN_P(val); + } *indpp = (dvoid *)&phpbind->indicator; } else if (phpbind->statement != 0) { /* RSET */ @@ -1089,25 +1134,41 @@ sb4 php_oci_bind_out_callback( php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid phpbind pointer value"); return retval; } + + phpbind->out = 1; /* mark as OUT bind */ if ((Z_TYPE_P(val) == IS_OBJECT) || (Z_TYPE_P(val) == IS_RESOURCE)) { retval = OCI_CONTINUE; - } else { - convert_to_string(val); - zval_dtor(val); - - Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */ - 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); - *bufpp = Z_STRVAL_P(phpbind->zval); - *piecep = OCI_ONE_PIECE; - *rcodepp = &phpbind->retcode; - *indpp = &phpbind->indicator; - retval = OCI_CONTINUE; + } else { + if (UG(unicode)) { + convert_to_unicode(val); + zval_dtor(val); + + Z_UNILEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */ + Z_UNIVAL_P(val).v = ecalloc(1, UBYTES(Z_UNILEN_P(phpbind->zval) + 1)); + + *alenpp = (ub4*) &Z_UNILEN_P(phpbind->zval); + *bufpp = Z_UNIVAL_P(phpbind->zval).v; + *piecep = OCI_ONE_PIECE; + *rcodepp = &phpbind->retcode; + *indpp = &phpbind->indicator; + retval = OCI_CONTINUE; + } else { + convert_to_string(val); + zval_dtor(val); + + Z_STRLEN_P(val) = PHP_OCI_PIECE_SIZE; /* 64K-1 is max XXX */ + 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); + *bufpp = Z_STRVAL_P(phpbind->zval); + *piecep = OCI_ONE_PIECE; + *rcodepp = &phpbind->retcode; + *indpp = &phpbind->indicator; + retval = OCI_CONTINUE; + } } - return retval; } /* }}} */ @@ -1134,15 +1195,15 @@ php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAME return NULL; } - if (Z_TYPE_PP(column_index) == IS_STRING) { - column = php_oci_statement_get_column(statement, -1, Z_STRVAL_PP(column_index), Z_STRLEN_PP(column_index) TSRMLS_CC); + if (Z_TYPE_PP(column_index) == IS_STRING || Z_TYPE_PP(column_index) == IS_UNICODE) { + column = php_oci_statement_get_column(statement, -1, Z_UNIVAL_PP(column_index), Z_UNILEN_PP(column_index) TSRMLS_CC); if (!column) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column name \"%s\"", Z_STRVAL_PP(column_index)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column name \"%v\"", Z_UNIVAL_PP(column_index)); return NULL; } } else { convert_to_long_ex(column_index); - column = php_oci_statement_get_column(statement, Z_LVAL_PP(column_index), NULL, 0 TSRMLS_CC); + column = php_oci_statement_get_column(statement, Z_LVAL_PP(column_index), NULL_ZSTR, 0 TSRMLS_CC); if (!column) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid column index \"%ld\"", Z_LVAL_PP(column_index)); return NULL; @@ -1195,7 +1256,7 @@ int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows TSR /* {{{ php_oci_bind_array_by_name() Bind arrays to PL/SQL types */ -int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int name_len, zval* var, long max_table_length, long maxlength, long type TSRMLS_DC) +int php_oci_bind_array_by_name(php_oci_statement *statement, zstr name, int name_len, zval* var, long max_table_length, long maxlength, long type, zend_uchar uni_type TSRMLS_DC) { php_oci_bind *bind, *bindp; @@ -1248,7 +1309,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam zend_hash_init(statement->binds, 13, NULL, php_oci_bind_hash_dtor, 0); } - zend_hash_update(statement->binds, name, name_len + 1, bind, sizeof(php_oci_bind), (void **)&bindp); + zend_hash_update(statement->binds, name.s, USTR_BYTES(uni_type, name_len + 1), bind, sizeof(php_oci_bind), (void **)&bindp); bindp->descriptor = NULL; bindp->statement = NULL; @@ -1264,10 +1325,10 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam statement->stmt, (OCIBind **)&bindp->bind, statement->err, - (text *)name, - name_len, + (text *)name.s, + USTR_BYTES(uni_type, name_len), (dvoid *) bindp->array.elements, - (sb4) bind->array.max_length, + (sb4) USTR_BYTES(uni_type, bind->array.max_length), type, (dvoid *)0, /* bindp->array.indicators, */ (ub2 *)bind->array.element_lengths, @@ -1303,9 +1364,9 @@ php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, if (maxlength == -1) { zend_hash_internal_pointer_reset(hash); while (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE) { - convert_to_string_ex(entry); - if (Z_STRLEN_PP(entry) > maxlength) { - maxlength = Z_STRLEN_PP(entry) + 1; + convert_to_text_ex(entry); + if (Z_UNILEN_PP(entry) > maxlength) { + maxlength = Z_UNILEN_PP(entry) + 1; } zend_hash_move_forward(hash); } @@ -1322,8 +1383,8 @@ php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, for (i = 0; i < bind->array.current_length; i++) { if (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE) { - convert_to_string_ex(entry); - bind->array.element_lengths[i] = Z_STRLEN_PP(entry); + convert_to_text_ex(entry); + bind->array.element_lengths[i] = Z_UNILEN_PP(entry); zend_hash_move_forward(hash); } else { break; @@ -1335,10 +1396,10 @@ php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, if ((i < bind->array.current_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) { int element_length; - convert_to_string_ex(entry); - element_length = (maxlength > Z_STRLEN_PP(entry)) ? Z_STRLEN_PP(entry) : maxlength; + convert_to_text_ex(entry); + element_length = (maxlength > Z_UNILEN_PP(entry)) ? Z_UNILEN_PP(entry) : maxlength; - memcpy((text *)bind->array.elements + i*maxlength, Z_STRVAL_PP(entry), element_length); + memcpy((text *)bind->array.elements + i*maxlength, Z_UNIVAL_PP(entry).s, element_length); ((text *)bind->array.elements)[i*maxlength + element_length] = '\0'; zend_hash_move_forward(hash); diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h index 22d7f8c37a..7181574e36 100644 --- a/ext/oci8/php_oci8_int.h +++ b/ext/oci8/php_oci8_int.h @@ -97,6 +97,11 @@ extern zend_class_entry *oci_coll_class_entry_ptr; /* }}} */ +typedef enum { + OCI_IS_CLOB=1, + OCI_IS_BLOB +} php_oci_lob_type; + typedef struct { /* php_oci_connection {{{ */ OCIEnv *env; /* private env handle */ ub2 charset; /* charset ID */ @@ -116,19 +121,21 @@ typedef struct { /* php_oci_connection {{{ */ time_t idle_expiry; /* time when the connection will be considered as expired */ time_t next_ping; /* time of the next ping */ char *hash_key; /* hashed details of the connection */ + int hash_key_len; } php_oci_connection; /* }}} */ typedef struct { /* php_oci_descriptor {{{ */ int id; php_oci_connection *connection; /* parent connection handle */ dvoid *descriptor; /* OCI descriptor handle */ - ub4 type; /* descriptor type */ + ub4 type; /* descriptor type (FILE/LOB) */ int lob_current_position; /* LOB internal pointer */ int lob_size; /* cached LOB size. -1 = Lob wasn't initialized yet */ int buffering; /* cached buffering flag. 0 - off, 1 - on, 2 - on and buffer was used */ ub4 chunk_size; /* chunk size of the LOB. 0 - unknown */ ub1 charset_form; /* charset form, required for NCLOBs */ ub2 charset_id; /* charset ID */ + php_oci_lob_type lob_type; /* CLOB/BLOB */ } php_oci_descriptor; /* }}} */ typedef struct { /* php_oci_lob_ctx {{{ */ @@ -149,7 +156,8 @@ typedef struct { /* php_oci_collection {{{ */ typedef struct { /* php_oci_define {{{ */ zval *zval; /* zval used in define */ - text *name; /* placeholder's name */ + zstr name; /* placeholder's name */ + zend_uchar name_type; /* unicode or not */ ub4 name_len; /* placeholder's name length */ ub4 type; /* define type */ } php_oci_define; /* }}} */ @@ -190,12 +198,13 @@ typedef struct { /* php_oci_bind {{{ */ } array; sb2 indicator; /* -1 means NULL */ ub2 retcode; /* */ + zend_bool out; /* OUT bind or not */ } php_oci_bind; /* }}} */ typedef struct { /* php_oci_out_column {{{ */ php_oci_statement *statement; /* statement handle. used when fetching REFCURSORS */ OCIDefine *oci_define; /* define handle */ - char *name; /* column name */ + zstr name; /* column name */ ub4 name_len; /* column name length */ ub2 data_type; /* column data type */ ub2 data_size; /* data size */ @@ -302,17 +311,17 @@ int php_oci_descriptor_delete_from_hash(void *data, void *id TSRMLS_DC); sb4 php_oci_error (OCIError *, sword TSRMLS_DC); sb4 php_oci_fetch_errmsg(OCIError *, text ** TSRMLS_DC); #ifdef HAVE_OCI8_ATTR_STATEMENT -int php_oci_fetch_sqltext_offset(php_oci_statement *, text **, ub2 * TSRMLS_DC); +int php_oci_fetch_sqltext_offset(php_oci_statement *, zstr *, ub2 * TSRMLS_DC); #endif void php_oci_do_connect (INTERNAL_FUNCTION_PARAMETERS, int , int); -php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, char *dbname, int dbname_len, char *charset, long session_mode, int persistent, int exclusive TSRMLS_DC); +php_oci_connection *php_oci_do_connect_ex(zstr username, int username_len, zstr password, int password_len, zstr new_password, int new_password_len, zstr dbname, int dbname_len, zstr charset, long session_mode, int persistent, int exclusive, zend_uchar type TSRMLS_DC); int php_oci_connection_rollback(php_oci_connection * TSRMLS_DC); int php_oci_connection_commit(php_oci_connection * TSRMLS_DC); -int php_oci_password_change(php_oci_connection *, char *, int, char *, int, char *, int TSRMLS_DC); -int php_oci_server_get_version(php_oci_connection *, char ** TSRMLS_DC); +int php_oci_password_change(php_oci_connection *, zstr, int, zstr, int, zstr, int, zend_uchar TSRMLS_DC); +int php_oci_server_get_version(php_oci_connection *, zstr* TSRMLS_DC); void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int, int); int php_oci_column_to_zval(php_oci_out_column *, zval *, int TSRMLS_DC); @@ -323,15 +332,16 @@ int php_oci_column_to_zval(php_oci_out_column *, zval *, int TSRMLS_DC); php_oci_descriptor * php_oci_lob_create (php_oci_connection *, long TSRMLS_DC); int php_oci_lob_get_length (php_oci_descriptor *, ub4 * TSRMLS_DC); -int php_oci_lob_read (php_oci_descriptor *, long, long, char **, ub4 * TSRMLS_DC); -int php_oci_lob_write (php_oci_descriptor *, ub4, char *, int, ub4 * TSRMLS_DC); +int php_oci_lob_get_type(php_oci_descriptor *descriptor, php_oci_lob_type *lob_type TSRMLS_DC); +int php_oci_lob_read (php_oci_descriptor *, long, long, zstr *, ub4 * TSRMLS_DC); +int php_oci_lob_write (php_oci_descriptor *, ub4, zstr, int, ub4 * TSRMLS_DC); int php_oci_lob_flush (php_oci_descriptor *, int TSRMLS_DC); int php_oci_lob_set_buffering (php_oci_descriptor *, int TSRMLS_DC); int php_oci_lob_get_buffering (php_oci_descriptor *); int php_oci_lob_copy (php_oci_descriptor *, php_oci_descriptor *, long TSRMLS_DC); #ifdef HAVE_OCI8_TEMP_LOB int php_oci_lob_close (php_oci_descriptor * TSRMLS_DC); -int php_oci_lob_write_tmp (php_oci_descriptor *, ub1, char *, int TSRMLS_DC); +int php_oci_lob_write_tmp (php_oci_descriptor *, ub1, zstr, int TSRMLS_DC); #endif void php_oci_lob_free(php_oci_descriptor * TSRMLS_DC); int php_oci_lob_import(php_oci_descriptor *descriptor, char * TSRMLS_DC); @@ -344,51 +354,50 @@ sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece #else sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece); #endif - /* }}} */ /* collection related prototypes {{{ */ -php_oci_collection * php_oci_collection_create(php_oci_connection *, char *, int, char *, int TSRMLS_DC); +php_oci_collection * php_oci_collection_create(php_oci_connection *, zstr, int, zstr, int TSRMLS_DC); int php_oci_collection_size(php_oci_collection *, sb4 * TSRMLS_DC); int php_oci_collection_max(php_oci_collection *, long * TSRMLS_DC); int php_oci_collection_trim(php_oci_collection *, long TSRMLS_DC); -int php_oci_collection_append(php_oci_collection *, char *, int TSRMLS_DC); +int php_oci_collection_append(php_oci_collection *, zstr, int TSRMLS_DC); int php_oci_collection_element_get(php_oci_collection *, long, zval** TSRMLS_DC); -int php_oci_collection_element_set(php_oci_collection *, long, char*, int TSRMLS_DC); +int php_oci_collection_element_set(php_oci_collection *, long, zstr, int TSRMLS_DC); int php_oci_collection_element_set_null(php_oci_collection *, long TSRMLS_DC); -int php_oci_collection_element_set_date(php_oci_collection *, long, char *, int TSRMLS_DC); -int php_oci_collection_element_set_number(php_oci_collection *, long, char *, int TSRMLS_DC); -int php_oci_collection_element_set_string(php_oci_collection *, long, char *, int TSRMLS_DC); +int php_oci_collection_element_set_date(php_oci_collection *, long, zstr, int TSRMLS_DC); +int php_oci_collection_element_set_number(php_oci_collection *, long, zstr, int TSRMLS_DC); +int php_oci_collection_element_set_string(php_oci_collection *, long, zstr, int TSRMLS_DC); int php_oci_collection_assign(php_oci_collection *, php_oci_collection * TSRMLS_DC); void php_oci_collection_close(php_oci_collection * TSRMLS_DC); int php_oci_collection_append_null(php_oci_collection * TSRMLS_DC); -int php_oci_collection_append_date(php_oci_collection *, char *, int TSRMLS_DC); -int php_oci_collection_append_number(php_oci_collection *, char *, int TSRMLS_DC); -int php_oci_collection_append_string(php_oci_collection *, char *, int TSRMLS_DC); +int php_oci_collection_append_date(php_oci_collection *, zstr, int TSRMLS_DC); +int php_oci_collection_append_number(php_oci_collection *, zstr, int TSRMLS_DC); +int php_oci_collection_append_string(php_oci_collection *, zstr, int TSRMLS_DC); /* }}} */ /* statement related prototypes {{{ */ -php_oci_statement * php_oci_statement_create (php_oci_connection *, char *, int TSRMLS_DC); +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_fetch (php_oci_statement *, ub4 TSRMLS_DC); -php_oci_out_column * php_oci_statement_get_column (php_oci_statement *, long, char*, int 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); int php_oci_statement_cancel (php_oci_statement * TSRMLS_DC); 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 *, char *, int, zval*, long, long TSRMLS_DC); +int php_oci_bind_by_name(php_oci_statement *, zstr, int, zval*, long, long, 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); int php_oci_statement_get_type(php_oci_statement *, ub2 * TSRMLS_DC); int php_oci_statement_get_numrows(php_oci_statement *, ub4 * TSRMLS_DC); -int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int name_len, zval* var, long max_table_length, long maxlength, long type TSRMLS_DC); +int php_oci_bind_array_by_name(php_oci_statement *statement, zstr name, int name_len, zval* var, long max_table_length, long maxlength, long type, zend_uchar uni_type TSRMLS_DC); php_oci_bind *php_oci_bind_array_helper_number(zval* var, long max_table_length TSRMLS_DC); php_oci_bind *php_oci_bind_array_helper_double(zval* var, long max_table_length TSRMLS_DC); php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, long maxlength TSRMLS_DC); diff --git a/ext/oci8/tests/array_bind_005.phpt b/ext/oci8/tests/array_bind_005.phpt index 15278532ea..4dfb7ffcf0 100644 --- a/ext/oci8/tests/array_bind_005.phpt +++ b/ext/oci8/tests/array_bind_005.phpt @@ -73,3 +73,18 @@ array(5) { string(0) "" } Done +--UEXPECTF-- +Warning: oci_execute(): ORA-01405: fetched column value is NULL in %s on line %d +array(5) { + [0]=> + unicode(0) "" + [1]=> + unicode(0) "" + [2]=> + unicode(0) "" + [3]=> + unicode(0) "" + [4]=> + unicode(0) "" +} +Done diff --git a/ext/oci8/tests/array_bind_008.phpt b/ext/oci8/tests/array_bind_008.phpt index c44304c11c..e73e04d705 100644 --- a/ext/oci8/tests/array_bind_008.phpt +++ b/ext/oci8/tests/array_bind_008.phpt @@ -76,3 +76,21 @@ array(5) { string(1) "5" } Done +--UEXPECTF-- +Warning: oci_execute(): ORA-06550: line 1, column 28: +PLS-00418: array bind type must match PL/SQL table row type +ORA-06550: line 1, column 7: +PL/SQL: Statement ignored in %s on line %d +array(5) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "2" + [2]=> + unicode(1) "3" + [3]=> + unicode(1) "4" + [4]=> + unicode(1) "5" +} +Done diff --git a/ext/oci8/tests/array_bind_010.phpt b/ext/oci8/tests/array_bind_010.phpt index a77ed913ea..e0af6add4e 100644 --- a/ext/oci8/tests/array_bind_010.phpt +++ b/ext/oci8/tests/array_bind_010.phpt @@ -1,5 +1,5 @@ --TEST-- -oci_bind_array_by_name() and invalid values 8 +oci_bind_array_by_name() and invalid values 10 --SKIPIF-- --FILE-- @@ -34,3 +34,18 @@ array(5) { string(1) "5" } Done +--UEXPECTF-- +Warning: oci_bind_array_by_name(): ORA-01036: illegal variable name/number in %s on line %d +array(5) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "2" + [2]=> + unicode(1) "3" + [3]=> + unicode(1) "4" + [4]=> + unicode(1) "5" +} +Done diff --git a/ext/oci8/tests/bind_long.phpt b/ext/oci8/tests/bind_long.phpt index c9e9c58d68..199c62ebc9 100644 --- a/ext/oci8/tests/bind_long.phpt +++ b/ext/oci8/tests/bind_long.phpt @@ -23,7 +23,7 @@ $stmt = oci_parse($c, "SELECT filetxt FROM phptestlng"); oci_execute($stmt); $row = oci_fetch_row($stmt); -var_dump(md5($row[0])); +var_dump(md5((binary)$row[0])); var_dump(strlen($row[0])); $stmt = oci_parse($c, "drop table phptestlng"); diff --git a/ext/oci8/tests/bind_long_raw.phpt b/ext/oci8/tests/bind_long_raw.phpt index e4a8d6e297..2e0e0426c1 100644 --- a/ext/oci8/tests/bind_long_raw.phpt +++ b/ext/oci8/tests/bind_long_raw.phpt @@ -23,7 +23,7 @@ $stmt = oci_parse($c, "SELECT fileimage FROM phptestlngraw"); oci_execute($stmt); $row = oci_fetch_row($stmt); -var_dump(md5($row[0])); +var_dump(md5((binary)$row[0])); var_dump(strlen($row[0])); $stmt = oci_parse($c, "drop table phptestlngraw"); diff --git a/ext/oci8/tests/bind_raw.phpt b/ext/oci8/tests/bind_raw.phpt index 7391a22528..163b529860 100644 --- a/ext/oci8/tests/bind_raw.phpt +++ b/ext/oci8/tests/bind_raw.phpt @@ -24,7 +24,7 @@ $stmt = oci_parse($c, "SELECT fileimage FROM phptestrawtable"); oci_execute($stmt); $row = oci_fetch_row($stmt); -var_dump(md5($row[0])); +var_dump(md5((binary)$row[0])); var_dump(strlen($row[0])); $stmt = oci_parse($c, "drop table phptestrawtable"); diff --git a/ext/oci8/tests/bug27303.phpt b/ext/oci8/tests/bug27303.phpt index 191cdffe67..ff1ac53a28 100644 --- a/ext/oci8/tests/bug27303.phpt +++ b/ext/oci8/tests/bug27303.phpt @@ -250,3 +250,204 @@ string(3) "197" string(3) "198" string(3) "199" Done +--UEXPECTF-- +unicode(1) "1" +unicode(1) "2" +unicode(1) "3" +unicode(1) "4" +unicode(1) "5" +unicode(1) "6" +unicode(1) "7" +unicode(1) "8" +unicode(1) "9" +unicode(2) "10" +unicode(2) "11" +unicode(2) "12" +unicode(2) "13" +unicode(2) "14" +unicode(2) "15" +unicode(2) "16" +unicode(2) "17" +unicode(2) "18" +unicode(2) "19" +unicode(2) "20" +unicode(2) "21" +unicode(2) "22" +unicode(2) "23" +unicode(2) "24" +unicode(2) "25" +unicode(2) "26" +unicode(2) "27" +unicode(2) "28" +unicode(2) "29" +unicode(2) "30" +unicode(2) "31" +unicode(2) "32" +unicode(2) "33" +unicode(2) "34" +unicode(2) "35" +unicode(2) "36" +unicode(2) "37" +unicode(2) "38" +unicode(2) "39" +unicode(2) "40" +unicode(2) "41" +unicode(2) "42" +unicode(2) "43" +unicode(2) "44" +unicode(2) "45" +unicode(2) "46" +unicode(2) "47" +unicode(2) "48" +unicode(2) "49" +unicode(2) "50" +unicode(2) "51" +unicode(2) "52" +unicode(2) "53" +unicode(2) "54" +unicode(2) "55" +unicode(2) "56" +unicode(2) "57" +unicode(2) "58" +unicode(2) "59" +unicode(2) "60" +unicode(2) "61" +unicode(2) "62" +unicode(2) "63" +unicode(2) "64" +unicode(2) "65" +unicode(2) "66" +unicode(2) "67" +unicode(2) "68" +unicode(2) "69" +unicode(2) "70" +unicode(2) "71" +unicode(2) "72" +unicode(2) "73" +unicode(2) "74" +unicode(2) "75" +unicode(2) "76" +unicode(2) "77" +unicode(2) "78" +unicode(2) "79" +unicode(2) "80" +unicode(2) "81" +unicode(2) "82" +unicode(2) "83" +unicode(2) "84" +unicode(2) "85" +unicode(2) "86" +unicode(2) "87" +unicode(2) "88" +unicode(2) "89" +unicode(2) "90" +unicode(2) "91" +unicode(2) "92" +unicode(2) "93" +unicode(2) "94" +unicode(2) "95" +unicode(2) "96" +unicode(2) "97" +unicode(2) "98" +unicode(2) "99" +unicode(3) "100" +unicode(3) "101" +unicode(3) "102" +unicode(3) "103" +unicode(3) "104" +unicode(3) "105" +unicode(3) "106" +unicode(3) "107" +unicode(3) "108" +unicode(3) "109" +unicode(3) "110" +unicode(3) "111" +unicode(3) "112" +unicode(3) "113" +unicode(3) "114" +unicode(3) "115" +unicode(3) "116" +unicode(3) "117" +unicode(3) "118" +unicode(3) "119" +unicode(3) "120" +unicode(3) "121" +unicode(3) "122" +unicode(3) "123" +unicode(3) "124" +unicode(3) "125" +unicode(3) "126" +unicode(3) "127" +unicode(3) "128" +unicode(3) "129" +unicode(3) "130" +unicode(3) "131" +unicode(3) "132" +unicode(3) "133" +unicode(3) "134" +unicode(3) "135" +unicode(3) "136" +unicode(3) "137" +unicode(3) "138" +unicode(3) "139" +unicode(3) "140" +unicode(3) "141" +unicode(3) "142" +unicode(3) "143" +unicode(3) "144" +unicode(3) "145" +unicode(3) "146" +unicode(3) "147" +unicode(3) "148" +unicode(3) "149" +unicode(3) "150" +unicode(3) "151" +unicode(3) "152" +unicode(3) "153" +unicode(3) "154" +unicode(3) "155" +unicode(3) "156" +unicode(3) "157" +unicode(3) "158" +unicode(3) "159" +unicode(3) "160" +unicode(3) "161" +unicode(3) "162" +unicode(3) "163" +unicode(3) "164" +unicode(3) "165" +unicode(3) "166" +unicode(3) "167" +unicode(3) "168" +unicode(3) "169" +unicode(3) "170" +unicode(3) "171" +unicode(3) "172" +unicode(3) "173" +unicode(3) "174" +unicode(3) "175" +unicode(3) "176" +unicode(3) "177" +unicode(3) "178" +unicode(3) "179" +unicode(3) "180" +unicode(3) "181" +unicode(3) "182" +unicode(3) "183" +unicode(3) "184" +unicode(3) "185" +unicode(3) "186" +unicode(3) "187" +unicode(3) "188" +unicode(3) "189" +unicode(3) "190" +unicode(3) "191" +unicode(3) "192" +unicode(3) "193" +unicode(3) "194" +unicode(3) "195" +unicode(3) "196" +unicode(3) "197" +unicode(3) "198" +unicode(3) "199" +Done diff --git a/ext/oci8/tests/bug27303_2.phpt b/ext/oci8/tests/bug27303_2.phpt index 67f3552f13..b0f72e9ad3 100644 --- a/ext/oci8/tests/bug27303_2.phpt +++ b/ext/oci8/tests/bug27303_2.phpt @@ -250,3 +250,204 @@ string(3) "197" string(3) "198" string(3) "199" Done +--UEXPECTF-- +unicode(1) "1" +unicode(1) "2" +unicode(1) "3" +unicode(1) "4" +unicode(1) "5" +unicode(1) "6" +unicode(1) "7" +unicode(1) "8" +unicode(1) "9" +unicode(2) "10" +unicode(2) "11" +unicode(2) "12" +unicode(2) "13" +unicode(2) "14" +unicode(2) "15" +unicode(2) "16" +unicode(2) "17" +unicode(2) "18" +unicode(2) "19" +unicode(2) "20" +unicode(2) "21" +unicode(2) "22" +unicode(2) "23" +unicode(2) "24" +unicode(2) "25" +unicode(2) "26" +unicode(2) "27" +unicode(2) "28" +unicode(2) "29" +unicode(2) "30" +unicode(2) "31" +unicode(2) "32" +unicode(2) "33" +unicode(2) "34" +unicode(2) "35" +unicode(2) "36" +unicode(2) "37" +unicode(2) "38" +unicode(2) "39" +unicode(2) "40" +unicode(2) "41" +unicode(2) "42" +unicode(2) "43" +unicode(2) "44" +unicode(2) "45" +unicode(2) "46" +unicode(2) "47" +unicode(2) "48" +unicode(2) "49" +unicode(2) "50" +unicode(2) "51" +unicode(2) "52" +unicode(2) "53" +unicode(2) "54" +unicode(2) "55" +unicode(2) "56" +unicode(2) "57" +unicode(2) "58" +unicode(2) "59" +unicode(2) "60" +unicode(2) "61" +unicode(2) "62" +unicode(2) "63" +unicode(2) "64" +unicode(2) "65" +unicode(2) "66" +unicode(2) "67" +unicode(2) "68" +unicode(2) "69" +unicode(2) "70" +unicode(2) "71" +unicode(2) "72" +unicode(2) "73" +unicode(2) "74" +unicode(2) "75" +unicode(2) "76" +unicode(2) "77" +unicode(2) "78" +unicode(2) "79" +unicode(2) "80" +unicode(2) "81" +unicode(2) "82" +unicode(2) "83" +unicode(2) "84" +unicode(2) "85" +unicode(2) "86" +unicode(2) "87" +unicode(2) "88" +unicode(2) "89" +unicode(2) "90" +unicode(2) "91" +unicode(2) "92" +unicode(2) "93" +unicode(2) "94" +unicode(2) "95" +unicode(2) "96" +unicode(2) "97" +unicode(2) "98" +unicode(2) "99" +unicode(3) "100" +unicode(3) "101" +unicode(3) "102" +unicode(3) "103" +unicode(3) "104" +unicode(3) "105" +unicode(3) "106" +unicode(3) "107" +unicode(3) "108" +unicode(3) "109" +unicode(3) "110" +unicode(3) "111" +unicode(3) "112" +unicode(3) "113" +unicode(3) "114" +unicode(3) "115" +unicode(3) "116" +unicode(3) "117" +unicode(3) "118" +unicode(3) "119" +unicode(3) "120" +unicode(3) "121" +unicode(3) "122" +unicode(3) "123" +unicode(3) "124" +unicode(3) "125" +unicode(3) "126" +unicode(3) "127" +unicode(3) "128" +unicode(3) "129" +unicode(3) "130" +unicode(3) "131" +unicode(3) "132" +unicode(3) "133" +unicode(3) "134" +unicode(3) "135" +unicode(3) "136" +unicode(3) "137" +unicode(3) "138" +unicode(3) "139" +unicode(3) "140" +unicode(3) "141" +unicode(3) "142" +unicode(3) "143" +unicode(3) "144" +unicode(3) "145" +unicode(3) "146" +unicode(3) "147" +unicode(3) "148" +unicode(3) "149" +unicode(3) "150" +unicode(3) "151" +unicode(3) "152" +unicode(3) "153" +unicode(3) "154" +unicode(3) "155" +unicode(3) "156" +unicode(3) "157" +unicode(3) "158" +unicode(3) "159" +unicode(3) "160" +unicode(3) "161" +unicode(3) "162" +unicode(3) "163" +unicode(3) "164" +unicode(3) "165" +unicode(3) "166" +unicode(3) "167" +unicode(3) "168" +unicode(3) "169" +unicode(3) "170" +unicode(3) "171" +unicode(3) "172" +unicode(3) "173" +unicode(3) "174" +unicode(3) "175" +unicode(3) "176" +unicode(3) "177" +unicode(3) "178" +unicode(3) "179" +unicode(3) "180" +unicode(3) "181" +unicode(3) "182" +unicode(3) "183" +unicode(3) "184" +unicode(3) "185" +unicode(3) "186" +unicode(3) "187" +unicode(3) "188" +unicode(3) "189" +unicode(3) "190" +unicode(3) "191" +unicode(3) "192" +unicode(3) "193" +unicode(3) "194" +unicode(3) "195" +unicode(3) "196" +unicode(3) "197" +unicode(3) "198" +unicode(3) "199" +Done diff --git a/ext/oci8/tests/bug27303_4.phpt b/ext/oci8/tests/bug27303_4.phpt index 8ba4ef44b4..311dea7cca 100644 --- a/ext/oci8/tests/bug27303_4.phpt +++ b/ext/oci8/tests/bug27303_4.phpt @@ -250,3 +250,204 @@ string(3) "197" string(3) "198" string(3) "199" Done +--UEXPECTF-- +unicode(1) "1" +unicode(1) "2" +unicode(1) "3" +unicode(1) "4" +unicode(1) "5" +unicode(1) "6" +unicode(1) "7" +unicode(1) "8" +unicode(1) "9" +unicode(2) "10" +unicode(2) "11" +unicode(2) "12" +unicode(2) "13" +unicode(2) "14" +unicode(2) "15" +unicode(2) "16" +unicode(2) "17" +unicode(2) "18" +unicode(2) "19" +unicode(2) "20" +unicode(2) "21" +unicode(2) "22" +unicode(2) "23" +unicode(2) "24" +unicode(2) "25" +unicode(2) "26" +unicode(2) "27" +unicode(2) "28" +unicode(2) "29" +unicode(2) "30" +unicode(2) "31" +unicode(2) "32" +unicode(2) "33" +unicode(2) "34" +unicode(2) "35" +unicode(2) "36" +unicode(2) "37" +unicode(2) "38" +unicode(2) "39" +unicode(2) "40" +unicode(2) "41" +unicode(2) "42" +unicode(2) "43" +unicode(2) "44" +unicode(2) "45" +unicode(2) "46" +unicode(2) "47" +unicode(2) "48" +unicode(2) "49" +unicode(2) "50" +unicode(2) "51" +unicode(2) "52" +unicode(2) "53" +unicode(2) "54" +unicode(2) "55" +unicode(2) "56" +unicode(2) "57" +unicode(2) "58" +unicode(2) "59" +unicode(2) "60" +unicode(2) "61" +unicode(2) "62" +unicode(2) "63" +unicode(2) "64" +unicode(2) "65" +unicode(2) "66" +unicode(2) "67" +unicode(2) "68" +unicode(2) "69" +unicode(2) "70" +unicode(2) "71" +unicode(2) "72" +unicode(2) "73" +unicode(2) "74" +unicode(2) "75" +unicode(2) "76" +unicode(2) "77" +unicode(2) "78" +unicode(2) "79" +unicode(2) "80" +unicode(2) "81" +unicode(2) "82" +unicode(2) "83" +unicode(2) "84" +unicode(2) "85" +unicode(2) "86" +unicode(2) "87" +unicode(2) "88" +unicode(2) "89" +unicode(2) "90" +unicode(2) "91" +unicode(2) "92" +unicode(2) "93" +unicode(2) "94" +unicode(2) "95" +unicode(2) "96" +unicode(2) "97" +unicode(2) "98" +unicode(2) "99" +unicode(3) "100" +unicode(3) "101" +unicode(3) "102" +unicode(3) "103" +unicode(3) "104" +unicode(3) "105" +unicode(3) "106" +unicode(3) "107" +unicode(3) "108" +unicode(3) "109" +unicode(3) "110" +unicode(3) "111" +unicode(3) "112" +unicode(3) "113" +unicode(3) "114" +unicode(3) "115" +unicode(3) "116" +unicode(3) "117" +unicode(3) "118" +unicode(3) "119" +unicode(3) "120" +unicode(3) "121" +unicode(3) "122" +unicode(3) "123" +unicode(3) "124" +unicode(3) "125" +unicode(3) "126" +unicode(3) "127" +unicode(3) "128" +unicode(3) "129" +unicode(3) "130" +unicode(3) "131" +unicode(3) "132" +unicode(3) "133" +unicode(3) "134" +unicode(3) "135" +unicode(3) "136" +unicode(3) "137" +unicode(3) "138" +unicode(3) "139" +unicode(3) "140" +unicode(3) "141" +unicode(3) "142" +unicode(3) "143" +unicode(3) "144" +unicode(3) "145" +unicode(3) "146" +unicode(3) "147" +unicode(3) "148" +unicode(3) "149" +unicode(3) "150" +unicode(3) "151" +unicode(3) "152" +unicode(3) "153" +unicode(3) "154" +unicode(3) "155" +unicode(3) "156" +unicode(3) "157" +unicode(3) "158" +unicode(3) "159" +unicode(3) "160" +unicode(3) "161" +unicode(3) "162" +unicode(3) "163" +unicode(3) "164" +unicode(3) "165" +unicode(3) "166" +unicode(3) "167" +unicode(3) "168" +unicode(3) "169" +unicode(3) "170" +unicode(3) "171" +unicode(3) "172" +unicode(3) "173" +unicode(3) "174" +unicode(3) "175" +unicode(3) "176" +unicode(3) "177" +unicode(3) "178" +unicode(3) "179" +unicode(3) "180" +unicode(3) "181" +unicode(3) "182" +unicode(3) "183" +unicode(3) "184" +unicode(3) "185" +unicode(3) "186" +unicode(3) "187" +unicode(3) "188" +unicode(3) "189" +unicode(3) "190" +unicode(3) "191" +unicode(3) "192" +unicode(3) "193" +unicode(3) "194" +unicode(3) "195" +unicode(3) "196" +unicode(3) "197" +unicode(3) "198" +unicode(3) "199" +Done diff --git a/ext/oci8/tests/bug35973.phpt b/ext/oci8/tests/bug35973.phpt index b62f5cfd0f..af91e6fd31 100644 --- a/ext/oci8/tests/bug35973.phpt +++ b/ext/oci8/tests/bug35973.phpt @@ -41,3 +41,14 @@ array(1) { string(%d) "%s5" string(%d) "%sa" Done +--UEXPECTF-- +array(1) { + [u"NC"]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +unicode(%d) "%s5" +unicode(%d) "%sa" +Done diff --git a/ext/oci8/tests/bug36096.phpt b/ext/oci8/tests/bug36096.phpt index 44b3a6ddca..487640ec4b 100644 --- a/ext/oci8/tests/bug36096.phpt +++ b/ext/oci8/tests/bug36096.phpt @@ -26,3 +26,9 @@ bool(false) string(5) "'ABC'" string(4) "CHAR" Done +--UEXPECT-- +bool(false) +bool(false) +unicode(5) "'ABC'" +unicode(4) "CHAR" +Done diff --git a/ext/oci8/tests/coll_011.phpt b/ext/oci8/tests/coll_011.phpt index 7d805d3f70..37019e13e4 100644 --- a/ext/oci8/tests/coll_011.phpt +++ b/ext/oci8/tests/coll_011.phpt @@ -41,3 +41,9 @@ bool(true) bool(true) string(6) "string" Done +--UEXPECT-- +bool(true) +bool(true) +bool(true) +unicode(6) "string" +Done diff --git a/ext/oci8/tests/coll_011_func.phpt b/ext/oci8/tests/coll_011_func.phpt index dca640e846..e53f4adb23 100644 --- a/ext/oci8/tests/coll_011_func.phpt +++ b/ext/oci8/tests/coll_011_func.phpt @@ -41,3 +41,9 @@ bool(true) bool(true) string(6) "string" Done +--UEXPECT-- +bool(true) +bool(true) +bool(true) +unicode(6) "string" +Done diff --git a/ext/oci8/tests/coll_012.phpt b/ext/oci8/tests/coll_012.phpt index 543dafd902..8d59078429 100644 --- a/ext/oci8/tests/coll_012.phpt +++ b/ext/oci8/tests/coll_012.phpt @@ -39,3 +39,8 @@ bool(true) bool(true) string(9) "28-JUL-05" Done +--UEXPECT-- +bool(true) +bool(true) +unicode(9) "28-JUL-05" +Done diff --git a/ext/oci8/tests/coll_012_func.phpt b/ext/oci8/tests/coll_012_func.phpt index fd1019e411..5359453606 100644 --- a/ext/oci8/tests/coll_012_func.phpt +++ b/ext/oci8/tests/coll_012_func.phpt @@ -39,3 +39,8 @@ bool(true) bool(true) string(9) "28-JUL-05" Done +--UEXPECT-- +bool(true) +bool(true) +unicode(9) "28-JUL-05" +Done diff --git a/ext/oci8/tests/coll_013.phpt b/ext/oci8/tests/coll_013.phpt index 00d88bb9a4..d19837bfee 100644 --- a/ext/oci8/tests/coll_013.phpt +++ b/ext/oci8/tests/coll_013.phpt @@ -36,3 +36,8 @@ bool(true) bool(true) string(9) "01-JAN-05" Done +--UEXPECT-- +bool(true) +bool(true) +unicode(9) "01-JAN-05" +Done diff --git a/ext/oci8/tests/coll_013_func.phpt b/ext/oci8/tests/coll_013_func.phpt index 0d01bc1744..83052a3d5c 100644 --- a/ext/oci8/tests/coll_013_func.phpt +++ b/ext/oci8/tests/coll_013_func.phpt @@ -36,3 +36,8 @@ bool(true) bool(true) string(9) "01-JAN-05" Done +--UEXPECT-- +bool(true) +bool(true) +unicode(9) "01-JAN-05" +Done diff --git a/ext/oci8/tests/coll_014.phpt b/ext/oci8/tests/coll_014.phpt index 8458525ae5..cadab3a384 100644 --- a/ext/oci8/tests/coll_014.phpt +++ b/ext/oci8/tests/coll_014.phpt @@ -36,3 +36,8 @@ bool(true) bool(true) string(4) "blah" Done +--UEXPECT-- +bool(true) +bool(true) +unicode(4) "blah" +Done diff --git a/ext/oci8/tests/coll_014_func.phpt b/ext/oci8/tests/coll_014_func.phpt index a0fe555b61..aaa7d28420 100644 --- a/ext/oci8/tests/coll_014_func.phpt +++ b/ext/oci8/tests/coll_014_func.phpt @@ -36,3 +36,8 @@ bool(true) bool(true) string(4) "blah" Done +--UEXPECT-- +bool(true) +bool(true) +unicode(4) "blah" +Done diff --git a/ext/oci8/tests/commit.phpt b/ext/oci8/tests/commit.phpt index 9e409f34c6..1594118e4f 100644 --- a/ext/oci8/tests/commit.phpt +++ b/ext/oci8/tests/commit.phpt @@ -172,24 +172,24 @@ array(5) { [u"ID"]=> array(4) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> - string(1) "1" + unicode(1) "1" [3]=> - string(1) "1" + unicode(1) "1" } [u"VALUE"]=> array(4) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> - string(1) "1" + unicode(1) "1" [3]=> - string(1) "1" + unicode(1) "1" } [u"BLOB"]=> array(4) { diff --git a/ext/oci8/tests/commit_old.phpt b/ext/oci8/tests/commit_old.phpt index a8a1c40e13..4cfc65a075 100644 --- a/ext/oci8/tests/commit_old.phpt +++ b/ext/oci8/tests/commit_old.phpt @@ -170,24 +170,24 @@ array(5) { [u"ID"]=> array(4) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> - string(1) "1" + unicode(1) "1" [3]=> - string(1) "1" + unicode(1) "1" } [u"VALUE"]=> array(4) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> - string(1) "1" + unicode(1) "1" [3]=> - string(1) "1" + unicode(1) "1" } [u"BLOB"]=> array(4) { diff --git a/ext/oci8/tests/cursor_bind.phpt b/ext/oci8/tests/cursor_bind.phpt index c2ce15cb38..3210034d2f 100644 --- a/ext/oci8/tests/cursor_bind.phpt +++ b/ext/oci8/tests/cursor_bind.phpt @@ -97,3 +97,24 @@ array(2) { } bool(false) Done +--UEXPECT-- +array(2) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" +} +array(2) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" +} +array(2) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" +} +bool(false) +Done diff --git a/ext/oci8/tests/cursors.phpt b/ext/oci8/tests/cursors.phpt index 865c15ecc0..f8c7059e18 100644 --- a/ext/oci8/tests/cursors.phpt +++ b/ext/oci8/tests/cursors.phpt @@ -66,9 +66,9 @@ Done --UEXPECTF-- array(5) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [u"BLOB"]=> NULL [u"CLOB"]=> diff --git a/ext/oci8/tests/cursors_old.phpt b/ext/oci8/tests/cursors_old.phpt index 13b39f1fb4..8be6f63059 100644 --- a/ext/oci8/tests/cursors_old.phpt +++ b/ext/oci8/tests/cursors_old.phpt @@ -65,18 +65,18 @@ Done --UEXPECTF-- array(2) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } bool(true) Warning: ocifetchinto(): ORA-01002: fetch out of sequence in %s on line %d array(2) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } bool(true) Done diff --git a/ext/oci8/tests/define.phpt b/ext/oci8/tests/define.phpt index c76f360f28..db775758f2 100644 --- a/ext/oci8/tests/define.phpt +++ b/ext/oci8/tests/define.phpt @@ -39,3 +39,6 @@ echo "Done\n"; --EXPECT-- string(4) "some" Done +--UEXPECT-- +unicode(4) "some" +Done diff --git a/ext/oci8/tests/define1.phpt b/ext/oci8/tests/define1.phpt index f6e04cc185..089c8c2914 100644 --- a/ext/oci8/tests/define1.phpt +++ b/ext/oci8/tests/define1.phpt @@ -50,3 +50,14 @@ Warning: oci_define_by_name() expects at least 3 parameters, 2 given in %s on li NULL string(4) "some" Done +--UEXPECTF-- +bool(true) +bool(false) + +Warning: oci_define_by_name(): Column name cannot be empty in %s on line %d +bool(false) + +Warning: oci_define_by_name() expects at least 3 parameters, 2 given in %s on line %d +NULL +unicode(4) "some" +Done diff --git a/ext/oci8/tests/define_old.phpt b/ext/oci8/tests/define_old.phpt index da52e619ce..fc3e2b0da9 100644 --- a/ext/oci8/tests/define_old.phpt +++ b/ext/oci8/tests/define_old.phpt @@ -39,3 +39,6 @@ echo "Done\n"; --EXPECT-- string(4) "some" Done +--UEXPECT-- +unicode(4) "some" +Done diff --git a/ext/oci8/tests/error.phpt b/ext/oci8/tests/error.phpt index c38432c90a..974a5f22e4 100644 --- a/ext/oci8/tests/error.phpt +++ b/ext/oci8/tests/error.phpt @@ -45,13 +45,13 @@ resource(%d) of type (oci8 statement) Warning: oci_execute(): ORA-00900: invalid SQL statement in %s on line %d bool(false) array(4) { - [u"code"]=> + ["code"]=> int(900) - [u"message"]=> - string(32) "ORA-00900: invalid SQL statement" - [u"offset"]=> + ["message"]=> + unicode(32) "ORA-00900: invalid SQL statement" + ["offset"]=> int(0) - [u"sqltext"]=> - string(12) "WRONG SYNTAX" + ["sqltext"]=> + unicode(12) "WRONG SYNTAX" } Done diff --git a/ext/oci8/tests/error1.phpt b/ext/oci8/tests/error1.phpt index db7670769e..25a3f09e92 100644 --- a/ext/oci8/tests/error1.phpt +++ b/ext/oci8/tests/error1.phpt @@ -25,17 +25,3 @@ array(4) { string(0) "" } Done ---UEXPECTF-- -Warning: oci_connect(): ORA-12154: TNS:could not resolve service name in %s on line %d -bool(false) -array(4) { - [u"code"]=> - int(12154) - [u"message"]=> - string(45) "ORA-12154: TNS:could not resolve service name" - [u"offset"]=> - int(0) - [u"sqltext"]=> - string(0) "" -} -Done diff --git a/ext/oci8/tests/error_old.phpt b/ext/oci8/tests/error_old.phpt index 2b2c279214..7c27a8b135 100644 --- a/ext/oci8/tests/error_old.phpt +++ b/ext/oci8/tests/error_old.phpt @@ -45,13 +45,13 @@ resource(%d) of type (oci8 statement) Warning: ociexecute(): ORA-00900: invalid SQL statement in %s on line %d bool(false) array(4) { - [u"code"]=> + ["code"]=> int(900) - [u"message"]=> - string(32) "ORA-00900: invalid SQL statement" - [u"offset"]=> + ["message"]=> + unicode(32) "ORA-00900: invalid SQL statement" + ["offset"]=> int(0) - [u"sqltext"]=> - string(12) "WRONG SYNTAX" + ["sqltext"]=> + unicode(12) "WRONG SYNTAX" } Done diff --git a/ext/oci8/tests/fetch.phpt b/ext/oci8/tests/fetch.phpt index 33cba657b6..4856e5cc51 100644 --- a/ext/oci8/tests/fetch.phpt +++ b/ext/oci8/tests/fetch.phpt @@ -54,3 +54,11 @@ string(1) "1" string(1) "1" string(1) "1" Done +--UEXPECT-- +unicode(1) "1" +unicode(1) "1" +unicode(1) "1" +unicode(1) "1" +unicode(1) "1" +unicode(1) "1" +Done diff --git a/ext/oci8/tests/fetch_all.phpt b/ext/oci8/tests/fetch_all.phpt index a3722c4788..234eacc5d5 100644 --- a/ext/oci8/tests/fetch_all.phpt +++ b/ext/oci8/tests/fetch_all.phpt @@ -153,20 +153,20 @@ array(5) { [u"ID"]=> array(3) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> - string(1) "1" + unicode(1) "1" } [u"VALUE"]=> array(3) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> - string(1) "1" + unicode(1) "1" } [u"BLOB"]=> array(3) { @@ -201,20 +201,20 @@ array(5) { [u"ID"]=> array(3) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> - string(1) "1" + unicode(1) "1" } [u"VALUE"]=> array(3) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> - string(1) "1" + unicode(1) "1" } [u"BLOB"]=> array(3) { diff --git a/ext/oci8/tests/fetch_array.phpt b/ext/oci8/tests/fetch_array.phpt index 62d5fcbe8f..07b3e461bb 100644 --- a/ext/oci8/tests/fetch_array.phpt +++ b/ext/oci8/tests/fetch_array.phpt @@ -309,13 +309,13 @@ Done --UEXPECT-- array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> @@ -331,13 +331,13 @@ array(10) { } array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> @@ -353,13 +353,13 @@ array(10) { } array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> @@ -375,109 +375,109 @@ array(10) { } array(2) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" } array(2) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" } array(2) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" } array(2) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(2) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(2) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(4) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(4) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(4) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(4) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(4) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(4) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> @@ -493,13 +493,13 @@ array(10) { } array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> @@ -515,13 +515,13 @@ array(10) { } array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> diff --git a/ext/oci8/tests/fetch_assoc.phpt b/ext/oci8/tests/fetch_assoc.phpt index 0c9e574751..62d9a332ec 100644 --- a/ext/oci8/tests/fetch_assoc.phpt +++ b/ext/oci8/tests/fetch_assoc.phpt @@ -83,9 +83,9 @@ Done --UEXPECT-- array(5) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [u"BLOB"]=> NULL [u"CLOB"]=> @@ -95,9 +95,9 @@ array(5) { } array(5) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [u"BLOB"]=> NULL [u"CLOB"]=> @@ -107,9 +107,9 @@ array(5) { } array(5) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [u"BLOB"]=> NULL [u"CLOB"]=> diff --git a/ext/oci8/tests/fetch_into.phpt b/ext/oci8/tests/fetch_into.phpt index 8bd93beaf0..74505423d4 100644 --- a/ext/oci8/tests/fetch_into.phpt +++ b/ext/oci8/tests/fetch_into.phpt @@ -84,20 +84,20 @@ Done int(5) array(2) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" } int(5) array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> diff --git a/ext/oci8/tests/fetch_into1.phpt b/ext/oci8/tests/fetch_into1.phpt index f7a1b6939d..3f8d65c80f 100644 --- a/ext/oci8/tests/fetch_into1.phpt +++ b/ext/oci8/tests/fetch_into1.phpt @@ -194,23 +194,23 @@ Done int(5) array(2) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" } int(5) array(2) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } int(5) array(5) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [3]=> @@ -221,31 +221,31 @@ array(5) { int(5) array(2) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" } int(5) array(4) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" } int(5) array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> @@ -262,13 +262,13 @@ array(10) { int(5) array(10) { [0]=> - string(1) "1" + unicode(1) "1" [u"ID"]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [u"BLOB"]=> @@ -285,9 +285,9 @@ array(10) { int(5) array(5) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [3]=> @@ -298,9 +298,9 @@ array(5) { int(5) array(5) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [u"BLOB"]=> NULL [u"CLOB"]=> @@ -311,9 +311,9 @@ array(5) { int(5) array(5) { [0]=> - string(1) "1" + unicode(1) "1" [1]=> - string(1) "1" + unicode(1) "1" [2]=> NULL [3]=> diff --git a/ext/oci8/tests/fetch_into2.phpt b/ext/oci8/tests/fetch_into2.phpt index c196d39f62..66ed2f88e8 100644 --- a/ext/oci8/tests/fetch_into2.phpt +++ b/ext/oci8/tests/fetch_into2.phpt @@ -68,3 +68,25 @@ array(2) { string(1) "1" } Done +--UEXPECTF-- +Warning: ocifetchinto() expects at least 2 parameters, 1 given in %s on line %d +NULL + +Notice: Undefined variable: all in %s on line %d +NULL + +Warning: ocifetchinto() expects at most 3 parameters, 4 given in %s on line %d +NULL +NULL + +Warning: ocifetchinto(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) +NULL +int(5) +array(2) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" +} +Done diff --git a/ext/oci8/tests/fetch_object.phpt b/ext/oci8/tests/fetch_object.phpt index ce78aa47d5..c4cceb0859 100644 --- a/ext/oci8/tests/fetch_object.phpt +++ b/ext/oci8/tests/fetch_object.phpt @@ -83,9 +83,9 @@ Done --UEXPECTF-- object(stdClass)#%d (5) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [u"BLOB"]=> NULL [u"CLOB"]=> @@ -95,9 +95,9 @@ object(stdClass)#%d (5) { } object(stdClass)#%d (5) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [u"BLOB"]=> NULL [u"CLOB"]=> @@ -107,9 +107,9 @@ object(stdClass)#%d (5) { } object(stdClass)#%d (5) { [u"ID"]=> - string(1) "1" + unicode(1) "1" [u"VALUE"]=> - string(1) "1" + unicode(1) "1" [u"BLOB"]=> NULL [u"CLOB"]=> diff --git a/ext/oci8/tests/fetch_row.phpt b/ext/oci8/tests/fetch_row.phpt index a637ecc6f4..35a669a59a 100644 --- a/ext/oci8/tests/fetch_row.phpt +++ b/ext/oci8/tests/fetch_row.phpt @@ -80,3 +80,41 @@ array(5) { NULL } Done +--UEXPECT-- +array(5) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +array(5) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +array(5) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +Done diff --git a/ext/oci8/tests/field_funcs.phpt b/ext/oci8/tests/field_funcs.phpt index 102f2fdc03..1f5e923af4 100644 --- a/ext/oci8/tests/field_funcs.phpt +++ b/ext/oci8/tests/field_funcs.phpt @@ -103,3 +103,52 @@ int(0) int(0) int(10) Done +--UEXPECTF-- +array(5) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +bool(false) +unicode(2) "ID" +unicode(6) "NUMBER" +int(2) +int(0) +int(0) +int(22) +bool(false) +unicode(5) "VALUE" +unicode(6) "NUMBER" +int(2) +int(0) +int(0) +int(22) +bool(true) +unicode(4) "BLOB" +unicode(4) "BLOB" +int(113) +int(0) +int(0) +int(4000) +bool(true) +unicode(4) "CLOB" +unicode(4) "CLOB" +int(112) +int(0) +int(0) +int(4000) +bool(true) +unicode(6) "STRING" +unicode(8) "VARCHAR2" +int(1) +int(0) +int(0) +int(10) +Done diff --git a/ext/oci8/tests/field_funcs1.phpt b/ext/oci8/tests/field_funcs1.phpt index b41e743e41..c802c09580 100644 --- a/ext/oci8/tests/field_funcs1.phpt +++ b/ext/oci8/tests/field_funcs1.phpt @@ -177,3 +177,104 @@ bool(false) Warning: oci_field_size() expects exactly 2 parameters, 1 given in %s on line %d bool(false) Done +--UEXPECTF-- +array(5) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} + +Warning: oci_field_is_null(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column index "-1" in %s on line %d +bool(false) + +Warning: oci_field_is_null(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column name "none" in %s on line %d +bool(false) + +Warning: oci_field_is_null(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_name(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_type(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_scale(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_precision(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_size(): supplied resource is not a valid oci8 statement resource in %s on line %d +bool(false) + +Warning: oci_field_is_null(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_name(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_type(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_type_raw(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_scale(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_precision(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_size(): Invalid column index "0" in %s on line %d +bool(false) + +Warning: oci_field_size() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/field_funcs_old.phpt b/ext/oci8/tests/field_funcs_old.phpt index e6f21d613d..7af640cc51 100644 --- a/ext/oci8/tests/field_funcs_old.phpt +++ b/ext/oci8/tests/field_funcs_old.phpt @@ -103,3 +103,52 @@ int(0) int(0) int(10) Done +--UEXPECTF-- +array(5) { + [0]=> + unicode(1) "1" + [1]=> + unicode(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL +} +bool(false) +unicode(2) "ID" +unicode(6) "NUMBER" +int(2) +int(0) +int(0) +int(22) +bool(false) +unicode(5) "VALUE" +unicode(6) "NUMBER" +int(2) +int(0) +int(0) +int(22) +bool(true) +unicode(4) "BLOB" +unicode(4) "BLOB" +int(113) +int(0) +int(0) +int(4000) +bool(true) +unicode(4) "CLOB" +unicode(4) "CLOB" +int(112) +int(0) +int(0) +int(4000) +bool(true) +unicode(6) "STRING" +unicode(8) "VARCHAR2" +int(1) +int(0) +int(0) +int(10) +Done diff --git a/ext/oci8/tests/lob_001.phpt b/ext/oci8/tests/lob_001.phpt index 569a85cbcd85fbe30dd8053fb54823f1153dc233..f9defc220d38a6afe25f6e556a7b9bb3011e1817 100644 GIT binary patch delta 52 zcmbQmvxsNIA|~!6rIOU*5+zMdYp%(wnIbupl!{A=GV{`vCLd%HnXJJ4oi(*0v&4F{ II14iq0K$$CbN~PV delta 31 ncmZ3)GmB@#A|_6ylGNf7B~4B1$!nP+H?uPfGj5h=VP*mVo~sCo diff --git a/ext/oci8/tests/lob_002.phpt b/ext/oci8/tests/lob_002.phpt index ab53b2805c..08fd84a623 100644 --- a/ext/oci8/tests/lob_002.phpt +++ b/ext/oci8/tests/lob_002.phpt @@ -22,12 +22,12 @@ oci_execute($statement, OCI_DEFAULT); var_dump($blob); -var_dump($blob->write("test", -1)); -var_dump($blob->write("test", "str")); -var_dump($blob->write("test", 1000000)); -var_dump($blob->write(str_repeat("test", 10000), 1000000)); +var_dump($blob->write(b"test", -1)); +var_dump($blob->write(b"test", "str")); +var_dump($blob->write(b"test", 1000000)); +var_dump($blob->write((binary)str_repeat("test", 10000), 1000000)); var_dump($blob->tell()); -var_dump($blob->seek("str", -5)); +var_dump($blob->seek(b"str", -5)); var_dump($blob->flush()); oci_commit($c); @@ -77,7 +77,7 @@ int(4) int(40000) int(40004) -Warning: OCI-Lob::seek() expects parameter 1 to be long, Unicode string given in %s on line %d +Warning: OCI-Lob::seek() expects parameter 1 to be long, binary string given in %s on line %d NULL bool(false) int(40004) diff --git a/ext/oci8/tests/lob_003.phpt b/ext/oci8/tests/lob_003.phpt index 5704548dc310cecd5f471e251ffe38480535d36f..9c3595418ddb27ca6c96352de205fdf18ae48ac3 100644 GIT binary patch delta 32 ocmcaEa8qEzLMFzf$qSj1IFpo$ONuh{(v>D3U=rCZ&uqa80LL^6-~a#s delta 40 tcmca9a9v=-LMAq)lGNf7rO5}GL?-WH^59S^E-A{)O9u;VR%Etd1pqGC4Uzx= diff --git a/ext/oci8/tests/lob_004.phpt b/ext/oci8/tests/lob_004.phpt index ca6b9e5e4e..c44afe2bb8 100644 --- a/ext/oci8/tests/lob_004.phpt +++ b/ext/oci8/tests/lob_004.phpt @@ -22,9 +22,9 @@ oci_execute($statement, OCI_DEFAULT); var_dump($blob); -var_dump($blob->write("test")); +var_dump($blob->write(b"test")); var_dump($blob->rewind()); -var_dump($blob->write("str")); +var_dump($blob->write(b"str")); var_dump($blob->seek(10, OCI_SEEK_SET)); oci_commit($c); diff --git a/ext/oci8/tests/lob_006.phpt b/ext/oci8/tests/lob_006.phpt index 58e6fb40a9a93e252b6042ea73589f85084356b8..4819aed2f6bd7d3c4779994c5869a15272e6c591 100644 GIT binary patch delta 26 hcmcaEa7$prEGEXJ$+MV_0?ByhM8>4e2bia`004?)38DZ1 delta 20 ccmca5a9v=-ET+k`nT}3QWKP_Cn0Y!20AF(me*gdg diff --git a/ext/oci8/tests/lob_007.phpt b/ext/oci8/tests/lob_007.phpt index 4928e1f7c8..e837826e71 100644 --- a/ext/oci8/tests/lob_007.phpt +++ b/ext/oci8/tests/lob_007.phpt @@ -23,7 +23,7 @@ oci_execute($statement, OCI_DEFAULT); var_dump($blob); var_dump($blob->size()); -var_dump($blob->write(str_repeat("string.", 1000))); +var_dump($blob->write((binary)str_repeat("string.", 1000))); var_dump($blob->size()); oci_commit($c); diff --git a/ext/oci8/tests/lob_008.phpt b/ext/oci8/tests/lob_008.phpt index bc8e87b4b3..0755b4452f 100644 --- a/ext/oci8/tests/lob_008.phpt +++ b/ext/oci8/tests/lob_008.phpt @@ -22,7 +22,7 @@ oci_execute($statement, OCI_DEFAULT); var_dump($blob); -var_dump($blob->write(str_repeat("string.", 1000))); +var_dump($blob->write((binary)str_repeat("string.", 1000))); oci_commit($c); $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; diff --git a/ext/oci8/tests/lob_010.phpt b/ext/oci8/tests/lob_010.phpt index 59f3e145f2..ffa34e5658 100644 --- a/ext/oci8/tests/lob_010.phpt +++ b/ext/oci8/tests/lob_010.phpt @@ -20,8 +20,8 @@ $blob = oci_new_descriptor($c,OCI_D_LOB); oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); oci_execute($statement, OCI_DEFAULT); -var_dump($blob->save("string")); -var_dump($blob->save("string", 3)); +var_dump($blob->save(b"string")); +var_dump($blob->save(b"string", 3)); oci_commit($c); $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; diff --git a/ext/oci8/tests/lob_011.phpt b/ext/oci8/tests/lob_011.phpt index 0b7f520d9d..cdd08de732 100644 --- a/ext/oci8/tests/lob_011.phpt +++ b/ext/oci8/tests/lob_011.phpt @@ -20,7 +20,7 @@ $blob = oci_new_descriptor($c,OCI_D_LOB); oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); oci_execute($statement, OCI_DEFAULT); -var_dump($blob->write("some string here. string, I said")); +var_dump($blob->write(b"some string here. string, I said")); oci_commit($c); $ora_sql = "INSERT INTO diff --git a/ext/oci8/tests/lob_012.phpt b/ext/oci8/tests/lob_012.phpt index 2061969bc4..5c29466e64 100644 --- a/ext/oci8/tests/lob_012.phpt +++ b/ext/oci8/tests/lob_012.phpt @@ -22,7 +22,7 @@ oci_execute($statement, OCI_DEFAULT); $blob; -var_dump($blob->write("test string is here\nnew string")); +var_dump($blob->write(b"test string is here\nnew string")); oci_commit($c); diff --git a/ext/oci8/tests/lob_013.phpt b/ext/oci8/tests/lob_013.phpt index c56de56198..7f780c461e 100644 --- a/ext/oci8/tests/lob_013.phpt +++ b/ext/oci8/tests/lob_013.phpt @@ -20,10 +20,10 @@ $blob = oci_new_descriptor($c,OCI_D_LOB); oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); oci_execute($statement, OCI_DEFAULT); -var_dump($blob->write("test")); +var_dump($blob->write(b"test")); var_dump($blob->getBuffering()); var_dump($blob->setBuffering(true)); -var_dump($blob->write("test")); +var_dump($blob->write(b"test")); var_dump($blob->getBuffering()); var_dump($blob->flush()); diff --git a/ext/oci8/tests/lob_014.phpt b/ext/oci8/tests/lob_014.phpt index 60ed945312..b32ab0b895 100644 --- a/ext/oci8/tests/lob_014.phpt +++ b/ext/oci8/tests/lob_014.phpt @@ -22,11 +22,11 @@ oci_execute($statement, OCI_DEFAULT); $blob; -var_dump($blob->write("test")); +var_dump($blob->write(b"test")); var_dump($blob->close()); -var_dump($blob->write("test")); +var_dump($blob->write(b"test")); var_dump($blob->free()); -var_dump($blob->write("test")); +var_dump($blob->write(b"test")); oci_commit($c); diff --git a/ext/oci8/tests/lob_016.phpt b/ext/oci8/tests/lob_016.phpt index fdb7374ccf..ffaf04f992 100644 --- a/ext/oci8/tests/lob_016.phpt +++ b/ext/oci8/tests/lob_016.phpt @@ -25,8 +25,8 @@ oci_execute($statement, OCI_DEFAULT); $row = oci_fetch_assoc($statement); -$row['LOB_1']->write("first"); -$row['LOB_2']->write("second"); +$row['LOB_1']->write(b"first"); +$row['LOB_2']->write(b"second"); unset($row); diff --git a/ext/oci8/tests/lob_017.phpt b/ext/oci8/tests/lob_017.phpt index 8ab0dc459e..4db7830b15 100644 --- a/ext/oci8/tests/lob_017.phpt +++ b/ext/oci8/tests/lob_017.phpt @@ -27,8 +27,8 @@ oci_execute($statement, OCI_DEFAULT); $row = oci_fetch_assoc($statement); -$row['LOB_1']->write("first"); -$row['LOB_2']->write("second"); +$row['LOB_1']->write(b"first"); +$row['LOB_2']->write(b"second"); unset($row); diff --git a/ext/oci8/tests/lob_018.phpt b/ext/oci8/tests/lob_018.phpt index 35cec4bd7d..d549a51e80 100644 --- a/ext/oci8/tests/lob_018.phpt +++ b/ext/oci8/tests/lob_018.phpt @@ -65,3 +65,9 @@ string(9) "long data" string(9) "long data" string(4) "data" Done +--UEXPECTF-- +unicode(4) "data" +unicode(9) "long data" +unicode(9) "long data" +unicode(4) "data" +Done diff --git a/ext/oci8/tests/lob_019.phpt b/ext/oci8/tests/lob_019.phpt index d972cd792aea62ec1f1d57a17f6edb54eb8f5e96..2f9285bca94fc5e5f91393ea1f92622a4c549f4f 100644 GIT binary patch delta 21 ccmbQwznp&qGc$)qQf6LaQKjZ)X689807tn7QUCw| delta 12 TcmZ3^Kc9aCGxKI{<~b|?8QBAT diff --git a/ext/oci8/tests/lob_020.phpt b/ext/oci8/tests/lob_020.phpt index 9110e759d6342572ecf8936132e6aecf2b8ff969..c590f2ee6994496652e22fdc5cf9baacede28d04 100644 GIT binary patch delta 54 tcmey(|BrveRCcY>yv*eMlvE8PO$8+e1|=>S-xSPeD9L~eP5#Gf4*=l75ZM3# delta 11 Scmeyz|C@iqRQAc&Swrite("test")); +var_dump($blob->write(b"test")); var_dump($blob->close()); -var_dump($blob->write("test")); +var_dump($blob->write(b"test")); var_dump(oci_free_descriptor($blob)); -var_dump($blob->write("test")); +var_dump($blob->write(b"test")); var_dump(oci_free_descriptor($blob)); var_dump(oci_free_descriptor(new stdclass)); diff --git a/ext/oci8/tests/lob_022.phpt b/ext/oci8/tests/lob_022.phpt index 5fb9dfab0e..da0d23b4a1 100644 --- a/ext/oci8/tests/lob_022.phpt +++ b/ext/oci8/tests/lob_022.phpt @@ -78,3 +78,16 @@ string(9) "long data" string(9) "long data" string(4) "data" Done +--UEXPECTF-- +Warning: OCI-Lob::save() expects at least 1 parameter, 0 given in %s on line %d + +Warning: oci_lob_save() expects at least 2 parameters, 0 given in %s on line %d + +Warning: oci_lob_save(): Unable to find descriptor property in %s on line %d + +Warning: OCI-Lob::save(): Offset parameter must be greater than or equal to 0 in %s on line %d +unicode(4) "data" +unicode(9) "long data" +unicode(9) "long data" +unicode(4) "data" +Done diff --git a/ext/oci8/tests/lob_023.phpt b/ext/oci8/tests/lob_023.phpt index 0c352956de..6d33d69880 100644 --- a/ext/oci8/tests/lob_023.phpt +++ b/ext/oci8/tests/lob_023.phpt @@ -82,3 +82,40 @@ file for test lob_009.phpt " Done +--UEXPECTF-- +object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +bool(true) +bool(true) + +Warning: OCI-Lob::import() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_import() expects exactly 2 parameters, 1 given in %s on line %d +NULL +bool(true) + +Warning: oci_lob_import(): Unable to find descriptor property in %s on line %d +bool(false) +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + [u"BLOB"]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(43) "this +is +a +test +file for +test lob_009.phpt +" +Done diff --git a/ext/oci8/tests/lob_024.phpt b/ext/oci8/tests/lob_024.phpt index 9a7f53240d..535196e4c6 100644 --- a/ext/oci8/tests/lob_024.phpt +++ b/ext/oci8/tests/lob_024.phpt @@ -23,7 +23,7 @@ oci_execute($statement, OCI_DEFAULT); var_dump($blob); var_dump($blob->size()); -var_dump($blob->write(str_repeat("string.", 1000))); +var_dump($blob->write((binary)str_repeat("string.", 1000))); var_dump($blob->size()); oci_commit($c); @@ -73,3 +73,32 @@ NULL Warning: oci_lob_load(): Unable to find descriptor property in %s on line %d bool(false) Done +--UEXPECTF-- +object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +int(0) +int(7000) +int(7000) +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + [u"BLOB"]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +int(7000) +int(7000) + +Warning: oci_lob_load() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_load(): Unable to find descriptor property in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/lob_025.phpt b/ext/oci8/tests/lob_025.phpt index 5b5e845a7a..64ecbca4ad 100644 --- a/ext/oci8/tests/lob_025.phpt +++ b/ext/oci8/tests/lob_025.phpt @@ -21,7 +21,7 @@ oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); oci_execute($statement, OCI_DEFAULT); var_dump($blob->size()); -var_dump($blob->write(str_repeat("string.", 1000))); +var_dump($blob->write((binary)str_repeat("string.", 1000))); var_dump($blob->size()); oci_commit($c); @@ -80,3 +80,37 @@ bool(false) Warning: oci_lob_eof(): Unable to find descriptor property in %s on line %d bool(false) Done +--UEXPECTF-- +int(0) +int(7000) +int(7000) +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + [u"BLOB"]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(2) "st" + +Warning: oci_lob_read() expects exactly 2 parameters, 1 given in %s on line %d +NULL + +Warning: oci_lob_read() expects exactly 2 parameters, 0 given in %s on line %d +NULL +bool(false) + +Warning: oci_lob_eof() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: oci_lob_read(): Unable to find descriptor property in %s on line %d +bool(false) + +Warning: oci_lob_eof(): Unable to find descriptor property in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/lob_026.phpt b/ext/oci8/tests/lob_026.phpt index 157d78a2b6..bd52d7739c 100644 --- a/ext/oci8/tests/lob_026.phpt +++ b/ext/oci8/tests/lob_026.phpt @@ -22,10 +22,10 @@ oci_execute($statement, OCI_DEFAULT); var_dump($blob); -var_dump(oci_lob_write($blob, "test")); +var_dump(oci_lob_write($blob, b"test")); var_dump(oci_lob_rewind()); var_dump(oci_lob_rewind($blob)); -var_dump(oci_lob_write($blob, "str")); +var_dump(oci_lob_write($blob, b"str")); var_dump(oci_lob_seek(10, OCI_SEEK_SET)); var_dump(oci_lob_seek($blob, 10, OCI_SEEK_SET)); @@ -98,3 +98,43 @@ NULL string(4) "strt" string(8) "strtstrt" Done +--UEXPECTF-- +object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) +} +int(4) + +Warning: oci_lob_rewind() expects exactly 1 parameter, 0 given in %s on line %d +NULL +bool(true) +int(3) + +Warning: oci_lob_seek() expects parameter 1 to be OCI-Lob, integer given in %s on line %d +NULL +bool(true) +array(2) { + [0]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } + [u"BLOB"]=> + object(OCI-Lob)#%d (1) { + [u"descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} + +Warning: oci_lob_append() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: oci_lob_append() expects exactly 2 parameters, 1 given in %s on line %d +NULL +bool(true) + +Warning: oci_lob_read() expects exactly 2 parameters, 1 given in %s on line %d +NULL +string(4) "strt" +string(8) "strtstrt" +Done diff --git a/ext/oci8/tests/lob_temp.phpt b/ext/oci8/tests/lob_temp.phpt index cad2d39058..ea8e9fe25b 100644 --- a/ext/oci8/tests/lob_temp.phpt +++ b/ext/oci8/tests/lob_temp.phpt @@ -34,3 +34,13 @@ string(4) "test" bool(true) string(2) "te" Done +--UEXPECTF-- +bool(true) +unicode(4) "test" +bool(true) +unicode(2) "te" +bool(true) +unicode(4) "test" +bool(true) +unicode(2) "te" +Done diff --git a/ext/oci8/tests/lob_temp1.phpt b/ext/oci8/tests/lob_temp1.phpt index 2482d65f64..bc843e41c7 100644 --- a/ext/oci8/tests/lob_temp1.phpt +++ b/ext/oci8/tests/lob_temp1.phpt @@ -30,3 +30,11 @@ bool(true) string(4) "test" bool(true) Done +--UEXPECTF-- +bool(true) +unicode(4) "test" +bool(true) +bool(true) +unicode(4) "test" +bool(true) +Done diff --git a/ext/oci8/tests/pecl_bug8816.phpt b/ext/oci8/tests/pecl_bug8816.phpt index c369711fcf..670d84ac5a 100644 --- a/ext/oci8/tests/pecl_bug8816.phpt +++ b/ext/oci8/tests/pecl_bug8816.phpt @@ -96,3 +96,35 @@ array(2) { string(19) "1234567890111111111" } Done +--UEXPECT-- +array(2) { + [u"L1"]=> + unicode(19) "1234567890111111111" + [u"L2"]=> + unicode(9) "987654321" +} +array(2) { + [u"L1"]=> + unicode(15) "122222222222222" + [u"L2"]=> + unicode(9) "123456789" +} +array(2) { + [u"L1"]=> + unicode(30) "985456745674567654567654567654" + [u"L2"]=> + unicode(30) "985456745674567654567654567654" +} +array(2) { + [u"L1"]=> + unicode(9) "123456789" + [u"L2"]=> + unicode(15) "122222222222222" +} +array(2) { + [u"L1"]=> + unicode(9) "987654321" + [u"L2"]=> + unicode(19) "1234567890111111111" +} +Done diff --git a/ext/oci8/tests/serverversion.phpt b/ext/oci8/tests/serverversion.phpt index bf32fe4b54..2cfcd37e32 100644 --- a/ext/oci8/tests/serverversion.phpt +++ b/ext/oci8/tests/serverversion.phpt @@ -28,3 +28,8 @@ resource(%d) of type (oci8 connection) string(%d) "%s" string(%d) "%s" Done +--UEXPECTF-- +resource(%d) of type (oci8 connection) +unicode(%d) "%s" +unicode(%d) "%s" +Done diff --git a/ext/oci8/tests/statement_cache.phpt b/ext/oci8/tests/statement_cache.phpt index 5e577f05d0..60398fe526 100644 --- a/ext/oci8/tests/statement_cache.phpt +++ b/ext/oci8/tests/statement_cache.phpt @@ -36,14 +36,14 @@ Done --UEXPECTF-- array(2) { [0]=> - string(1) "4" + unicode(1) "4" [u"1+3"]=> - string(1) "4" + unicode(1) "4" } array(2) { [0]=> - string(1) "4" + unicode(1) "4" [u"1+3"]=> - string(1) "4" + unicode(1) "4" } Done -- 2.50.1