diff options
author | Christopher Jones <sixd@php.net> | 2013-07-24 15:33:22 -0700 |
---|---|---|
committer | Christopher Jones <sixd@php.net> | 2013-07-24 15:33:22 -0700 |
commit | bfc3c223dac2a5ebd5c2614c9c39b594ab393f4f (patch) | |
tree | 82f8350b79c81240dfcfb8ff854bfad66b23b072 | |
parent | 86064e0701888877ea04ea35bf87bc96e1bf3ed8 (diff) | |
download | php-git-bfc3c223dac2a5ebd5c2614c9c39b594ab393f4f.tar.gz |
Initial PHP OCI8 2.0.0-dev commit.
Includes Oracle Database 12c Implicit Result Set support, DTrace
support, and various code cleanups.
See package.xml for details.
102 files changed, 7752 insertions, 1158 deletions
diff --git a/ext/oci8/README b/ext/oci8/README index 420d5dac58..af5beeb5c0 100644 --- a/ext/oci8/README +++ b/ext/oci8/README @@ -6,8 +6,8 @@ Use the OCI8 extension to access Oracle Database. Documentation is at http://php.net/oci8 The extension can be built with PHP versions 4.3.9 to 5.x using Oracle -9.2, 10, or 11 client libraries. Oracle's standard cross-version -connectivity applies. For example PHP linked with Oracle 11.2 client -libraries can connect to Oracle Database 9.2 onwards. See Oracle's -note "Oracle Client / Server Interoperability Support" (ID 207303.1) -for details. +Database 9.2, 10, 11 or 12 client libraries. Oracle's standard +cross-version connectivity applies. For example PHP linked with +Oracle 11.2 client libraries can connect to Oracle Database 9.2 +onwards. See Oracle's note "Oracle Client / Server Interoperability +Support" (ID 207303.1) for details. diff --git a/ext/oci8/config.m4 b/ext/oci8/config.m4 index 34ae76c44b..eee4b4ec80 100644 --- a/ext/oci8/config.m4 +++ b/ext/oci8/config.m4 @@ -140,12 +140,29 @@ if test "$PHP_OCI8" != "no"; then if test "$oci8_php_version" -lt "4003009"; then AC_MSG_ERROR([You need at least PHP 4.3.9 to be able to use this version of OCI8. PHP $php_version found]) - elif test "$oci8_php_version" -ge "6000000"; then - AC_MSG_ERROR([This version of OCI8 is not compatible with PHP 6 or higher]) else AC_MSG_RESULT([$php_version, ok]) fi + dnl conditionally define PHP_INIT_DTRACE. + dnl This prevents 'configure' failing for PECL installs on older PHP versions. + dnl Note DTrace support can't be enabled on older PHP versions. + AC_PROVIDE_IFELSE([PHP_INIT_DTRACE], [], [AC_DEFUN([PHP_INIT_DTRACE], )]) + + if test "$PHP_DTRACE" = "yes"; then + if test "$oci8_php_version" -lt "5004000"; then + AC_MSG_ERROR([You need at least PHP 5.4 to be able to use DTrace with PHP OCI8]) + else + AC_CHECK_HEADERS([sys/sdt.h], [ + PHP_INIT_DTRACE([ext/oci8/oci8_dtrace.d],[ext/oci8/oci8_dtrace_gen.h],[ext/oci8/oci8.c \ + ext/oci8/oci8_interface.c ext/oci8/oci8_collection.c ext/oci8/oci8_lob.c ext/oci8/oci8_statement.c]) + ], [ + AC_MSG_ERROR( + [Cannot find sys/sdt.h which is required for DTrace support]) + ]) + fi + fi + dnl Set some port specific directory components for use later AC_CHECK_SIZEOF(long int, 4) diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 44bfa71398..c3bb49c2df 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -58,11 +58,17 @@ #include "php_oci8_int.h" #include "zend_hash.h" -#if defined(HAVE_STDINT_H) || defined(PHP_WIN32) -#define OCI8_INT_TO_PTR(I) ((void *)(intptr_t)(I)) +#if defined(__PTRDIFF_TYPE__) +# define OCI8_INT_TO_PTR(I) ((void*)(__PTRDIFF_TYPE__)(I)) +# define OCI8_PTR_TO_INT(P) ((int)(__PTRDIFF_TYPE__)(P)) +#elif !defined(__GNUC__) +#define OCI8_INT_TO_PTR(I) ((void*)&((char*)0)[I]) +#define OCI8_PTR_TO_INT(P) ((int)(((char*)P)-(char*)0)) +#elif defined(HAVE_STDINT_H) +#define OCI8_INT_TO_PTR(I) ((void*)(intptr_t)(I)) #define OCI8_PTR_TO_INT(P) ((int)(intptr_t)(P)) #else -#define OCI8_INT_TO_PTR(I) ((void *)(I)) +#define OCI8_INT_TO_PTR(I) ((void*)(I)) #define OCI8_PTR_TO_INT(P) ((int)(P)) #endif @@ -128,7 +134,7 @@ zend_class_entry *oci_coll_class_entry_ptr; #define PHP_OCI_INIT_MODE (OCI_DEFAULT | OCI_OBJECT) #endif -/* static protos {{{ */ +/* {{{ static protos */ static void php_oci_connection_list_dtor (zend_rsrc_list_entry * TSRMLS_DC); static void php_oci_pconnection_list_dtor (zend_rsrc_list_entry * TSRMLS_DC); static void php_oci_pconnection_list_np_dtor (zend_rsrc_list_entry * TSRMLS_DC); @@ -425,6 +431,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_parse, 0, 0, 2) ZEND_ARG_INFO(0, sql_text) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_get_implicit_resultset, 0, 0, 1) +ZEND_ARG_INFO(0, statement_resource) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_prefetch, 0, 0, 2) ZEND_ARG_INFO(0, statement_resource) ZEND_ARG_INFO(0, number_of_rows) @@ -698,6 +708,7 @@ static unsigned char arginfo_oci_bind_array_by_name[] = { 3, BYREF_NONE, BYREF_N #define arginfo_oci_error NULL #define arginfo_oci_num_fields NULL #define arginfo_oci_parse NULL +#define arginfo_oci_get_implicit_resultset NULL #define arginfo_oci_set_prefetch NULL #define arginfo_oci_set_client_identifier NULL #define arginfo_oci_set_edition NULL @@ -786,6 +797,7 @@ PHP_FUNCTION(oci_rollback); PHP_FUNCTION(oci_new_descriptor); PHP_FUNCTION(oci_num_fields); PHP_FUNCTION(oci_parse); +PHP_FUNCTION(oci_get_implicit_resultset); PHP_FUNCTION(oci_new_cursor); PHP_FUNCTION(oci_result); PHP_FUNCTION(oci_client_version); @@ -862,6 +874,7 @@ zend_function_entry php_oci_functions[] = { PHP_FE(oci_internal_debug, arginfo_oci_internal_debug) PHP_FE(oci_num_fields, arginfo_oci_num_fields) PHP_FE(oci_parse, arginfo_oci_parse) + PHP_FE(oci_get_implicit_resultset, arginfo_oci_get_implicit_resultset) PHP_FE(oci_new_cursor, arginfo_oci_new_cursor) PHP_FE(oci_result, arginfo_oci_result) PHP_FE(oci_client_version, arginfo_oci_client_version) @@ -1055,8 +1068,12 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY( "oci8.statement_cache_size", "20", PHP_INI_SYSTEM, ONUPDATELONGFUNC, statement_cache_size, zend_oci_globals, oci_globals) STD_PHP_INI_ENTRY( "oci8.default_prefetch", "100", PHP_INI_SYSTEM, ONUPDATELONGFUNC, default_prefetch, zend_oci_globals, oci_globals) STD_PHP_INI_BOOLEAN("oci8.old_oci_close_semantics", "0", PHP_INI_SYSTEM, OnUpdateBool, old_oci_close_semantics,zend_oci_globals, oci_globals) +#if (OCI_MAJOR_VERSION >= 11) STD_PHP_INI_ENTRY( "oci8.connection_class", "", PHP_INI_ALL, OnUpdateString, connection_class, zend_oci_globals, oci_globals) +#endif +#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) STD_PHP_INI_BOOLEAN("oci8.events", "0", PHP_INI_SYSTEM, OnUpdateBool, events, zend_oci_globals, oci_globals) +#endif PHP_INI_END() /* }}} */ @@ -1105,10 +1122,10 @@ static void php_oci_init_global_handles(TSRMLS_D) */ OCICPool *cpoolh; ub4 cpoolmode = 0x80000000; /* Pass invalid mode to OCIConnectionPoolCreate */ - PHP_OCI_CALL(OCIHandleAlloc, (OCI_G(env), (dvoid **) &cpoolh, OCI_HTYPE_CPOOL, (size_t) 0, (dvoid **) 0)); - PHP_OCI_CALL(OCIConnectionPoolCreate, (OCI_G(env), OCI_G(err), cpoolh, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, NULL, 0, cpoolmode)); - PHP_OCI_CALL(OCIConnectionPoolDestroy, (cpoolh, OCI_G(err), OCI_DEFAULT)); - PHP_OCI_CALL(OCIHandleFree, (cpoolh, OCI_HTYPE_CPOOL)); + PHP_OCI_CALL(OCIHANDLEALLOC, OCIHandleAlloc, (OCI_G(env), (dvoid **) &cpoolh, OCI_HTYPE_CPOOL, (size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL(OCICONNECTIONPOOLCREATE, OCIConnectionPoolCreate, (OCI_G(env), OCI_G(err), cpoolh, NULL, 0, NULL, 0, 0, 0, 0, NULL, 0, NULL, 0, cpoolmode)); + PHP_OCI_CALL(OCICONNECTIONPOOLDESTROY, OCIConnectionPoolDestroy, (cpoolh, OCI_G(err), OCI_DEFAULT)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, (cpoolh, OCI_HTYPE_CPOOL)); #endif } else { OCIErrorGet(OCI_G(env), (ub4)1, NULL, &ora_error_code, tmp_buf, (ub4)OCI_ERROR_MAXMSG_SIZE, (ub4)OCI_HTYPE_ERROR); @@ -1132,7 +1149,8 @@ static void php_oci_init_global_handles(TSRMLS_D) } } } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_cleanup_global_handles() * @@ -1141,15 +1159,16 @@ static void php_oci_init_global_handles(TSRMLS_D) static void php_oci_cleanup_global_handles(TSRMLS_D) { if (OCI_G(err)) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) OCI_G(err), OCI_HTYPE_ERROR)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) OCI_G(err), OCI_HTYPE_ERROR)); OCI_G(err) = NULL; } if (OCI_G(env)) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) OCI_G(env), OCI_HTYPE_ENV)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) OCI_G(env), OCI_HTYPE_ENV)); OCI_G(env) = NULL; } -} /* }}} */ +} +/* }}} */ /* {{{ PHP_GINIT_FUNCTION * @@ -1336,18 +1355,15 @@ PHP_RSHUTDOWN_FUNCTION(oci) PHP_MINFO_FUNCTION(oci) { char buf[32]; +#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) char *ver; +#endif php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); - php_info_print_table_row(2, "Version", PHP_OCI8_VERSION); + php_info_print_table_row(2, "OCI8 Version", PHP_OCI8_VERSION); php_info_print_table_row(2, "Revision", "$Id$"); - snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent)); - php_info_print_table_row(2, "Active Persistent Connections", buf); - snprintf(buf, sizeof(buf), "%ld", OCI_G(num_links)); - php_info_print_table_row(2, "Active Connections", buf); - #if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) php_oci_client_get_version(&ver TSRMLS_CC); php_info_print_table_row(2, "Oracle Run-time Client Library Version", ver); @@ -1361,9 +1377,9 @@ PHP_MINFO_FUNCTION(oci) snprintf(buf, sizeof(buf), "Unknown"); #endif #if defined(HAVE_OCI_INSTANT_CLIENT) - php_info_print_table_row(2, "Oracle Instant Client Version", buf); + php_info_print_table_row(2, "Oracle Compile-time Instant Client Version", buf); #else - php_info_print_table_row(2, "Oracle Version", buf); + php_info_print_table_row(2, "Oracle Compile-time Version", buf); #endif #if !defined(PHP_WIN32) && !defined(HAVE_OCI_INSTANT_CLIENT) @@ -1375,14 +1391,21 @@ PHP_MINFO_FUNCTION(oci) #endif #endif - php_info_print_table_row(2, "Temporary Lob support", "enabled"); - php_info_print_table_row(2, "Collections support", "enabled"); php_info_print_table_end(); + DISPLAY_INI_ENTRIES(); + + php_info_print_table_start(); + php_info_print_table_header(2, "Statistics", ""); + snprintf(buf, sizeof(buf), "%ld", OCI_G(num_persistent)); + php_info_print_table_row(2, "Active Persistent Connections", buf); + snprintf(buf, sizeof(buf), "%ld", OCI_G(num_links)); + php_info_print_table_row(2, "Active Connections", buf); + php_info_print_table_end(); } /* }}} */ -/* list destructors {{{ */ +/* {{{ list destructors */ /* {{{ php_oci_connection_list_dtor() * @@ -1396,7 +1419,8 @@ static void php_oci_connection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) php_oci_connection_close(connection TSRMLS_CC); OCI_G(num_links)--; } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_pconnection_list_dtor() * @@ -1411,7 +1435,8 @@ static void php_oci_pconnection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) OCI_G(num_persistent)--; OCI_G(num_links)--; } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_pconnection_list_np_dtor() * @@ -1449,11 +1474,12 @@ static void php_oci_pconnection_list_np_dtor(zend_rsrc_list_entry *entry TSRMLS_ OCI_G(num_persistent)--; } - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG L1: np_dtor cleaning up: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_CONNECT_P_DTOR_CLOSE_ENABLED()) { + DTRACE_OCI8_CONNECT_P_DTOR_CLOSE(connection); } - } - else { +#endif /* HAVE_DTRACE */ + } else { /* * Release the connection to underlying pool. We do this unconditionally so that * out-of-scope pconnects are now consistent with oci_close and out-of-scope new connect @@ -1465,11 +1491,14 @@ static void php_oci_pconnection_list_np_dtor(zend_rsrc_list_entry *entry TSRMLS_ */ php_oci_connection_release(connection TSRMLS_CC); - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG L1: np_dtor releasing: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_CONNECT_P_DTOR_RELEASE_ENABLED()) { + DTRACE_OCI8_CONNECT_P_DTOR_RELEASE(connection); } +#endif /* HAVE_DTRACE */ } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_statement_list_dtor() * @@ -1479,7 +1508,8 @@ static void php_oci_statement_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) { php_oci_statement *statement = (php_oci_statement *)entry->ptr; php_oci_statement_free(statement TSRMLS_CC); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_descriptor_list_dtor() * @@ -1489,7 +1519,8 @@ static void php_oci_descriptor_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) { php_oci_descriptor *descriptor = (php_oci_descriptor *)entry->ptr; php_oci_lob_free(descriptor TSRMLS_CC); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_list_dtor() * @@ -1499,11 +1530,12 @@ static void php_oci_collection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) { php_oci_collection *collection = (php_oci_collection *)entry->ptr; php_oci_collection_close(collection TSRMLS_CC); -} /* }}} */ +} +/* }}} */ /* }}} */ -/* Hash Destructors {{{ */ +/* {{{ Hash Destructors */ /* {{{ php_oci_define_hash_dtor() * @@ -1605,7 +1637,6 @@ void php_oci_connection_descriptors_free(php_oci_connection *connection TSRMLS_D } /* }}} */ - /* {{{ php_oci_error() * * Fetch & print out error message if we get an error @@ -1662,6 +1693,13 @@ sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC) php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown OCI error code: %d", status); break; } + +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_ERROR_ENABLED()) { + DTRACE_OCI8_ERROR(status, errcode); + } +#endif /* HAVE_DTRACE */ + return errcode; } /* }}} */ @@ -1676,7 +1714,7 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC) text err_buf[PHP_OCI_ERRBUF_LEN]; memset(err_buf, 0, sizeof(err_buf)); - PHP_OCI_CALL(OCIErrorGet, (error_handle, (ub4)1, NULL, &error_code, err_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ERROR)); + PHP_OCI_CALL(OCIERRORGET, OCIErrorGet, (error_handle, (ub4)1, NULL, &error_code, err_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ERROR)); if (error_code) { int err_buf_len = strlen((char *)err_buf); @@ -1690,7 +1728,8 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC) } } return error_code; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_fetch_sqltext_offset() * @@ -1702,7 +1741,7 @@ int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, u *sqltext = NULL; *error_offset = 0; - PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (dvoid *) sqltext, (ub4 *)0, OCI_ATTR_STATEMENT, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, errstatus, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (dvoid *) sqltext, (ub4 *)0, OCI_ATTR_STATEMENT, statement->err)); if (errstatus != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); @@ -1710,7 +1749,7 @@ int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, u return 1; } - PHP_OCI_CALL_RETURN(errstatus, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)error_offset, (ub4 *)0, OCI_ATTR_PARSE_ERROR_OFFSET, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, errstatus, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)error_offset, (ub4 *)0, OCI_ATTR_PARSE_ERROR_OFFSET, statement->err)); if (errstatus != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, errstatus TSRMLS_CC); @@ -1718,7 +1757,8 @@ int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, u return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_do_connect() * @@ -1738,18 +1778,32 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus return; } +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_CONNECT_START_ENABLED()) { + DTRACE_OCI8_CONNECT_START(username, dbname, charset, session_mode, persistent, exclusive); + } +#endif /* HAVE_DTRACE */ + 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); +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_CONNECT_DONE_ENABLED()) { + DTRACE_OCI8_CONNECT_DONE(); + } +#endif /* HAVE_DTRACE */ + + if (!connection) { RETURN_FALSE; } - RETURN_RESOURCE(connection->rsrc_id); + RETURN_RESOURCE(connection->id); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_do_connect_ex() * @@ -1857,7 +1911,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char smart_str_appendl_ex(&hashed_details, "**", sizeof("**") - 1, 0); if (charset && *charset) { - PHP_OCI_CALL_RETURN(charsetid, OCINlsCharSetNameToId, (OCI_G(env), (CONST oratext *)charset)); + PHP_OCI_CALL_RETURN(OCINLSCHARSETNAMETOID, charsetid, OCINlsCharSetNameToId, (OCI_G(env), (CONST oratext *)charset)); if (!charsetid) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid character set name: %s", charset); } else { @@ -1870,7 +1924,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char size_t rsize = 0; sword result; - PHP_OCI_CALL_RETURN(result, OCINlsEnvironmentVariableGet, (&charsetid_nls_lang, 0, OCI_NLS_CHARSET_ID, 0, &rsize)); + PHP_OCI_CALL_RETURN(OCINLSENVIRONMENTVARIABLEGET, result, OCINlsEnvironmentVariableGet, (&charsetid_nls_lang, 0, OCI_NLS_CHARSET_ID, 0, &rsize)); if (result != OCI_SUCCESS) { charsetid_nls_lang = 0; } @@ -1908,16 +1962,11 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char } } - /* Debug statements {{{ */ - if (OCI_G(debug_mode)) { - if (connection && connection->is_stub) { - php_printf ("OCI8 DEBUG L1: Got a cached stub: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); - } else if (connection) { - php_printf ("OCI8 DEBUG L1: Got a cached connection: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); - } else { - php_printf ("OCI8 DEBUG L1: Got NO cached connection at (%s:%d) \n", __FILE__, __LINE__); - } - } /* }}} */ +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_CONNECT_LOOKUP_ENABLED()) { + DTRACE_OCI8_CONNECT_LOOKUP(connection, connection && connection->is_stub ? 1 : 0); + } +#endif /* HAVE_DTRACE */ /* If we got a pconnection stub, then 'load'(OCISessionGet) the real connection from its * private spool A connection is a stub if it is only a cached structure and the real @@ -1963,24 +2012,20 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char /* okay, the connection is open and the server is still alive */ connection->used_this_request = 1; - tmp = (php_oci_connection *)zend_list_find(connection->rsrc_id, &rsrc_type); + tmp = (php_oci_connection *)zend_list_find(connection->id, &rsrc_type); if (tmp != NULL && rsrc_type == le_pconnection && strlen(tmp->hash_key) == hashed_details.len && - memcmp(tmp->hash_key, hashed_details.c, hashed_details.len) == 0 && zend_list_addref(connection->rsrc_id) == SUCCESS) { + memcmp(tmp->hash_key, hashed_details.c, hashed_details.len) == 0 && zend_list_addref(connection->id) == SUCCESS) { /* do nothing */ } else { -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC); -#else - connection->rsrc_id = zend_list_insert(connection, le_pconnection); -#endif + PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection); /* Persistent connections: For old close semantics we artificially * bump up the refcount to prevent the non-persistent destructor * from getting called until request shutdown. The refcount is * decremented in the persistent helper */ if (OCI_G(old_oci_close_semantics)) { - zend_list_addref(connection->rsrc_id); + zend_list_addref(connection->id); } } smart_str_free_ex(&hashed_details, 0); @@ -1991,7 +2036,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char } else { /* we do not ping non-persistent connections */ smart_str_free_ex(&hashed_details, 0); - zend_list_addref(connection->rsrc_id); + zend_list_addref(connection->id); return connection; } } /* is_open is true? */ @@ -2008,7 +2053,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char /* We have to do a hash_del but need to preserve the resource if there is a positive * refcount. Set the data pointer in the list entry to NULL */ - if (connection == zend_list_find(connection->rsrc_id, &rsrc_type) && rsrc_type == le_pconnection) { + if (connection == zend_list_find(connection->id, &rsrc_type) && rsrc_type == le_pconnection) { le->ptr = NULL; } @@ -2085,7 +2130,8 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char smart_str_free_ex(&hashed_details, 0); return NULL; } - } /* }}} */ + } + /* }}} */ connection->idle_expiry = (OCI_G(persistent_timeout) > 0) ? (timestamp + OCI_G(persistent_timeout)) : 0; @@ -2124,50 +2170,34 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char new_le.ptr = connection; new_le.type = le_pconnection; connection->used_this_request = 1; -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - connection->rsrc_id = zend_list_insert(connection, le_pconnection TSRMLS_CC); -#else - connection->rsrc_id = zend_list_insert(connection, le_pconnection); -#endif + PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection); /* Persistent connections: For old close semantics we artificially bump up the refcount to * prevent the non-persistent destructor from getting called until request shutdown. The * refcount is decremented in the persistent helper */ if (OCI_G(old_oci_close_semantics)) { - zend_list_addref(connection->rsrc_id); + zend_list_addref(connection->id); } zend_hash_update(&EG(persistent_list), connection->hash_key, strlen(connection->hash_key)+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL); OCI_G(num_persistent)++; OCI_G(num_links)++; } else if (!exclusive) { -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC); -#else - connection->rsrc_id = zend_list_insert(connection, le_connection); -#endif - new_le.ptr = OCI8_INT_TO_PTR(connection->rsrc_id); + PHP_OCI_REGISTER_RESOURCE(connection, le_connection); + new_le.ptr = OCI8_INT_TO_PTR(connection->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); OCI_G(num_links)++; } else { -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - connection->rsrc_id = zend_list_insert(connection, le_connection TSRMLS_CC); -#else - connection->rsrc_id = zend_list_insert(connection, le_connection); -#endif + PHP_OCI_REGISTER_RESOURCE(connection, le_connection); OCI_G(num_links)++; } - /* Debug statements {{{ */ - if (OCI_G(debug_mode)) { - if (connection->is_persistent) { - php_printf ("OCI8 DEBUG L1: New Persistent Connection address: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); - } else { - php_printf ("OCI8 DEBUG L1: New Non-Persistent Connection address: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__); - } - php_printf ("OCI8 DEBUG L1: num_persistent=(%ld), num_links=(%ld) at (%s:%d) \n", OCI_G(num_persistent), OCI_G(num_links), __FILE__, __LINE__); - } /* }}} */ +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_CONNECT_TYPE_ENABLED()) { + DTRACE_OCI8_CONNECT_TYPE(connection->is_persistent ? 1 : 0, exclusive ? 1 : 0, connection, OCI_G(num_persistent), OCI_G(num_links)); + } +#endif /* HAVE_DTRACE */ return connection; } @@ -2185,11 +2215,11 @@ static int php_oci_connection_ping(php_oci_connection *connection TSRMLS_DC) * Pre-10.2 clients */ #if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) /* OCIPing available 10.2 onwards */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIPing, (connection->svc, OCI_G(err), OCI_DEFAULT)); + PHP_OCI_CALL_RETURN(OCIPING, OCI_G(errcode), OCIPing, (connection->svc, OCI_G(err), OCI_DEFAULT)); #else char version[256]; /* use good old OCIServerVersion() */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIServerVersion, (connection->svc, OCI_G(err), (text *)version, sizeof(version), OCI_HTYPE_SVCCTX)); + PHP_OCI_CALL_RETURN(OCISERVERVERSION, OCI_G(errcode), OCIServerVersion, (connection->svc, OCI_G(err), (text *)version, sizeof(version), OCI_HTYPE_SVCCTX)); #endif if (OCI_G(errcode) == OCI_SUCCESS) { @@ -2220,7 +2250,7 @@ static int php_oci_connection_status(php_oci_connection *connection TSRMLS_DC) ub4 ss = 0; /* get OCI_ATTR_SERVER_STATUS */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->server, OCI_HTYPE_SERVER, (dvoid *)&ss, (ub4 *)0, OCI_ATTR_SERVER_STATUS, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRGET, OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->server, OCI_HTYPE_SERVER, (dvoid *)&ss, (ub4 *)0, OCI_ATTR_SERVER_STATUS, OCI_G(err))); if (OCI_G(errcode) == OCI_SUCCESS && ss == OCI_SERVER_NORMAL) { return 1; @@ -2238,8 +2268,8 @@ static int php_oci_connection_status(php_oci_connection *connection TSRMLS_DC) */ int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC) { - PHP_OCI_CALL_RETURN(connection->errcode, OCITransRollback, (connection->svc, connection->err, (ub4) 0)); - connection->needs_commit = 0; + PHP_OCI_CALL_RETURN(OCITRANSROLLBACK, connection->errcode, OCITransRollback, (connection->svc, connection->err, (ub4) 0)); + connection->rb_on_disconnect = 0; if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -2247,7 +2277,8 @@ int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC) return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_connection_commit() * @@ -2255,8 +2286,8 @@ int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC) */ int php_oci_connection_commit(php_oci_connection *connection TSRMLS_DC) { - PHP_OCI_CALL_RETURN(connection->errcode, OCITransCommit, (connection->svc, connection->err, (ub4) 0)); - connection->needs_commit = 0; + PHP_OCI_CALL_RETURN(OCITRANSCOMMIT, connection->errcode, OCITransCommit, (connection->svc, connection->err, (ub4) 0)); + connection->rb_on_disconnect = 0; if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -2264,7 +2295,8 @@ int php_oci_connection_commit(php_oci_connection *connection TSRMLS_DC) return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_connection_close() * @@ -2281,36 +2313,36 @@ static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC) } if (!connection->using_spool && connection->svc) { - PHP_OCI_CALL(OCISessionEnd, (connection->svc, connection->err, connection->session, (ub4) 0)); + PHP_OCI_CALL(OCISESSIONEND, OCISessionEnd, (connection->svc, connection->err, connection->session, (ub4) 0)); } if (connection->err) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->err, (ub4) OCI_HTYPE_ERROR)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) connection->err, (ub4) OCI_HTYPE_ERROR)); } if (connection->authinfo) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->authinfo, (ub4) OCI_HTYPE_AUTHINFO)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) connection->authinfo, (ub4) OCI_HTYPE_AUTHINFO)); } /* No Handlefrees for session pool connections */ if (!connection->using_spool) { if (connection->session) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->session, OCI_HTYPE_SESSION)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) connection->session, OCI_HTYPE_SESSION)); } if (connection->is_attached) { - PHP_OCI_CALL(OCIServerDetach, (connection->server, OCI_G(err), OCI_DEFAULT)); + PHP_OCI_CALL(OCISERVERDETACH, OCIServerDetach, (connection->server, OCI_G(err), OCI_DEFAULT)); } if (connection->svc) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX)); } if (connection->server) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->server, (ub4) OCI_HTYPE_SERVER)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) connection->server, (ub4) OCI_HTYPE_SERVER)); } if (connection->env) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) connection->env, OCI_HTYPE_ENV)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) connection->env, OCI_HTYPE_ENV)); } } else if (connection->private_spool) { /* Keep this as the last member to be freed, as there are dependencies @@ -2333,7 +2365,8 @@ static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC) connection = NULL; OCI_G(in_call) = in_call_save; return result; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_connection_release() * @@ -2357,7 +2390,7 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) if (connection->svc) { /* rollback outstanding transactions */ - if (connection->needs_commit) { + if (connection->rb_on_disconnect) { if (php_oci_connection_rollback(connection TSRMLS_CC)) { /* rollback failed */ result = 1; @@ -2398,7 +2431,7 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) #endif if (connection->svc) { - PHP_OCI_CALL(OCISessionRelease, (connection->svc, connection->err, NULL, + PHP_OCI_CALL(OCISESSIONRELEASE, OCISessionRelease, (connection->svc, connection->err, NULL, 0, rlsMode)); } /* It no longer has relation with the database session. However authinfo and env are @@ -2408,7 +2441,7 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) connection->server = NULL; connection->session = NULL; - connection->is_attached = connection->is_open = connection->needs_commit = connection->used_this_request = 0; + connection->is_attached = connection->is_open = connection->rb_on_disconnect = connection->used_this_request = 0; connection->is_stub = 1; /* Cut the link between the connection structure and the time_t structure allocated within @@ -2419,7 +2452,8 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) OCI_G(in_call) = in_call_save; return result; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_password_change() * @@ -2427,7 +2461,7 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC) */ 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) { - 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(OCIPASSWORDCHANGE, 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)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -2436,8 +2470,8 @@ int php_oci_password_change(php_oci_connection *connection, char *user, int user } connection->passwd_changed = 1; return 0; -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_client_get_version() * @@ -2446,21 +2480,21 @@ int php_oci_password_change(php_oci_connection *connection, char *user, int user void php_oci_client_get_version(char **version TSRMLS_DC) { char version_buff[256]; +#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) /* OCIClientVersion only available 10.2 onwards */ sword major_version = 0; sword minor_version = 0; sword update_num = 0; sword patch_num = 0; sword port_update_num = 0; -#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) /* OCIClientVersion only available 10.2 onwards */ - PHP_OCI_CALL(OCIClientVersion, (&major_version, &minor_version, &update_num, &patch_num, &port_update_num)); + PHP_OCI_CALL(OCICLIENTVERSION, OCIClientVersion, (&major_version, &minor_version, &update_num, &patch_num, &port_update_num)); snprintf(version_buff, sizeof(version_buff), "%d.%d.%d.%d.%d", major_version, minor_version, update_num, patch_num, port_update_num); #else memcpy(version_buff, "Unknown", sizeof("Unknown")); #endif *version = estrdup(version_buff); -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_server_get_version() * @@ -2470,7 +2504,7 @@ int php_oci_server_get_version(php_oci_connection *connection, char **version TS { char version_buff[256]; - PHP_OCI_CALL_RETURN(connection->errcode, OCIServerVersion, (connection->svc, connection->err, (text *)version_buff, sizeof(version_buff), OCI_HTYPE_SVCCTX)); + PHP_OCI_CALL_RETURN(OCISERVERVERSION, connection->errcode, OCIServerVersion, (connection->svc, connection->err, (text *)version_buff, sizeof(version_buff), OCI_HTYPE_SVCCTX)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -2480,7 +2514,8 @@ int php_oci_server_get_version(php_oci_connection *connection, char **version TS *version = estrdup(version_buff); return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_column_to_zval() * @@ -2564,14 +2599,19 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSR } /* }}} */ + /* {{{ php_oci_fetch_row() * * Fetch the next row from the given statement + * Has logic for Oracle 12c Implicit Result Sets */ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args) { zval *z_statement, *array; - php_oci_statement *statement; + php_oci_statement *statement; /* statement that will be fetched from */ +#if (OCI_MAJOR_VERSION >= 12) + php_oci_statement *invokedstatement; /* statement this function was invoked with */ +#endif /* OCI_MAJOR_VERSION */ php_oci_out_column *column; ub4 nrows = 1; int i; @@ -2617,11 +2657,65 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg } } +#if (OCI_MAJOR_VERSION < 12) PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement); if (php_oci_statement_fetch(statement, nrows TSRMLS_CC)) { - RETURN_FALSE; + RETURN_FALSE; /* end of fetch */ } +#else /* OCI_MAJOR_VERSION */ + PHP_OCI_ZVAL_TO_STATEMENT(z_statement, invokedstatement); + + if (invokedstatement->impres_flag == PHP_OCI_IMPRES_NO_CHILDREN) { + /* Already know there are no Implicit Result Sets */ + statement = invokedstatement; + } else if (invokedstatement->impres_flag == PHP_OCI_IMPRES_HAS_CHILDREN) { + /* Previously saw an Implicit Result Set in an earlier invocation of php_oci_fetch_row */ + statement = (php_oci_statement *)invokedstatement->impres_child_stmt; + } else { + sword errstatus; + + /* Check for an Implicit Result Set on this statement handle */ + PHP_OCI_CALL_RETURN(OCIATTRGET, errstatus, OCIAttrGet, ((dvoid *)invokedstatement->stmt, OCI_HTYPE_STMT, + (dvoid *) &invokedstatement->impres_count, + (ub4 *)NULL, OCI_ATTR_IMPLICIT_RESULT_COUNT, invokedstatement->err)); + if (errstatus) { + RETURN_FALSE; + } + if (invokedstatement->impres_count > 0) { + /* Make it so the fetch occurs on the first Implicit Result Set */ + statement = php_oci_get_implicit_resultset(invokedstatement); + if (!statement) + RETURN_FALSE; + invokedstatement->impres_count--; + invokedstatement->impres_child_stmt = (struct php_oci_statement *)statement; + invokedstatement->impres_flag = PHP_OCI_IMPRES_HAS_CHILDREN; + php_oci_statement_execute(statement, (ub4)OCI_DEFAULT TSRMLS_CC); + } else { + statement = invokedstatement; /* didn't find Implicit Result Sets */ + invokedstatement->impres_flag = PHP_OCI_IMPRES_NO_CHILDREN; /* Don't bother checking again */ + } + } + + if (php_oci_statement_fetch(statement, nrows TSRMLS_CC)) { + /* End of fetch */ + if (invokedstatement->impres_count > 0) { + /* Check next Implicit Result Set */ + statement = php_oci_get_implicit_resultset(invokedstatement); + if (!statement) + RETURN_FALSE; + invokedstatement->impres_count--; + invokedstatement->impres_child_stmt = (struct php_oci_statement *)statement; + php_oci_statement_execute(statement, (ub4)OCI_DEFAULT TSRMLS_CC); + if (php_oci_statement_fetch(statement, nrows TSRMLS_CC)) { + /* End of all fetches */ + RETURN_FALSE; + } + } else { + RETURN_FALSE; + } + } +#endif /* OCI_MAJOR_VERSION */ array_init(return_value); @@ -2688,9 +2782,11 @@ static int php_oci_persistent_helper(zend_rsrc_list_entry *le TSRMLS_DC) connection = (php_oci_connection *)le->ptr; if (!connection->used_this_request && OCI_G(persistent_timeout) != -1) { - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG L1: persistent_helper processing for timeout: (%p stub=%d) at (%s:%d) \n", connection, connection->is_stub, __FILE__, __LINE__); +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_CONNECT_EXPIRY_ENABLED()) { + DTRACE_OCI8_CONNECT_EXPIRY(connection, connection->is_stub ? 1 : 0, connection->idle_expiry, timestamp); } +#endif /* HAVE_DTRACE */ if (connection->idle_expiry < timestamp) { /* connection has timed out */ return ZEND_HASH_APPLY_REMOVE; @@ -2698,7 +2794,8 @@ static int php_oci_persistent_helper(zend_rsrc_list_entry *le TSRMLS_DC) } } return ZEND_HASH_APPLY_KEEP; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_create_spool() * @@ -2734,7 +2831,7 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha } /* Allocate the pool handle */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (session_pool->env, (dvoid **) &session_pool->poolh, OCI_HTYPE_SPOOL, (size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, (session_pool->env, (dvoid **) &session_pool->poolh, OCI_HTYPE_SPOOL, (size_t) 0, (dvoid **) 0)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -2746,7 +2843,7 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha * generic bug which can free up the OCI_G(err) variable before destroying connections. We * cannot use this for other roundtrip calls as there is no way the user can access this error */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, ((dvoid *) session_pool->env, (dvoid **)&(session_pool->err), (ub4) OCI_HTYPE_ERROR,(size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, ((dvoid *) session_pool->env, (dvoid **)&(session_pool->err), (ub4) OCI_HTYPE_ERROR,(size_t) 0, (dvoid **) 0)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -2762,49 +2859,53 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha #endif #if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2))) - /* Allocate auth handle for session pool {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (session_pool->env, (dvoid **)&(spoolAuth), OCI_HTYPE_AUTHINFO, 0, NULL)); + /* {{{ Allocate auth handle for session pool */ + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, (session_pool->env, (dvoid **)&(spoolAuth), OCI_HTYPE_AUTHINFO, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); iserror = 1; goto exit_create_spool; - } /* }}} */ + } + /* }}} */ - /* Set the edition attribute on the auth handle {{{ */ + /* {{{ Set the edition attribute on the auth handle */ if (OCI_G(edition)) { - PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) OCI_G(edition), (ub4)(strlen(OCI_G(edition))), (ub4)OCI_ATTR_EDITION, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode),OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) OCI_G(edition), (ub4)(strlen(OCI_G(edition))), (ub4)OCI_ATTR_EDITION, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); iserror = 1; goto exit_create_spool; } - } /* }}} */ + } + /* }}} */ - /* Set the driver name attribute on the auth handle {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, OCI_G(err))); + /* {{{ Set the driver name attribute on the auth handle */ + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); iserror = 1; goto exit_create_spool; - } /* }}} */ + } + /* }}} */ - /* Set the auth handle on the session pool {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) (session_pool->poolh),(ub4) OCI_HTYPE_SPOOL, (dvoid *) spoolAuth, (ub4)0, (ub4)OCI_ATTR_SPOOL_AUTH, OCI_G(err))); + /* {{{ Set the auth handle on the session pool */ + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode),OCIAttrSet, ((dvoid *) (session_pool->poolh),(ub4) OCI_HTYPE_SPOOL, (dvoid *) spoolAuth, (ub4)0, (ub4)OCI_ATTR_SPOOL_AUTH, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); iserror = 1; goto exit_create_spool; - } /* }}} */ + } + /* }}} */ #endif /* Create the homogeneous session pool - We have different session pools for every different * username, password, charset and dbname. */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCISessionPoolCreate,(session_pool->env, OCI_G(err), session_pool->poolh, (OraText **)&session_pool->poolname, &session_pool->poolname_len, (OraText *)dbname, (ub4)dbname_len, 0, UB4MAXVAL, 1,(OraText *)username, (ub4)username_len, (OraText *)password,(ub4)password_len, poolmode)); + PHP_OCI_CALL_RETURN(OCISESSIONPOOLCREATE, OCI_G(errcode), OCISessionPoolCreate,(session_pool->env, OCI_G(err), session_pool->poolh, (OraText **)&session_pool->poolname, &session_pool->poolname_len, (OraText *)dbname, (ub4)dbname_len, 0, UB4MAXVAL, 1,(OraText *)username, (ub4)username_len, (OraText *)password,(ub4)password_len, poolmode)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -2818,15 +2919,18 @@ exit_create_spool: } if (spoolAuth) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) spoolAuth, (ub4) OCI_HTYPE_AUTHINFO)); } - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG L1: create_spool: (%p) at (%s:%d) \n", session_pool, __FILE__, __LINE__); +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_SESSPOOL_CREATE_ENABLED()) { + DTRACE_OCI8_SESSPOOL_CREATE(session_pool); } +#endif /* HAVE_DTRACE */ return session_pool; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_get_spool() * @@ -2841,7 +2945,7 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char * zend_rsrc_list_entry *spool_out_le = NULL; zend_bool iserror = 0; - /* Create the spool hash key {{{ */ + /* {{{ Create the spool hash key */ smart_str_appendl_ex(&spool_hashed_details, "oci8spool***", sizeof("oci8spool***") - 1, 0); smart_str_appendl_ex(&spool_hashed_details, username, username_len, 0); smart_str_appendl_ex(&spool_hashed_details, "**", sizeof("**") - 1, 0); @@ -2880,11 +2984,7 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char * } spool_le.ptr = session_pool; spool_le.type = le_psessionpool; -#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5) - zend_list_insert(session_pool, le_psessionpool TSRMLS_CC); -#else - zend_list_insert(session_pool, le_psessionpool); -#endif + PHP_OCI_REGISTER_RESOURCE(session_pool, le_psessionpool); zend_hash_update(&EG(persistent_list), session_pool->spool_hash_key, strlen(session_pool->spool_hash_key)+1,(void *)&spool_le, sizeof(zend_rsrc_list_entry),NULL); } else if (spool_out_le->type == le_psessionpool && strlen(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key) == spool_hashed_details.len && @@ -2902,7 +3002,8 @@ exit_get_spool: return session_pool; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_create_env() * @@ -2913,7 +3014,7 @@ static OCIEnv *php_oci_create_env(ub2 charsetid TSRMLS_DC) OCIEnv *retenv = NULL; /* create an environment using the character set id */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIEnvNlsCreate, (&retenv, OCI_G(events) ? PHP_OCI_INIT_MODE | OCI_EVENTS : PHP_OCI_INIT_MODE, 0, NULL, NULL, NULL, 0, NULL, charsetid, charsetid)); + PHP_OCI_CALL_RETURN(OCIENVNLSCREATE, OCI_G(errcode), OCIEnvNlsCreate, (&retenv, OCI_G(events) ? PHP_OCI_INIT_MODE | OCI_EVENTS : PHP_OCI_INIT_MODE, 0, NULL, NULL, NULL, 0, NULL, charsetid, charsetid)); if (OCI_G(errcode) != OCI_SUCCESS) { sb4 ora_error_code = 0; @@ -2933,7 +3034,8 @@ static OCIEnv *php_oci_create_env(ub2 charsetid TSRMLS_DC) return NULL; } return retenv; -}/* }}} */ +} +/* }}} */ /* {{{ php_oci_old_create_session() * @@ -2944,131 +3046,139 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna { ub4 statement_cache_size = (OCI_G(statement_cache_size) > 0) ? OCI_G(statement_cache_size) : 0; - if (OCI_G(debug_mode)) { - php_printf ("OCI8 DEBUG: Bypassing client-side session pool for session create at (%s:%d) \n", __FILE__, __LINE__); - } - /* Create the OCI environment separate for each connection */ if (!(connection->env = php_oci_create_env(connection->charset TSRMLS_CC))) { return 1; } - /* Allocate our server handle {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->server), OCI_HTYPE_SERVER, 0, NULL)); + /* {{{ Allocate our server handle */ + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->server), OCI_HTYPE_SERVER, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Attach to the server {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIServerAttach, (connection->server, OCI_G(err), (text *)dbname, dbname_len, (ub4) OCI_DEFAULT)); + /* {{{ Attach to the server */ + PHP_OCI_CALL_RETURN(OCISERVERATTACH, OCI_G(errcode), OCIServerAttach, (connection->server, OCI_G(err), (text *)dbname, dbname_len, (ub4) OCI_DEFAULT)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ connection->is_attached = 1; - /* Allocate our session handle {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->session), OCI_HTYPE_SESSION, 0, NULL)); + /* {{{ Allocate our session handle */ + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->session), OCI_HTYPE_SESSION, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Allocate our private error-handle {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->err), OCI_HTYPE_ERROR, 0, NULL)); + /* {{{ Allocate our private error-handle */ + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->err), OCI_HTYPE_ERROR, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Allocate our service-context {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->svc), OCI_HTYPE_SVCCTX, 0, NULL)); + /* {{{ Allocate our service-context */ + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->svc), OCI_HTYPE_SVCCTX, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Set the username {{{ */ + /* {{{ 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))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) username, (ub4) 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); return 1; } - }/* }}} */ + } + /* }}} */ - /* Set the password {{{ */ + /* {{{ 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))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) password, (ub4) 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); return 1; } - }/* }}} */ + } + /* }}} */ - /* Set the edition attribute on the session handle {{{ */ + /* {{{ Set the edition attribute on the session handle */ #if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2))) if (OCI_G(edition)) { - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) OCI_G(edition), (ub4) (strlen(OCI_G(edition))), (ub4) OCI_ATTR_EDITION, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) OCI_G(edition), (ub4) (strlen(OCI_G(edition))), (ub4) OCI_ATTR_EDITION, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; } } -#endif /* }}} */ +#endif +/* }}} */ - /* Set the driver name attribute on the session handle {{{ */ + /* {{{ Set the driver name attribute on the session handle */ #if (OCI_MAJOR_VERSION >= 11) - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) PHP_OCI8_DRIVER_NAME, (ub4) sizeof(PHP_OCI8_DRIVER_NAME)-1, (ub4) OCI_ATTR_DRIVER_NAME, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; } -#endif /* }}} */ +#endif +/* }}} */ - /* Set the server handle in the service handle {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, (connection->svc, OCI_HTYPE_SVCCTX, connection->server, 0, OCI_ATTR_SERVER, OCI_G(err))); + /* {{{ Set the server handle in the service handle */ + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, (connection->svc, OCI_HTYPE_SVCCTX, connection->server, 0, OCI_ATTR_SERVER, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ - /* Set the authentication handle in the service handle {{{ */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, (connection->svc, OCI_HTYPE_SVCCTX, connection->session, 0, OCI_ATTR_SESSION, OCI_G(err))); + /* {{{ Set the authentication handle in the service handle */ + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, (connection->svc, OCI_HTYPE_SVCCTX, connection->session, 0, OCI_ATTR_SESSION, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ if (new_password) { - /* 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)); + /* {{{ Try to change password if new one was provided */ + PHP_OCI_CALL_RETURN(OCIPASSWORDCHANGE, 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)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; } - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->session), (ub4 *)0, OCI_ATTR_SESSION, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRGET, OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->session), (ub4 *)0, OCI_ATTR_SESSION, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; - } /* }}} */ + } + /* }}} */ } else { - /* start the session {{{ */ + /* {{{ start the session */ ub4 cred_type = OCI_CRED_RDBMS; /* Extract the overloaded session_mode parameter into valid Oracle credential and session mode values */ @@ -3079,7 +3189,7 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna session_mode |= OCI_STMT_CACHE; - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCISessionBegin, (connection->svc, OCI_G(err), connection->session, (ub4) cred_type, (ub4) session_mode)); + PHP_OCI_CALL_RETURN(OCISESSIONBEGIN, OCI_G(errcode), OCISessionBegin, (connection->svc, OCI_G(err), connection->session, (ub4) cred_type, (ub4) session_mode)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -3089,7 +3199,8 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna if (OCI_G(errcode) != OCI_SUCCESS_WITH_INFO) { return 1; } - } /* }}} */ + } + /* }}} */ } /* Brand new connection: Init and update the next_ping in the connection */ @@ -3098,7 +3209,7 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna return 1; } - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX, (ub4 *) &statement_cache_size, 0, (ub4) OCI_ATTR_STMTCACHESIZE, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX, (ub4 *) &statement_cache_size, 0, (ub4) OCI_ATTR_STMTCACHESIZE, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -3107,7 +3218,8 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna /* Successfully created session */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_create_session() * @@ -3138,20 +3250,18 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool connection->using_spool = 1; } - if (OCI_G(debug_mode)) { - if (session_pool) { - php_printf ("OCI8 DEBUG L1: using shared pool: (%p) at (%s:%d) \n", session_pool, __FILE__, __LINE__); - } else { - php_printf ("OCI8 DEBUG L1: using private pool: (%p) at (%s:%d) \n", connection->private_spool, __FILE__, __LINE__); - } +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_SESSPOOL_TYPE_ENABLED()) { + DTRACE_OCI8_SESSPOOL_TYPE(session_pool ? 1 : 0, session_pool ? session_pool : connection->private_spool); } +#endif /* HAVE_DTRACE */ /* The passed in "connection" can be a cached stub from plist or freshly created. In the former * case, we do not have to allocate any handles */ if (!connection->err) { - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->err), OCI_HTYPE_ERROR, 0, NULL)); + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->err), OCI_HTYPE_ERROR, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -3161,7 +3271,7 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool /* {{{ Allocate and initialize the connection-private authinfo handle if not allocated yet */ if (!connection->authinfo) { - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->authinfo), OCI_HTYPE_AUTHINFO, 0, NULL)); + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, OCI_G(errcode), OCIHandleAlloc, (connection->env, (dvoid **)&(connection->authinfo), OCI_HTYPE_AUTHINFO, 0, NULL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -3170,7 +3280,7 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool /* Set the Connection class and purity if OCI client version >= 11g */ #if (OCI_MAJOR_VERSION > 10) - PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) connection->authinfo,(ub4) OCI_HTYPE_SESSION, (dvoid *) OCI_G(connection_class), (ub4)(strlen(OCI_G(connection_class))), (ub4)OCI_ATTR_CONNECTION_CLASS, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode),OCIAttrSet, ((dvoid *) connection->authinfo,(ub4) OCI_HTYPE_SESSION, (dvoid *) OCI_G(connection_class), (ub4)(strlen(OCI_G(connection_class))), (ub4)OCI_ATTR_CONNECTION_CLASS, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -3182,23 +3292,27 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool else purity = OCI_ATTR_PURITY_NEW; - PHP_OCI_CALL_RETURN(OCI_G(errcode),OCIAttrSet, ((dvoid *) connection->authinfo,(ub4) OCI_HTYPE_AUTHINFO, (dvoid *) &purity, (ub4)0, (ub4)OCI_ATTR_PURITY, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode),OCIAttrSet, ((dvoid *) connection->authinfo,(ub4) OCI_HTYPE_AUTHINFO, (dvoid *) &purity, (ub4)0, (ub4)OCI_ATTR_PURITY, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; } #endif - } /* }}} */ + } + /* }}} */ - /* Debug statements {{{ */ - if (OCI_G(debug_mode)) { + /* {{{ Debug statements */ +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_SESSPOOL_STATS_ENABLED()) { ub4 numfree = 0, numbusy = 0, numopen = 0; - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)actual_spool->poolh, OCI_HTYPE_SPOOL, (dvoid *)&numopen, (ub4 *)0, OCI_ATTR_SPOOL_OPEN_COUNT, OCI_G(err))); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)actual_spool->poolh, OCI_HTYPE_SPOOL, (dvoid *)&numbusy, (ub4 *)0, OCI_ATTR_SPOOL_BUSY_COUNT, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRGET, OCI_G(errcode), OCIAttrGet, ((dvoid *)actual_spool->poolh, OCI_HTYPE_SPOOL, (dvoid *)&numopen, (ub4 *)0, OCI_ATTR_SPOOL_OPEN_COUNT, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRGET, OCI_G(errcode), OCIAttrGet, ((dvoid *)actual_spool->poolh, OCI_HTYPE_SPOOL, (dvoid *)&numbusy, (ub4 *)0, OCI_ATTR_SPOOL_BUSY_COUNT, OCI_G(err))); numfree = numopen - numbusy; /* number of free connections in the pool */ - php_printf ("OCI8 DEBUG L1: (numopen=%d)(numbusy=%d)(numfree=%d) at (%s:%d) \n", numopen, numbusy, numfree, __FILE__, __LINE__); - } /* }}} */ + DTRACE_OCI8_SESSPOOL_STATS(numfree, numbusy, numopen); + } +#endif /* HAVE_DTRACE */ + /* }}} */ /* Ping loop: Ping and loop till we get a good connection. When a database instance goes * down, it can leave several bad connections that need to be flushed out before getting a @@ -3208,7 +3322,7 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool */ do { /* Continue to use the global error handle as the connection is closed when an error occurs */ - PHP_OCI_CALL_RETURN(OCI_G(errcode),OCISessionGet, (connection->env, OCI_G(err), &(connection->svc), (OCIAuthInfo *)connection->authinfo, (OraText *)actual_spool->poolname, (ub4)actual_spool->poolname_len, NULL, 0, NULL, NULL, NULL, OCI_SESSGET_SPOOL)); + PHP_OCI_CALL_RETURN(OCISESSIONGET, OCI_G(errcode),OCISessionGet, (connection->env, OCI_G(err), &(connection->svc), (OCIAuthInfo *)connection->authinfo, (OraText *)actual_spool->poolname, (ub4)actual_spool->poolname_len, NULL, 0, NULL, NULL, NULL, OCI_SESSGET_SPOOL)); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -3223,11 +3337,12 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool } /* {{{ Populate the session and server fields of the connection */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->server), (ub4 *)0, OCI_ATTR_SERVER, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRGET, OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->server), (ub4 *)0, OCI_ATTR_SERVER, OCI_G(err))); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->session), (ub4 *)0, OCI_ATTR_SESSION, OCI_G(err))); /* }}} */ + PHP_OCI_CALL_RETURN(OCIATTRGET, OCI_G(errcode), OCIAttrGet, ((dvoid *)connection->svc, OCI_HTYPE_SVCCTX, (dvoid *)&(connection->session), (ub4 *)0, OCI_ATTR_SESSION, OCI_G(err))); + /* }}} */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIContextGetValue, (connection->session, OCI_G(err), (ub1 *)"NEXT_PING", (ub1)sizeof("NEXT_PING"), (void **)&(connection->next_pingp))); + PHP_OCI_CALL_RETURN(OCICONTEXTGETVALUE, OCI_G(errcode), OCIContextGetValue, (connection->session, OCI_G(err), (ub1 *)"NEXT_PING", (ub1)sizeof("NEXT_PING"), (void **)&(connection->next_pingp))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); return 1; @@ -3245,7 +3360,7 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool *(connection->next_pingp) = timestamp + OCI_G(ping_interval); } else { /* Bad connection - remove from pool */ - PHP_OCI_CALL(OCISessionRelease, (connection->svc, connection->err, NULL,0, (ub4) OCI_SESSRLS_DROPSESS)); + PHP_OCI_CALL(OCISESSIONRELEASE, OCISessionRelease, (connection->svc, connection->err, NULL,0, (ub4) OCI_SESSRLS_DROPSESS)); connection->svc = NULL; connection->server = NULL; connection->session = NULL; @@ -3253,7 +3368,7 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool } /* If ping applicable */ } while (!(connection->svc)); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX, (ub4 *) &statement_cache_size, 0, (ub4) OCI_ATTR_STMTCACHESIZE, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->svc, (ub4) OCI_HTYPE_SVCCTX, (ub4 *) &statement_cache_size, 0, (ub4) OCI_ATTR_STMTCACHESIZE, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -3265,7 +3380,8 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool connection->is_attached = connection->is_open = 1; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_spool_list_dtor() * @@ -3280,7 +3396,8 @@ static void php_oci_spool_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) } return; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_spool_close() * @@ -3289,20 +3406,20 @@ static void php_oci_spool_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC) static void php_oci_spool_close(php_oci_spool *session_pool TSRMLS_DC) { if (session_pool->poolname_len) { - PHP_OCI_CALL(OCISessionPoolDestroy, ((dvoid *) session_pool->poolh, + PHP_OCI_CALL(OCISESSIONPOOLDESTROY, OCISessionPoolDestroy, ((dvoid *) session_pool->poolh, (dvoid *) session_pool->err, OCI_SPD_FORCE)); } if (session_pool->poolh) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) session_pool->poolh, OCI_HTYPE_SPOOL)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) session_pool->poolh, OCI_HTYPE_SPOOL)); } if (session_pool->err) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) session_pool->err, OCI_HTYPE_ERROR)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) session_pool->err, OCI_HTYPE_ERROR)); } if (session_pool->env) { - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) session_pool->env, OCI_HTYPE_ENV)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) session_pool->env, OCI_HTYPE_ENV)); } if (session_pool->spool_hash_key) { @@ -3310,7 +3427,8 @@ static void php_oci_spool_close(php_oci_spool *session_pool TSRMLS_DC) } free(session_pool); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_ping_init() * @@ -3322,14 +3440,14 @@ static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TS { time_t *next_pingp = NULL; - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIContextGetValue, (connection->session, errh, (ub1 *)"NEXT_PING", (ub1)sizeof("NEXT_PING"), (void **)&next_pingp)); + PHP_OCI_CALL_RETURN(OCICONTEXTGETVALUE, OCI_G(errcode), OCIContextGetValue, (connection->session, errh, (ub1 *)"NEXT_PING", (ub1)sizeof("NEXT_PING"), (void **)&next_pingp)); if (OCI_G(errcode) != OCI_SUCCESS) { return OCI_G(errcode); } /* This must be a brand-new connection. Allocate memory for the ping */ if (!next_pingp) { - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIMemoryAlloc, (connection->session, errh, (void **)&next_pingp, OCI_DURATION_SESSION, sizeof(time_t), OCI_MEMORY_CLEARED)); + PHP_OCI_CALL_RETURN(OCIMEMORYALLOC, OCI_G(errcode), OCIMemoryAlloc, (connection->session, errh, (void **)&next_pingp, OCI_DURATION_SESSION, sizeof(time_t), OCI_MEMORY_CLEARED)); if (OCI_G(errcode) != OCI_SUCCESS) { return OCI_G(errcode); } @@ -3343,7 +3461,7 @@ static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TS } /* Set the new ping value into the connection */ - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIContextSetValue, (connection->session, errh, OCI_DURATION_SESSION, (ub1 *)"NEXT_PING", (ub1)sizeof("NEXT_PING"), next_pingp)); + PHP_OCI_CALL_RETURN(OCICONTEXTSETVALUE, OCI_G(errcode), OCIContextSetValue, (connection->session, errh, OCI_DURATION_SESSION, (ub1 *)"NEXT_PING", (ub1)sizeof("NEXT_PING"), next_pingp)); if (OCI_G(errcode) != OCI_SUCCESS) { OCIMemoryFree(connection->session, errh, next_pingp); return OCI_G(errcode); @@ -3353,7 +3471,8 @@ static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TS connection->next_pingp = next_pingp; return OCI_SUCCESS; -} /* }}} */ +} +/* }}} */ #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c index 763e12e924..27430e8823 100644 --- a/ext/oci8/oci8_collection.c +++ b/ext/oci8/oci8_collection.c @@ -55,10 +55,10 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c collection->connection = connection; collection->collection = NULL; - zend_list_addref(collection->connection->rsrc_id); + zend_list_addref(collection->connection->id); /* get type handle by name */ - PHP_OCI_CALL_RETURN(connection->errcode, OCITypeByName, + PHP_OCI_CALL_RETURN(OCITYPEBYNAME, connection->errcode, OCITypeByName, ( connection->env, connection->err, @@ -80,14 +80,14 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c } /* allocate describe handle */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIHandleAlloc, (connection->env, (dvoid **) &dschp1, (ub4) OCI_HTYPE_DESCRIBE, (size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL_RETURN(OCIHANDLEALLOC, connection->errcode, OCIHandleAlloc, (connection->env, (dvoid **) &dschp1, (ub4) OCI_HTYPE_DESCRIBE, (size_t) 0, (dvoid **) 0)); if (connection->errcode != OCI_SUCCESS) { goto CLEANUP; } /* describe TDO */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIDescribeAny, + PHP_OCI_CALL_RETURN(OCIDESCRIBEANY, connection->errcode, OCIDescribeAny, ( connection->svc, connection->err, @@ -105,14 +105,14 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c } /* get first parameter handle */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, ((dvoid *) dschp1, (ub4) OCI_HTYPE_DESCRIBE, (dvoid *)&parmp1, (ub4 *)0, (ub4)OCI_ATTR_PARAM, connection->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, connection->errcode, OCIAttrGet, ((dvoid *) dschp1, (ub4) OCI_HTYPE_DESCRIBE, (dvoid *)&parmp1, (ub4 *)0, (ub4)OCI_ATTR_PARAM, connection->err)); if (connection->errcode != OCI_SUCCESS) { goto CLEANUP; } /* get the collection type code of the attribute */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, + PHP_OCI_CALL_RETURN(OCIATTRGET, connection->errcode, OCIAttrGet, ( (dvoid*) parmp1, (ub4) OCI_DTYPE_PARAM, @@ -131,7 +131,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c case OCI_TYPECODE_TABLE: case OCI_TYPECODE_VARRAY: /* get collection element handle */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, + PHP_OCI_CALL_RETURN(OCIATTRGET, connection->errcode, OCIAttrGet, ( (dvoid*) parmp1, (ub4) OCI_DTYPE_PARAM, @@ -147,7 +147,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c } /* get REF of the TDO for the type */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, + PHP_OCI_CALL_RETURN(OCIATTRGET, connection->errcode, OCIAttrGet, ( (dvoid*) parmp2, (ub4) OCI_DTYPE_PARAM, @@ -163,7 +163,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c } /* get the TDO (only header) */ - PHP_OCI_CALL_RETURN(connection->errcode, OCITypeByRef, + PHP_OCI_CALL_RETURN(OCITYPEBYREF, connection->errcode, OCITypeByRef, ( connection->env, connection->err, @@ -179,7 +179,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c } /* get typecode */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet, + PHP_OCI_CALL_RETURN(OCIATTRGET, connection->errcode, OCIAttrGet, ( (dvoid*) parmp2, (ub4) OCI_DTYPE_PARAM, @@ -201,7 +201,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c } /* Create object to hold return table */ - PHP_OCI_CALL_RETURN(connection->errcode, OCIObjectNew, + PHP_OCI_CALL_RETURN(OCIOBJECTNEW, connection->errcode, OCIObjectNew, ( connection->env, connection->err, @@ -220,7 +220,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c } /* free the describe handle (Bug #44113) */ - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE)); PHP_OCI_REGISTER_RESOURCE(collection, le_collection); return collection; @@ -228,13 +228,14 @@ CLEANUP: if (dschp1) { /* free the describe handle (Bug #44113) */ - PHP_OCI_CALL(OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, ((dvoid *) dschp1, OCI_HTYPE_DESCRIBE)); } connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); php_oci_collection_close(collection TSRMLS_CC); return NULL; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_size() Return size of the collection */ @@ -242,7 +243,7 @@ int php_oci_collection_size(php_oci_collection *collection, sb4 *size TSRMLS_DC) { php_oci_connection *connection = collection->connection; - PHP_OCI_CALL_RETURN(connection->errcode, OCICollSize, (connection->env, connection->err, collection->collection, (sb4 *)size)); + PHP_OCI_CALL_RETURN(OCICOLLSIZE, connection->errcode, OCICollSize, (connection->env, connection->err, collection->collection, (sb4 *)size)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -250,7 +251,8 @@ int php_oci_collection_size(php_oci_collection *collection, sb4 *size TSRMLS_DC) return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_max() Return max number of elements in the collection */ @@ -258,11 +260,12 @@ int php_oci_collection_max(php_oci_collection *collection, long *max TSRMLS_DC) { php_oci_connection *connection = collection->connection; - PHP_OCI_CALL_RETURN(*max, OCICollMax, (connection->env, collection->collection)); + PHP_OCI_CALL_RETURN(OCICOLLMAX, *max, OCICollMax, (connection->env, collection->collection)); /* error handling is not necessary here? */ return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_trim() Trim collection to the given number of elements */ @@ -270,7 +273,7 @@ int php_oci_collection_trim(php_oci_collection *collection, long trim_size TSRML { php_oci_connection *connection = collection->connection; - PHP_OCI_CALL_RETURN(connection->errcode, OCICollTrim, (connection->env, connection->err, trim_size, collection->collection)); + PHP_OCI_CALL_RETURN(OCICOLLTRIM, connection->errcode, OCICollTrim, (connection->env, connection->err, trim_size, collection->collection)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -278,7 +281,8 @@ int php_oci_collection_trim(php_oci_collection *collection, long trim_size TSRML return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append_null() Append NULL element to the end of the collection */ @@ -288,7 +292,7 @@ int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC) php_oci_connection *connection = collection->connection; /* append NULL element */ - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAppend, (connection->env, connection->err, (dvoid *)0, &null_index, collection->collection)); + PHP_OCI_CALL_RETURN(OCICOLLAPPEND, connection->errcode, OCICollAppend, (connection->env, connection->err, (dvoid *)0, &null_index, collection->collection)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -296,7 +300,8 @@ int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC) return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append_date() Append DATE element to the end of the collection (use "DD-MON-YY" format) */ @@ -307,7 +312,7 @@ int php_oci_collection_append_date(php_oci_collection *collection, char *date, i 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, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(OCIDATEFROMTEXT, connection->errcode, OCIDateFromText, (connection->err, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date)); if (connection->errcode != OCI_SUCCESS) { /* failed to convert string to date */ @@ -316,7 +321,7 @@ int php_oci_collection_append_date(php_oci_collection *collection, char *date, i return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAppend, + PHP_OCI_CALL_RETURN(OCICOLLAPPEND, connection->errcode, OCICollAppend, ( connection->env, connection->err, @@ -333,7 +338,8 @@ int php_oci_collection_append_date(php_oci_collection *collection, char *date, i } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append_number() Append NUMBER to the end of the collection */ @@ -352,7 +358,7 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe element_double = zend_strtod(number, NULL); #endif - PHP_OCI_CALL_RETURN(connection->errcode, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); + PHP_OCI_CALL_RETURN(OCINUMBERFROMREAL, connection->errcode, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -360,7 +366,7 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAppend, + PHP_OCI_CALL_RETURN(OCICOLLAPPEND, connection->errcode, OCICollAppend, ( connection->env, connection->err, @@ -377,7 +383,8 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append_string() Append STRING to the end of the collection */ @@ -387,7 +394,7 @@ int php_oci_collection_append_string(php_oci_collection *collection, char *eleme OCIString *ocistr = (OCIString *)0; php_oci_connection *connection = collection->connection; - PHP_OCI_CALL_RETURN(connection->errcode, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr)); + PHP_OCI_CALL_RETURN(OCISTRINGASSIGNTEXT, connection->errcode, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -395,7 +402,7 @@ int php_oci_collection_append_string(php_oci_collection *collection, char *eleme return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAppend, + PHP_OCI_CALL_RETURN(OCICOLLAPPEND, connection->errcode, OCICollAppend, ( connection->env, connection->err, @@ -412,7 +419,8 @@ int php_oci_collection_append_string(php_oci_collection *collection, char *eleme } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_append() Append wrapper. Appends any supported element to the end of the collection */ @@ -452,7 +460,8 @@ int php_oci_collection_append(php_oci_collection *collection, char *element, int } /* never reached */ return 1; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_get() Get the element with the given index */ @@ -468,7 +477,7 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z MAKE_STD_ZVAL(*result_element); ZVAL_NULL(*result_element); - PHP_OCI_CALL_RETURN(connection->errcode, OCICollGetElem, + PHP_OCI_CALL_RETURN(OCICOLLGETELEM, connection->errcode, OCICollGetElem, ( connection->env, connection->err, @@ -500,7 +509,7 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z switch (collection->element_typecode) { case OCI_TYPECODE_DATE: - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateToText, (connection->err, element, 0, 0, 0, 0, &buff_len, buff)); + PHP_OCI_CALL_RETURN(OCIDATETOTEXT, connection->errcode, OCIDateToText, (connection->err, element, 0, 0, 0, 0, &buff_len, buff)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -520,7 +529,7 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z OCIString *oci_string = *(OCIString **)element; text *str; - PHP_OCI_CALL_RETURN(str, OCIStringPtr, (connection->env, oci_string)); + PHP_OCI_CALL_RETURN(OCISTRINGPTR, str, OCIStringPtr, (connection->env, oci_string)); if (str) { ZVAL_STRING(*result_element, (char *)str, 1); @@ -543,7 +552,7 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z { double double_number; - PHP_OCI_CALL_RETURN(connection->errcode, OCINumberToReal, (connection->err, (CONST OCINumber *) element, (uword) sizeof(double), (dvoid *) &double_number)); + PHP_OCI_CALL_RETURN(OCINUMBERTOREAL, connection->errcode, OCINumberToReal, (connection->err, (CONST OCINumber *) element, (uword) sizeof(double), (dvoid *) &double_number)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -565,7 +574,8 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z } /* never reached */ return 1; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set_null() Set the element with the given index to NULL */ @@ -575,7 +585,7 @@ int php_oci_collection_element_set_null(php_oci_collection *collection, long ind php_oci_connection *connection = collection->connection; /* set NULL element */ - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssignElem, (connection->env, connection->err, (ub4) index, (dvoid *)"", &null_index, collection->collection)); + PHP_OCI_CALL_RETURN(OCICOLLASSIGNELEM, connection->errcode, OCICollAssignElem, (connection->env, connection->err, (ub4) index, (dvoid *)"", &null_index, collection->collection)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -583,7 +593,8 @@ int php_oci_collection_element_set_null(php_oci_collection *collection, long ind return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set_date() Change element's value to the given DATE */ @@ -594,7 +605,7 @@ int php_oci_collection_element_set_date(php_oci_collection *collection, long ind 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, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(OCIDATEFROMTEXT, connection->errcode, OCIDateFromText, (connection->err, (CONST text *)date, date_len, NULL, 0, NULL, 0, &oci_date)); if (connection->errcode != OCI_SUCCESS) { /* failed to convert string to date */ @@ -603,7 +614,7 @@ int php_oci_collection_element_set_date(php_oci_collection *collection, long ind return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssignElem, + PHP_OCI_CALL_RETURN(OCICOLLASSIGNELEM, connection->errcode, OCICollAssignElem, ( connection->env, connection->err, @@ -621,7 +632,8 @@ int php_oci_collection_element_set_date(php_oci_collection *collection, long ind } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set_number() Change element's value to the given NUMBER */ @@ -640,7 +652,7 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i element_double = zend_strtod(number, NULL); #endif - PHP_OCI_CALL_RETURN(connection->errcode, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); + PHP_OCI_CALL_RETURN(OCINUMBERFROMREAL, connection->errcode, OCINumberFromReal, (connection->err, &element_double, sizeof(double), &oci_number)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -648,7 +660,7 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssignElem, + PHP_OCI_CALL_RETURN(OCICOLLASSIGNELEM, connection->errcode, OCICollAssignElem, ( connection->env, connection->err, @@ -666,7 +678,8 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set_string() Change element's value to the given string */ @@ -676,7 +689,7 @@ int php_oci_collection_element_set_string(php_oci_collection *collection, long i OCIString *ocistr = (OCIString *)0; php_oci_connection *connection = collection->connection; - PHP_OCI_CALL_RETURN(connection->errcode, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr)); + PHP_OCI_CALL_RETURN(OCISTRINGASSIGNTEXT, connection->errcode, OCIStringAssignText, (connection->env, connection->err, (CONST oratext *)element, element_len, &ocistr)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -684,7 +697,7 @@ int php_oci_collection_element_set_string(php_oci_collection *collection, long i return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssignElem, + PHP_OCI_CALL_RETURN(OCICOLLASSIGNELEM, connection->errcode, OCICollAssignElem, ( connection->env, connection->err, @@ -702,7 +715,8 @@ int php_oci_collection_element_set_string(php_oci_collection *collection, long i } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_element_set() Collection element setter */ @@ -742,7 +756,8 @@ int php_oci_collection_element_set(php_oci_collection *collection, long index, c } /* never reached */ return 1; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_assign() Assigns a value to the collection from another collection */ @@ -750,7 +765,7 @@ int php_oci_collection_assign(php_oci_collection *collection_dest, php_oci_colle { php_oci_connection *connection = collection_dest->connection; - PHP_OCI_CALL_RETURN(connection->errcode, OCICollAssign, (connection->env, connection->err, collection_from->collection, collection_dest->collection)); + PHP_OCI_CALL_RETURN(OCICOLLASSIGN, connection->errcode, OCICollAssign, (connection->env, connection->err, collection_from->collection, collection_dest->collection)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -758,7 +773,8 @@ int php_oci_collection_assign(php_oci_collection *collection_dest, php_oci_colle return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_collection_close() Destroy collection and all associated resources */ @@ -767,7 +783,7 @@ void php_oci_collection_close(php_oci_collection *collection TSRMLS_DC) php_oci_connection *connection = collection->connection; if (collection->collection) { - PHP_OCI_CALL_RETURN(connection->errcode, OCIObjectFree, (connection->env, connection->err, (dvoid *)collection->collection, (ub2)OCI_OBJECTFREE_FORCE)); + PHP_OCI_CALL_RETURN(OCIOBJECTFREE, connection->errcode, OCIObjectFree, (connection->env, connection->err, (dvoid *)collection->collection, (ub2)OCI_OBJECTFREE_FORCE)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -775,11 +791,12 @@ void php_oci_collection_close(php_oci_collection *collection TSRMLS_DC) } } - zend_list_delete(collection->connection->rsrc_id); + zend_list_delete(collection->connection->id); efree(collection); return; -} /* }}} */ +} +/* }}} */ #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/oci8_dtrace.d b/ext/oci8/oci8_dtrace.d new file mode 100644 index 0000000000..61f42ae17c --- /dev/null +++ b/ext/oci8/oci8_dtrace.d @@ -0,0 +1,195 @@ +/* + +----------------------------------------------------------------------+ + | Zend Engine | + +----------------------------------------------------------------------+ + | Copyright (c) 2013 Zend Technologies Ltd. (http://www.zend.com) | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the Zend license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.zend.com/license/3_01.txt. | + | If you did not receive a copy of the Zend license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@zend.com so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Christopher Jones <christopher.jones@oracle.com> | + +----------------------------------------------------------------------+ +*/ + +provider php { + probe oci8__connect_start(char *username, char *dbname, char *charset, long session_mode, int persistent, int exclusive); + probe oci8__connect_done(); + probe oci8__sqltext(char *sql); + probe oci8__error(int status, long errcode); + probe oci8__execute_mode(unsigned int mode); + + probe oci8__connect_p_dtor_close(void *connection); + probe oci8__connect_p_dtor_release(void *connection); + probe oci8__connect_lookup(void *connection, int is_stub); + probe oci8__connect_expiry(void *connection, int is_stub, time_t idle_expiry, time_t timestamp); + probe oci8__connect_type(int is_persistent, int exclusive, void *connection, long num_persistent, long num_links); + probe oci8__sesspool_create(void *session_pool); + probe oci8__sesspool_stats(unsigned long free, unsigned long busy, unsigned long open); + probe oci8__sesspool_type(int type, void *session_pool); + + probe oci8__ociattrget_start(); + probe oci8__ociattrget_done(); + probe oci8__ociattrset_start(); + probe oci8__ociattrset_done(); + probe oci8__ocibindbyname_start(); + probe oci8__ocibindbyname_done(); + probe oci8__ocibinddynamic_start(); + probe oci8__ocibinddynamic_done(); + probe oci8__ocibindobject_start(); + probe oci8__ocibindobject_done(); + probe oci8__ociclientversion_start(); + probe oci8__ociclientversion_done(); + probe oci8__ocicollappend_start(); + probe oci8__ocicollappend_done(); + probe oci8__ocicollassign_start(); + probe oci8__ocicollassign_done(); + probe oci8__ocicollassignelem_start(); + probe oci8__ocicollassignelem_done(); + probe oci8__ocicollgetelem_start(); + probe oci8__ocicollgetelem_done(); + probe oci8__ocicollmax_start(); + probe oci8__ocicollmax_done(); + probe oci8__ocicollsize_start(); + probe oci8__ocicollsize_done(); + probe oci8__ocicolltrim_start(); + probe oci8__ocicolltrim_done(); + probe oci8__ocicontextgetvalue_start(); + probe oci8__ocicontextgetvalue_done(); + probe oci8__ocicontextsetvalue_start(); + probe oci8__ocicontextsetvalue_done(); + probe oci8__ocidatefromtext_start(); + probe oci8__ocidatefromtext_done(); + probe oci8__ocidatetotext_start(); + probe oci8__ocidatetotext_done(); + probe oci8__ocidefinebypos_start(); + probe oci8__ocidefinebypos_done(); + probe oci8__ocidefinedynamic_start(); + probe oci8__ocidefinedynamic_done(); + probe oci8__ocidescribeany_start(); + probe oci8__ocidescribeany_done(); + probe oci8__ocidescriptoralloc_start(); + probe oci8__ocidescriptoralloc_done(); + probe oci8__ocidescriptorfree_start(); + probe oci8__ocidescriptorfree_done(); + probe oci8__ocienvnlscreate_start(); + probe oci8__ocienvnlscreate_done(); + probe oci8__ocierrorget_start(); + probe oci8__ocierrorget_done(); + probe oci8__ocihandlealloc_start(); + probe oci8__ocihandlealloc_done(); + probe oci8__ocihandlefree_start(); + probe oci8__ocihandlefree_done(); + probe oci8__ocilobappend_start(); + probe oci8__ocilobappend_done(); + probe oci8__ocilobcharsetid_start(); + probe oci8__ocilobcharsetid_done(); + probe oci8__ocilobclose_start(); + probe oci8__ocilobclose_done(); + probe oci8__ocilobcopy_start(); + probe oci8__ocilobcopy_done(); + probe oci8__ocilobcreatetemporary_start(); + probe oci8__ocilobcreatetemporary_done(); + probe oci8__ocilobdisablebuffering_start(); + probe oci8__ocilobdisablebuffering_done(); + probe oci8__ocilobenablebuffering_start(); + probe oci8__ocilobenablebuffering_done(); + probe oci8__ociloberase_start(); + probe oci8__ociloberase_done(); + probe oci8__ocilobfileclose_start(); + probe oci8__ocilobfileclose_done(); + probe oci8__ocilobfileopen_start(); + probe oci8__ocilobfileopen_done(); + probe oci8__ocilobflushbuffer_start(); + probe oci8__ocilobflushbuffer_done(); + probe oci8__ocilobfreetemporary_start(); + probe oci8__ocilobfreetemporary_done(); + probe oci8__ocilobgetchunksize_start(); + probe oci8__ocilobgetchunksize_done(); + probe oci8__ocilobgetlength_start(); + probe oci8__ocilobgetlength_done(); + probe oci8__ocilobisequal_start(); + probe oci8__ocilobisequal_done(); + probe oci8__ocilobistemporary_start(); + probe oci8__ocilobistemporary_done(); + probe oci8__ocilobopen_start(); + probe oci8__ocilobopen_done(); + probe oci8__ocilobread2_start(); + probe oci8__ocilobread2_done(); + probe oci8__ocilobtrim_start(); + probe oci8__ocilobtrim_done(); + probe oci8__ocilobwrite_start(); + probe oci8__ocilobwrite_done(); + probe oci8__ocimemoryalloc_start(); + probe oci8__ocimemoryalloc_done(); + probe oci8__ocimemoryfree_start(); + probe oci8__ocimemoryfree_done(); + probe oci8__ocinlscharsetnametoid_start(); + probe oci8__ocinlscharsetnametoid_done(); + probe oci8__ocinlsenvironmentvariableget_start(); + probe oci8__ocinlsenvironmentvariableget_done(); + probe oci8__ocinlsnumericinfoget_start(); + probe oci8__ocinlsnumericinfoget_done(); + probe oci8__ocinumberfromreal_start(); + probe oci8__ocinumberfromreal_done(); + probe oci8__ocinumbertoreal_start(); + probe oci8__ocinumbertoreal_done(); + probe oci8__ociobjectfree_start(); + probe oci8__ociobjectfree_done(); + probe oci8__ociobjectnew_start(); + probe oci8__ociobjectnew_done(); + probe oci8__ociparamget_start(); + probe oci8__ociparamget_done(); + probe oci8__ocipasswordchange_start(); + probe oci8__ocipasswordchange_done(); + probe oci8__ociping_start(); + probe oci8__ociping_done(); + probe oci8__ociserverattach_start(); + probe oci8__ociserverattach_done(); + probe oci8__ociserverdetach_start(); + probe oci8__ociserverdetach_done(); + probe oci8__ociserverversion_start(); + probe oci8__ociserverversion_done(); + probe oci8__ocisessionbegin_start(); + probe oci8__ocisessionbegin_done(); + probe oci8__ocisessionend_start(); + probe oci8__ocisessionend_done(); + probe oci8__ocisessionget_start(); + probe oci8__ocisessionget_done(); + probe oci8__ocisessionpoolcreate_start(); + probe oci8__ocisessionpoolcreate_done(); + probe oci8__ocisessionpooldestroy_start(); + probe oci8__ocisessionpooldestroy_done(); + probe oci8__ocisessionrelease_start(); + probe oci8__ocisessionrelease_done(); + probe oci8__ocistmtexecute_start(); + probe oci8__ocistmtexecute_done(); + probe oci8__ocistmtfetch_start(); + probe oci8__ocistmtfetch_done(); + probe oci8__ocistmtgetnextresult_start(); + probe oci8__ocistmtgetnextresult_done(); + probe oci8__ocistmtgetpieceinfo_start(); + probe oci8__ocistmtgetpieceinfo_done(); + probe oci8__ocistmtprepare2_start(); + probe oci8__ocistmtprepare2_done(); + probe oci8__ocistmtrelease_start(); + probe oci8__ocistmtrelease_done(); + probe oci8__ocistmtsetpieceinfo_start(); + probe oci8__ocistmtsetpieceinfo_done(); + probe oci8__ocistringassigntext_start(); + probe oci8__ocistringassigntext_done(); + probe oci8__ocistringptr_start(); + probe oci8__ocistringptr_done(); + probe oci8__ocitranscommit_start(); + probe oci8__ocitranscommit_done(); + probe oci8__ocitransrollback_start(); + probe oci8__ocitransrollback_done(); + probe oci8__ocitypebyname_start(); + probe oci8__ocitypebyname_done(); + probe oci8__ocitypebyref_start(); + probe oci8__ocitypebyref_done(); +}; diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c index e51d3c92f5..f93c0c0d45 100644 --- a/ext/oci8/oci8_interface.c +++ b/ext/oci8/oci8_interface.c @@ -1583,7 +1583,7 @@ PHP_FUNCTION(oci_close) } PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - zend_list_delete(connection->rsrc_id); + zend_list_delete(connection->id); ZVAL_NULL(z_connection); @@ -1591,7 +1591,7 @@ PHP_FUNCTION(oci_close) } /* }}} */ -/* {{{ proto resource oci_new_connect(string user, string pass [, string db]) +/* {{{ proto resource oci_new_connect(string user, string pass [, string db, string charset [, int session_mode ]]) Connect to an Oracle database and log on. Returns a new session. */ PHP_FUNCTION(oci_new_connect) { @@ -1607,7 +1607,7 @@ PHP_FUNCTION(oci_connect) } /* }}} */ -/* {{{ proto resource oci_pconnect(string user, string pass [, string db [, string charset ]]) +/* {{{ proto resource oci_pconnect(string user, string pass [, string db [, string charset [, int session_mode ]]) Connect to an Oracle database using a persistent connection and log on. Returns a new session. */ PHP_FUNCTION(oci_pconnect) { @@ -1766,7 +1766,7 @@ PHP_FUNCTION(oci_set_client_identifier) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_id, (ub4) client_id_len, (ub4) OCI_ATTR_CLIENT_IDENTIFIER, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_id, (ub4) client_id_len, (ub4) OCI_ATTR_CLIENT_IDENTIFIER, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -1809,7 +1809,7 @@ PHP_FUNCTION(oci_set_edition) /* }}} */ /* {{{ proto bool oci_set_module_name(resource connection, string value) - Sets the module attribute on the connection */ + Sets the module attribute on the connection for end-to-end tracing */ PHP_FUNCTION(oci_set_module_name) { #if (OCI_MAJOR_VERSION >= 10) @@ -1824,7 +1824,7 @@ PHP_FUNCTION(oci_set_module_name) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) module, (ub4) module_len, (ub4) OCI_ATTR_MODULE, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) module, (ub4) module_len, (ub4) OCI_ATTR_MODULE, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -1840,7 +1840,7 @@ PHP_FUNCTION(oci_set_module_name) /* }}} */ /* {{{ proto bool oci_set_action(resource connection, string value) - Sets the action attribute on the connection */ + Sets the action attribute on the connection for end-to-end tracing */ PHP_FUNCTION(oci_set_action) { #if (OCI_MAJOR_VERSION >= 10) @@ -1855,7 +1855,7 @@ PHP_FUNCTION(oci_set_action) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) action, (ub4) action_len, (ub4) OCI_ATTR_ACTION, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) action, (ub4) action_len, (ub4) OCI_ATTR_ACTION, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -1871,7 +1871,7 @@ PHP_FUNCTION(oci_set_action) /* }}} */ /* {{{ proto bool oci_set_client_info(resource connection, string value) - Sets the client info attribute on the connection */ + Sets the client info attribute on the connection for end-to-end tracing */ PHP_FUNCTION(oci_set_client_info) { #if (OCI_MAJOR_VERSION >= 10) @@ -1886,7 +1886,7 @@ PHP_FUNCTION(oci_set_client_info) PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_info, (ub4) client_info_len, (ub4) OCI_ATTR_CLIENT_INFO, OCI_G(err))); + PHP_OCI_CALL_RETURN(OCIATTRSET, OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_info, (ub4) client_info_len, (ub4) OCI_ATTR_CLIENT_INFO, OCI_G(err))); if (OCI_G(errcode) != OCI_SUCCESS) { php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -1957,7 +1957,7 @@ PHP_FUNCTION(oci_password_change) if (!connection) { RETURN_FALSE; } - RETURN_RESOURCE(connection->rsrc_id); + RETURN_RESOURCE(connection->id); } WRONG_PARAM_COUNT; } @@ -2395,6 +2395,32 @@ PHP_FUNCTION(oci_new_collection) } /* }}} */ +/* {{{ proto bool oci_get_implicit(resource stmt) + Get the next statement resource from an Oracle 12c PL/SQL Implicit Result Set */ +PHP_FUNCTION(oci_get_implicit_resultset) +{ + zval *z_statement; + php_oci_statement *statement; + php_oci_statement *imp_statement; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_statement) == FAILURE) { + return; + } + + PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement); + + imp_statement = php_oci_get_implicit_resultset(statement); + + if (imp_statement) { + if (php_oci_statement_execute(imp_statement, (ub4)OCI_DEFAULT TSRMLS_CC)) + RETURN_FALSE; + RETURN_RESOURCE(imp_statement->id); + } + RETURN_FALSE; +} + +/* }}} */ + #endif /* HAVE_OCI8 */ /* diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c index d05e053919..bd5b7065f4 100644 --- a/ext/oci8/oci8_lob.c +++ b/ext/oci8/oci8_lob.c @@ -70,9 +70,9 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ descriptor = ecalloc(1, sizeof(php_oci_descriptor)); descriptor->type = type; descriptor->connection = connection; - zend_list_addref(descriptor->connection->rsrc_id); + zend_list_addref(descriptor->connection->id); - PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0)); + PHP_OCI_CALL_RETURN(OCIDESCRIPTORALLOC, OCI_G(errcode), OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0)); if (OCI_G(errcode) != OCI_SUCCESS) { OCI_G(errcode) = php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC); @@ -109,7 +109,8 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ } return descriptor; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_get_length() Get length of the LOB. The length is cached so we don't need to ask Oracle every time */ @@ -124,7 +125,7 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D return 0; } else { if (descriptor->type == OCI_DTYPE_FILE) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY)); + PHP_OCI_CALL_RETURN(OCILOBFILEOPEN, connection->errcode, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); @@ -132,7 +133,7 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D } } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobGetLength, (connection->svc, connection->err, descriptor->descriptor, (ub4 *)length)); + PHP_OCI_CALL_RETURN(OCILOBGETLENGTH, connection->errcode, OCILobGetLength, (connection->svc, connection->err, descriptor->descriptor, (ub4 *)length)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -143,7 +144,7 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D descriptor->lob_size = *length; if (descriptor->type == OCI_DTYPE_FILE) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(OCILOBFILECLOSE, connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -153,7 +154,8 @@ int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_D } } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_callback() Append LOB portion to a memory buffer */ @@ -203,7 +205,8 @@ sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece) } /* }}} */ -/* {{{ php_oci_lob_calculate_buffer() */ +/* {{{ php_oci_lob_calculate_buffer() + Work out the size for LOB buffering */ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, long read_length TSRMLS_DC) { php_oci_connection *connection = descriptor->connection; @@ -214,7 +217,7 @@ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, l } if (!descriptor->chunk_size) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobGetChunkSize, (connection->svc, connection->err, descriptor->descriptor, &chunk_size)); + PHP_OCI_CALL_RETURN(OCILOBGETCHUNKSIZE, connection->errcode, OCILobGetChunkSize, (connection->svc, connection->err, descriptor->descriptor, &chunk_size)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -286,7 +289,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini offset = initial_offset; if (descriptor->type == OCI_DTYPE_FILE) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY)); + PHP_OCI_CALL_RETURN(OCILOBFILEOPEN, connection->errcode, OCILobFileOpen, (connection->svc, connection->err, descriptor->descriptor, OCI_FILE_READONLY)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -296,7 +299,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini } else { ub2 charset_id = 0; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id)); + PHP_OCI_CALL_RETURN(OCILOBCHARSETID, connection->errcode, OCILobCharSetId, (connection->env, connection->err, descriptor->descriptor, &charset_id)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -310,7 +313,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini } if (is_clob) { - PHP_OCI_CALL_RETURN(connection->errcode, OCINlsNumericInfoGet, (connection->env, connection->err, &bytes_per_char, OCI_NLS_CHARSET_MAXBYTESZ)); + PHP_OCI_CALL_RETURN(OCINLSNUMERICINFOGET, connection->errcode, OCINlsNumericInfoGet, (connection->env, connection->err, &bytes_per_char, OCI_NLS_CHARSET_MAXBYTESZ)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -337,7 +340,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini buffer_size = php_oci_lob_calculate_buffer(descriptor, buffer_size TSRMLS_CC); /* use chunk size */ bufp = (ub1 *) ecalloc(1, buffer_size); - PHP_OCI_CALL_RETURN(connection->errcode, OCILobRead2, + PHP_OCI_CALL_RETURN(OCILOBREAD2, connection->errcode, OCILobRead2, ( connection->svc, connection->err, @@ -370,7 +373,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini buffer_size = php_oci_lob_calculate_buffer(descriptor, buffer_size TSRMLS_CC); /* use chunk size */ bufp = (ub1 *) ecalloc(1, buffer_size); - PHP_OCI_CALL_RETURN(connection->errcode, OCILobRead, + PHP_OCI_CALL_RETURN(OCILOBREAD, connection->errcode, OCILobRead, ( connection->svc, connection->err, @@ -405,7 +408,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini descriptor->lob_current_position = (int)offset; if (descriptor->type == OCI_DTYPE_FILE) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(OCILOBFILECLOSE, connection->errcode, OCILobFileClose, (connection->svc, connection->err, descriptor->descriptor)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -420,7 +423,8 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_write() Write data to the LOB */ @@ -447,7 +451,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i offset = descriptor->lob_current_position; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobWrite, + PHP_OCI_CALL_RETURN(OCILOBWRITE, connection->errcode, OCILobWrite, ( connection->svc, connection->err, @@ -483,7 +487,8 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_set_buffering() Turn buffering off/onn for this particular LOB */ @@ -502,9 +507,9 @@ int php_oci_lob_set_buffering (php_oci_descriptor *descriptor, int on_off TSRMLS } if (on_off) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobEnableBuffering, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(OCILOBENABLEBUFFERING, connection->errcode, OCILobEnableBuffering, (connection->svc, connection->err, descriptor->descriptor)); } else { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobDisableBuffering, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(OCILOBDISABLEBUFFERING, connection->errcode, OCILobDisableBuffering, (connection->svc, connection->err, descriptor->descriptor)); } if (connection->errcode != OCI_SUCCESS) { @@ -514,7 +519,8 @@ int php_oci_lob_set_buffering (php_oci_descriptor *descriptor, int on_off TSRMLS } descriptor->buffering = on_off ? PHP_OCI_LOB_BUFFER_ENABLED : PHP_OCI_LOB_BUFFER_DISABLED; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_get_buffering() Return current buffering state for the LOB */ @@ -525,7 +531,8 @@ int php_oci_lob_get_buffering (php_oci_descriptor *descriptor) } else { return 0; } -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_copy() Copy one LOB (or its part) to another one */ @@ -553,7 +560,7 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobCopy, + PHP_OCI_CALL_RETURN(OCILOBCOPY, connection->errcode, OCILobCopy, ( connection->svc, connection->err, @@ -572,7 +579,8 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_close() Close LOB */ @@ -581,7 +589,7 @@ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) php_oci_connection *connection = descriptor->connection; if (descriptor->is_open) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(OCILOBCLOSE, connection->errcode, OCILobClose, (connection->svc, connection->err, descriptor->descriptor)); } if (connection->errcode != OCI_SUCCESS) { @@ -595,7 +603,8 @@ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_temp_lob_close() Close Temporary LOB */ @@ -604,7 +613,7 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) php_oci_connection *connection = descriptor->connection; int is_temporary; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsTemporary, (connection->env,connection->err, descriptor->descriptor, &is_temporary)); + PHP_OCI_CALL_RETURN(OCILOBISTEMPORARY, connection->errcode, OCILobIsTemporary, (connection->env,connection->err, descriptor->descriptor, &is_temporary)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -613,7 +622,7 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) } if (is_temporary) { - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor)); + PHP_OCI_CALL_RETURN(OCILOBFREETEMPORARY, connection->errcode, OCILobFreeTemporary, (connection->svc, connection->err, descriptor->descriptor)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -622,8 +631,8 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC) } } return 0; -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_lob_flush() Flush buffers for the LOB (only if they have been used) */ @@ -654,7 +663,7 @@ int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC) return 0; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobFlushBuffer, (connection->svc, connection->err, lob, flush_flag)); + PHP_OCI_CALL_RETURN(OCILOBFLUSHBUFFER, connection->errcode, OCILobFlushBuffer, (connection->svc, connection->err, lob, flush_flag)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -665,7 +674,8 @@ int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC) /* marking buffer as enabled and not used */ descriptor->buffering = PHP_OCI_LOB_BUFFER_ENABLED; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_free() Close LOB descriptor and free associated resources */ @@ -707,11 +717,12 @@ void php_oci_lob_free (php_oci_descriptor *descriptor TSRMLS_DC) php_oci_temp_lob_close(descriptor TSRMLS_CC); } - PHP_OCI_CALL(OCIDescriptorFree, (descriptor->descriptor, descriptor->type)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (descriptor->descriptor, descriptor->type)); - zend_list_delete(descriptor->connection->rsrc_id); + zend_list_delete(descriptor->connection->id); efree(descriptor); -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_import() Import LOB contents from the given file */ @@ -739,7 +750,7 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC } while ((loblen = read(fp, &buf, sizeof(buf))) > 0) { - PHP_OCI_CALL_RETURN(connection->errcode, + PHP_OCI_CALL_RETURN(OCILOBWRITE, connection->errcode, OCILobWrite, ( connection->svc, @@ -768,7 +779,8 @@ int php_oci_lob_import (php_oci_descriptor *descriptor, char *filename TSRMLS_DC close(fp); return 0; -} /* }}} */ +} + /* }}} */ /* {{{ php_oci_lob_append() Append data to the end of the LOB */ @@ -791,7 +803,7 @@ int php_oci_lob_append (php_oci_descriptor *descriptor_dest, php_oci_descriptor return 0; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobAppend, (connection->svc, connection->err, lob_dest, lob_from)); + PHP_OCI_CALL_RETURN(OCILOBAPPEND, connection->errcode, OCILobAppend, (connection->svc, connection->err, lob_dest, lob_from)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -799,7 +811,8 @@ int php_oci_lob_append (php_oci_descriptor *descriptor_dest, php_oci_descriptor return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_truncate() Truncate LOB to the given length */ @@ -827,7 +840,7 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, long new_lob_length TS return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobTrim, (connection->svc, connection->err, lob, new_lob_length)); + PHP_OCI_CALL_RETURN(OCILOBTRIM, connection->errcode, OCILobTrim, (connection->svc, connection->err, lob, new_lob_length)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -837,7 +850,8 @@ int php_oci_lob_truncate (php_oci_descriptor *descriptor, long new_lob_length TS descriptor->lob_size = new_lob_length; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_erase() Erase (or fill with whitespaces, depending on LOB type) the LOB (or its part) */ @@ -861,7 +875,7 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, ub4 length, length = lob_length; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, offset+1)); + PHP_OCI_CALL_RETURN(OCILOBERASE, connection->errcode, OCILobErase, (connection->svc, connection->err, lob, (ub4 *)&length, offset+1)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -871,7 +885,8 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, ub4 length, *bytes_erased = length; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_is_equal() Compare two LOB descriptors and figure out if they are pointing to the same LOB */ @@ -881,7 +896,7 @@ int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descript OCILobLocator *first_lob = descriptor_first->descriptor; OCILobLocator *second_lob = descriptor_second->descriptor; - PHP_OCI_CALL_RETURN(connection->errcode, OCILobIsEqual, (connection->env, first_lob, second_lob, result)); + PHP_OCI_CALL_RETURN(OCILOBISEQUAL, connection->errcode, OCILobIsEqual, (connection->env, first_lob, second_lob, result)); if (connection->errcode) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -889,7 +904,8 @@ int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descript return 1; } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_lob_write_tmp() Create temporary LOB and write data to it */ @@ -914,7 +930,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobCreateTemporary, + PHP_OCI_CALL_RETURN(OCILOBCREATETEMPORARY, connection->errcode, OCILobCreateTemporary, ( connection->svc, connection->err, @@ -933,7 +949,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data return 1; } - PHP_OCI_CALL_RETURN(connection->errcode, OCILobOpen, (connection->svc, connection->err, lob, OCI_LOB_READWRITE)); + PHP_OCI_CALL_RETURN(OCILOBOPEN, connection->errcode, OCILobOpen, (connection->svc, connection->err, lob, OCI_LOB_READWRITE)); if (connection->errcode) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); @@ -944,7 +960,8 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, long type, char *data descriptor->is_open = 1; return php_oci_lob_write(descriptor, 0, data, data_len, &bytes_written TSRMLS_CC); -} /* }}} */ +} +/* }}} */ #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c index 89facb0703..266262305f 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, char *query, int query_len TSRMLS_DC) { php_oci_statement *statement; @@ -51,13 +51,19 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha if (!query_len) { /* do not allocate stmt handle for refcursors, we'll get it from OCIStmtPrepare2() */ - PHP_OCI_CALL(OCIHandleAlloc, (connection->env, (dvoid **)&(statement->stmt), OCI_HTYPE_STMT, 0, NULL)); + PHP_OCI_CALL(OCIHANDLEALLOC, OCIHandleAlloc, (connection->env, (dvoid **)&(statement->stmt), OCI_HTYPE_STMT, 0, NULL)); + } else { +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_SQLTEXT_ENABLED()) { + DTRACE_OCI8_SQLTEXT(query); + } +#endif /* HAVE_DTRACE */ } - PHP_OCI_CALL(OCIHandleAlloc, (connection->env, (dvoid **)&(statement->err), OCI_HTYPE_ERROR, 0, NULL)); + PHP_OCI_CALL(OCIHANDLEALLOC, OCIHandleAlloc, (connection->env, (dvoid **)&(statement->err), OCI_HTYPE_ERROR, 0, NULL)); if (query_len > 0) { - PHP_OCI_CALL_RETURN(connection->errcode, OCIStmtPrepare2, + PHP_OCI_CALL_RETURN(OCISTMTPREPARE2, connection->errcode, OCIStmtPrepare2, ( connection->svc, &(statement->stmt), @@ -73,8 +79,8 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); - PHP_OCI_CALL(OCIStmtRelease, (statement->stmt, statement->err, NULL, 0, statement->errcode ? OCI_STRLS_CACHE_DELETE : OCI_DEFAULT)); - PHP_OCI_CALL(OCIHandleFree,(statement->err, OCI_HTYPE_ERROR)); + PHP_OCI_CALL(OCISTMTRELEASE, OCIStmtRelease, (statement->stmt, statement->err, NULL, 0, statement->errcode ? OCI_STRLS_CACHE_DELETE : OCI_DEFAULT)); + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree,(statement->err, OCI_HTYPE_ERROR)); efree(statement); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); @@ -95,7 +101,10 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha statement->has_data = 0; statement->has_descr = 0; statement->parent_stmtid = 0; - zend_list_addref(statement->connection->rsrc_id); + statement->impres_child_stmt = NULL; + statement->impres_count = 0; + statement->impres_flag = PHP_OCI_IMPRES_UNKNOWN; /* may or may not have Implicit Result Set children */ + zend_list_addref(statement->connection->id); if (OCI_G(default_prefetch) >= 0) { php_oci_statement_set_prefetch(statement, OCI_G(default_prefetch) TSRMLS_CC); @@ -109,6 +118,66 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha } /* }}} */ +/* {{{ php_oci_get_implicit_resultset() + Fetch implicit result set statement resource */ +php_oci_statement *php_oci_get_implicit_resultset(php_oci_statement *statement TSRMLS_DC) +{ + void *result; + ub4 rtype; + php_oci_statement *statement2; /* implicit result set statement handle */ + +#if (OCI_MAJOR_VERSION < 12) + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Implicit results are available in Oracle Database 12c onwards"); + return NULL; +#else + PHP_OCI_CALL_RETURN(OCISTMTGETNEXTRESULT, statement->errcode, OCIStmtGetNextResult, (statement->stmt, statement->err, &result, &rtype, OCI_DEFAULT)); + if (statement->errcode == OCI_NO_DATA) { + return NULL; + } + + if (rtype != OCI_RESULT_TYPE_SELECT) { + /* Only OCI_RESULT_TYPE_SELECT is supported by Oracle DB 12cR1 */ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unexpected implicit result type returned from Oracle Database"); + return NULL; + } else { + statement2 = ecalloc(1,sizeof(php_oci_statement)); + + PHP_OCI_CALL(OCIHANDLEALLOC, OCIHandleAlloc, (statement->connection->env, (dvoid **)&(statement2->err), OCI_HTYPE_ERROR, 0, NULL)); + statement2->stmt = (OCIStmt *)result; + statement2->parent_stmtid = statement->id; + statement2->impres_child_stmt = NULL; + statement2->impres_count = 0; + statement2->impres_flag = PHP_OCI_IMPRES_IS_CHILD; + statement2->connection = statement->connection; + statement2->errcode = 0; + statement2->last_query = NULL; + statement2->last_query_len = 0; + statement2->columns = NULL; + statement2->binds = NULL; + statement2->defines = NULL; + statement2->ncolumns = 0; + statement2->executed = 0; + statement2->has_data = 0; + statement2->has_descr = 0; + statement2->stmttype = 0; + + zend_list_addref(statement->id); + zend_list_addref(statement2->connection->id); + + if (OCI_G(default_prefetch) >= 0) { + php_oci_statement_set_prefetch(statement2, OCI_G(default_prefetch) TSRMLS_CC); + } + + PHP_OCI_REGISTER_RESOURCE(statement2, le_statement); + + OCI_G(num_statements)++; + + return statement2; + } +#endif /* OCI_MAJOR_VERSION < 12 */ +} +/* }}} */ + /* {{{ php_oci_statement_set_prefetch() Set prefetch buffer size for the statement (we're assuming that one row is ~1K sized) */ int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRMLS_DC) @@ -120,7 +189,7 @@ int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRML return 1; } - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrSet, (statement->stmt, OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_ROWS, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRSET, statement->errcode, OCIAttrSet, (statement->stmt, OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_ROWS, statement->err)); if (statement->errcode != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); @@ -163,8 +232,8 @@ int php_oci_cleanup_pre_fetch(void *data TSRMLS_DC) } return ZEND_HASH_APPLY_KEEP; -} /* }}} */ - +} +/* }}} */ /* {{{ php_oci_statement_fetch() Fetch a row from the statement */ @@ -182,7 +251,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) zend_hash_apply(statement->columns, (apply_func_t) php_oci_cleanup_pre_fetch TSRMLS_CC); } - PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); + PHP_OCI_CALL_RETURN(OCISTMTFETCH, statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); if ( statement->errcode == OCI_NO_DATA || nrows == 0 ) { if (statement->last_query == NULL) { @@ -209,7 +278,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); - if (column->piecewise) { + if (column && column->piecewise) { column->retlen4 = 0; piecewisecols = 1; } @@ -217,7 +286,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) while (statement->errcode == OCI_NEED_DATA) { if (piecewisecols) { - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(OCISTMTGETPIECEINFO,statement->errcode, OCIStmtGetPieceInfo, ( statement->stmt, @@ -234,7 +303,7 @@ 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) { + if (column && column->piecewise && handlepp == column->oci_define) { if (!column->data) { column->data = (text *) ecalloc(1, PHP_OCI_PIECE_SIZE + 1); } else { @@ -243,7 +312,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) column->cb_retlen = PHP_OCI_PIECE_SIZE; /* and instruct fetch to fetch waiting piece into our buffer */ - PHP_OCI_CALL(OCIStmtSetPieceInfo, + PHP_OCI_CALL(OCISTMTSETPIECEINFO, OCIStmtSetPieceInfo, ( (void *) column->oci_define, OCI_HTYPE_DEFINE, @@ -259,7 +328,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC) } } - PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); + PHP_OCI_CALL_RETURN(OCISTMTFETCH, statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT)); if (piecewisecols) { for (i = 0; i < statement->ncolumns; i++) { @@ -332,7 +401,7 @@ php_oci_out_column *php_oci_statement_get_column(php_oci_statement *statement, l } /* }}} */ -/* php_oci_define_callback() {{{ */ +/* {{{ php_oci_define_callback() */ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **bufpp, ub4 **alenpp, ub1 *piecep, dvoid **indpp, ub2 **rcpp) { php_oci_out_column *outcol = (php_oci_out_column *)ctx; @@ -421,6 +490,11 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) case OCI_DESCRIBE_ONLY: case OCI_DEFAULT: /* only these are allowed */ +#ifdef HAVE_DTRACE + if (DTRACE_OCI8_EXECUTE_MODE_ENABLED()) { + DTRACE_OCI8_EXECUTE_MODE(mode); + } +#endif /* HAVE_DTRACE */ break; default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid execute mode given: %d", mode); @@ -430,7 +504,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) if (!statement->stmttype) { /* get statement type */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)&statement->stmttype, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)&statement->stmttype, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->err)); if (statement->errcode != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); @@ -445,9 +519,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) iters = 1; } - if (statement->last_query) { - /* if we execute refcursors we don't have a query and - we don't want to execute!!! */ + if (statement->last_query) { /* Don't execute REFCURSORS or Implicit Result Set handles */ if (statement->binds) { int result = 0; @@ -458,7 +530,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } /* execute statement */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIStmtExecute, (statement->connection->svc, statement->stmt, statement->err, iters, 0, NULL, NULL, mode)); + PHP_OCI_CALL_RETURN(OCISTMTEXECUTE, statement->errcode, OCIStmtExecute, (statement->connection->svc, statement->stmt, statement->err, iters, 0, NULL, NULL, mode)); if (statement->errcode != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); @@ -471,10 +543,18 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } if (mode & OCI_COMMIT_ON_SUCCESS) { - statement->connection->needs_commit = 0; - } else { - statement->connection->needs_commit = 1; + /* No need to rollback on disconnect */ + statement->connection->rb_on_disconnect = 0; + } else if (statement->stmttype != OCI_STMT_SELECT) { + /* Assume some uncommitted DML occurred */ + statement->connection->rb_on_disconnect = 1; } + /* else for SELECT with OCI_NO_AUTO_COMMIT, leave + * "rb_on_disconnect" at its previous value. SELECT can't + * initiate uncommitted DML. (An AUTONOMOUS_TRANSACTION in + * invoked PL/SQL must explicitly rollback/commit else the + * SELECT fails). + */ } if (statement->stmttype == OCI_STMT_SELECT && statement->executed == 0) { @@ -487,7 +567,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) counter = 1; /* get number of columns */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (dvoid *)&colcount, (ub4 *)0, OCI_ATTR_PARAM_COUNT, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (dvoid *)&colcount, (ub4 *)0, OCI_ATTR_PARAM_COUNT, statement->err)); if (statement->errcode != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); @@ -507,7 +587,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } /* get column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)¶m, counter)); + PHP_OCI_CALL_RETURN(OCIPARAMGET, statement->errcode, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)¶m, counter)); if (statement->errcode != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); @@ -516,40 +596,40 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } /* get column datatype */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->data_type, (ub4 *)0, OCI_ATTR_DATA_TYPE, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->data_type, (ub4 *)0, OCI_ATTR_DATA_TYPE, statement->err)); if (statement->errcode != OCI_SUCCESS) { - PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get character set form */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->charset_form, (ub4 *)0, OCI_ATTR_CHARSET_FORM, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->charset_form, (ub4 *)0, OCI_ATTR_CHARSET_FORM, statement->err)); if (statement->errcode != OCI_SUCCESS) { - PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get character set id */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->charset_id, (ub4 *)0, OCI_ATTR_CHARSET_ID, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->charset_id, (ub4 *)0, OCI_ATTR_CHARSET_ID, statement->err)); if (statement->errcode != OCI_SUCCESS) { - PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get size of the column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->data_size, (dvoid *)0, OCI_ATTR_DATA_SIZE, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->data_size, (dvoid *)0, OCI_ATTR_DATA_SIZE, statement->err)); if (statement->errcode != OCI_SUCCESS) { - PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; @@ -559,39 +639,39 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) outcol->retlen = 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)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->scale, (dvoid *)0, OCI_ATTR_SCALE, statement->err)); if (statement->errcode != OCI_SUCCESS) { - PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get precision of the column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->precision, (dvoid *)0, OCI_ATTR_PRECISION, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid *)&outcol->precision, (dvoid *)0, OCI_ATTR_PRECISION, statement->err)); if (statement->errcode != OCI_SUCCESS) { - PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } /* get name of the column */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid **)&colname, (ub4 *)&outcol->name_len, (ub4)OCI_ATTR_NAME, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)param, OCI_DTYPE_PARAM, (dvoid **)&colname, (ub4 *)&outcol->name_len, (ub4)OCI_ATTR_NAME, statement->err)); if (statement->errcode != OCI_SUCCESS) { - PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode); return 1; } - PHP_OCI_CALL(OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); + PHP_OCI_CALL(OCIDESCRIPTORFREE, OCIDescriptorFree, (param, OCI_DTYPE_PARAM)); outcol->name = estrndup((char*) colname, outcol->name_len); - /* find a user-setted define */ + /* find a user-set define */ if (statement->defines) { if (zend_hash_find(statement->defines,outcol->name,outcol->name_len,(void **) &outcol->define) == SUCCESS) { if (outcol->define->type) { @@ -679,7 +759,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) } if (dynamic == OCI_DYNAMIC_FETCH) { - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(OCIDEFINEBYPOS, statement->errcode, OCIDefineByPos, ( statement->stmt, /* IN/OUT handle to the requested SQL query */ @@ -697,7 +777,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) ); } else { - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(OCIDEFINEBYPOS, statement->errcode, OCIDefineByPos, ( statement->stmt, /* IN/OUT handle to the requested SQL query */ @@ -729,7 +809,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) case SQLT_BLOB: case SQLT_CLOB: case SQLT_BFILE: - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(OCIDEFINEDYNAMIC, statement->errcode, OCIDefineDynamic, ( outcol->oci_define, @@ -752,10 +832,9 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC) Cancel statement */ int php_oci_statement_cancel(php_oci_statement *statement TSRMLS_DC) { - return php_oci_statement_fetch(statement, 0 TSRMLS_CC); - -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_statement_free() Destroy statement handle and free associated resources */ @@ -763,16 +842,16 @@ void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC) { if (statement->stmt) { if (statement->last_query_len) { /* FIXME: magical */ - PHP_OCI_CALL(OCIStmtRelease, (statement->stmt, statement->err, NULL, 0, statement->errcode ? OCI_STRLS_CACHE_DELETE : OCI_DEFAULT)); - } else { - PHP_OCI_CALL(OCIHandleFree, (statement->stmt, OCI_HTYPE_STMT)); + PHP_OCI_CALL(OCISTMTRELEASE, OCIStmtRelease, (statement->stmt, statement->err, NULL, 0, statement->errcode ? OCI_STRLS_CACHE_DELETE : OCI_DEFAULT)); + } else if (statement->impres_flag != PHP_OCI_IMPRES_IS_CHILD) { /* Oracle doc says don't free Implicit Result Set handles */ + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, (statement->stmt, OCI_HTYPE_STMT)); } - statement->stmt = 0; + statement->stmt = NULL; } if (statement->err) { - PHP_OCI_CALL(OCIHandleFree, (statement->err, OCI_HTYPE_ERROR)); - statement->err = 0; + PHP_OCI_CALL(OCIHANDLEFREE, OCIHandleFree, (statement->err, OCI_HTYPE_ERROR)); + statement->err = NULL; } if (statement->last_query) { @@ -798,11 +877,12 @@ void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC) zend_list_delete(statement->parent_stmtid); } - zend_list_delete(statement->connection->rsrc_id); + zend_list_delete(statement->connection->id); efree(statement); OCI_G(num_statements)--; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_pre_exec() Helper function */ @@ -931,7 +1011,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) memset((void*)buff,0,sizeof(buff)); if ((i < bind->array.old_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) { - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); + PHP_OCI_CALL_RETURN(OCIDATETOTEXT, connection->errcode, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); zval_dtor(*entry); if (connection->errcode != OCI_SUCCESS) { @@ -943,7 +1023,7 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC) } zend_hash_move_forward(hash); } else { - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); + PHP_OCI_CALL_RETURN(OCIDATETOTEXT, connection->errcode, OCIDateToText, (connection->err, &(((OCIDate *)(bind->array.elements))[i]), 0, 0, 0, 0, &buff_len, buff)); if (connection->errcode != OCI_SUCCESS) { connection->errcode = php_oci_error(connection->err, connection->errcode TSRMLS_CC); PHP_OCI_HANDLE_ERROR(connection, connection->errcode); @@ -982,7 +1062,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, ub2 type TSRMLS_DC) +int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, long maxlength, ub2 type TSRMLS_DC) { php_oci_collection *bind_collection = NULL; php_oci_descriptor *bind_descriptor = NULL; @@ -1117,7 +1197,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, bindp->type = type; zval_add_ref(&var); - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(OCIBINDBYNAME, statement->errcode, OCIBindByName, ( statement->stmt, /* statement handle */ @@ -1144,7 +1224,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, } if (mode == OCI_DATA_AT_EXEC) { - PHP_OCI_CALL_RETURN(statement->errcode, OCIBindDynamic, + PHP_OCI_CALL_RETURN(OCIBINDDYNAMIC, statement->errcode, OCIBindDynamic, ( bindp->bind, statement->err, @@ -1164,7 +1244,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, if (type == SQLT_NTY) { /* Bind object */ - PHP_OCI_CALL_RETURN(statement->errcode, OCIBindObject, + PHP_OCI_CALL_RETURN(OCIBINDOBJECT, statement->errcode, OCIBindObject, ( bindp->bind, statement->err, @@ -1184,7 +1264,8 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, } return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_in_callback() Callback used when binding LOBs and VARCHARs */ @@ -1235,7 +1316,8 @@ sb4 php_oci_bind_in_callback( *piecep = OCI_ONE_PIECE; /* pass all data in one go */ return OCI_CONTINUE; -}/* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_out_callback() Callback used when binding LOBs and VARCHARs */ @@ -1358,7 +1440,8 @@ php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAME zval_dtor(&tmp); } return column; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_statement_get_type() Return type of the statement */ @@ -1368,7 +1451,7 @@ int php_oci_statement_get_type(php_oci_statement *statement, ub2 *type TSRMLS_DC *type = 0; - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)&statement_type, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub2 *)&statement_type, (ub4 *)0, OCI_ATTR_STMT_TYPE, statement->err)); if (statement->errcode != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); @@ -1379,7 +1462,8 @@ int php_oci_statement_get_type(php_oci_statement *statement, ub2 *type TSRMLS_DC *type = statement_type; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_statement_get_numrows() Get the number of rows fetched to the clientside (NOT the number of rows in the result set) */ @@ -1389,7 +1473,7 @@ int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows TSR *numrows = 0; - PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub4 *)&statement_numrows, (ub4 *)0, OCI_ATTR_ROW_COUNT, statement->err)); + PHP_OCI_CALL_RETURN(OCIATTRGET, statement->errcode, OCIAttrGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, (ub4 *)&statement_numrows, (ub4 *)0, OCI_ATTR_ROW_COUNT, statement->err)); if (statement->errcode != OCI_SUCCESS) { statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC); @@ -1400,11 +1484,12 @@ int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows TSR *numrows = statement_numrows; return 0; -} /* }}} */ +} +/* }}} */ /* {{{ 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, char *name, int name_len, zval *var, long max_table_length, long maxlength, long type TSRMLS_DC) { php_oci_bind *bind, *bindp; @@ -1470,7 +1555,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam zval_add_ref(&var); - PHP_OCI_CALL_RETURN(statement->errcode, + PHP_OCI_CALL_RETURN(OCIBINDBYNAME, statement->errcode, OCIBindByName, ( statement->stmt, @@ -1499,11 +1584,12 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam } efree(bind); return 0; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_helper_string() Bind arrays to PL/SQL types */ -php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, long maxlength TSRMLS_DC) +php_oci_bind *php_oci_bind_array_helper_string(zval *var, long max_table_length, long maxlength TSRMLS_DC) { php_oci_bind *bind; ub4 i; @@ -1568,11 +1654,12 @@ php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length, zend_hash_internal_pointer_reset(hash); return bind; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_helper_number() Bind arrays to PL/SQL types */ -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_number(zval *var, long max_table_length TSRMLS_DC) { php_oci_bind *bind; ub4 i; @@ -1606,11 +1693,12 @@ php_oci_bind *php_oci_bind_array_helper_number(zval* var, long max_table_length zend_hash_internal_pointer_reset(hash); return bind; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_helper_double() Bind arrays to PL/SQL types */ -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_double(zval *var, long max_table_length TSRMLS_DC) { php_oci_bind *bind; ub4 i; @@ -1644,11 +1732,12 @@ php_oci_bind *php_oci_bind_array_helper_double(zval* var, long max_table_length zend_hash_internal_pointer_reset(hash); return bind; -} /* }}} */ +} +/* }}} */ /* {{{ php_oci_bind_array_helper_date() Bind arrays to PL/SQL types */ -php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, php_oci_connection *connection TSRMLS_DC) +php_oci_bind *php_oci_bind_array_helper_date(zval *var, long max_table_length, php_oci_connection *connection TSRMLS_DC) { php_oci_bind *bind; ub4 i; @@ -1675,7 +1764,7 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p if ((i < bind->array.current_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) { convert_to_string_ex(entry); - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (CONST text *)Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(OCIDATEFROMTEXT, connection->errcode, OCIDateFromText, (connection->err, (CONST text *)Z_STRVAL_PP(entry), Z_STRLEN_PP(entry), NULL, 0, NULL, 0, &oci_date)); if (connection->errcode != OCI_SUCCESS) { /* failed to convert string to date */ @@ -1690,7 +1779,7 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p ((OCIDate *)bind->array.elements)[i] = oci_date; zend_hash_move_forward(hash); } else { - PHP_OCI_CALL_RETURN(connection->errcode, OCIDateFromText, (connection->err, (CONST text *)"01-JAN-00", sizeof("01-JAN-00")-1, NULL, 0, NULL, 0, &oci_date)); + PHP_OCI_CALL_RETURN(OCIDATEFROMTEXT, connection->errcode, OCIDateFromText, (connection->err, (CONST text *)"01-JAN-00", sizeof("01-JAN-00")-1, NULL, 0, NULL, 0, &oci_date)); if (connection->errcode != OCI_SUCCESS) { /* failed to convert string to date */ @@ -1708,7 +1797,8 @@ php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, p zend_hash_internal_pointer_reset(hash); return bind; -} /* }}} */ +} +/* }}} */ #endif /* HAVE_OCI8 */ diff --git a/ext/oci8/package.xml b/ext/oci8/package.xml index feadf1907b..38bb5d4b4e 100644 --- a/ext/oci8/package.xml +++ b/ext/oci8/package.xml @@ -6,7 +6,14 @@ http://pear.php.net/dtd/package-2.0.xsd"> <name>oci8</name> <channel>pecl.php.net</channel> <summary>Extension for Oracle Database</summary> - <description>This extension allows you to access Oracle databases. It can be built with PHP 4.3.9 to 5.x. It can be linked with Oracle 9.2, 10, 11, or 12.1 client libraries. + + <description> + This extension allows you to access Oracle Database. OCI8 2.0 can be + built with PHP 5.4 onwards. (OCI8 1.4 can be built with PHP 4.3.9 + onwards). OCI8 can be linked with Oracle Database 9.2, 10, 11, or + 12.1 client libraries. Oracle's standard cross-version connectivity + applies. For example PHP linked with Oracle Database 11.2 client + libraries can connect to Oracle Database 9.2 onwards. </description> <lead> <name>Christopher Jones</name> @@ -18,7 +25,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> <name>Antony Dovgal</name> <user>tony2001</user> <email>tony2001@php.net</email> - <active>yes</active> + <active>no</active> </lead> <lead> <name>Wez Furlong</name> @@ -33,21 +40,83 @@ http://pear.php.net/dtd/package-2.0.xsd"> <active>no</active> </lead> - <date>2013-07-08</date> + <date>2013-07-24</date> <time>12:00:00</time> - <version> - <release>1.4.10</release> - <api>1.4.10</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <license uri="http://www.php.net/license">PHP</license> - <notes> - Bump PECL package info version check to allow PECL installs with PHP 5.5+ - </notes> + <version> + <release>2.0.0</release> + <api>2.0.0</api> + </version> + <stability> + <release>devel</release> + <api>devel</api> + </stability> + <license uri="http://www.php.net/license">PHP</license> + <notes> + - NEW FUNCTIONALITY: + + - Added Implicit Result Set support for Oracle Database 12c. + Streaming of all IRS's returned from a PL/SQL block is available + via oci_fetch_array, oci_fetch_assoc, oci_fetch_object and + oci_fetch_row (but not oci_fetch or oci_fetch_all). + Alternatively individual IRS statement resources can be obtained + with the new function 'oci_get_implicit_resultset' and passed to + any oci_fetch_* function. + + - Added DTrace probes enabled with PHP's generic --enable-dtrace + + - IMPROVED FUNCTIONALITY: + + - Using 'oci_execute($s, OCI_NO_AUTO_COMMIT)' for a SELECT no + longer unnecessarily initiates an internal ROLLBACK during + connection close. This can improve overall scalability by + reducing "round trips" between PHP and the database. + + - CHANGED FUNCTIONALITY: + + - PHPINFO() CHANGES: + + - The oci8.event and oci8.connection_class values are now shown + only when the Oracle client libraries support the respective + functionality. + + - Connection statistics are now in a separate phpinfo() table. + + - Temporary LOB and Collection support status lines in + phpinfo() were removed. These features have always been + enabled since 2007. + + - OCI_INTERNAL_DEBUG() CHANGES: + + - The oci_internal_debug() function is now a no-op. Use PHP's + --enable-dtrace functionality with DTrace or SystemTap instead. + + - INTERNAL CHANGES: + + - Fixed a potential NULL pointer dereference flagged by Parfait + static code analyis. + + - Extended testing of existing OCI8 functionality. + + - Improved test output portability when using the PHP development + web server to run tests. + + - Removed no-longer necessary unicode patterns from tests + (vestiges of PHP's previous PHP 6 project) + + - Improved build portability by removing compilation type cast + warnings with some compilers. + + - Fixed compilation warnings when building with Oracle 9.2 + client libraries. + + - Updated code to use internal macro PHP_OCI_REGISTER_RESOURCE. + + - Regularized code prototypes and fixed some in-line documenation + prototypes. + + - Fixed code folding. + </notes> <contents> <dir name="/"> <dir name="tests"> @@ -94,6 +163,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> <file name="bind_misccoltypes.phpt" role="test" /> <file name="bind_number.phpt" role="test" /> <file name="bind_query.phpt" role="test" /> + <file name="bind_raw_2.phpt" role="test" /> <file name="bind_raw.phpt" role="test" /> <file name="bind_rowid.phpt" role="test" /> <file name="bind_sqltafc.phpt" role="test" /> @@ -287,6 +357,38 @@ http://pear.php.net/dtd/package-2.0.xsd"> <file name="field_funcs_old.phpt" role="test" /> <file name="field_funcs.phpt" role="test" /> <file name="function_aliases.phpt" role="test" /> + <file name="imp_res_1.phpt" role="test" /> + <file name="imp_res_2.phpt" role="test" /> + <file name="imp_res_3.phpt" role="test" /> + <file name="imp_res_4.phpt" role="test" /> + <file name="imp_res_5.phpt" role="test" /> + <file name="imp_res_6.phpt" role="test" /> + <file name="imp_res_7.phpt" role="test" /> + <file name="imp_res_call_error.phpt" role="test" /> + <file name="imp_res_cancel.phpt" role="test" /> + <file name="imp_res_close.phpt" role="test" /> + <file name="imp_res_cursor.phpt" role="test" /> + <file name="imp_res_dbmsoutput.phpt" role="test" /> + <file name="imp_res_field.phpt" role="test" /> + <file name="imp_res_func_error.phpt" role="test" /> + <file name="imp_res_get_1.phpt" role="test" /> + <file name="imp_res_get_2.phpt" role="test" /> + <file name="imp_res_get_3.phpt" role="test" /> + <file name="imp_res_get_4.phpt" role="test" /> + <file name="imp_res_get_5.phpt" role="test" /> + <file name="imp_res_get_all.phpt" role="test" /> + <file name="imp_res_get_cancel.phpt" role="test" /> + <file name="imp_res_get_close_1.phpt" role="test" /> + <file name="imp_res_get_close_2.phpt" role="test" /> + <file name="imp_res_get_close_3.phpt" role="test" /> + <file name="imp_res_get_cursor.phpt" role="test" /> + <file name="imp_res_get_dbmsoutput.phpt" role="test" /> + <file name="imp_res_get_exec.phpt" role="test" /> + <file name="imp_res_get_none.phpt" role="test" /> + <file name="imp_res_insert.phpt" role="test" /> + <file name="imp_res_lob.phpt" role="test" /> + <file name="imp_res_prefetch.phpt" role="test" /> + <file name="ini_1.phpt" role="test" /> <file name="lob_001.phpt" role="test" /> <file name="lob_002.phpt" role="test" /> <file name="lob_003.phpt" role="test" /> @@ -335,6 +437,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> <file name="lob_aliases.phpt" role="test" /> <file name="lob_null.phpt" role="test" /> <file name="lob_temp1.phpt" role="test" /> + <file name="lob_temp2.phpt" role="test" /> <file name="lob_temp.phpt" role="test" /> <file name="minfo.phpt" role="test" /> <file name="null_byte_1.phpt" role="test" /> @@ -383,13 +486,14 @@ http://pear.php.net/dtd/package-2.0.xsd"> <file name="config.w32" role="src" /> <file name="CREDITS" role="doc" /> <file name="oci8.c" role="src" /> - <file name="oci8.dsp" role="src" /> + <file name="oci8_dtrace.d" role="src" /> <file name="oci8_collection.c" role="src" /> <file name="oci8_interface.c" role="src" /> <file name="oci8_lob.c" role="src" /> <file name="oci8_statement.c" role="src" /> <file name="php_oci8.h" role="src" /> <file name="php_oci8_int.h" role="src" /> + <file name="oci8.dsp" role="src" /> <file name="README" role="doc" /> </dir> <!-- / --> </contents> @@ -412,6 +516,21 @@ http://pear.php.net/dtd/package-2.0.xsd"> <release> <version> + <release>1.4.10</release> + <api>1.4.10</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <license uri="http://www.php.net/license">PHP</license> + <notes> + Bump PECL package info version check to allow PECL installs with PHP 5.5+ + </notes> +</release> + +<release> + <version> <release>1.4.9</release> <api>1.4.9</api> </version> @@ -457,7 +576,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> Fixed OCI8 part of bug #55748 (CVE-2011-4153: multiple NULL pointer dereferences with zend_strndup) Fixed OCI8 part of bug #55301 (multiple null pointer dereferences with calloc) Increased maximum Oracle error message buffer length for new Oracle 11.2.0.3 size - Improve internal initalization failure error messages + Improve internal initialization failure error messages </notes> </release> @@ -472,7 +591,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> </stability> <license uri="http://www.php.net/license">PHP</license> <notes> - Added oci_client_version() returning the runtime Oracle client library version + Added oci_client_version() returning the run time Oracle client library version Made OCI8 extension buildable with PHP 5.4-development code </notes> </release> @@ -846,7 +965,7 @@ Fixed bug #36820 (Privileged connection with an Oracle password file fails) <date>2006-03-16</date> <license uri="http://www.php.net/license">PHP</license> <notes>Changed OCI8 code to use OCIServerVersion() instead of OCIPing(), which may crash Oracle server of version < 10.2 -Fixed bug #36235 (ocicolumnname returns false before a successfull fetch) +Fixed bug #36235 (ocicolumnname returns false before a successful fetch) Fixed bug #36096 (oci_result() returns garbage after oci_fetch() failed) Fixed bug #36055 (possible OCI8 crash in multithreaded environment) Fixed bug #36010 (Segfault when re-creating and re-executing statements with bound parameters) diff --git a/ext/oci8/php_oci8.h b/ext/oci8/php_oci8.h index f1079526f6..d1fe087792 100644 --- a/ext/oci8/php_oci8.h +++ b/ext/oci8/php_oci8.h @@ -46,7 +46,7 @@ */ #undef PHP_OCI8_VERSION #endif -#define PHP_OCI8_VERSION "1.4.10" +#define PHP_OCI8_VERSION "2.0.0-dev" extern zend_module_entry oci8_module_entry; #define phpext_oci8_ptr &oci8_module_entry diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h index 155e57d2cd..98c236893e 100644 --- a/ext/oci8/php_oci8_int.h +++ b/ext/oci8/php_oci8_int.h @@ -31,7 +31,7 @@ # ifndef PHP_OCI8_INT_H # define PHP_OCI8_INT_H -/* misc defines {{{ */ +/* {{{ misc defines */ # if (defined(__osf__) && defined(__alpha)) # ifndef A_OSF # define A_OSF @@ -44,6 +44,10 @@ # endif # endif /* osf alpha */ +#ifdef HAVE_DTRACE +#include "oci8_dtrace_gen.h" +#endif + #if defined(min) #undef min #endif @@ -66,7 +70,7 @@ extern int le_session; extern zend_class_entry *oci_lob_class_entry_ptr; extern zend_class_entry *oci_coll_class_entry_ptr; -/* constants {{{ */ +/* {{{ constants */ #define PHP_OCI_SEEK_SET 0 #define PHP_OCI_SEEK_CUR 1 #define PHP_OCI_SEEK_END 2 @@ -101,6 +105,11 @@ extern zend_class_entry *oci_coll_class_entry_ptr; #error Invalid value for PHP_OCI_CRED_EXT #endif +#define PHP_OCI_IMPRES_UNKNOWN 0 +#define PHP_OCI_IMPRES_NO_CHILDREN 1 +#define PHP_OCI_IMPRES_HAS_CHILDREN 2 +#define PHP_OCI_IMPRES_IS_CHILD 3 + /* * Name passed to Oracle for tracing. Note some DB views only show * the first nine characters of the driver name. @@ -109,16 +118,21 @@ extern zend_class_entry *oci_coll_class_entry_ptr; /* }}} */ -typedef struct { /* php_oci_spool {{{ */ - OCIEnv *env; /*env of this session pool */ +/* {{{ php_oci_spool */ +typedef struct { + int id; /* resource id */ + OCIEnv *env; /* env of this session pool */ OCIError *err; /* pool's error handle */ OCISPool *poolh; /* pool handle */ void *poolname; /* session pool name */ unsigned int poolname_len; /* length of session pool name */ char *spool_hash_key; /* Hash key for session pool in plist */ -} php_oci_spool; /* }}} */ +} php_oci_spool; +/* }}} */ -typedef struct { /* php_oci_connection {{{ */ +/* {{{ php_oci_connection */ +typedef struct { + int id; /* resource ID */ OCIEnv *env; /* private env handle */ ub2 charset; /* charset ID */ OCIServer *server; /* private server handle */ @@ -135,17 +149,18 @@ typedef struct { /* php_oci_connection {{{ */ unsigned is_attached:1; /* hels to determine if we should detach from the server when closing/freeing the connection */ unsigned is_persistent:1; /* self-descriptive */ unsigned used_this_request:1; /* helps to determine if we should reset connection's next ping time and check its timeout */ - unsigned needs_commit:1; /* helps to determine if we should rollback this connection on close/shutdown */ + unsigned rb_on_disconnect:1; /* helps to determine if we should rollback this connection on close/shutdown */ unsigned passwd_changed:1; /* helps determine if a persistent connection hash should be invalidated after a password change */ unsigned is_stub:1; /* flag to keep track whether the connection structure has a real OCI connection associated */ unsigned using_spool:1; /* Is this connection from session pool? */ - int rsrc_id; /* resource ID */ time_t idle_expiry; /* time when the connection will be considered as expired */ time_t *next_pingp; /* (pointer to) time of the next ping */ char *hash_key; /* hashed details of the connection */ -} php_oci_connection; /* }}} */ +} php_oci_connection; +/* }}} */ -typedef struct { /* php_oci_descriptor {{{ */ +/* {{{ php_oci_descriptor */ +typedef struct { int id; ulong index; /* descriptors hash table index */ php_oci_connection *connection; /* parent connection handle */ @@ -158,15 +173,19 @@ typedef struct { /* php_oci_descriptor {{{ */ ub1 charset_form; /* charset form, required for NCLOBs */ ub2 charset_id; /* charset ID */ unsigned is_open:1; /* helps to determine if lob is open or not */ -} php_oci_descriptor; /* }}} */ +} php_oci_descriptor; +/* }}} */ -typedef struct { /* php_oci_lob_ctx {{{ */ +/* {{{ php_oci_lob_ctx */ +typedef struct { char **lob_data; /* address of pointer to LOB data */ ub4 *lob_len; /* address of LOB length variable (bytes) */ ub4 alloc_len; -} php_oci_lob_ctx; /* }}} */ +} php_oci_lob_ctx; +/* }}} */ -typedef struct { /* php_oci_collection {{{ */ +/* {{{ php_oci_collection */ +typedef struct { int id; php_oci_connection *connection; /* parent connection handle */ OCIType *tdo; /* collection's type handle */ @@ -175,23 +194,30 @@ typedef struct { /* php_oci_collection {{{ */ OCIType *element_type; /* element's type handle */ OCITypeCode element_typecode; /* element's typecode handle */ OCIColl *collection; /* collection handle */ -} php_oci_collection; /* }}} */ +} php_oci_collection; +/* }}} */ -typedef struct { /* php_oci_define {{{ */ +/* {{{ php_oci_define */ +typedef struct { zval *zval; /* zval used in define */ text *name; /* placeholder's name */ ub4 name_len; /* placeholder's name length */ ub4 type; /* define type */ -} php_oci_define; /* }}} */ +} php_oci_define; +/* }}} */ -typedef struct { /* php_oci_statement {{{ */ +/* {{{ php_oci_statement */ +typedef struct { int id; int parent_stmtid; /* parent statement id */ + struct php_oci_statement *impres_child_stmt; /* child of current Implicit Result Set statement handle */ + ub4 impres_count; /* count of remaining Implicit Result children on parent statement handle */ php_oci_connection *connection; /* parent connection handle */ sword errcode; /* last errcode*/ OCIError *err; /* private error handle */ OCIStmt *stmt; /* statement handle */ - char *last_query; /* last query issued. also used to determine if this is a statement or a refcursor received from Oracle */ + char *last_query; /* last query issued. also used to determine if this is a statement or a refcursor recieved from Oracle */ + char impres_flag; /* PHP_OCI_IMPRES_*_ */ long last_query_len; /* last query length */ HashTable *columns; /* hash containing all the result columns */ HashTable *binds; /* binds hash */ @@ -201,9 +227,11 @@ typedef struct { /* php_oci_statement {{{ */ unsigned has_data:1; /* statement has more data flag */ unsigned has_descr:1; /* statement has at least one descriptor or cursor column */ ub2 stmttype; /* statement type */ -} php_oci_statement; /* }}} */ +} php_oci_statement; +/* }}} */ -typedef struct { /* php_oci_bind {{{ */ +/* {{{ php_oci_bind */ +typedef struct { OCIBind *bind; /* bind handle */ zval *zval; /* value */ dvoid *descriptor; /* used for binding of LOBS etc */ @@ -222,9 +250,11 @@ typedef struct { /* php_oci_bind {{{ */ sb2 indicator; /* -1 means NULL */ ub2 retcode; ub4 dummy_len; /* a dummy var to store alenpp value in bind OUT callback */ -} php_oci_bind; /* }}} */ +} php_oci_bind; +/* }}} */ -typedef struct { /* php_oci_out_column {{{ */ +/* {{{ php_oci_out_column */ +typedef struct { php_oci_statement *statement; /* statement handle. used when fetching REFCURSORS */ php_oci_statement *nested_statement; /* statement handle. used when fetching REFCURSORS */ OCIDefine *oci_define; /* define handle */ @@ -249,29 +279,54 @@ typedef struct { /* php_oci_out_column {{{ */ sb2 precision; /* column precision */ ub1 charset_form; /* charset form, required for NCLOBs */ ub2 charset_id; /* charset ID */ -} php_oci_out_column; /* }}} */ +} php_oci_out_column; +/* }}} */ /* {{{ macros */ -#define PHP_OCI_CALL(func, params) \ - do { \ - if (OCI_G(debug_mode)) { \ - php_printf ("OCI8 DEBUG: " #func " at (%s:%d) \n", __FILE__, __LINE__); \ - } \ - OCI_G(in_call) = 1; \ - func params; \ - OCI_G(in_call) = 0; \ +#ifdef HAVE_DTRACE +#define PHP_OCI_CALL(func_uc, func, params) \ + do { \ + if (DTRACE_OCI8_ ## func_uc ## _START_ENABLED()) { \ + DTRACE_OCI8_ ## func_uc ## _START(); \ + } \ + OCI_G(in_call) = 1; \ + func params; \ + OCI_G(in_call) = 0; \ + if (DTRACE_OCI8_ ## func_uc ## _DONE_ENABLED()) { \ + DTRACE_OCI8_ ## func_uc ## _DONE(); \ + } \ } while (0) - -#define PHP_OCI_CALL_RETURN(__retval, func, params) \ - do { \ - if (OCI_G(debug_mode)) { \ - php_printf ("OCI8 DEBUG: " #func " at (%s:%d) \n", __FILE__, __LINE__); \ - } \ - OCI_G(in_call) = 1; \ - __retval = func params; \ - OCI_G(in_call) = 0; \ +#else /* HAVE_DTRACE */ +#define PHP_OCI_CALL(func_uc, func, params) \ + do { \ + OCI_G(in_call) = 1; \ + func params; \ + OCI_G(in_call) = 0; \ } while (0) +#endif /* HAVE_DTRACE */ + +#ifdef HAVE_DTRACE +#define PHP_OCI_CALL_RETURN(func_uc, __retval, func, params) \ + do { \ + if (DTRACE_OCI8_ ## func_uc ## _START_ENABLED()) { \ + DTRACE_OCI8_ ## func_uc ## _START(); \ + } \ + OCI_G(in_call) = 1; \ + __retval = func params; \ + OCI_G(in_call) = 0; \ + if (DTRACE_OCI8_ ## func_uc ## _DONE_ENABLED()) { \ + DTRACE_OCI8_ ## func_uc ## _DONE(); \ + } \ + } while (0) +#else /* HAVE_DTRACE */ +#define PHP_OCI_CALL_RETURN(func_uc, __retval, func, params) \ + do { \ + OCI_G(in_call) = 1; \ + __retval = func params; \ + OCI_G(in_call) = 0; \ + } while (0) +#endif /* HAVE_DTRACE */ /* Check for errors that indicate the connection to the DB is no * longer valid. If it isn't, then the PHP connection is marked to be @@ -314,7 +369,7 @@ typedef struct { /* php_oci_out_column {{{ */ default: \ { \ ub4 serverStatus = OCI_SERVER_NORMAL; \ - PHP_OCI_CALL(OCIAttrGet, ((dvoid *)(connection)->server, OCI_HTYPE_SERVER, (dvoid *)&serverStatus, \ + PHP_OCI_CALL(OCIATTRGET, OCIAttrGet, ((dvoid *)(connection)->server, OCI_HTYPE_SERVER, (dvoid *)&serverStatus, \ (ub4 *)0, OCI_ATTR_SERVER_STATUS, (connection)->err)); \ if (serverStatus != OCI_SERVER_NORMAL) { \ (connection)->is_open = 0; \ @@ -365,112 +420,106 @@ typedef struct { /* php_oci_out_column {{{ */ /* PROTOS */ -/* main prototypes {{{ */ - -void php_oci_column_hash_dtor (void *data); -void php_oci_define_hash_dtor (void *data); -void php_oci_bind_hash_dtor (void *data); -void php_oci_descriptor_flush_hash_dtor (void *data); +/* {{{ main prototypes */ +void php_oci_column_hash_dtor(void *data); +void php_oci_define_hash_dtor(void *data); +void php_oci_bind_hash_dtor(void *data); +void php_oci_descriptor_flush_hash_dtor(void *data); void php_oci_connection_descriptors_free(php_oci_connection *connection TSRMLS_DC); - -sb4 php_oci_error (OCIError *, sword TSRMLS_DC); -sb4 php_oci_fetch_errmsg(OCIError *, text ** TSRMLS_DC); -int php_oci_fetch_sqltext_offset(php_oci_statement *, text **, ub2 * TSRMLS_DC); - -void php_oci_do_connect (INTERNAL_FUNCTION_PARAMETERS, int , int); +sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC); +sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC); +int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, ub2 *error_offset TSRMLS_DC); +void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclusive); 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); - -int php_oci_connection_rollback(php_oci_connection * TSRMLS_DC); -int php_oci_connection_commit(php_oci_connection * TSRMLS_DC); +int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC); +int php_oci_connection_commit(php_oci_connection *connection TSRMLS_DC); int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC); - -int php_oci_password_change(php_oci_connection *, char *, int, char *, int, char *, int TSRMLS_DC); -void php_oci_client_get_version(char ** TSRMLS_DC); -int php_oci_server_get_version(php_oci_connection *, char ** 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); +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); +void php_oci_client_get_version(char **version TSRMLS_DC); +int php_oci_server_get_version(php_oci_connection *connection, char **version TSRMLS_DC); +void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args); +int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSRMLS_DC); /* }}} */ -/* lob related prototypes {{{ */ - -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_flush (php_oci_descriptor *, long 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); -int php_oci_lob_close (php_oci_descriptor * TSRMLS_DC); -int php_oci_temp_lob_close (php_oci_descriptor * TSRMLS_DC); -int php_oci_lob_write_tmp (php_oci_descriptor *, long, char *, int TSRMLS_DC); -void php_oci_lob_free(php_oci_descriptor * TSRMLS_DC); -int php_oci_lob_import(php_oci_descriptor *descriptor, char * TSRMLS_DC); -int php_oci_lob_append (php_oci_descriptor *, php_oci_descriptor * TSRMLS_DC); -int php_oci_lob_truncate (php_oci_descriptor *, long TSRMLS_DC); -int php_oci_lob_erase (php_oci_descriptor *, long, ub4, ub4 * TSRMLS_DC); -int php_oci_lob_is_equal (php_oci_descriptor *, php_oci_descriptor *, boolean * TSRMLS_DC); +/* {{{ lob related prototypes */ + +php_oci_descriptor *php_oci_lob_create(php_oci_connection *connection, long type TSRMLS_DC); +int php_oci_lob_get_length(php_oci_descriptor *descriptor, ub4 *length TSRMLS_DC); +int php_oci_lob_read(php_oci_descriptor *descriptor, long read_length, long inital_offset, char **data, ub4 *data_len TSRMLS_DC); +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_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC); +int php_oci_lob_set_buffering(php_oci_descriptor *descriptor, int on_off TSRMLS_DC); +int php_oci_lob_get_buffering(php_oci_descriptor *descriptor); +int php_oci_lob_copy(php_oci_descriptor *descriptor, php_oci_descriptor *descriptor_from, long length TSRMLS_DC); +int php_oci_lob_close(php_oci_descriptor *descriptor TSRMLS_DC); +int php_oci_temp_lob_close(php_oci_descriptor *descriptor TSRMLS_DC); +int php_oci_lob_write_tmp(php_oci_descriptor *descriptor, long type, char *data, int data_len TSRMLS_DC); +void php_oci_lob_free(php_oci_descriptor *descriptor TSRMLS_DC); +int php_oci_lob_import(php_oci_descriptor *descriptor, char *filename TSRMLS_DC); +int php_oci_lob_append(php_oci_descriptor *descriptor_dest, php_oci_descriptor *descriptor_from TSRMLS_DC); +int php_oci_lob_truncate(php_oci_descriptor *descriptor, long new_lob_length TSRMLS_DC); +int php_oci_lob_erase(php_oci_descriptor *descriptor, long offset, ub4 length, ub4 *bytes_erased TSRMLS_DC); +int php_oci_lob_is_equal(php_oci_descriptor *descriptor_first, php_oci_descriptor *descriptor_second, boolean *result TSRMLS_DC); #if defined(HAVE_OCI_LOB_READ2) -sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece, dvoid **changed_bufpp, oraub8 *changed_lenp); +sb4 php_oci_lob_callback(dvoid *ctxp, CONST dvoid *bufxp, oraub8 len, ub1 piece, dvoid **changed_bufpp, oraub8 *changed_lenp); #else -sb4 php_oci_lob_callback (dvoid *ctxp, CONST dvoid *bufxp, ub4 len, ub1 piece); +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); -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_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_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_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); +/* {{{ collection related prototypes */ + +php_oci_collection *php_oci_collection_create(php_oci_connection *connection, char *tdo, int tdo_len, char *schema, int schema_len TSRMLS_DC); +int php_oci_collection_size(php_oci_collection *collection, sb4 *size TSRMLS_DC); +int php_oci_collection_max(php_oci_collection *collection, long *max TSRMLS_DC); +int php_oci_collection_trim(php_oci_collection *collection, long trim_size TSRMLS_DC); +int php_oci_collection_append(php_oci_collection *collection, char *element, int element_len TSRMLS_DC); +int php_oci_collection_element_get(php_oci_collection *collection, long index, zval **result_element TSRMLS_DC); +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_null(php_oci_collection *collection, long index TSRMLS_DC); +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_number(php_oci_collection *collection, long index, char *number, int number_len TSRMLS_DC); +int php_oci_collection_element_set_string(php_oci_collection *collection, long index, char *element, int element_len TSRMLS_DC); +int php_oci_collection_assign(php_oci_collection *collection_dest, php_oci_collection *collection_from TSRMLS_DC); +void php_oci_collection_close(php_oci_collection *collection TSRMLS_DC); +int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC); +int php_oci_collection_append_date(php_oci_collection *collection, char *date, int date_len TSRMLS_DC); +int php_oci_collection_append_number(php_oci_collection *collection, char *number, int number_len TSRMLS_DC); +int php_oci_collection_append_string(php_oci_collection *collection, char *element, int element_len TSRMLS_DC); /* }}} */ -/* statement related prototypes {{{ */ +/* {{{ statement related prototypes */ -php_oci_statement * php_oci_statement_create (php_oci_connection *, char *, int TSRMLS_DC); -int php_oci_statement_set_prefetch (php_oci_statement *, long TSRMLS_DC); -int php_oci_statement_fetch (php_oci_statement *, ub4 TSRMLS_DC); -php_oci_out_column * php_oci_statement_get_column (php_oci_statement *, long, char *, 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); +php_oci_statement *php_oci_statement_create(php_oci_connection *connection, char *query, int query_len TSRMLS_DC); +php_oci_statement *php_oci_get_implicit_resultset(php_oci_statement *statement TSRMLS_DC); +int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRMLS_DC); +int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC); +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); +int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC); +int php_oci_statement_cancel(php_oci_statement *statement TSRMLS_DC); +void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC); int php_oci_bind_pre_exec(void *data, void *result 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, ub2 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 **); +int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval *var, long maxlength, ub2 type TSRMLS_DC); +sb4 php_oci_bind_in_callback(dvoid *ictxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 *alenp, ub1 *piecep, dvoid **indpp); +sb4 php_oci_bind_out_callback(dvoid *octxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 **alenpp, ub1 *piecep, dvoid **indpp, ub2 **rcodepp); php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAMETERS, int need_data); int php_oci_cleanup_pre_fetch(void *data TSRMLS_DC); - -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); -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); -php_oci_bind *php_oci_bind_array_helper_date(zval* var, long max_table_length, php_oci_connection *connection TSRMLS_DC); +int php_oci_statement_get_type(php_oci_statement *statement, ub2 *type TSRMLS_DC); +int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows 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); +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); +php_oci_bind *php_oci_bind_array_helper_date(zval *var, long max_table_length, php_oci_connection *connection TSRMLS_DC); /* }}} */ -ZEND_BEGIN_MODULE_GLOBALS(oci) /* {{{ */ +ZEND_BEGIN_MODULE_GLOBALS(oci) /* {{{ Module globals */ sword errcode; /* global last error code (used when connect fails, for example) */ OCIError *err; /* global error handle */ diff --git a/ext/oci8/tests/bind_char_1.phpt b/ext/oci8/tests/bind_char_1.phpt index 91fa4b75b7..d68991a7f2 100644 --- a/ext/oci8/tests/bind_char_1.phpt +++ b/ext/oci8/tests/bind_char_1.phpt @@ -5,12 +5,15 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { - die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bind_char_1_11gR1.phpt b/ext/oci8/tests/bind_char_1_11gR1.phpt index a7feff9f6a..2a7c713aa7 100644 --- a/ext/oci8/tests/bind_char_1_11gR1.phpt +++ b/ext/oci8/tests/bind_char_1_11gR1.phpt @@ -5,10 +5,12 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] == 1) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } ?> --ENV-- diff --git a/ext/oci8/tests/bind_char_2.phpt b/ext/oci8/tests/bind_char_2.phpt index 43661a065d..3695c85854 100644 --- a/ext/oci8/tests/bind_char_2.phpt +++ b/ext/oci8/tests/bind_char_2.phpt @@ -5,12 +5,15 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { - die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bind_char_2_11gR1.phpt b/ext/oci8/tests/bind_char_2_11gR1.phpt index edb2a12ff0..b9afd6940b 100644 --- a/ext/oci8/tests/bind_char_2_11gR1.phpt +++ b/ext/oci8/tests/bind_char_2_11gR1.phpt @@ -5,10 +5,12 @@ SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] == 1) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } ?> --ENV-- diff --git a/ext/oci8/tests/bind_char_3.phpt b/ext/oci8/tests/bind_char_3.phpt index 25115836df..009e60a542 100644 --- a/ext/oci8/tests/bind_char_3.phpt +++ b/ext/oci8/tests/bind_char_3.phpt @@ -5,12 +5,15 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { - die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bind_char_3_11gR1.phpt b/ext/oci8/tests/bind_char_3_11gR1.phpt index fea77754d1..a894de00c0 100644 --- a/ext/oci8/tests/bind_char_3_11gR1.phpt +++ b/ext/oci8/tests/bind_char_3_11gR1.phpt @@ -5,10 +5,12 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] == 1) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } ?> --ENV-- diff --git a/ext/oci8/tests/bind_char_4.phpt b/ext/oci8/tests/bind_char_4.phpt index 36765f8137..0ac60e503d 100644 --- a/ext/oci8/tests/bind_char_4.phpt +++ b/ext/oci8/tests/bind_char_4.phpt @@ -5,12 +5,15 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 2) { - die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bind_char_4_11gR1.phpt b/ext/oci8/tests/bind_char_4_11gR1.phpt index 2bc2f14246..d5ce116afb 100644 --- a/ext/oci8/tests/bind_char_4_11gR1.phpt +++ b/ext/oci8/tests/bind_char_4_11gR1.phpt @@ -5,10 +5,12 @@ PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 11\.1\./', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] == 1) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 11gR1 or 11.2.0.3 databases"); } ?> --ENV-- diff --git a/ext/oci8/tests/bind_unsupported_2.phpt b/ext/oci8/tests/bind_unsupported_2.phpt index d3e5375df6..a2bf9de5a6 100644 --- a/ext/oci8/tests/bind_unsupported_2.phpt +++ b/ext/oci8/tests/bind_unsupported_2.phpt @@ -3,7 +3,8 @@ Bind with various unsupported 10g+ bind types --SKIPIF-- <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); -if (preg_match('/^1[01]\./', oci_client_version()) !== 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die ("skip expected output only valid for Oracle 10g+ clients"); } ?> diff --git a/ext/oci8/tests/bug27303_1.phpt b/ext/oci8/tests/bug27303_1.phpt index 40ab4ebed2..0ef47f13dd 100644 --- a/ext/oci8/tests/bug27303_1.phpt +++ b/ext/oci8/tests/bug27303_1.phpt @@ -5,12 +5,15 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && - preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); - // Other point releases may also work +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] >= 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bug27303_1_11gR1.phpt b/ext/oci8/tests/bug27303_1_11gR1.phpt index 6de9b99378..7b4c158561 100644 --- a/ext/oci8/tests/bug27303_1_11gR1.phpt +++ b/ext/oci8/tests/bug27303_1_11gR1.phpt @@ -5,12 +5,13 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using specific Oracle database versions"); - } - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) || + ($matches[1] == 11 && $matches[2] == 1 && $matches[3] == 0 && $matches[4] == 6) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using Oracle 10gR2 or 11.2.0.2 databases"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug27303_2.phpt b/ext/oci8/tests/bug27303_2.phpt index 1fb2b31682..72d4e5a7dd 100644 --- a/ext/oci8/tests/bug27303_2.phpt +++ b/ext/oci8/tests/bug27303_2.phpt @@ -5,12 +5,15 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && - preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); - // Other point releases may also work +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bug27303_2_11gR1.phpt b/ext/oci8/tests/bug27303_2_11gR1.phpt index 1e3e3105ad..27d8a585bd 100644 --- a/ext/oci8/tests/bug27303_2_11gR1.phpt +++ b/ext/oci8/tests/bug27303_2_11gR1.phpt @@ -5,12 +5,13 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using specific Oracle database versions"); - } - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) || + ($matches[1] == 11 && $matches[2] == 1 && $matches[3] == 0 && $matches[4] == 6) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using specific Oracle database versions"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug27303_4.phpt b/ext/oci8/tests/bug27303_4.phpt index 3137db8659..a24ae705ab 100644 --- a/ext/oci8/tests/bug27303_4.phpt +++ b/ext/oci8/tests/bug27303_4.phpt @@ -5,12 +5,16 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.2/', oci_server_version($c), $matches) !== 1 && - preg_match('/Release 11\.2\.0\.2/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); - // Other point releases may also work +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 2) + ))) { + die("skip expected output only valid when using Oracle 10.2.0.2 or 11.2.0.2 databases"); + // Other point releases may also work } -if (preg_match('/^11\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 11) { die("skip test expected to work only with Oracle 11g or greater version of client"); } ?> diff --git a/ext/oci8/tests/bug27303_4_11gR1.phpt b/ext/oci8/tests/bug27303_4_11gR1.phpt index f9bc2da8a2..01db1dc5a0 100644 --- a/ext/oci8/tests/bug27303_4_11gR1.phpt +++ b/ext/oci8/tests/bug27303_4_11gR1.phpt @@ -5,12 +5,13 @@ Bug #27303 (OCIBindByName binds numeric PHP values as characters) if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); // The bind buffer size edge cases seem to change each DB version. -if (preg_match('/Release 10\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.1\.0\.6/', oci_server_version($c), $matches) !== 1) { - if (preg_match('/Release 11\.2\.0\.3/', oci_server_version($c), $matches) !== 1) { - die("skip expected output only valid when using specific Oracle database versions"); - } - } +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) || + ($matches[1] == 11 && $matches[2] == 1 && $matches[3] == 0 && $matches[4] == 6) || + ($matches[1] == 11 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] == 3) + ))) { + die("skip expected output only valid when using specific Oracle database versions"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug36403.phpt b/ext/oci8/tests/bug36403.phpt index 53dae694ec..4ac32c4b06 100644 --- a/ext/oci8/tests/bug36403.phpt +++ b/ext/oci8/tests/bug36403.phpt @@ -3,8 +3,9 @@ Bug #36403 (oci_execute no longer supports OCI_DESCRIBE_ONLY) --SKIPIF-- <?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); -if (preg_match('/^1[01]\./', oci_client_version()) != 1) { - die("skip expected output only valid with Oracle 10g or greater version of client"); +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { + die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug43497.phpt b/ext/oci8/tests/bug43497.phpt index 8c57fabeef..05798889c4 100644 --- a/ext/oci8/tests/bug43497.phpt +++ b/ext/oci8/tests/bug43497.phpt @@ -5,8 +5,9 @@ Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory) $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs require(dirname(__FILE__).'/skipif.inc'); if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); -if (preg_match('/^1[01]\./', oci_client_version()) != 1) { - die("skip expected output only valid with Oracle 10g or greater version of client"); +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { + die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- diff --git a/ext/oci8/tests/bug47281.phpt b/ext/oci8/tests/bug47281.phpt index d0e0023537..0098ec5ebb 100644 --- a/ext/oci8/tests/bug47281.phpt +++ b/ext/oci8/tests/bug47281.phpt @@ -6,11 +6,12 @@ $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on t require(dirname(__FILE__).'/skipif.inc'); // error3.phpt obsoletes this test for newer Oracle client versions // Assume runtime client version is >= compile time client version -$cv = explode('.', oci_client_version()); -if ($cv[0] > 11 || ($cv[0] == 11 && $cv[1] > 2) || ($cv[0] == 11 && $cv[1] == 2 && $cv[3] >= 3)) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!isset($matches[0]) || + ($matches[0] > 11 || ($matches[0] == 11 && $matches[1] > 2) || ($matches[0] == 11 && $matches[1] == 2 && $matches[3] >= 3) + )) { die("skip test works only with Oracle 11.2.0.2 or earlier Oracle client libraries"); } - ?> --ENV-- NLS_LANG=.AL32UTF8 diff --git a/ext/oci8/tests/commit_001.phpt b/ext/oci8/tests/commit_001.phpt index 806fb193a0..ef4018118e 100644 --- a/ext/oci8/tests/commit_001.phpt +++ b/ext/oci8/tests/commit_001.phpt @@ -81,48 +81,48 @@ echo "Done\n"; bool(true) int(0) array(5) { - [%u|b%"ID"]=> + ["ID"]=> array(0) { } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(0) { } - [%u|b%"BLOB"]=> + ["BLOB"]=> array(0) { } - [%u|b%"CLOB"]=> + ["CLOB"]=> array(0) { } - [%u|b%"STRING"]=> + ["STRING"]=> array(0) { } } bool(true) int(4) array(5) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %string|unicode%(1) "1" + string(1) "1" [1]=> - %string|unicode%(1) "1" + string(1) "1" [2]=> - %string|unicode%(1) "1" + string(1) "1" [3]=> - %string|unicode%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %string|unicode%(1) "1" + string(1) "1" [1]=> - %string|unicode%(1) "1" + string(1) "1" [2]=> - %string|unicode%(1) "1" + string(1) "1" [3]=> - %string|unicode%(1) "1" + string(1) "1" } - [%u|b%"BLOB"]=> + ["BLOB"]=> array(4) { [0]=> NULL @@ -133,7 +133,7 @@ array(5) { [3]=> NULL } - [%u|b%"CLOB"]=> + ["CLOB"]=> array(4) { [0]=> NULL @@ -144,7 +144,7 @@ array(5) { [3]=> NULL } - [%u|b%"STRING"]=> + ["STRING"]=> array(4) { [0]=> NULL diff --git a/ext/oci8/tests/conn_attr.inc b/ext/oci8/tests/conn_attr.inc index 220e688210..2edc1c9552 100644 --- a/ext/oci8/tests/conn_attr.inc +++ b/ext/oci8/tests/conn_attr.inc @@ -2,30 +2,28 @@ require(dirname(__FILE__)."/connect.inc"); -$sv = oci_server_version($c); -$sv = preg_match('/Release (11\.2|12)\./', $sv, $matches); -if ($sv == 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if ((isset($matches[1]) && $matches[1] >= 11)) { // Server is Oracle 11.2+ $stmtarray = array( - "drop user testuser cascade", - "create user testuser identified by testuser", - "grant connect,resource,dba to testuser", - "alter user testuser enable editions", - "drop edition myedition1", - "drop edition myedition", - "grant create any edition to testuser", + "drop user $testuser cascade", + "create user $testuser identified by $testpassword", // $testuser should be set by the file that includes conn_attr.inc + "grant connect,resource,dba to $testuser", + "alter user $testuser enable editions", + "drop edition myedition1 cascade", + "drop edition myedition cascade", + "grant create any edition to $testuser", "create edition myedition", "create edition myedition1 as child of myedition", - "grant use on edition myedition to testuser", - "grant use on edition myedition1 to testuser", + "grant use on edition myedition to $testuser", + "grant use on edition myedition1 to $testuser", ); -} -else { +} else { // Server is Pre 11.2 $stmtarray = array( - "drop user testuser cascade", - "create user testuser identified by testuser", - "grant connect,resource,dba to testuser", + "drop user $testuser cascade", + "create user $testuser identified by $testpassword", + "grant connect,resource,dba to $testuser", ); } @@ -68,8 +66,8 @@ function get_attr($conn,$attr) function get_conn($conn_type) { - $user = 'testuser'; - $password = 'testuser'; + $user = $GLOBALS['testuser']; + $password = $GLOBALS['testpassword']; $dbase = $GLOBALS['dbase']; switch($conn_type) { case 1: @@ -139,9 +137,9 @@ function get_sys_attr($conn,$attr) function clean_up($c) { $stmtarray = array( - "drop user testuser cascade", - "drop edition myedition1", - "drop edition myedition", + "drop edition myedition1 cascade", + "drop edition myedition cascade", + "drop user " . $GLOBALS['testuser'] . " cascade", ); foreach ($stmtarray as $stmt) { diff --git a/ext/oci8/tests/conn_attr_1.phpt b/ext/oci8/tests/conn_attr_1.phpt index ad508a2ed2..631bc19c1d 100644 --- a/ext/oci8/tests/conn_attr_1.phpt +++ b/ext/oci8/tests/conn_attr_1.phpt @@ -9,15 +9,21 @@ if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 10)) { die("skip expected output only valid when using Oracle 10g or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } - ?> --FILE-- <?php + +$testuser = 'testuser_attr_1'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); $attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); diff --git a/ext/oci8/tests/conn_attr_2.phpt b/ext/oci8/tests/conn_attr_2.phpt index 1072503529..432a3cff04 100644 --- a/ext/oci8/tests/conn_attr_2.phpt +++ b/ext/oci8/tests/conn_attr_2.phpt @@ -8,40 +8,45 @@ require(dirname(__FILE__).'/skipif.inc'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 10)) { die("skip expected output only valid when using Oracle 10g or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } - ?> --INI-- oci8.privileged_connect = On --FILE-- <?php + +$testuser = 'testuser_attr_2'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); -$user='testuser'; -$password='testuser'; + $attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); echo"**Set values using pconnect-1**\n"; -var_dump($pc1 = oci_pconnect($user,$password,$dbase)); +var_dump($pc1 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { set_attr($pc1,$attr,100); } // using pc1 again echo"\n**Get values using pconnect-2**\n"; -var_dump($pc3 = oci_pconnect($user,$password,$dbase)); +var_dump($pc3 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { get_attr($pc3,$attr); } // Get with different pconnect echo"\n**Get values using pconnect-3**\n"; -var_dump($pc2 = oci_pconnect($user,$password,$dbase,'UTF8')); +var_dump($pc2 = oci_pconnect($testuser,$testpassword,$dbase,'UTF8')); foreach($attr_array as $attr) { get_attr($pc2,$attr); } @@ -52,15 +57,22 @@ oci_close($pc3); // Re-open a persistent connection and check for the attr values. echo "\n**Re-open a pconnect()**\n"; -var_dump($pc4 = oci_pconnect($user,$password,$dbase)); +var_dump($pc4 = oci_pconnect($testuser,$testpassword,$dbase)); foreach($attr_array as $attr) { get_attr($pc4,$attr); } oci_close($pc4); // Test with SYSDBA connection. -var_dump($sys_c1 = oci_pconnect($user,$password,$dbase,false,OCI_SYSDBA)); -if ($sys_c1) { +echo "\n**Test with SYSDBA connection**\n"; +$sys_c1 = @oci_pconnect($testuser,$testpassword,$dbase,false,OCI_SYSDBA); +var_dump($sys_c1); +if (!$sys_c1) { + $e = oci_error(); + if ($e['code'] != 1031 && $e['code'] != 1017) { + var_dump($e); + } +} else { set_attr($sys_c1,'ACTION',10); get_sys_attr($sys_c1,'ACTION'); get_attr($pc2,'ACTION'); @@ -100,6 +112,6 @@ The value of ACTION is TASK100 The value of CLIENT_INFO is INFO1100 The value of CLIENT_IDENTIFIER is ID00100 -Warning: oci_pconnect(): ORA-01031: %s on line %d +**Test with SYSDBA connection** bool(false) Done diff --git a/ext/oci8/tests/conn_attr_3.phpt b/ext/oci8/tests/conn_attr_3.phpt index be8d3306de..921487c9a0 100644 --- a/ext/oci8/tests/conn_attr_3.phpt +++ b/ext/oci8/tests/conn_attr_3.phpt @@ -8,14 +8,21 @@ require(dirname(__FILE__).'/skipif.inc'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 10)) { die("skip expected output only valid when using Oracle 10g or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- <?php + +$testuser = 'testuser_attr_3'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); echo"**Test Set and get values for the attributes with oci_close() ************\n"; diff --git a/ext/oci8/tests/conn_attr_4.phpt b/ext/oci8/tests/conn_attr_4.phpt index 4885f80b71..f32f9876d5 100644 --- a/ext/oci8/tests/conn_attr_4.phpt +++ b/ext/oci8/tests/conn_attr_4.phpt @@ -9,21 +9,27 @@ if (getenv('SKIP_SLOW_TESTS')) die('skip slow tests excluded by request'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release (11\.2|12)\./', oci_server_version($c), $matches) !== 1) { - // Bug fixed in 11.2 prevents client_info being rest +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && + (($matches[1] == 11 && $matches[2] >= 2) || + ($matches[1] >= 12) + ))) { + // Bug fixed in 11.2 prevents client_info being reset die("skip expected output only valid when using Oracle 11gR2 or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- <?php +$testuser = 'testuser_attr_4'; // Used in conn_attr.inc +$testpassword = 'testuser'; require(dirname(__FILE__)."/conn_attr.inc"); -$user='testuser'; -$password='testuser'; $attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER'); echo"**Test Negative cases************\n"; @@ -40,7 +46,7 @@ var_dump(oci_set_client_info($str1,$str1)); // Setting an Invalid value. echo "\nInvalid Value \n"; -$c1=oci_connect($user,$password,$dbase); +$c1=oci_connect($testuser,$testpassword,$dbase); var_dump(oci_set_action($c1,$c1)); // Setting values multiple times. diff --git a/ext/oci8/tests/conn_attr_5.phpt b/ext/oci8/tests/conn_attr_5.phpt index d694ec06a5..77f233b4e2 100644 --- a/ext/oci8/tests/conn_attr_5.phpt +++ b/ext/oci8/tests/conn_attr_5.phpt @@ -8,14 +8,21 @@ require(dirname(__FILE__).'/skipif.inc'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); if ($test_drcp) die("skip output might vary with DRCP"); -if (preg_match('/Release 1[01]\./', oci_server_version($c), $matches) !== 1) { +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 10)) { die("skip expected output only valid when using Oracle 10g or greater database server"); -} else if (preg_match('/^1[01]\./', oci_client_version()) != 1) { +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (isset($matches[0]) && $matches[0] < 10) { die("skip test expected to work only with Oracle 10g or greater version of client"); } ?> --FILE-- <?php + +$testuser = 'testuser_attr_5'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); echo"**Test - Set and get values for the attributes with scope end ************\n"; diff --git a/ext/oci8/tests/connect_without_oracle_home.phpt b/ext/oci8/tests/connect_without_oracle_home.phpt index e14fb93695..0acd2bc33a 100644 --- a/ext/oci8/tests/connect_without_oracle_home.phpt +++ b/ext/oci8/tests/connect_without_oracle_home.phpt @@ -10,8 +10,8 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); if ($ov !== 1) { die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); } -$iv = preg_match('/Oracle .*Version => (10\.2)/', $phpinfo); -if ($iv != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!isset($matches[0]) || !($matches[0] == 10 && $matches[0] == 2)) { die ("skip tests a feature that works only with Oracle 10gR2"); } ?> diff --git a/ext/oci8/tests/connect_without_oracle_home_11.phpt b/ext/oci8/tests/connect_without_oracle_home_11.phpt index 1620803dbb..40dc5a98fc 100644 --- a/ext/oci8/tests/connect_without_oracle_home_11.phpt +++ b/ext/oci8/tests/connect_without_oracle_home_11.phpt @@ -10,7 +10,11 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); if ($ov != 1) { die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); } -if (preg_match('/^11\.2|12\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && + (($matches[0] == 11 && $matches[1] >= 2) || + ($matches[0] >= 12) + ))) { die("skip test expected to work only with Oracle 11gR2 or greater version of client"); } ?> diff --git a/ext/oci8/tests/connect_without_oracle_home_old_11.phpt b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt index c7cfecf396..e04016f41a 100644 --- a/ext/oci8/tests/connect_without_oracle_home_old_11.phpt +++ b/ext/oci8/tests/connect_without_oracle_home_old_11.phpt @@ -10,7 +10,11 @@ $ov = preg_match('/Compile-time ORACLE_HOME/', $phpinfo); if ($ov !== 1) { die ("skip Test only valid when OCI8 is built with an ORACLE_HOME"); } -if (preg_match('/^11\.2|12\./', oci_client_version()) != 1) { +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && + (($matches[0] == 11 && $matches[1] >= 2) || + ($matches[0] >= 12) + ))) { die("skip test expected to work only with Oracle 11gR2 or greater version of client"); } ?> diff --git a/ext/oci8/tests/cursors_old.phpt b/ext/oci8/tests/cursors_old.phpt index d60e2ff1ea..aa25937570 100644 --- a/ext/oci8/tests/cursors_old.phpt +++ b/ext/oci8/tests/cursors_old.phpt @@ -52,19 +52,19 @@ echo "Done\n"; ?> --EXPECTF-- array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(1) "1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" } bool(true) Warning: ocifetchinto():%sORA-01002: %s in %scursors_old.php on line %d array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(1) "1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" } bool(true) Done diff --git a/ext/oci8/tests/debug.phpt b/ext/oci8/tests/debug.phpt index fe96e6e87e..66ab0f0d00 100644 --- a/ext/oci8/tests/debug.phpt +++ b/ext/oci8/tests/debug.phpt @@ -16,10 +16,9 @@ else { oci_connect($user, $password); } -echo "Done\n"; - oci_internal_debug(false); ?> ---EXPECTREGEX-- -^OCI8 DEBUG: .*Done$ +===DONE=== +--EXPECT-- +===DONE=== diff --git a/ext/oci8/tests/define.phpt b/ext/oci8/tests/define.phpt index c6ce7bd9b3..b78f698e7c 100644 --- a/ext/oci8/tests/define.phpt +++ b/ext/oci8/tests/define.phpt @@ -44,5 +44,5 @@ echo "Done\n"; ?> --EXPECTF-- -%unicode|string%(%d) "some" +string(%d) "some" Done diff --git a/ext/oci8/tests/define1.phpt b/ext/oci8/tests/define1.phpt index 6e4b74e3ba..be16271d5b 100644 --- a/ext/oci8/tests/define1.phpt +++ b/ext/oci8/tests/define1.phpt @@ -55,5 +55,5 @@ bool(false) Warning: oci_define_by_name() expects at least 3 parameters, 2 given in %s on line %d NULL -%unicode|string%(4) "some" +string(4) "some" Done diff --git a/ext/oci8/tests/define4.phpt b/ext/oci8/tests/define4.phpt index 266fd7edd7..3114a73937 100644 --- a/ext/oci8/tests/define4.phpt +++ b/ext/oci8/tests/define4.phpt @@ -58,15 +58,15 @@ echo "Done\n"; Test 1 bool(true) Test 2 -%unicode|string%(4) "1234" -%unicode|string%(4) "some" -%unicode|string%(4) "some" -%unicode|string%(4) "some" -%unicode|string%(4) "1234" -%unicode|string%(4) "some" +string(4) "1234" +string(4) "some" +string(4) "some" +string(4) "some" +string(4) "1234" +string(4) "some" Test 3 bool(true) -%unicode|string%(4) "some" +string(4) "some" Warning: oci_result(): %d is not a valid oci8 statement resource in %s on line %d bool(false) diff --git a/ext/oci8/tests/define5.phpt b/ext/oci8/tests/define5.phpt index 68fa01d09a..978d66b260 100644 --- a/ext/oci8/tests/define5.phpt +++ b/ext/oci8/tests/define5.phpt @@ -61,12 +61,12 @@ echo "Done\n"; Test 1 - must do define before execute bool(true) NULL -%unicode|string%(4) "some" +string(4) "some" Test 2 - normal define order bool(true) -%unicode|string%(4) "some" +string(4) "some" Test 3 - no new define done -%unicode|string%(4) "some" -%unicode|string%(5) "thing" +string(4) "some" +string(5) "thing" Done diff --git a/ext/oci8/tests/define_old.phpt b/ext/oci8/tests/define_old.phpt index f65e6b8080..cc07e2ea94 100644 --- a/ext/oci8/tests/define_old.phpt +++ b/ext/oci8/tests/define_old.phpt @@ -44,5 +44,5 @@ echo "Done\n"; ?> --EXPECTF-- -%unicode|string%(4) "some" +string(4) "some" Done diff --git a/ext/oci8/tests/details.inc b/ext/oci8/tests/details.inc index 9a86c46868..e54ea84abd 100644 --- a/ext/oci8/tests/details.inc +++ b/ext/oci8/tests/details.inc @@ -52,7 +52,7 @@ if (!function_exists('oci8_test_sql_execute')) { $s = oci_parse($c, $stmt); if (!$s) { $m = oci_error($c); - echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; + echo "oci8_test_sql_execute() error:". PHP_EOL . $stmt . PHP_EOL . $m['message'] . PHP_EOL; } else { $r = @oci_execute($s); @@ -66,7 +66,7 @@ if (!function_exists('oci8_test_sql_execute')) { , 4080 // trigger does not exist , 38802 // edition does not exist ))) { - echo $stmt . PHP_EOL . $m['message'] . PHP_EOL; + echo "oci8_test_sql_execute() error:". PHP_EOL . $stmt . PHP_EOL . $m['message'] . PHP_EOL; } } } diff --git a/ext/oci8/tests/edition_1.phpt b/ext/oci8/tests/edition_1.phpt index b9c8fd817e..d8ca53cddf 100644 --- a/ext/oci8/tests/edition_1.phpt +++ b/ext/oci8/tests/edition_1.phpt @@ -24,6 +24,9 @@ if (preg_match('/Release (1[1]\.2|12)\./', oci_server_version($c), $matches) !== * already */ +$testuser = 'testuser_attr_1'; // Used in conn_attr.inc +$testpassword = 'testuser'; + require(dirname(__FILE__)."/conn_attr.inc"); function select_fn($conn) { @@ -39,7 +42,7 @@ function select_fn($conn) { select from both the editions and verify the contents. */ set_edit_attr('MYEDITION'); -$conn = oci_connect('testuser','testuser',$dbase); +$conn = oci_connect($testuser,$testpassword,$dbase); if ($conn === false) { $m = oci_error(); die("Error:" . $m['message']); @@ -61,7 +64,7 @@ select_fn($conn); // Create a different version of view_ed in MYEDITION1. set_edit_attr('MYEDITION1'); -$conn2 = oci_new_connect('testuser','testuser',$dbase); +$conn2 = oci_new_connect($testuser,$testpassword,$dbase); $stmt = "create or replace editioning view view_ed as select name,age,job,salary from edit_tab"; $s = oci_parse($conn2, $stmt); oci_execute($s); @@ -87,58 +90,58 @@ The value of edition has been successfully set The value of current EDITION is MYEDITION array(3) { [0]=> - %unicode|string%(%d) "mike" + string(%d) "mike" [1]=> - %unicode|string%(%d) "30" + string(%d) "30" [2]=> - %unicode|string%(%d) "Senior engineer" + string(%d) "Senior engineer" } array(3) { [0]=> - %unicode|string%(%d) "juan" + string(%d) "juan" [1]=> - %unicode|string%(%d) "25" + string(%d) "25" [2]=> - %unicode|string%(%d) "engineer" + string(%d) "engineer" } The value of edition has been successfully set The value of current EDITION is MYEDITION1 array(4) { [0]=> - %unicode|string%(%d) "mike" + string(%d) "mike" [1]=> - %unicode|string%(%d) "30" + string(%d) "30" [2]=> - %unicode|string%(%d) "Senior engineer" + string(%d) "Senior engineer" [3]=> - %unicode|string%(%d) "200" + string(%d) "200" } array(4) { [0]=> - %unicode|string%(%d) "juan" + string(%d) "juan" [1]=> - %unicode|string%(%d) "25" + string(%d) "25" [2]=> - %unicode|string%(%d) "engineer" + string(%d) "engineer" [3]=> - %unicode|string%(%d) "100" + string(%d) "100" } version of view_ed in MYEDITION The value of current EDITION is MYEDITION array(3) { [0]=> - %unicode|string%(%d) "mike" + string(%d) "mike" [1]=> - %unicode|string%(%d) "30" + string(%d) "30" [2]=> - %unicode|string%(%d) "Senior engineer" + string(%d) "Senior engineer" } array(3) { [0]=> - %unicode|string%(%d) "juan" + string(%d) "juan" [1]=> - %unicode|string%(%d) "25" + string(%d) "25" [2]=> - %unicode|string%(%d) "engineer" + string(%d) "engineer" } Done diff --git a/ext/oci8/tests/edition_2.phpt b/ext/oci8/tests/edition_2.phpt index 030e6a673c..0ffb62dc32 100644 --- a/ext/oci8/tests/edition_2.phpt +++ b/ext/oci8/tests/edition_2.phpt @@ -24,10 +24,10 @@ if (preg_match('/Release (1[1]\.2|12)\./', oci_server_version($c), $matches) !== * already */ -require(dirname(__FILE__)."/conn_attr.inc"); +$testuser = 'testuser_ed_2'; // Used in conn_attr.inc +$testpassword = 'testuser'; -$user = 'testuser'; -$password = 'testuser'; +require(dirname(__FILE__)."/conn_attr.inc"); echo"**Test 1.1 - Default value for the attribute **************\n"; get_edit_attr($c); @@ -50,7 +50,7 @@ get_edit_attr($conn3); oci_close($conn1); // With a oci_pconnect with a different charset. -$pc1 = oci_pconnect($user,$password,$dbase,"utf8"); +$pc1 = oci_pconnect($testuser,$testpassword,$dbase,"utf8"); get_edit_attr($pc1); oci_close($pc1); @@ -145,7 +145,7 @@ function set_scope() { } function get_scope() { - $sc1 = oci_connect($GLOBALS['user'],$GLOBALS['password'],$GLOBALS['dbase']); + $sc1 = oci_connect($GLOBALS['testuser'],$GLOBALS['testpassword'],$GLOBALS['dbase']); if ($sc1 === false) { $m = oci_error(); die("Error:" . $m['message']); diff --git a/ext/oci8/tests/extauth_01.phpt b/ext/oci8/tests/extauth_01.phpt index 37f8f3834d..1194ae180d 100644 --- a/ext/oci8/tests/extauth_01.phpt +++ b/ext/oci8/tests/extauth_01.phpt @@ -143,56 +143,56 @@ Test 7 Warning: oci_connect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 8 Warning: oci_connect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 9 Warning: oci_connect(): ORA-%d: TNS:%s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 10 Warning: oci_connect(): ORA-%d: TNS:%s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) ===DONE=== diff --git a/ext/oci8/tests/extauth_02.phpt b/ext/oci8/tests/extauth_02.phpt index f3b517f730..0a3227019c 100644 --- a/ext/oci8/tests/extauth_02.phpt +++ b/ext/oci8/tests/extauth_02.phpt @@ -142,56 +142,56 @@ Test 7 Warning: oci_new_connect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 8 Warning: oci_new_connect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 9 Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 10 Warning: oci_new_connect(): ORA-%d: TNS:%s %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) ===DONE=== diff --git a/ext/oci8/tests/extauth_03.phpt b/ext/oci8/tests/extauth_03.phpt index e6685eb176..d7884ce6b4 100644 --- a/ext/oci8/tests/extauth_03.phpt +++ b/ext/oci8/tests/extauth_03.phpt @@ -142,56 +142,56 @@ Test 7 Warning: oci_pconnect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 8 Warning: oci_pconnect(): ORA-12154: %s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(12154) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-12154: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-12154: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 9 Warning: oci_pconnect(): ORA-%d: TNS:%s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) Test 10 Warning: oci_pconnect(): ORA-%d: TNS:%s in %s on line %d array(4) { - [%u|b%"code"]=> + ["code"]=> int(%d) - [%u|b%"message"]=> - %unicode|string%(%d) "ORA-%d: %s" - [%u|b%"offset"]=> + ["message"]=> + string(%d) "ORA-%d: %s" + ["offset"]=> int(0) - [%u|b%"sqltext"]=> - %unicode|string%(0) "" + ["sqltext"]=> + string(0) "" } bool(false) ===DONE=== diff --git a/ext/oci8/tests/fetch.phpt b/ext/oci8/tests/fetch.phpt index e48aeefd87..b968ae4bf6 100644 --- a/ext/oci8/tests/fetch.phpt +++ b/ext/oci8/tests/fetch.phpt @@ -47,10 +47,10 @@ oci8_test_sql_execute($c, $stmtarray); echo "Done\n"; ?> --EXPECTF-- -%unicode|string%(1) "1" -%unicode|string%(1) "1" -%unicode|string%(1) "1" -%unicode|string%(1) "1" -%unicode|string%(1) "1" -%unicode|string%(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" +string(1) "1" Done diff --git a/ext/oci8/tests/fetch_all.phpt b/ext/oci8/tests/fetch_all.phpt index 4fc41daad4..b8155b170b 100644 --- a/ext/oci8/tests/fetch_all.phpt +++ b/ext/oci8/tests/fetch_all.phpt @@ -51,44 +51,44 @@ echo "Done\n"; --EXPECTF-- int(3) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } } int(3) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } } Done diff --git a/ext/oci8/tests/fetch_all1.phpt b/ext/oci8/tests/fetch_all1.phpt index 4fc41daad4..b8155b170b 100644 --- a/ext/oci8/tests/fetch_all1.phpt +++ b/ext/oci8/tests/fetch_all1.phpt @@ -51,44 +51,44 @@ echo "Done\n"; --EXPECTF-- int(3) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } } int(3) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" [2]=> - %unicode|string%(1) "1" + string(1) "1" } } Done diff --git a/ext/oci8/tests/fetch_all3.phpt b/ext/oci8/tests/fetch_all3.phpt index 1748ea5658..4c0be1cc07 100644 --- a/ext/oci8/tests/fetch_all3.phpt +++ b/ext/oci8/tests/fetch_all3.phpt @@ -129,105 +129,105 @@ echo "Done\n"; None int(4) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_ASSOC int(4) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_COLUMN int(4) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC int(4) array(2) { - [%u|b%"ID"]=> + ["ID"]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } - [%u|b%"VALUE"]=> + ["VALUE"]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM @@ -236,24 +236,24 @@ array(2) { [0]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } [1]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC @@ -262,24 +262,24 @@ array(2) { [0]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } [1]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW @@ -287,31 +287,31 @@ int(4) array(4) { [0]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" } [1]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "2" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-2" + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" } [2]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "3" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-3" + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" } [3]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "4" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-4" + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC @@ -319,31 +319,31 @@ int(4) array(4) { [0]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" } [1]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "2" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-2" + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" } [2]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "3" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-3" + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" } [3]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "4" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-4" + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN @@ -351,31 +351,31 @@ int(4) array(4) { [0]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" } [1]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "2" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-2" + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" } [2]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "3" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-3" + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" } [3]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "4" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-4" + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC @@ -383,31 +383,31 @@ int(4) array(4) { [0]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-1" + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" } [1]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "2" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-2" + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" } [2]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "3" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-3" + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" } [3]=> array(2) { - [%u|b%"ID"]=> - %unicode|string%(1) "4" - [%u|b%"VALUE"]=> - %unicode|string%(2) "-4" + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM @@ -416,30 +416,30 @@ array(4) { [0]=> array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(2) "-1" + string(2) "-1" } [1]=> array(2) { [0]=> - %unicode|string%(1) "2" + string(1) "2" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" } [2]=> array(2) { [0]=> - %unicode|string%(1) "3" + string(1) "3" [1]=> - %unicode|string%(2) "-3" + string(2) "-3" } [3]=> array(2) { [0]=> - %unicode|string%(1) "4" + string(1) "4" [1]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC @@ -448,30 +448,30 @@ array(4) { [0]=> array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(2) "-1" + string(2) "-1" } [1]=> array(2) { [0]=> - %unicode|string%(1) "2" + string(1) "2" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" } [2]=> array(2) { [0]=> - %unicode|string%(1) "3" + string(1) "3" [1]=> - %unicode|string%(2) "-3" + string(2) "-3" } [3]=> array(2) { [0]=> - %unicode|string%(1) "4" + string(1) "4" [1]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM @@ -480,30 +480,30 @@ array(4) { [0]=> array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(2) "-1" + string(2) "-1" } [1]=> array(2) { [0]=> - %unicode|string%(1) "2" + string(1) "2" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" } [2]=> array(2) { [0]=> - %unicode|string%(1) "3" + string(1) "3" [1]=> - %unicode|string%(2) "-3" + string(2) "-3" } [3]=> array(2) { [0]=> - %unicode|string%(1) "4" + string(1) "4" [1]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC @@ -512,30 +512,30 @@ array(4) { [0]=> array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(2) "-1" + string(2) "-1" } [1]=> array(2) { [0]=> - %unicode|string%(1) "2" + string(1) "2" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" } [2]=> array(2) { [0]=> - %unicode|string%(1) "3" + string(1) "3" [1]=> - %unicode|string%(2) "-3" + string(2) "-3" } [3]=> array(2) { [0]=> - %unicode|string%(1) "4" + string(1) "4" [1]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_NUM @@ -544,24 +544,24 @@ array(2) { [0]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } [1]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } OCI_NUM|OCI_ASSOC @@ -570,24 +570,24 @@ array(2) { [0]=> array(4) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" [3]=> - %unicode|string%(1) "4" + string(1) "4" } [1]=> array(4) { [0]=> - %unicode|string%(2) "-1" + string(2) "-1" [1]=> - %unicode|string%(2) "-2" + string(2) "-2" [2]=> - %unicode|string%(2) "-3" + string(2) "-3" [3]=> - %unicode|string%(2) "-4" + string(2) "-4" } } Done diff --git a/ext/oci8/tests/fetch_all4.phpt b/ext/oci8/tests/fetch_all4.phpt index 1d3c9677ee..1d4a8df7b7 100644 --- a/ext/oci8/tests/fetch_all4.phpt +++ b/ext/oci8/tests/fetch_all4.phpt @@ -51,10 +51,10 @@ oci8_test_sql_execute($c, $stmtarray); Test 1 int(0) array(2) { - [%u|b%"MYCOL1"]=> + ["MYCOL1"]=> array(0) { } - [%u|b%"MYCOL2"]=> + ["MYCOL2"]=> array(0) { } } diff --git a/ext/oci8/tests/fetch_all5.phpt b/ext/oci8/tests/fetch_all5.phpt index a6bb3c3f18..d82fd30e41 100644 --- a/ext/oci8/tests/fetch_all5.phpt +++ b/ext/oci8/tests/fetch_all5.phpt @@ -62,45 +62,45 @@ oci_close($c); Test 1 int(3) array(2) { - [%u|b%"MYCOL1"]=> + ["MYCOL1"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" } - [%u|b%"MYCOL2"]=> + ["MYCOL2"]=> array(3) { [0]=> - %unicode|string%(3) "abc" + string(3) "abc" [1]=> - %unicode|string%(3) "def" + string(3) "def" [2]=> - %unicode|string%(3) "ghi" + string(3) "ghi" } } Test 1 int(3) array(2) { - [%u|b%"MYCOL1"]=> + ["MYCOL1"]=> array(3) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "2" + string(1) "2" [2]=> - %unicode|string%(1) "3" + string(1) "3" } - [%u|b%"MYCOL2"]=> + ["MYCOL2"]=> array(3) { [0]=> - %unicode|string%(3) "abc" + string(3) "abc" [1]=> - %unicode|string%(3) "def" + string(3) "def" [2]=> - %unicode|string%(3) "ghi" + string(3) "ghi" } } Test 3 diff --git a/ext/oci8/tests/fetch_into.phpt b/ext/oci8/tests/fetch_into.phpt index 45a6a8132e..d90c4d95dc 100644 --- a/ext/oci8/tests/fetch_into.phpt +++ b/ext/oci8/tests/fetch_into.phpt @@ -53,19 +53,19 @@ echo "Done\n"; int(2) array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } int(2) array(4) { [0]=> - %unicode|string%(1) "1" - [%u|b%"ID"]=> - %unicode|string%(1) "1" + string(1) "1" + ["ID"]=> + string(1) "1" [1]=> - %unicode|string%(1) "1" - [%u|b%"VALUE"]=> - %unicode|string%(1) "1" + string(1) "1" + ["VALUE"]=> + string(1) "1" } Done diff --git a/ext/oci8/tests/fetch_object.phpt b/ext/oci8/tests/fetch_object.phpt index 1c290d5e95..73711baa18 100644 --- a/ext/oci8/tests/fetch_object.phpt +++ b/ext/oci8/tests/fetch_object.phpt @@ -82,28 +82,28 @@ oci8_test_sql_execute($c, $stmtarray); --EXPECTF-- Test 1 object(stdClass)#1 (3) { - [%u|b%"caseSensitive"]=> - %unicode|string%(3) "123" - [%u|b%"SECONDCOL"]=> - %unicode|string%(19) "1st row col2 string" - [%u|b%"ANOTHERCOL"]=> - %unicode|string%(15) "1 more text " + ["caseSensitive"]=> + string(3) "123" + ["SECONDCOL"]=> + string(19) "1st row col2 string" + ["ANOTHERCOL"]=> + string(15) "1 more text " } object(stdClass)#2 (3) { - [%u|b%"caseSensitive"]=> - %unicode|string%(3) "456" - [%u|b%"SECONDCOL"]=> - %unicode|string%(19) "2nd row col2 string" - [%u|b%"ANOTHERCOL"]=> - %unicode|string%(15) "2 more text " + ["caseSensitive"]=> + string(3) "456" + ["SECONDCOL"]=> + string(19) "2nd row col2 string" + ["ANOTHERCOL"]=> + string(15) "2 more text " } object(stdClass)#1 (3) { - [%u|b%"caseSensitive"]=> - %unicode|string%(3) "789" - [%u|b%"SECONDCOL"]=> - %unicode|string%(19) "3rd row col2 string" - [%u|b%"ANOTHERCOL"]=> - %unicode|string%(15) "3 more text " + ["caseSensitive"]=> + string(3) "789" + ["SECONDCOL"]=> + string(19) "3rd row col2 string" + ["ANOTHERCOL"]=> + string(15) "3 more text " } Test 2 123 diff --git a/ext/oci8/tests/fetch_row.phpt b/ext/oci8/tests/fetch_row.phpt index 2b28634ab3..40bc4f893c 100644 --- a/ext/oci8/tests/fetch_row.phpt +++ b/ext/oci8/tests/fetch_row.phpt @@ -46,20 +46,20 @@ echo "Done\n"; --EXPECTF-- array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } Done diff --git a/ext/oci8/tests/field_funcs1.phpt b/ext/oci8/tests/field_funcs1.phpt index c14ee8957e..41d8627ce4 100644 --- a/ext/oci8/tests/field_funcs1.phpt +++ b/ext/oci8/tests/field_funcs1.phpt @@ -85,9 +85,9 @@ echo "Done\n"; --EXPECTF-- array(2) { [0]=> - %unicode|string%(1) "1" + string(1) "1" [1]=> - %unicode|string%(1) "1" + string(1) "1" } Test 1 diff --git a/ext/oci8/tests/imp_res_1.phpt b/ext/oci8/tests/imp_res_1.phpt new file mode 100644 index 0000000000..a36f89f4da --- /dev/null +++ b/ext/oci8/tests/imp_res_1.phpt @@ -0,0 +1,630 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: basic test +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_1_tab_1", + "create table imp_res_1_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_1_tab_1 values (1, 'abcde')", + "insert into imp_res_1_tab_1 values (2, 'fghij')", + "insert into imp_res_1_tab_1 values (3, 'klmno')", + + "drop table imp_res_1_tab_2", + "create table imp_res_1_tab_2 (c3 varchar2(1))", + "insert into imp_res_1_tab_2 values ('t')", + "insert into imp_res_1_tab_2 values ('u')", + "insert into imp_res_1_tab_2 values ('v')", + + "create or replace procedure imp_res_1_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_1_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_1_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + + open c1 for select 99 from dual; + dbms_sql.return_result (c1); + + open c1 for select NULL, 'Z' from dual; + dbms_sql.return_result (c1); + + open c1 for select * from imp_res_1_tab_1 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1 - oci_fetch_assoc\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_assoc($s)) != false) + var_dump($row); + +echo "\nTest 2 - oci_fetch_object\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_object($s)) != false) + var_dump($row); + +echo "\nTest 3 - oci_fetch_row\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "\nTest 4 - oci_fetch_array(OCI_ASSOC+OCI_RETURN_NULLS)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) + var_dump($row); + +echo "\nTest 5 - oci_fetch_array(OCI_ASSOC)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC)) != false) + var_dump($row); + +echo "\nTest 6 - oci_fetch_array(OCI_NUM)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_NUM)) != false) + var_dump($row); + +echo "\nTest 7 - oci_fetch_array(OCI_BOTH)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_BOTH)) != false) + var_dump($row); + +echo "\nTest 8 - oci_fetch_array(OCI_BOTH+OCI_RETURN_NULLS)\n"; +$s = oci_parse($c, "begin imp_res_1_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_BOTH+OCI_RETURN_NULLS)) != false) + var_dump($row); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_1_proc", + "drop table imp_res_1_tab_1", + "drop table imp_res_1_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - oci_fetch_assoc +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} +array(1) { + ["C3"]=> + string(1) "t" +} +array(1) { + ["C3"]=> + string(1) "u" +} +array(1) { + [99]=> + string(2) "99" +} +array(2) { + ["NULL"]=> + NULL + ["'Z'"]=> + string(1) "Z" +} +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} + +Test 2 - oci_fetch_object +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} +object(stdClass)#%d (1) { + ["C3"]=> + string(1) "t" +} +object(stdClass)#%d (1) { + ["C3"]=> + string(1) "u" +} +object(stdClass)#%d (1) { + [99]=> + string(2) "99" +} +object(stdClass)#%d (2) { + ["NULL"]=> + NULL + ["'Z'"]=> + string(1) "Z" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} + +Test 3 - oci_fetch_row +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(2) "99" +} +array(2) { + [0]=> + NULL + [1]=> + string(1) "Z" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} + +Test 4 - oci_fetch_array(OCI_ASSOC+OCI_RETURN_NULLS) +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} +array(1) { + ["C3"]=> + string(1) "t" +} +array(1) { + ["C3"]=> + string(1) "u" +} +array(1) { + [99]=> + string(2) "99" +} +array(2) { + ["NULL"]=> + NULL + ["'Z'"]=> + string(1) "Z" +} +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} + +Test 5 - oci_fetch_array(OCI_ASSOC) +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} +array(1) { + ["C3"]=> + string(1) "t" +} +array(1) { + ["C3"]=> + string(1) "u" +} +array(1) { + [99]=> + string(2) "99" +} +array(1) { + ["'Z'"]=> + string(1) "Z" +} +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(5) "abcde" +} +array(2) { + ["C1"]=> + string(1) "2" + ["C2"]=> + string(5) "fghij" +} +array(2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(5) "klmno" +} + +Test 6 - oci_fetch_array(OCI_NUM) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(2) "99" +} +array(1) { + [1]=> + string(1) "Z" +} +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} + +Test 7 - oci_fetch_array(OCI_BOTH) +array(4) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "abcde" + ["C2"]=> + string(5) "abcde" +} +array(4) { + [0]=> + string(1) "2" + ["C1"]=> + string(1) "2" + [1]=> + string(5) "fghij" + ["C2"]=> + string(5) "fghij" +} +array(4) { + [0]=> + string(1) "3" + ["C1"]=> + string(1) "3" + [1]=> + string(5) "klmno" + ["C2"]=> + string(5) "klmno" +} +array(2) { + [0]=> + string(1) "t" + ["C3"]=> + string(1) "t" +} +array(2) { + [0]=> + string(1) "u" + ["C3"]=> + string(1) "u" +} +array(2) { + [0]=> + string(2) "99" + [99]=> + string(2) "99" +} +array(2) { + [1]=> + string(1) "Z" + ["'Z'"]=> + string(1) "Z" +} +array(4) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "abcde" + ["C2"]=> + string(5) "abcde" +} +array(4) { + [0]=> + string(1) "2" + ["C1"]=> + string(1) "2" + [1]=> + string(5) "fghij" + ["C2"]=> + string(5) "fghij" +} +array(4) { + [0]=> + string(1) "3" + ["C1"]=> + string(1) "3" + [1]=> + string(5) "klmno" + ["C2"]=> + string(5) "klmno" +} + +Test 8 - oci_fetch_array(OCI_BOTH+OCI_RETURN_NULLS) +array(4) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "abcde" + ["C2"]=> + string(5) "abcde" +} +array(4) { + [0]=> + string(1) "2" + ["C1"]=> + string(1) "2" + [1]=> + string(5) "fghij" + ["C2"]=> + string(5) "fghij" +} +array(4) { + [0]=> + string(1) "3" + ["C1"]=> + string(1) "3" + [1]=> + string(5) "klmno" + ["C2"]=> + string(5) "klmno" +} +array(2) { + [0]=> + string(1) "t" + ["C3"]=> + string(1) "t" +} +array(2) { + [0]=> + string(1) "u" + ["C3"]=> + string(1) "u" +} +array(2) { + [0]=> + string(2) "99" + [99]=> + string(2) "99" +} +array(4) { + [0]=> + NULL + ["NULL"]=> + NULL + [1]=> + string(1) "Z" + ["'Z'"]=> + string(1) "Z" +} +array(4) { + [0]=> + string(1) "1" + ["C1"]=> + string(1) "1" + [1]=> + string(5) "abcde" + ["C2"]=> + string(5) "abcde" +} +array(4) { + [0]=> + string(1) "2" + ["C1"]=> + string(1) "2" + [1]=> + string(5) "fghij" + ["C2"]=> + string(5) "fghij" +} +array(4) { + [0]=> + string(1) "3" + ["C1"]=> + string(1) "3" + [1]=> + string(5) "klmno" + ["C2"]=> + string(5) "klmno" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_2.phpt b/ext/oci8/tests/imp_res_2.phpt new file mode 100644 index 0000000000..860a5fbb34 --- /dev/null +++ b/ext/oci8/tests/imp_res_2.phpt @@ -0,0 +1,99 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: Zero Rows +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_2_proc_a as + c1 sys_refcursor; + begin + open c1 for select * from dual where 1 = 0; + dbms_sql.return_result(c1); + end;", + + "create or replace procedure imp_res_2_proc_b as + c1 sys_refcursor; + begin + open c1 for select * from dual; + dbms_sql.return_result(c1); + open c1 for select * from dual where 1 = 0; + dbms_sql.return_result(c1); + end;", + + "create or replace procedure imp_res_2_proc_c as + c1 sys_refcursor; + begin + open c1 for select * from dual where 1 = 0; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result(c1); + end;" + +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_2_proc_a(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "Test 2\n"; +$s = oci_parse($c, "begin imp_res_2_proc_b(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "Test 2\n"; +$s = oci_parse($c, "begin imp_res_2_proc_c(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_2_proc_a", + "drop procedure imp_res_2_proc_b", + "drop procedure imp_res_2_proc_c" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +Test 2 +array(1) { + [0]=> + string(1) "X" +} +Test 2 +array(1) { + [0]=> + string(1) "X" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_3.phpt b/ext/oci8/tests/imp_res_3.phpt new file mode 100644 index 0000000000..0fc4815893 --- /dev/null +++ b/ext/oci8/tests/imp_res_3.phpt @@ -0,0 +1,1257 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: bigger data size +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_3_tab_1", + "create table imp_res_3_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_3_tab_1 values (1, 'a')", + "insert into imp_res_3_tab_1 values (2, 'f')", + + "drop table imp_res_3_tab_2", + "create table imp_res_3_tab_2 (c3 varchar2(1))", + "insert into imp_res_3_tab_2 values ('t')", + "insert into imp_res_3_tab_2 values ('u')", + "insert into imp_res_3_tab_2 values ('v')", + "insert into imp_res_3_tab_2 values ('w')", + + "create or replace procedure imp_res_3_proc as + c1 sys_refcursor; + i pls_integer; + begin + for i in 1..30 loop -- if this value is too big for Oracle's open_cursors, calling imp_res_3_proc() can fail with ORA-1000 + open c1 for select t1.*, t2.*, t3.*, t4.*, t5.* + from imp_res_3_tab_1 t1, imp_res_3_tab_1 t2, imp_res_3_tab_1 t3, + imp_res_3_tab_1 t4, imp_res_3_tab_1 t5 order by 1,3,5,7,9,2,4,6,8,10; + dbms_sql.return_result(c1); + open c1 for select c2 from imp_res_3_tab_1 order by 1; + dbms_sql.return_result(c1); + open c1 for select * from imp_res_3_tab_2 order by 1; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result (c1); + end loop; + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_3_proc(); end;"); +oci_execute($s); + +while (($row = oci_fetch_array($s, OCI_NUM+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_3_proc", + "drop table imp_res_3_tab_1", + "drop table imp_res_3_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X + 1 a 1 a 1 a 1 a 1 a + 1 a 1 a 1 a 1 a 2 f + 1 a 1 a 1 a 2 f 1 a + 1 a 1 a 1 a 2 f 2 f + 1 a 1 a 2 f 1 a 1 a + 1 a 1 a 2 f 1 a 2 f + 1 a 1 a 2 f 2 f 1 a + 1 a 1 a 2 f 2 f 2 f + 1 a 2 f 1 a 1 a 1 a + 1 a 2 f 1 a 1 a 2 f + 1 a 2 f 1 a 2 f 1 a + 1 a 2 f 1 a 2 f 2 f + 1 a 2 f 2 f 1 a 1 a + 1 a 2 f 2 f 1 a 2 f + 1 a 2 f 2 f 2 f 1 a + 1 a 2 f 2 f 2 f 2 f + 2 f 1 a 1 a 1 a 1 a + 2 f 1 a 1 a 1 a 2 f + 2 f 1 a 1 a 2 f 1 a + 2 f 1 a 1 a 2 f 2 f + 2 f 1 a 2 f 1 a 1 a + 2 f 1 a 2 f 1 a 2 f + 2 f 1 a 2 f 2 f 1 a + 2 f 1 a 2 f 2 f 2 f + 2 f 2 f 1 a 1 a 1 a + 2 f 2 f 1 a 1 a 2 f + 2 f 2 f 1 a 2 f 1 a + 2 f 2 f 1 a 2 f 2 f + 2 f 2 f 2 f 1 a 1 a + 2 f 2 f 2 f 1 a 2 f + 2 f 2 f 2 f 2 f 1 a + 2 f 2 f 2 f 2 f 2 f + a + f + t + u + v + w + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_4.phpt b/ext/oci8/tests/imp_res_4.phpt new file mode 100644 index 0000000000..762ae77224 --- /dev/null +++ b/ext/oci8/tests/imp_res_4.phpt @@ -0,0 +1,82 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_fetch +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_4_proc as + c1 sys_refcursor; + begin + open c1 for select 1 from dual union select 2 from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_4_proc(); end;"); +oci_execute($s); +oci_fetch($s); // This will fail with ORA-24374 +var_dump(oci_result($s, 1)); + +echo "\nTest 2\n"; +$s = oci_parse($c, "begin imp_res_4_proc(); end;"); +oci_execute($s); +$r = oci_fetch_row($s); +var_dump($r); +oci_fetch($s); // This will fail with ORA-24374 +var_dump(oci_result($s, 1)); +$r = oci_fetch_row($s); +var_dump($r); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_4_proc", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d +bool(false) + +Test 2 +array(1) { + [0]=> + string(1) "1" +} + +Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d +bool(false) +array(1) { + [0]=> + string(1) "2" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_5.phpt b/ext/oci8/tests/imp_res_5.phpt new file mode 100644 index 0000000000..564a7a3740 --- /dev/null +++ b/ext/oci8/tests/imp_res_5.phpt @@ -0,0 +1,84 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_fetch_all +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_5_proc as + c1 sys_refcursor; + begin + open c1 for select 1 from dual union select 2 from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_5_proc(); end;"); +oci_execute($s); +oci_fetch_all($s,$res); // This will fail with ORA-24374 +var_dump($res); + +echo "\nTest 2\n"; +$s = oci_parse($c, "begin imp_res_5_proc(); end;"); +oci_execute($s); +$r = oci_fetch_row($s); +var_dump($r); +oci_fetch_all($s, $res); // This will fail with ORA-24374 +var_dump($res); +$r = oci_fetch_row($s); +var_dump($r); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_5_proc", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_fetch_all(): ORA-24374: %s in %simp_res_5.php on line %d +array(0) { +} + +Test 2 +array(1) { + [0]=> + string(1) "1" +} + +Warning: oci_fetch_all(): ORA-24374: %s in %simp_res_5.php on line %d +array(0) { +} +array(1) { + [0]=> + string(1) "2" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_6.phpt b/ext/oci8/tests/imp_res_6.phpt new file mode 100644 index 0000000000..f94efe70db --- /dev/null +++ b/ext/oci8/tests/imp_res_6.phpt @@ -0,0 +1,118 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: alternating oci_fetch_* calls +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_6_tab", + "create table imp_res_6_tab (c1 number, c2 varchar2(10))", + "insert into imp_res_6_tab values (1, 'a')", + "insert into imp_res_6_tab values (2, 'b')", + "insert into imp_res_6_tab values (3, 'c')", + "insert into imp_res_6_tab values (4, 'd')", + "insert into imp_res_6_tab values (5, 'e')", + "insert into imp_res_6_tab values (6, 'f')", + + "create or replace procedure imp_res_6_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_6_tab order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_6_proc(); end;"); +oci_execute($s); + +$row = oci_fetch_assoc($s); +var_dump($row); +$row = oci_fetch_row($s); +var_dump($row); +$row = oci_fetch_object($s); +var_dump($row); +$row = oci_fetch_array($s); +var_dump($row); +$row = oci_fetch_array($s, OCI_NUM); +var_dump($row); +$row = oci_fetch_array($s, OCI_ASSOC); +var_dump($row); + + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_6_proc", + "drop table imp_res_6_tab", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(2) { + ["C1"]=> + string(1) "1" + ["C2"]=> + string(1) "a" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(1) "b" +} +object(stdClass)#%d (2) { + ["C1"]=> + string(1) "3" + ["C2"]=> + string(1) "c" +} +array(4) { + [0]=> + string(1) "4" + ["C1"]=> + string(1) "4" + [1]=> + string(1) "d" + ["C2"]=> + string(1) "d" +} +array(2) { + [0]=> + string(1) "5" + [1]=> + string(1) "e" +} +array(2) { + ["C1"]=> + string(1) "6" + ["C2"]=> + string(1) "f" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_7.phpt b/ext/oci8/tests/imp_res_7.phpt new file mode 100644 index 0000000000..05ae5e6857 --- /dev/null +++ b/ext/oci8/tests/imp_res_7.phpt @@ -0,0 +1,873 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: bigger data size +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmt = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual; + dbms_sql.return_result(c1); + open c1 for select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual; + dbms_sql.return_result(c1); + open c1 for select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual; + dbms_sql.return_result(c1); + open c1 for select 6 from dual; + dbms_sql.return_result(c1); + open c1 for select 7 from dual; + dbms_sql.return_result(c1); + open c1 for select 8 from dual; + dbms_sql.return_result(c1); + open c1 for select 9 from dual; + dbms_sql.return_result(c1); + open c1 for select 10 from dual; + dbms_sql.return_result(c1); + open c1 for select 11 from dual; + dbms_sql.return_result(c1); + open c1 for select 12 from dual; + dbms_sql.return_result(c1); + open c1 for select 13 from dual; + dbms_sql.return_result(c1); + open c1 for select 14 from dual; + dbms_sql.return_result(c1); + open c1 for select 15 from dual; + dbms_sql.return_result(c1); + open c1 for select 16 from dual; + dbms_sql.return_result(c1); + open c1 for select 17 from dual; + dbms_sql.return_result(c1); + open c1 for select 18 from dual; + dbms_sql.return_result(c1); + open c1 for select 19 from dual; + dbms_sql.return_result(c1); + open c1 for select 20 from dual; + dbms_sql.return_result(c1); + open c1 for select 21 from dual; + dbms_sql.return_result(c1); + open c1 for select 22 from dual; + dbms_sql.return_result(c1); + open c1 for select 23 from dual; + dbms_sql.return_result(c1); + open c1 for select 24 from dual; + dbms_sql.return_result(c1); + open c1 for select 25 from dual; + dbms_sql.return_result(c1); + open c1 for select 26 from dual; + dbms_sql.return_result(c1); + open c1 for select 27 from dual; + dbms_sql.return_result(c1); + open c1 for select 28 from dual; + dbms_sql.return_result(c1); + open c1 for select 29 from dual; + dbms_sql.return_result(c1); + open c1 for select 30 from dual; + dbms_sql.return_result(c1); + open c1 for select 31 from dual; + dbms_sql.return_result(c1); + open c1 for select 32 from dual; + dbms_sql.return_result(c1); + open c1 for select 33 from dual; + dbms_sql.return_result(c1); + open c1 for select 34 from dual; + dbms_sql.return_result(c1); + open c1 for select 35 from dual; + dbms_sql.return_result(c1); + open c1 for select 36 from dual; + dbms_sql.return_result(c1); + open c1 for select 37 from dual; + dbms_sql.return_result(c1); + open c1 for select 38 from dual; + dbms_sql.return_result(c1); + open c1 for select 39 from dual; + dbms_sql.return_result(c1); + open c1 for select 40 from dual; + dbms_sql.return_result(c1); + open c1 for select 41 from dual; + dbms_sql.return_result(c1); + open c1 for select 42 from dual; + dbms_sql.return_result(c1); + open c1 for select 43 from dual; + dbms_sql.return_result(c1); + open c1 for select 44 from dual; + dbms_sql.return_result(c1); + open c1 for select 45 from dual; + dbms_sql.return_result(c1); + open c1 for select 46 from dual; + dbms_sql.return_result(c1); + open c1 for select 47 from dual; + dbms_sql.return_result(c1); + open c1 for select 48 from dual; + dbms_sql.return_result(c1); + open c1 for select 49 from dual; + dbms_sql.return_result(c1); + open c1 for select 50 from dual; + dbms_sql.return_result(c1); + open c1 for select 51 from dual; + dbms_sql.return_result(c1); + open c1 for select 52 from dual; + dbms_sql.return_result(c1); + open c1 for select 53 from dual; + dbms_sql.return_result(c1); + open c1 for select 54 from dual; + dbms_sql.return_result(c1); + open c1 for select 55 from dual; + dbms_sql.return_result(c1); + open c1 for select 56 from dual; + dbms_sql.return_result(c1); + open c1 for select 57 from dual; + dbms_sql.return_result(c1); + open c1 for select 58 from dual; + dbms_sql.return_result(c1); + open c1 for select 59 from dual; + dbms_sql.return_result(c1); + open c1 for select 60 from dual; + dbms_sql.return_result(c1); + open c1 for select 61 from dual; + dbms_sql.return_result(c1); + open c1 for select 62 from dual; + dbms_sql.return_result(c1); + open c1 for select 63 from dual; + dbms_sql.return_result(c1); + open c1 for select 64 from dual; + dbms_sql.return_result(c1); + open c1 for select 65 from dual; + dbms_sql.return_result(c1); + open c1 for select 66 from dual; + dbms_sql.return_result(c1); + open c1 for select 67 from dual; + dbms_sql.return_result(c1); + open c1 for select 68 from dual; + dbms_sql.return_result(c1); + open c1 for select 69 from dual; + dbms_sql.return_result(c1); + open c1 for select 70 from dual; + dbms_sql.return_result(c1); + open c1 for select 71 from dual; + dbms_sql.return_result(c1); + open c1 for select 72 from dual; + dbms_sql.return_result(c1); + open c1 for select 73 from dual; + dbms_sql.return_result(c1); + open c1 for select 74 from dual; + dbms_sql.return_result(c1); + open c1 for select 75 from dual; + dbms_sql.return_result(c1); + open c1 for select 76 from dual; + dbms_sql.return_result(c1); + open c1 for select 77 from dual; + dbms_sql.return_result(c1); + open c1 for select 78 from dual; + dbms_sql.return_result(c1); + open c1 for select 79 from dual; + dbms_sql.return_result(c1); + open c1 for select 80 from dual; + dbms_sql.return_result(c1); + open c1 for select 81 from dual; + dbms_sql.return_result(c1); + open c1 for select 82 from dual; + dbms_sql.return_result(c1); + open c1 for select 83 from dual; + dbms_sql.return_result(c1); + open c1 for select 84 from dual; + dbms_sql.return_result(c1); + open c1 for select 85 from dual; + dbms_sql.return_result(c1); + open c1 for select 86 from dual; + dbms_sql.return_result(c1); + open c1 for select 87 from dual; + dbms_sql.return_result(c1); + open c1 for select 88 from dual; + dbms_sql.return_result(c1); + open c1 for select 89 from dual; + dbms_sql.return_result(c1); + open c1 for select 90 from dual; + dbms_sql.return_result(c1); + open c1 for select 91 from dual; + dbms_sql.return_result(c1); + open c1 for select 92 from dual; + dbms_sql.return_result(c1); + open c1 for select 93 from dual; + dbms_sql.return_result(c1); + open c1 for select 94 from dual; + dbms_sql.return_result(c1); + open c1 for select 95 from dual; + dbms_sql.return_result(c1); + open c1 for select 96 from dual; + dbms_sql.return_result(c1); + open c1 for select 97 from dual; + dbms_sql.return_result(c1); + open c1 for select 98 from dual; + dbms_sql.return_result(c1); + open c1 for select 99 from dual; + dbms_sql.return_result(c1); + open c1 for select 100 from dual; + dbms_sql.return_result(c1); + open c1 for select 101 from dual; + dbms_sql.return_result(c1); + open c1 for select 102 from dual; + dbms_sql.return_result(c1); + open c1 for select 103 from dual; + dbms_sql.return_result(c1); + open c1 for select 104 from dual; + dbms_sql.return_result(c1); + open c1 for select 105 from dual; + dbms_sql.return_result(c1); + open c1 for select 106 from dual; + dbms_sql.return_result(c1); + open c1 for select 107 from dual; + dbms_sql.return_result(c1); + open c1 for select 108 from dual; + dbms_sql.return_result(c1); + open c1 for select 109 from dual; + dbms_sql.return_result(c1); + open c1 for select 110 from dual; + dbms_sql.return_result(c1); + open c1 for select 111 from dual; + dbms_sql.return_result(c1); + open c1 for select 112 from dual; + dbms_sql.return_result(c1); + open c1 for select 113 from dual; + dbms_sql.return_result(c1); + open c1 for select 114 from dual; + dbms_sql.return_result(c1); + open c1 for select 115 from dual; + dbms_sql.return_result(c1); + open c1 for select 116 from dual; + dbms_sql.return_result(c1); + open c1 for select 117 from dual; + dbms_sql.return_result(c1); + open c1 for select 118 from dual; + dbms_sql.return_result(c1); + open c1 for select 119 from dual; + dbms_sql.return_result(c1); + open c1 for select 120 from dual; + dbms_sql.return_result(c1); + open c1 for select 121 from dual; + dbms_sql.return_result(c1); + open c1 for select 122 from dual; + dbms_sql.return_result(c1); + open c1 for select 123 from dual; + dbms_sql.return_result(c1); + open c1 for select 124 from dual; + dbms_sql.return_result(c1); + open c1 for select 125 from dual; + dbms_sql.return_result(c1); + open c1 for select 126 from dual; + dbms_sql.return_result(c1); + open c1 for select 127 from dual; + dbms_sql.return_result(c1); + open c1 for select 128 from dual; + dbms_sql.return_result(c1); + open c1 for select 129 from dual; + dbms_sql.return_result(c1); + open c1 for select 130 from dual; + dbms_sql.return_result(c1); + open c1 for select 131 from dual; + dbms_sql.return_result(c1); + open c1 for select 132 from dual; + dbms_sql.return_result(c1); + open c1 for select 133 from dual; + dbms_sql.return_result(c1); + open c1 for select 134 from dual; + dbms_sql.return_result(c1); + open c1 for select 135 from dual; + dbms_sql.return_result(c1); + open c1 for select 136 from dual; + dbms_sql.return_result(c1); + open c1 for select 137 from dual; + dbms_sql.return_result(c1); + open c1 for select 138 from dual; + dbms_sql.return_result(c1); + open c1 for select 139 from dual; + dbms_sql.return_result(c1); + open c1 for select 140 from dual; + dbms_sql.return_result(c1); + open c1 for select 141 from dual; + dbms_sql.return_result(c1); + open c1 for select 142 from dual; + dbms_sql.return_result(c1); + open c1 for select 143 from dual; + dbms_sql.return_result(c1); + open c1 for select 144 from dual; + dbms_sql.return_result(c1); + open c1 for select 145 from dual; + dbms_sql.return_result(c1); + open c1 for select 146 from dual; + dbms_sql.return_result(c1); + open c1 for select 147 from dual; + dbms_sql.return_result(c1); + open c1 for select 148 from dual; + dbms_sql.return_result(c1); + open c1 for select 149 from dual; + dbms_sql.return_result(c1); + open c1 for select 150 from dual; + dbms_sql.return_result(c1); + open c1 for select 151 from dual; + dbms_sql.return_result(c1); + open c1 for select 152 from dual; + dbms_sql.return_result(c1); + open c1 for select 153 from dual; + dbms_sql.return_result(c1); + open c1 for select 154 from dual; + dbms_sql.return_result(c1); + open c1 for select 155 from dual; + dbms_sql.return_result(c1); + open c1 for select 156 from dual; + dbms_sql.return_result(c1); + open c1 for select 157 from dual; + dbms_sql.return_result(c1); + open c1 for select 158 from dual; + dbms_sql.return_result(c1); + open c1 for select 159 from dual; + dbms_sql.return_result(c1); + open c1 for select 160 from dual; + dbms_sql.return_result(c1); + open c1 for select 161 from dual; + dbms_sql.return_result(c1); + open c1 for select 162 from dual; + dbms_sql.return_result(c1); + open c1 for select 163 from dual; + dbms_sql.return_result(c1); + open c1 for select 164 from dual; + dbms_sql.return_result(c1); + open c1 for select 165 from dual; + dbms_sql.return_result(c1); + open c1 for select 166 from dual; + dbms_sql.return_result(c1); + open c1 for select 167 from dual; + dbms_sql.return_result(c1); + open c1 for select 168 from dual; + dbms_sql.return_result(c1); + open c1 for select 169 from dual; + dbms_sql.return_result(c1); + open c1 for select 170 from dual; + dbms_sql.return_result(c1); + open c1 for select 171 from dual; + dbms_sql.return_result(c1); + open c1 for select 172 from dual; + dbms_sql.return_result(c1); + open c1 for select 173 from dual; + dbms_sql.return_result(c1); + open c1 for select 174 from dual; + dbms_sql.return_result(c1); + open c1 for select 175 from dual; + dbms_sql.return_result(c1); + open c1 for select 176 from dual; + dbms_sql.return_result(c1); + open c1 for select 177 from dual; + dbms_sql.return_result(c1); + open c1 for select 178 from dual; + dbms_sql.return_result(c1); + open c1 for select 179 from dual; + dbms_sql.return_result(c1); + open c1 for select 180 from dual; + dbms_sql.return_result(c1); + open c1 for select 181 from dual; + dbms_sql.return_result(c1); + open c1 for select 182 from dual; + dbms_sql.return_result(c1); + open c1 for select 183 from dual; + dbms_sql.return_result(c1); + open c1 for select 184 from dual; + dbms_sql.return_result(c1); + open c1 for select 185 from dual; + dbms_sql.return_result(c1); + open c1 for select 186 from dual; + dbms_sql.return_result(c1); + open c1 for select 187 from dual; + dbms_sql.return_result(c1); + open c1 for select 188 from dual; + dbms_sql.return_result(c1); + open c1 for select 189 from dual; + dbms_sql.return_result(c1); + open c1 for select 190 from dual; + dbms_sql.return_result(c1); + open c1 for select 191 from dual; + dbms_sql.return_result(c1); + open c1 for select 192 from dual; + dbms_sql.return_result(c1); + open c1 for select 193 from dual; + dbms_sql.return_result(c1); + open c1 for select 194 from dual; + dbms_sql.return_result(c1); + open c1 for select 195 from dual; + dbms_sql.return_result(c1); + open c1 for select 196 from dual; + dbms_sql.return_result(c1); + open c1 for select 197 from dual; + dbms_sql.return_result(c1); + open c1 for select 198 from dual; + dbms_sql.return_result(c1); + open c1 for select 199 from dual; + dbms_sql.return_result(c1); + open c1 for select 200 from dual; + dbms_sql.return_result(c1); + open c1 for select 201 from dual; + dbms_sql.return_result(c1); + open c1 for select 202 from dual; + dbms_sql.return_result(c1); + open c1 for select 203 from dual; + dbms_sql.return_result(c1); + open c1 for select 204 from dual; + dbms_sql.return_result(c1); + open c1 for select 205 from dual; + dbms_sql.return_result(c1); + open c1 for select 206 from dual; + dbms_sql.return_result(c1); + open c1 for select 207 from dual; + dbms_sql.return_result(c1); + open c1 for select 208 from dual; + dbms_sql.return_result(c1); + open c1 for select 209 from dual; + dbms_sql.return_result(c1); + open c1 for select 210 from dual; + dbms_sql.return_result(c1); + open c1 for select 211 from dual; + dbms_sql.return_result(c1); + open c1 for select 212 from dual; + dbms_sql.return_result(c1); + open c1 for select 213 from dual; + dbms_sql.return_result(c1); + open c1 for select 214 from dual; + dbms_sql.return_result(c1); + open c1 for select 215 from dual; + dbms_sql.return_result(c1); + open c1 for select 216 from dual; + dbms_sql.return_result(c1); + open c1 for select 217 from dual; + dbms_sql.return_result(c1); + open c1 for select 218 from dual; + dbms_sql.return_result(c1); + open c1 for select 219 from dual; + dbms_sql.return_result(c1); + open c1 for select 220 from dual; + dbms_sql.return_result(c1); + open c1 for select 221 from dual; + dbms_sql.return_result(c1); + open c1 for select 222 from dual; + dbms_sql.return_result(c1); + open c1 for select 223 from dual; + dbms_sql.return_result(c1); + open c1 for select 224 from dual; + dbms_sql.return_result(c1); + open c1 for select 225 from dual; + dbms_sql.return_result(c1); + open c1 for select 226 from dual; + dbms_sql.return_result(c1); + open c1 for select 227 from dual; + dbms_sql.return_result(c1); + open c1 for select 228 from dual; + dbms_sql.return_result(c1); + open c1 for select 229 from dual; + dbms_sql.return_result(c1); + open c1 for select 230 from dual; + dbms_sql.return_result(c1); + open c1 for select 231 from dual; + dbms_sql.return_result(c1); + open c1 for select 232 from dual; + dbms_sql.return_result(c1); + open c1 for select 233 from dual; + dbms_sql.return_result(c1); + open c1 for select 234 from dual; + dbms_sql.return_result(c1); + open c1 for select 235 from dual; + dbms_sql.return_result(c1); + open c1 for select 236 from dual; + dbms_sql.return_result(c1); + open c1 for select 237 from dual; + dbms_sql.return_result(c1); + open c1 for select 238 from dual; + dbms_sql.return_result(c1); + open c1 for select 239 from dual; + dbms_sql.return_result(c1); + open c1 for select 240 from dual; + dbms_sql.return_result(c1); + open c1 for select 241 from dual; + dbms_sql.return_result(c1); + open c1 for select 242 from dual; + dbms_sql.return_result(c1); + open c1 for select 243 from dual; + dbms_sql.return_result(c1); + open c1 for select 244 from dual; + dbms_sql.return_result(c1); + open c1 for select 245 from dual; + dbms_sql.return_result(c1); + open c1 for select 246 from dual; + dbms_sql.return_result(c1); + open c1 for select 247 from dual; + dbms_sql.return_result(c1); + open c1 for select 248 from dual; + dbms_sql.return_result(c1); + open c1 for select 249 from dual; + dbms_sql.return_result(c1); + open c1 for select 250 from dual; + dbms_sql.return_result(c1); + open c1 for select 251 from dual; + dbms_sql.return_result(c1); + open c1 for select 252 from dual; + dbms_sql.return_result(c1); + open c1 for select 253 from dual; + dbms_sql.return_result(c1); + open c1 for select 254 from dual; + dbms_sql.return_result(c1); + open c1 for select 255 from dual; + dbms_sql.return_result(c1); + open c1 for select 256 from dual; + dbms_sql.return_result(c1); + open c1 for select 257 from dual; + dbms_sql.return_result(c1); + open c1 for select 258 from dual; + dbms_sql.return_result(c1); + open c1 for select 259 from dual; + dbms_sql.return_result(c1); + open c1 for select 260 from dual; + dbms_sql.return_result(c1); + open c1 for select 261 from dual; + dbms_sql.return_result(c1); + open c1 for select 262 from dual; + dbms_sql.return_result(c1); + open c1 for select 263 from dual; + dbms_sql.return_result(c1); + open c1 for select 264 from dual; + dbms_sql.return_result(c1); + open c1 for select 265 from dual; + dbms_sql.return_result(c1); + open c1 for select 266 from dual; + dbms_sql.return_result(c1); + open c1 for select 267 from dual; + dbms_sql.return_result(c1); + open c1 for select 268 from dual; + dbms_sql.return_result(c1); + open c1 for select 269 from dual; + dbms_sql.return_result(c1); + open c1 for select 270 from dual; + dbms_sql.return_result(c1); + open c1 for select 271 from dual; + dbms_sql.return_result(c1); + open c1 for select 272 from dual; + dbms_sql.return_result(c1); + open c1 for select 273 from dual; + dbms_sql.return_result(c1); + open c1 for select 274 from dual; + dbms_sql.return_result(c1); + open c1 for select 275 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, $stmt); +oci_execute($s); + +while (($row = oci_fetch_row($s)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 + 100 + 101 + 102 + 103 + 104 + 105 + 106 + 107 + 108 + 109 + 110 + 111 + 112 + 113 + 114 + 115 + 116 + 117 + 118 + 119 + 120 + 121 + 122 + 123 + 124 + 125 + 126 + 127 + 128 + 129 + 130 + 131 + 132 + 133 + 134 + 135 + 136 + 137 + 138 + 139 + 140 + 141 + 142 + 143 + 144 + 145 + 146 + 147 + 148 + 149 + 150 + 151 + 152 + 153 + 154 + 155 + 156 + 157 + 158 + 159 + 160 + 161 + 162 + 163 + 164 + 165 + 166 + 167 + 168 + 169 + 170 + 171 + 172 + 173 + 174 + 175 + 176 + 177 + 178 + 179 + 180 + 181 + 182 + 183 + 184 + 185 + 186 + 187 + 188 + 189 + 190 + 191 + 192 + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + 202 + 203 + 204 + 205 + 206 + 207 + 208 + 209 + 210 + 211 + 212 + 213 + 214 + 215 + 216 + 217 + 218 + 219 + 220 + 221 + 222 + 223 + 224 + 225 + 226 + 227 + 228 + 229 + 230 + 231 + 232 + 233 + 234 + 235 + 236 + 237 + 238 + 239 + 240 + 241 + 242 + 243 + 244 + 245 + 246 + 247 + 248 + 249 + 250 + 251 + 252 + 253 + 254 + 255 + 256 + 257 + 258 + 259 + 260 + 261 + 262 + 263 + 264 + 265 + 266 + 267 + 268 + 269 + 270 + 271 + 272 + 273 + 274 + 275 +===DONE=== diff --git a/ext/oci8/tests/imp_res_call_error.phpt b/ext/oci8/tests/imp_res_call_error.phpt new file mode 100644 index 0000000000..8b0fa78db9 --- /dev/null +++ b/ext/oci8/tests/imp_res_call_error.phpt @@ -0,0 +1,61 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: using SQL 'CALL' +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_call_err_proc as + c1 sys_refcursor; + begin + open c1 for select * from dual; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;"); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "call imp_res_call_err_proc()"); +oci_execute($s); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_call_err_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_execute(): ORA-29478: %s +ORA-06512: at "SYS.DBMS_SQL", line %d +ORA-06512: at "SYS.DBMS_SQL", line %d +ORA-06512: at "SYSTEM.IMP_RES_CALL_ERR_PROC", line %d in %simp_res_call_error.php on line %d +===DONE=== diff --git a/ext/oci8/tests/imp_res_cancel.phpt b/ext/oci8/tests/imp_res_cancel.phpt new file mode 100644 index 0000000000..663d630dfb --- /dev/null +++ b/ext/oci8/tests/imp_res_cancel.phpt @@ -0,0 +1,68 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_cancel +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$stmtarray = array( + "create or replace procedure imp_res_cancel_proc as + c1 sys_refcursor; + c2 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c2 for select 3 from dual; + dbms_sql.return_result (c2); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_cancel_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + var_dump(oci_cancel($s)); +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_cancel_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 +bool(true) + 2 +bool(true) + 3 +bool(true) +===DONE=== diff --git a/ext/oci8/tests/imp_res_close.phpt b/ext/oci8/tests/imp_res_close.phpt new file mode 100644 index 0000000000..01ac2c75e0 --- /dev/null +++ b/ext/oci8/tests/imp_res_close.phpt @@ -0,0 +1,69 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_free_statement #1 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace procedure imp_res_close_proc as + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual order by 1; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual order by 1; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_close_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + oci_free_statement($s); // Free the implicit result handle +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_close_proc" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 + +Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %simp_res_close.php on line %d +===DONE=== diff --git a/ext/oci8/tests/imp_res_cursor.phpt b/ext/oci8/tests/imp_res_cursor.phpt new file mode 100644 index 0000000000..cac0a5d1c0 --- /dev/null +++ b/ext/oci8/tests/imp_res_cursor.phpt @@ -0,0 +1,99 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: nested cursor +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_cursor_tab_1", + "create table imp_res_cursor_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_cursor_tab_1 values (1, 'abcde')", + "insert into imp_res_cursor_tab_1 values (2, 'fghij')", + "insert into imp_res_cursor_tab_1 values (3, 'klmno')", + + "drop table imp_res_cursor_tab_2", + "create table imp_res_cursor_tab_2 (c3 varchar2(1))", + "insert into imp_res_cursor_tab_2 values ('t')", + "insert into imp_res_cursor_tab_2 values ('u')", + "insert into imp_res_cursor_tab_2 values ('v')", + + "create or replace procedure imp_res_cursor_proc as + c1 sys_refcursor; + begin + open c1 for select * from dual; + dbms_sql.return_result (c1); + + open c1 for select cursor(select c1, c2 from imp_res_cursor_tab_1 order by 1) as curs from dual; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_cursor_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function do_fetch($s) +{ + while (($row = oci_fetch_assoc($s)) != false) { + foreach ($row as $item) { + if (is_resource($item)) { // Nested cursor + oci_execute($item); + do_fetch($item); + } else { + echo " ".$item; + } + } + echo "\n"; + } +} + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_cursor_proc(); end;"); +oci_execute($s); + +do_fetch($s); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_cursor_proc", + "drop table imp_res_cursor_tab_1", + "drop table imp_res_cursor_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + X + 1 abcde + 2 fghij + 3 klmno + + t + u +===DONE=== diff --git a/ext/oci8/tests/imp_res_dbmsoutput.phpt b/ext/oci8/tests/imp_res_dbmsoutput.phpt new file mode 100644 index 0000000000..8c9808d96c --- /dev/null +++ b/ext/oci8/tests/imp_res_dbmsoutput.phpt @@ -0,0 +1,136 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: interleaved with DBMS_OUTPUT +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_dbmsoutput_tab_1", + "create table imp_res_dbmsoutput_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_dbmsoutput_tab_1 values (1, 'abcde')", + "insert into imp_res_dbmsoutput_tab_1 values (2, 'fghij')", + "insert into imp_res_dbmsoutput_tab_1 values (3, 'klmno')", + + "drop table imp_res_dbmsoutput_tab_2", + "create table imp_res_dbmsoutput_tab_2 (c3 varchar2(1))", + "insert into imp_res_dbmsoutput_tab_2 values ('t')", + "insert into imp_res_dbmsoutput_tab_2 values ('u')", + "insert into imp_res_dbmsoutput_tab_2 values ('v')", + + "create or replace procedure imp_res_dbmsoutput_proc as + c1 sys_refcursor; + begin + dbms_output.put_line('dbms_output Line 1'); + open c1 for select * from imp_res_dbmsoutput_tab_1 order by 1; + dbms_sql.return_result(c1); + dbms_output.put_line('dbms_output Line 2'); + open c1 for select * from imp_res_dbmsoutput_tab_2 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function setserveroutputon($c) +{ + $s = oci_parse($c, "begin dbms_output.enable(null); end;"); + oci_execute($s); +} + +function getdbmsoutput_do($c) +{ + $s = oci_parse($c, "begin dbms_output.get_line(:ln, :st); end;"); + oci_bind_by_name($s, ":ln", $ln, 100); + oci_bind_by_name($s, ":st", $st, -1, SQLT_INT); + $res = false; + while (($succ = oci_execute($s)) && !$st) { + $res[] = $ln; // append each line to the array + } + return $res; +} + +setserveroutputon($c); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_dbmsoutput_proc(); end;"); +oci_execute($s); +var_dump(getdbmsoutput_do($c)); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +echo "\nTest 2\n"; +$s = oci_parse($c, "begin imp_res_dbmsoutput_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} +var_dump(getdbmsoutput_do($c)); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_dbmsoutput_proc", + "drop table imp_res_dbmsoutput_tab_1", + "drop table imp_res_dbmsoutput_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(2) { + [0]=> + string(18) "dbms_output Line 1" + [1]=> + string(18) "dbms_output Line 2" +} + 1 abcde + 2 fghij + 3 klmno + t + u + v + +Test 2 + 1 abcde + 2 fghij + 3 klmno + t + u + v +array(2) { + [0]=> + string(18) "dbms_output Line 1" + [1]=> + string(18) "dbms_output Line 2" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_field.phpt b/ext/oci8/tests/imp_res_field.phpt new file mode 100644 index 0000000000..54b8295cf9 --- /dev/null +++ b/ext/oci8/tests/imp_res_field.phpt @@ -0,0 +1,227 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: field tests +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_field_tab_1", + "create table imp_res_field_tab_1 (c1_number number, c2_varchar210 varchar2(10))", + "insert into imp_res_field_tab_1 values (1111, 'abcde')", + + "drop table imp_res_field_tab_2", + "create table imp_res_field_tab_2 (c3_varchar21 varchar2(4))", + "insert into imp_res_field_tab_2 values ('tttt')", + + "drop table imp_res_field_tab_3", + "create table imp_res_field_tab_3 (c4_number52 number(5,2))", + "insert into imp_res_field_tab_3 values (33)", + "insert into imp_res_field_tab_3 values (NULL)", + + "create or replace procedure imp_res_field_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_field_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_field_tab_2 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_field_tab_3 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function print_fields($s) +{ + echo "num fields : " . oci_num_fields($s) . "\n"; + for ($i = 1; $i <= oci_num_fields($s); $i++) { + $is_null = oci_field_is_null($s, $i) ? "T" : "F"; + $name = oci_field_name($s, $i); + $precision = oci_field_precision($s, $i); + $scale = oci_field_scale($s, $i); + $size = oci_field_size($s, $i); + $typeraw = oci_field_type_raw($s, $i); + $type = oci_field_type($s, $i); + echo "$name\t: is_null $is_null, precision $precision, scale $scale, size $size, typeraw $typeraw, type $type\n"; + } +} + +// Run Test + +echo "Test 1 - can't get IRS fields from parent\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +print_fields($s); + +echo "\nTest 2 - can't get IRS fields from parent when fetching\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +while (($r = oci_fetch_row($s))) { + var_dump($r); + print_fields($s); +} + +echo "\nTest 3 - get IRS fields\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + print_fields($s1); +} + +echo "\nTest 4 - get IRS fields before fetching rows\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +$i = 0; +while (($s1 = oci_get_implicit_resultset($s))) { + echo "===> Result set ".++$i."\n"; + print_fields($s1); + while (($r = oci_fetch_row($s1)) !== false) { + var_dump($r); + } +} + +echo "\nTest 5 - get IRS fields when fetching rows\n"; +$s = oci_parse($c, "begin imp_res_field_proc(); end;"); +oci_execute($s); +$i = 0; +while (($s1 = oci_get_implicit_resultset($s))) { + echo "===> Result set ".++$i."\n"; + while (($r = oci_fetch_row($s1)) !== false) { + var_dump($r); + print_fields($s1); + } +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_field_proc", + "drop table imp_res_field_tab_1", + "drop table imp_res_field_tab_2", + "drop table imp_res_field_tab_3" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - can't get IRS fields from parent +num fields : 0 + +Test 2 - can't get IRS fields from parent when fetching +array(2) { + [0]=> + string(4) "1111" + [1]=> + string(5) "abcde" +} +num fields : 0 +array(1) { + [0]=> + string(4) "tttt" +} +num fields : 0 +array(1) { + [0]=> + string(2) "33" +} +num fields : 0 +array(1) { + [0]=> + NULL +} +num fields : 0 + +Test 3 - get IRS fields +num fields : 2 +C1_NUMBER : is_null F, precision 0, scale -127, size 22, typeraw 2, type NUMBER +C2_VARCHAR210 : is_null F, precision 0, scale 0, size 10, typeraw 1, type VARCHAR2 +num fields : 1 +C3_VARCHAR21 : is_null F, precision 0, scale 0, size 4, typeraw 1, type VARCHAR2 +num fields : 1 +C4_NUMBER52 : is_null F, precision 5, scale 2, size 22, typeraw 2, type NUMBER + +Test 4 - get IRS fields before fetching rows +===> Result set 1 +num fields : 2 +C1_NUMBER : is_null F, precision 0, scale -127, size 22, typeraw 2, type NUMBER +C2_VARCHAR210 : is_null F, precision 0, scale 0, size 10, typeraw 1, type VARCHAR2 +array(2) { + [0]=> + string(4) "1111" + [1]=> + string(5) "abcde" +} +===> Result set 2 +num fields : 1 +C3_VARCHAR21 : is_null F, precision 0, scale 0, size 4, typeraw 1, type VARCHAR2 +array(1) { + [0]=> + string(4) "tttt" +} +===> Result set 3 +num fields : 1 +C4_NUMBER52 : is_null F, precision 5, scale 2, size 22, typeraw 2, type NUMBER +array(1) { + [0]=> + string(2) "33" +} +array(1) { + [0]=> + NULL +} + +Test 5 - get IRS fields when fetching rows +===> Result set 1 +array(2) { + [0]=> + string(4) "1111" + [1]=> + string(5) "abcde" +} +num fields : 2 +C1_NUMBER : is_null F, precision 0, scale -127, size 22, typeraw 2, type NUMBER +C2_VARCHAR210 : is_null F, precision 0, scale 0, size 10, typeraw 1, type VARCHAR2 +===> Result set 2 +array(1) { + [0]=> + string(4) "tttt" +} +num fields : 1 +C3_VARCHAR21 : is_null F, precision 0, scale 0, size 4, typeraw 1, type VARCHAR2 +===> Result set 3 +array(1) { + [0]=> + string(2) "33" +} +num fields : 1 +C4_NUMBER52 : is_null F, precision 5, scale 2, size 22, typeraw 2, type NUMBER +array(1) { + [0]=> + NULL +} +num fields : 1 +C4_NUMBER52 : is_null T, precision 5, scale 2, size 22, typeraw 2, type NUMBER +===DONE=== diff --git a/ext/oci8/tests/imp_res_func_error.phpt b/ext/oci8/tests/imp_res_func_error.phpt new file mode 100644 index 0000000000..73c0557930 --- /dev/null +++ b/ext/oci8/tests/imp_res_func_error.phpt @@ -0,0 +1,67 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: test with a PL/SQL function +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "create or replace function imp_res_func_error return number as + c1 sys_refcursor; + begin + open c1 for select * from dual; + dbms_sql.return_result(c1); + return 1234; + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "select imp_res_func_error from dual"); +$r = oci_execute($s); // This will fail with ORA-29478 in Oracle 12.1 +if ($r) { + while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} +// Clean up + +$stmtarray = array( + "drop function imp_res_func_error", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + +Warning: oci_execute(): ORA-29478: %s +ORA-06512: %s +ORA-06512: %s +ORA-06512: %s +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_1.phpt b/ext/oci8/tests/imp_res_get_1.phpt new file mode 100644 index 0000000000..665f773b57 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_1.phpt @@ -0,0 +1,109 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: basic test +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_1_tab_1", + "create table imp_res_get_1_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_1_tab_1 values (1, 'abcde')", + "insert into imp_res_get_1_tab_1 values (2, 'fghij')", + "insert into imp_res_get_1_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_1_tab_2", + "create table imp_res_get_1_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_1_tab_2 values ('t')", + "insert into imp_res_get_1_tab_2 values ('u')", + "insert into imp_res_get_1_tab_2 values ('v')", + + "create or replace procedure imp_res_get_1_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_get_1_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_get_1_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_get_1_proc(); end;"); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +echo "\nTest 2 - with execute\n"; +$s = oci_parse($c, "begin imp_res_get_1_proc(); end;"); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + oci_execute($s1); // no op + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_1_proc", + "drop table imp_res_get_1_tab_1", + "drop table imp_res_get_1_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + 2 fghij + 3 klmno + t + u + X + +Test 2 - with execute + 1 abcde + 2 fghij + 3 klmno + t + u + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_2.phpt b/ext/oci8/tests/imp_res_get_2.phpt new file mode 100644 index 0000000000..b20b8dd397 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_2.phpt @@ -0,0 +1,107 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: similar to imp_res_get_1 but with unrolled loop +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_2_tab_1", + "create table imp_res_get_2_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_2_tab_1 values (1, 'abcde')", + "insert into imp_res_get_2_tab_1 values (2, 'fghij')", + "insert into imp_res_get_2_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_2_tab_2", + "create table imp_res_get_2_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_2_tab_2 values ('t')", + "insert into imp_res_get_2_tab_2 values ('u')", + "insert into imp_res_get_2_tab_2 values ('v')", + + "create or replace procedure imp_res_get_2_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_get_2_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_get_2_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_2_proc(); end;"); +oci_execute($s); + +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS))) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +$s2 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS))) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} +oci_free_statement($s2); + +$s3 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_array($s3, OCI_ASSOC+OCI_RETURN_NULLS))) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} +oci_free_statement($s3); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_2_proc", + "drop table imp_res_get_2_tab_1", + "drop table imp_res_get_2_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + 2 fghij + 3 klmno + t + u + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_3.phpt b/ext/oci8/tests/imp_res_get_3.phpt new file mode 100644 index 0000000000..15b2efaef0 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_3.phpt @@ -0,0 +1,267 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: basic test 3 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--INI-- +oci8.statement_cache_size = 0 +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_3_tab_1", + "create table imp_res_get_3_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_3_tab_1 values (1, 'abcde')", + "insert into imp_res_get_3_tab_1 values (2, 'fghij')", + "insert into imp_res_get_3_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_3_tab_2", + "create table imp_res_get_3_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_3_tab_2 values ('t')", + "insert into imp_res_get_3_tab_2 values ('u')", + "insert into imp_res_get_3_tab_2 values ('v')", + + "create or replace procedure imp_res_get_3_proc as + c1 sys_refcursor; + i pls_integer; + begin + for i in 1..30 loop -- if this value is too big for Oracle's open_cursors, calling imp_res_get_3_proc() can fail with ORA-1000 + open c1 for select * from imp_res_get_3_tab_1 order by 1; + dbms_sql.return_result(c1); + open c1 for select * from imp_res_get_3_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result (c1); + end loop; + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_3_proc(); end;"); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_3_proc", + "drop table imp_res_get_3_tab_1", + "drop table imp_res_get_3_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X + 1 abcde + 2 fghij + 3 klmno + t + u + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_4.phpt b/ext/oci8/tests/imp_res_get_4.phpt new file mode 100644 index 0000000000..ea7fb8775a --- /dev/null +++ b/ext/oci8/tests/imp_res_get_4.phpt @@ -0,0 +1,146 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: interleaved fetches +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_4_tab_1", + "create table imp_res_get_4_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_4_tab_1 values (1, 'abcde')", + "insert into imp_res_get_4_tab_1 values (2, 'fghij')", + "insert into imp_res_get_4_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_4_tab_2", + "create table imp_res_get_4_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_4_tab_2 values ('t')", + "insert into imp_res_get_4_tab_2 values ('u')", + "insert into imp_res_get_4_tab_2 values ('v')", + + "create or replace procedure imp_res_get_4_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_get_4_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_get_4_tab_2 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function print_row($row) +{ + if ($row === false) { + print "Return is false\n"; + return; + } + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_4_proc(); end;"); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +$s2 = oci_get_implicit_resultset($s); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); + +echo "Test 2 - too many fetches\n"; + +$s = oci_parse($c, "begin imp_res_get_4_proc(); end;"); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +$s2 = oci_get_implicit_resultset($s); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); +$row = oci_fetch_array($s2, OCI_ASSOC+OCI_RETURN_NULLS); +print_row($row); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_4_proc", + "drop table imp_res_get_4_tab_1", + "drop table imp_res_get_4_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + t + 2 fghij + u + 3 klmno + v +Test 2 - too many fetches + 1 abcde + t + 2 fghij + u + 3 klmno + v +Return is false +Return is false + +Warning: oci_fetch_array(): ORA-01002: %s in %simp_res_get_4.php on line %d +Return is false + +Warning: oci_fetch_array(): ORA-01002: %s in %simp_res_get_4.php on line %d +Return is false +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_5.phpt b/ext/oci8/tests/imp_res_get_5.phpt new file mode 100644 index 0000000000..3cfa0967a2 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_5.phpt @@ -0,0 +1,124 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: get from wrong statement +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +function print_row($row) +{ + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} + +$plsql = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; +// This test effectively discards all the first IRS results +$s = oci_parse($c, $plsql); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { // $s1 is never used again so its results are lost + while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { // use parent $s instead of $s1 + print_row($row); + } +} +oci_free_statement($s); + +echo "\nTest 2 - fetch first IRS explicitly\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_row($s1)) != false) { + print_row($row); +} +while (($row = oci_fetch_row($s)) != false) { + print_row($row); +} +oci_free_statement($s); + +echo "\nTest 3 - fetch part of IRS explicitly\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_row($s1)) != false) { + print_row($row); +} +$row = oci_fetch_row($s); +print_row($row); +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_row($s1)) != false) { + print_row($row); +} +while (($row = oci_fetch_row($s)) != false) { + print_row($row); +} +oci_free_statement($s); + +echo "\nTest 4 - skip IRSs\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +$s1 = oci_get_implicit_resultset($s); +$s1 = oci_get_implicit_resultset($s); +while (($row = oci_fetch_row($s)) != false) { // parent + print_row($row); +} +oci_free_statement($s); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 3 + 4 + 5 + 6 + +Test 2 - fetch first IRS explicitly + 1 + 2 + 3 + 4 + 5 + 6 + +Test 3 - fetch part of IRS explicitly + 1 + 2 + 3 + 5 + 6 + 4 + +Test 4 - skip IRSs + 5 + 6 +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_all.phpt b/ext/oci8/tests/imp_res_get_all.phpt new file mode 100644 index 0000000000..d2dcbea6c7 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_all.phpt @@ -0,0 +1,120 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_fetch_all +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$plsql = "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); + +$s1 = oci_get_implicit_resultset($s); +oci_fetch_all($s1, $res); +var_dump($res); + +$s2 = oci_get_implicit_resultset($s); +oci_fetch_all($s2, $res); +var_dump($res); + +$s3 = oci_get_implicit_resultset($s); +oci_fetch_all($s3, $res); +var_dump($res); + +echo "\nTest 2\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + $r = oci_fetch_all($s1, $res); + var_dump($res); +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(1) { + [1]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + } +} +array(1) { + [3]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(1) "4" + } +} +array(1) { + [5]=> + array(2) { + [0]=> + string(1) "5" + [1]=> + string(1) "6" + } +} + +Test 2 +array(1) { + [1]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + } +} +array(1) { + [3]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(1) "4" + } +} +array(1) { + [5]=> + array(2) { + [0]=> + string(1) "5" + [1]=> + string(1) "6" + } +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_cancel.phpt b/ext/oci8/tests/imp_res_get_cancel.phpt new file mode 100644 index 0000000000..7dbcecbfe9 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_cancel.phpt @@ -0,0 +1,56 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_cancel +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$plsql = + "declare + c1 sys_refcursor; + c2 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c2 for select 3 from dual; + dbms_sql.return_result (c2); + end;"; + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, $plsql); +oci_execute($s); +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + oci_cancel($s1); + } +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 3 +===DONE=== + diff --git a/ext/oci8/tests/imp_res_get_close_1.phpt b/ext/oci8/tests/imp_res_get_close_1.phpt new file mode 100644 index 0000000000..2edc8bf604 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_close_1.phpt @@ -0,0 +1,68 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_free_statement #1 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$plsql = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, $plsql); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + oci_free_statement($s1); // Free the implicit result handle + } +} +oci_free_statement($s); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + +Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d + 3 + +Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d + 5 + +Warning: oci_fetch_array(): %d is not a valid oci8 statement resource in %s on line %d +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_close_2.phpt b/ext/oci8/tests/imp_res_get_close_2.phpt new file mode 100644 index 0000000000..b3153834ba --- /dev/null +++ b/ext/oci8/tests/imp_res_get_close_2.phpt @@ -0,0 +1,64 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_free_statement #2 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$plsql = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, $plsql); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + oci_free_statement($s); // close parent + } +} + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 + +Warning: oci_fetch_array(): OCI_INVALID_HANDLE in %s on line %d + +Warning: oci_get_implicit_resultset(): %d is not a valid oci8 statement resource in %s on line %d +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_close_3.phpt b/ext/oci8/tests/imp_res_get_close_3.phpt new file mode 100644 index 0000000000..4793a6c882 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_close_3.phpt @@ -0,0 +1,65 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_free_statement #3 +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$plsql = + "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + open c1 for select 3 from dual union all select 4 from dual; + dbms_sql.return_result(c1); + open c1 for select 5 from dual union all select 6 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, $plsql); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } + oci_free_statement($s1); +} +oci_free_statement($s); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 + 3 + 4 + 5 + 6 +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_cursor.phpt b/ext/oci8/tests/imp_res_get_cursor.phpt new file mode 100644 index 0000000000..ccdb6f5490 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_cursor.phpt @@ -0,0 +1,101 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: nested cursor +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_cursor_tab_1", + "create table imp_res_get_cursor_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_cursor_tab_1 values (1, 'abcde')", + "insert into imp_res_get_cursor_tab_1 values (2, 'fghij')", + "insert into imp_res_get_cursor_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_cursor_tab_2", + "create table imp_res_get_cursor_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_cursor_tab_2 values ('t')", + "insert into imp_res_get_cursor_tab_2 values ('u')", + "insert into imp_res_get_cursor_tab_2 values ('v')", + + "create or replace procedure imp_res_get_cursor_proc as + c1 sys_refcursor; + begin + open c1 for select cursor(select c1, c2 from imp_res_get_cursor_tab_1 order by 1) as curs from dual; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_get_cursor_tab_2 where rownum < 3 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +function do_fetch($s) +{ + while (($row = oci_fetch_assoc($s)) != false) { + foreach ($row as $item) { + if (is_resource($item)) { // Nested cursor + oci_execute($item); + do_fetch($item); + } else { + echo " ".$item; + } + } + echo "\n"; + } +} + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_cursor_proc(); end;"); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + do_fetch($s1); +} + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_cursor_proc", + "drop table imp_res_get_cursor_tab_1", + "drop table imp_res_get_cursor_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 abcde + 2 fghij + 3 klmno + + t + u + X +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_dbmsoutput.phpt b/ext/oci8/tests/imp_res_get_dbmsoutput.phpt new file mode 100644 index 0000000000..cbc2389e46 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_dbmsoutput.phpt @@ -0,0 +1,156 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: interleaved with DBMS_OUTPUT +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_get_dbmsoutput_tab_1", + "create table imp_res_get_dbmsoutput_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_get_dbmsoutput_tab_1 values (1, 'abcde')", + "insert into imp_res_get_dbmsoutput_tab_1 values (2, 'fghij')", + "insert into imp_res_get_dbmsoutput_tab_1 values (3, 'klmno')", + + "drop table imp_res_get_dbmsoutput_tab_2", + "create table imp_res_get_dbmsoutput_tab_2 (c3 varchar2(1))", + "insert into imp_res_get_dbmsoutput_tab_2 values ('t')", + "insert into imp_res_get_dbmsoutput_tab_2 values ('u')", + "insert into imp_res_get_dbmsoutput_tab_2 values ('v')", + + "create or replace procedure imp_res_get_dbmsoutput_proc as + c1 sys_refcursor; + begin + dbms_output.put_line('Line 1'); + open c1 for select * from imp_res_get_dbmsoutput_tab_1 order by 1; + dbms_sql.return_result(c1); + dbms_output.put_line('Line 2'); + open c1 for select * from imp_res_get_dbmsoutput_tab_2 order by 1; + dbms_sql.return_result(c1); + dbms_output.put_line('Line 3'); + open c1 for select * from dual; + dbms_sql.return_result (c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Turn DBMS_OUTPUT on +function setserveroutputon($c) +{ + $s = oci_parse($c, "begin dbms_output.enable(null); end;"); + oci_execute($s); +} + +function getdbmsoutput_do($c) +{ + $s = oci_parse($c, "begin dbms_output.get_line(:ln, :st); end;"); + oci_bind_by_name($s, ":ln", $ln, 100); + oci_bind_by_name($s, ":st", $st, -1, SQLT_INT); + $res = false; + while (($succ = oci_execute($s)) && !$st) { + $res[] = $ln; // append each line to the array + } + return $res; +} + +setserveroutputon($c); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "begin imp_res_get_dbmsoutput_proc(); end;"); +oci_execute($s); + +var_dump(getdbmsoutput_do($c)); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +echo "Test 2\n"; + +$s = oci_parse($c, "begin imp_res_get_dbmsoutput_proc(); end;"); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +var_dump(getdbmsoutput_do($c)); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_get_dbmsoutput_proc", + "drop table imp_res_get_dbmsoutput_tab_1", + "drop table imp_res_get_dbmsoutput_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +array(3) { + [0]=> + string(6) "Line 1" + [1]=> + string(6) "Line 2" + [2]=> + string(6) "Line 3" +} + 1 abcde + 2 fghij + 3 klmno + t + u + v + X +Test 2 + 1 abcde + 2 fghij + 3 klmno + t + u + v + X +array(3) { + [0]=> + string(6) "Line 1" + [1]=> + string(6) "Line 2" + [2]=> + string(6) "Line 3" +} +===DONE=== + diff --git a/ext/oci8/tests/imp_res_get_exec.phpt b/ext/oci8/tests/imp_res_get_exec.phpt new file mode 100644 index 0000000000..dbd8f3ef3a --- /dev/null +++ b/ext/oci8/tests/imp_res_get_exec.phpt @@ -0,0 +1,55 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: Execute twice +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +$plsql = "declare + c1 sys_refcursor; + begin + open c1 for select 1 from dual union all select 2 from dual; + dbms_sql.return_result(c1); + end;"; + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, $plsql); +oci_execute($s); + +$s1 = oci_get_implicit_resultset($s); +oci_execute($s1); +oci_execute($s1); // execute twice; should be NOP +while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; +} +oci_free_statement($s); + + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 + 2 +===DONE=== diff --git a/ext/oci8/tests/imp_res_get_none.phpt b/ext/oci8/tests/imp_res_get_none.phpt new file mode 100644 index 0000000000..981f4945e2 --- /dev/null +++ b/ext/oci8/tests/imp_res_get_none.phpt @@ -0,0 +1,46 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: no implicit results +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Run Test + +echo "Test 1\n"; + +$s = oci_parse($c, "select * from dual"); +oci_execute($s); + +while (($s1 = oci_get_implicit_resultset($s))) { + while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { + foreach ($row as $item) { + echo " ".$item; + } + echo "\n"; + } +} + +var_dump($s1); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 +bool(false) +===DONE=== diff --git a/ext/oci8/tests/imp_res_insert.phpt b/ext/oci8/tests/imp_res_insert.phpt new file mode 100644 index 0000000000..d9c0705b55 --- /dev/null +++ b/ext/oci8/tests/imp_res_insert.phpt @@ -0,0 +1,152 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: Commit modes +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$c2 = oci_new_connect($user, $password, $dbase); + +$stmtarray = array( + "drop table imp_res_insert_tab", + "create table imp_res_insert_tab (c1 number)", + + "create or replace procedure imp_res_insert_proc_nc (p1 in number) as + c1 sys_refcursor; + begin + execute immediate 'insert into imp_res_insert_tab values ('||p1||')'; + open c1 for select * from imp_res_insert_tab order by 1; + dbms_sql.return_result(c1); + end;", + + "create or replace procedure imp_res_insert_proc_c (p1 in number) as + c1 sys_refcursor; + begin + execute immediate 'insert into imp_res_insert_tab values ('||p1||')'; + commit; + open c1 for select * from imp_res_insert_tab order by 1; + dbms_sql.return_result(c1); + end;" + +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1 - No commit in procedure, OCI_COMMIT_ON_SUCCESS mode\n"; +$s = oci_parse($c, "begin imp_res_insert_proc_nc(111); end;"); +oci_execute($s, OCI_COMMIT_ON_SUCCESS); +while (($row = oci_fetch_row($s)) !== false) + echo $row[0], "\n"; +$s2 = oci_parse($c2, "select * from imp_res_insert_tab order by 1"); +oci_execute($s2, OCI_NO_AUTO_COMMIT); +oci_fetch_all($s2, $res); +var_dump($res['C1']); + +echo "\nTest 2 - No commit in procedure, OCI_NO_AUTO_COMMIT mode\n"; +$s = oci_parse($c, "begin imp_res_insert_proc_nc(222); end;"); +oci_execute($s, OCI_NO_AUTO_COMMIT); +while (($row = oci_fetch_row($s)) !== false) + echo $row[0], "\n"; +// The 2nd connection won't see the newly inserted data +$s2 = oci_parse($c2, "select * from imp_res_insert_tab order by 1"); +oci_execute($s2, OCI_NO_AUTO_COMMIT); +oci_fetch_all($s2, $res); +var_dump($res['C1']); + +echo "\nTest 3 - Commit in procedure, OCI_COMMIT_ON_SUCCESS mode\n"; +$s = oci_parse($c, "begin imp_res_insert_proc_c(333); end;"); +oci_execute($s, OCI_COMMIT_ON_SUCCESS); +// The 2nd connection will now see the previously uncommitted data inserted in the previous test +while (($row = oci_fetch_row($s)) !== false) + echo $row[0], "\n"; +$s2 = oci_parse($c2, "select * from imp_res_insert_tab order by 1"); +oci_execute($s2, OCI_NO_AUTO_COMMIT); +oci_fetch_all($s2, $res); +var_dump($res['C1']); + +echo "\nTest 4 - Commit in procedure, OCI_NO_AUTO_COMMIT mode\n"; +$s = oci_parse($c, "begin imp_res_insert_proc_c(444); end;"); +oci_execute($s, OCI_NO_AUTO_COMMIT); +while (($row = oci_fetch_row($s)) !== false) + echo $row[0], "\n"; +$s2 = oci_parse($c2, "select * from imp_res_insert_tab order by 1"); +oci_execute($s2, OCI_NO_AUTO_COMMIT); +oci_fetch_all($s2, $res); +var_dump($res['C1']); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_insert_proc_nc", + "drop procedure imp_res_insert_proc_c", + "drop table imp_res_insert_tab", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - No commit in procedure, OCI_COMMIT_ON_SUCCESS mode +111 +array(1) { + [0]=> + string(3) "111" +} + +Test 2 - No commit in procedure, OCI_NO_AUTO_COMMIT mode +111 +222 +array(1) { + [0]=> + string(3) "111" +} + +Test 3 - Commit in procedure, OCI_COMMIT_ON_SUCCESS mode +111 +222 +333 +array(3) { + [0]=> + string(3) "111" + [1]=> + string(3) "222" + [2]=> + string(3) "333" +} + +Test 4 - Commit in procedure, OCI_NO_AUTO_COMMIT mode +111 +222 +333 +444 +array(4) { + [0]=> + string(3) "111" + [1]=> + string(3) "222" + [2]=> + string(3) "333" + [3]=> + string(3) "444" +} +===DONE=== diff --git a/ext/oci8/tests/imp_res_lob.phpt b/ext/oci8/tests/imp_res_lob.phpt new file mode 100644 index 0000000000..247803581d --- /dev/null +++ b/ext/oci8/tests/imp_res_lob.phpt @@ -0,0 +1,101 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: LOBs +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_lob_tab", + "create table imp_res_lob_tab (c1 number, c2 clob, c3 varchar2(10))", + "insert into imp_res_lob_tab values (1, 'aaaaa', 'a')", + "insert into imp_res_lob_tab values (2, 'bbbbb', 'b')", + "insert into imp_res_lob_tab values (3, 'ccccc', 'c')", + "insert into imp_res_lob_tab values (4, 'ddddd', 'd')", + + "create or replace procedure imp_res_lob_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_lob_tab order by 1; + dbms_sql.return_result(c1); + open c1 for select * from dual; + dbms_sql.return_result(c1); + open c1 for select c2 from imp_res_lob_tab order by c1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1\n"; +$s = oci_parse($c, "begin imp_res_lob_proc(); end;"); +oci_execute($s); +while (($row = oci_fetch_row($s)) != false) { + foreach ($row as $item) { + if (is_object($item)) { + echo " " . $item->load(); + } else { + echo " " . $item; + } + } + echo "\n"; +} + +echo "\nTest 2 - don't fetch all rows\n"; +$s = oci_parse($c, "begin imp_res_lob_proc(); end;"); +oci_execute($s); +$row = oci_fetch_row($s); +foreach ($row as $item) { + if (is_object($item)) { + echo " " . $item->load(); + } else { + echo " " . $item; + } +} +echo "\n"; + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_lob_proc", + "drop table imp_res_lob_tab", +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 + 1 aaaaa a + 2 bbbbb b + 3 ccccc c + 4 ddddd d + X + aaaaa + bbbbb + ccccc + ddddd + +Test 2 - don't fetch all rows + 1 aaaaa a +===DONE=== diff --git a/ext/oci8/tests/imp_res_prefetch.phpt b/ext/oci8/tests/imp_res_prefetch.phpt new file mode 100644 index 0000000000..5acdd518e5 --- /dev/null +++ b/ext/oci8/tests/imp_res_prefetch.phpt @@ -0,0 +1,185 @@ +--TEST-- +Oracle Database 12c Implicit Result Sets: basic test +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); +if (!(isset($matches[0]) && $matches[1] >= 12)) { + die("skip expected output only valid when using Oracle Database 12c or greater"); +} +preg_match('/^[[:digit:]]+/', oci_client_version(), $matches); +if (!(isset($matches[0]) && $matches[0] >= 12)) { + die("skip works only with Oracle 12c or greater version of Oracle client libraries"); +} +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); + +// Initialization + +$stmtarray = array( + "drop table imp_res_prefetch_tab_1", + "create table imp_res_prefetch_tab_1 (c1 number, c2 varchar2(10))", + "insert into imp_res_prefetch_tab_1 values (1, 'abcde')", + "insert into imp_res_prefetch_tab_1 values (2, 'fghij')", + "insert into imp_res_prefetch_tab_1 values (3, 'klmno')", + + "drop table imp_res_prefetch_tab_2", + "create table imp_res_prefetch_tab_2 (c3 varchar2(1))", + "insert into imp_res_prefetch_tab_2 values ('t')", + "insert into imp_res_prefetch_tab_2 values ('u')", + "insert into imp_res_prefetch_tab_2 values ('v')", + + "create or replace procedure imp_res_prefetch_proc as + c1 sys_refcursor; + begin + open c1 for select * from imp_res_prefetch_tab_1 order by 1; + dbms_sql.return_result(c1); + + open c1 for select * from imp_res_prefetch_tab_2 order by 1; + dbms_sql.return_result(c1); + end;" +); + +oci8_test_sql_execute($c, $stmtarray); + +// Run Test + +echo "Test 1 - prefetch 0\n"; +$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); +oci_execute($s); +var_dump(oci_set_prefetch($s, 0)); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "\nTest 1 - prefetch 1\n"; +$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); +oci_execute($s); +var_dump(oci_set_prefetch($s, 1)); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +echo "\nTest 1 - prefetch 2\n"; +$s = oci_parse($c, "begin imp_res_prefetch_proc(); end;"); +oci_execute($s); +var_dump(oci_set_prefetch($s, 2)); +while (($row = oci_fetch_row($s)) != false) + var_dump($row); + +// Clean up + +$stmtarray = array( + "drop procedure imp_res_prefetch_proc", + "drop table imp_res_prefetch_tab_1", + "drop table imp_res_prefetch_tab_2" +); + +oci8_test_sql_execute($c, $stmtarray); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Test 1 - prefetch 0 +bool(true) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(1) "v" +} + +Test 1 - prefetch 1 +bool(true) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(1) "v" +} + +Test 1 - prefetch 2 +bool(true) +array(2) { + [0]=> + string(1) "1" + [1]=> + string(5) "abcde" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(5) "fghij" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(5) "klmno" +} +array(1) { + [0]=> + string(1) "t" +} +array(1) { + [0]=> + string(1) "u" +} +array(1) { + [0]=> + string(1) "v" +} +===DONE=== diff --git a/ext/oci8/tests/lob_015.phpt b/ext/oci8/tests/lob_015.phpt index b4a19684a3..59e8fec42a 100644 --- a/ext/oci8/tests/lob_015.phpt +++ b/ext/oci8/tests/lob_015.phpt @@ -48,7 +48,7 @@ Warning: oci_bind_by_name() expects at least 3 parameters, 2 given in %s on line Warning: oci_bind_by_name() expects at least 3 parameters, 1 given in %s on line %d -Warning: oci_execute(): ORA-00932: %s NUMBER %s BLOB in %s on line %d +Warning: oci_execute(): ORA-00932: %s on line %d object(OCI-Lob)#%d (1) { ["descriptor"]=> resource(%d) of type (oci8 descriptor) diff --git a/ext/oci8/tests/lob_temp2.phpt b/ext/oci8/tests/lob_temp2.phpt new file mode 100644 index 0000000000..d774b4d724 --- /dev/null +++ b/ext/oci8/tests/lob_temp2.phpt @@ -0,0 +1,40 @@ +--TEST-- +Writing temporary lob before binding +--SKIPIF-- +<?php +if (!extension_loaded('oci8')) die ("skip no oci8 extension"); +$target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs +require(dirname(__FILE__).'/skipif.inc'); +?> +--FILE-- +<?php + +require(dirname(__FILE__).'/connect.inc'); +require(dirname(__FILE__).'/create_table.inc'); + +$ora_sql = "INSERT INTO ".$schema.$table_name." (clob) VALUES (:v_clob)"; + +$clob = oci_new_descriptor($c, OCI_D_LOB); +var_dump($clob->writeTemporary("test")); + +$statement = oci_parse($c, $ora_sql); +oci_bind_by_name($statement, ":v_clob", $clob, -1, OCI_B_CLOB); +oci_execute($statement, OCI_DEFAULT); + +$s = oci_parse($c, "select clob from ". $schema.$table_name); +oci_execute($s); +oci_fetch_all($s, $res); +var_dump($res); + +?> +===DONE=== +--EXPECTF-- +bool(true) +array(1) { + ["CLOB"]=> + array(1) { + [0]=> + string(4) "test" + } +} +===DONE=== diff --git a/ext/oci8/tests/minfo.phpt b/ext/oci8/tests/minfo.phpt index f6b95ff296..34a19ca693 100644 --- a/ext/oci8/tests/minfo.phpt +++ b/ext/oci8/tests/minfo.phpt @@ -8,12 +8,12 @@ Code coverage for PHP_MINFO_FUNCTION(oci) ob_start(); phpinfo(INFO_MODULES); $v = ob_get_clean(); -$r = strpos($v, 'OCI8 Support => enabled'); -var_dump($r); +$r = preg_match('/OCI8 Support .* enabled/', $v); +if ($r !== 1) + var_dump($r); echo "Done\n"; ?> --EXPECTF-- -int(%d) Done diff --git a/ext/oci8/tests/password.phpt b/ext/oci8/tests/password.phpt index 1738702cb6..8ea81d3fc0 100644 --- a/ext/oci8/tests/password.phpt +++ b/ext/oci8/tests/password.phpt @@ -14,28 +14,28 @@ if ($test_drcp) die("skip password change not supported in DRCP Mode"); require(dirname(__FILE__)."/connect.inc"); $stmtarray = array( - "drop user testuser cascade", - "create user testuser identified by testuserpwd", - "grant connect, create session to testuser" + "drop user testuser_pw cascade", + "create user testuser_pw identified by testuserpwd", + "grant connect, create session to testuser_pw" ); oci8_test_sql_execute($c, $stmtarray); // Connect and change the password -$c1 = oci_connect("testuser", "testuserpwd", $dbase); +$c1 = oci_connect("testuser_pw", "testuserpwd", $dbase); var_dump($c1); $rn1 = (int)$c1; -oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2"); +oci_password_change($c1, "testuser_pw", "testuserpwd", "testuserpwd2"); // Second connect should return a new resource because the hash string will be different from $c1 -$c2 = oci_connect("testuser", "testuserpwd2", $dbase); +$c2 = oci_connect("testuser_pw", "testuserpwd2", $dbase); var_dump($c2); $rn2 = (int)$c2; // Despite using the old password this connect should succeed and return the original resource -$c3 = oci_connect("testuser", "testuserpwd", $dbase); +$c3 = oci_connect("testuser_pw", "testuserpwd", $dbase); var_dump($c3); $rn3 = (int)$c3; @@ -67,7 +67,7 @@ echo "Done\n"; require(dirname(__FILE__)."/connect.inc"); $stmtarray = array( - "drop user testuser cascade" + "drop user testuser_pw cascade" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/password_2.phpt b/ext/oci8/tests/password_2.phpt index ceba0bba80..13da9ff7b2 100644 --- a/ext/oci8/tests/password_2.phpt +++ b/ext/oci8/tests/password_2.phpt @@ -14,27 +14,27 @@ if ($test_drcp) die("skip password change not supported in DRCP Mode"); require(dirname(__FILE__)."/connect.inc"); $stmtarray = array( - "drop user testuser cascade", - "create user testuser identified by testuserpwd", - "grant connect, create session to testuser" + "drop user testuser_pw2 cascade", + "create user testuser_pw2 identified by testuserpwd", + "grant connect, create session to testuser_pw2" ); oci8_test_sql_execute($c, $stmtarray); // Connect (persistent) and change the password -$c1 = oci_pconnect("testuser", "testuserpwd", $dbase); +$c1 = oci_pconnect("testuser_pw2", "testuserpwd", $dbase); var_dump($c1); $rn1 = (int)$c1; -oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2"); +oci_password_change($c1, "testuser_pw2", "testuserpwd", "testuserpwd2"); // Second connect should return a new resource because the hash string will be different from $c1 -$c2 = oci_pconnect("testuser", "testuserpwd2", $dbase); +$c2 = oci_pconnect("testuser_pw2", "testuserpwd2", $dbase); var_dump($c2); $rn2 = (int)$c2; // Despite using the old password this connect should succeed and return the original resource -$c3 = oci_pconnect("testuser", "testuserpwd", $dbase); +$c3 = oci_pconnect("testuser_pw2", "testuserpwd", $dbase); var_dump($c3); $rn3 = (int)$c3; @@ -66,7 +66,7 @@ echo "Done\n"; require(dirname(__FILE__)."/connect.inc"); $stmtarray = array( - "drop user testuser cascade" + "drop user testuser_pw2 cascade" ); oci8_test_sql_execute($c, $stmtarray); diff --git a/ext/oci8/tests/password_new.phpt b/ext/oci8/tests/password_new.phpt index c218d904fa..2c66dd94ab 100644 --- a/ext/oci8/tests/password_new.phpt +++ b/ext/oci8/tests/password_new.phpt @@ -3,15 +3,27 @@ oci_password_change() --SKIPIF-- <?php $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on thes -require(dirname(__FILE__).'/skipif.inc'); +require(dirname(__FILE__).'/connect.inc'); if (empty($dbase)) die ("skip requires database connection string be set"); if ($test_drcp) die("skip password change not supported in DRCP Mode"); -// This test is known to fail with Oracle 10.2.0.4 client libraries -// connecting to Oracle Database 11 (Oracle bug 6277160, fixed 10.2.0.5) -if (preg_match('/Release (11|12)\./', oci_server_version($c), $matches) === 1 && - preg_match('/^10\.2\.0\.[1234]/', oci_client_version()) === 1) { - die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv); +if (isset($matches_sv[1]) && $matches_sv[1] >= 11) { + preg_match('/([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)/', oci_client_version(), $matches); + if (isset($matches[0]) && $matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] < 5) { + die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); + } +} + +// This test in Oracle 12c needs a non-CDB or the root container +if (isset($matches_sv[1]) && $matches_sv[1] >= 12) { + $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual"); + $r = @oci_execute($s); + if (!$r) + die('skip could not identify container type'); + $r = oci_fetch_array($s); + if ($r['DBTYPE'] !== 'CDB$ROOT') + die('skip cannot run test using a PDB'); } ?> --FILE-- diff --git a/ext/oci8/tests/password_old.phpt b/ext/oci8/tests/password_old.phpt index fdbb1f9e89..2e186528e3 100644 --- a/ext/oci8/tests/password_old.phpt +++ b/ext/oci8/tests/password_old.phpt @@ -3,18 +3,28 @@ ocipasswordchange() --SKIPIF-- <?php $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on thes -require(dirname(__FILE__).'/skipif.inc'); +require(dirname(__FILE__).'/connect.inc'); if (empty($dbase)) die ("skip requires database connection string be set"); if ($test_drcp) die("skip password change not supported in DRCP Mode"); -// This test is known to fail with Oracle 10.2.0.4 client libraries -// connecting to Oracle Database 11 (Oracle bug 6277160, fixed 10.2.0.5) -if (preg_match('/Release (11|12)\./', oci_server_version($c), $matches) === 1 && - preg_match('/^10\.2\.0\.[1234]/', oci_client_version()) === 1) { - die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); +preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv); +if (isset($matches_sv[1]) && $matches_sv[1] >= 11) { + preg_match('/([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)/', oci_client_version(), $matches); + if (isset($matches[0]) && $matches[1] == 10 && $matches[2] == 2 && $matches[3] == 0 && $matches[4] < 5) { + die ("skip test known to fail using Oracle 10.2.0.4 client libs connecting to Oracle 11 (6277160)"); + } } - +// This test in Oracle 12c needs a non-CDB or the root container +if (isset($matches_sv[1]) && $matches_sv[1] >= 12) { + $s = oci_parse($c, "select nvl(sys_context('userenv', 'con_name'), 'notacdb') as dbtype from dual"); + $r = @oci_execute($s); + if (!$r) + die('skip could not identify container type'); + $r = oci_fetch_array($s); + if ($r['DBTYPE'] !== 'CDB$ROOT') + die('skip cannot run test using a PDB'); +} ?> --FILE-- <?php diff --git a/ext/oci8/tests/refcur_prefetch_3.phpt b/ext/oci8/tests/refcur_prefetch_3.phpt index 8c0414042b..974864cbd9 100644 --- a/ext/oci8/tests/refcur_prefetch_3.phpt +++ b/ext/oci8/tests/refcur_prefetch_3.phpt @@ -86,52 +86,52 @@ Test with Nested Cursors Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test0" + string(%d) "test0" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test1" + string(%d) "test1" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test2" + string(%d) "test2" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test3" + string(%d) "test3" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test4" + string(%d) "test4" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test5" + string(%d) "test5" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test6" + string(%d) "test6" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test7" + string(%d) "test7" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test8" + string(%d) "test8" } Fetch Row using Nested cursor Query array(1) { [0]=> - %unicode|string%(%d) "test9" + string(%d) "test9" } Number of roundtrips made with prefetch count 5 for 10 rows is 3 Done diff --git a/ext/oci8/tests/reflection1.phpt b/ext/oci8/tests/reflection1.phpt index 5f2e73d80b..f76d7261aa 100644 --- a/ext/oci8/tests/reflection1.phpt +++ b/ext/oci8/tests/reflection1.phpt @@ -126,6 +126,7 @@ reflection::export(new reflectionfunction('oci_set_module_name')); reflection::export(new reflectionfunction('oci_set_action')); reflection::export(new reflectionfunction('oci_set_client_info')); reflection::export(new reflectionfunction('oci_set_client_identifier')); +reflection::export(new reflectionfunction('oci_get_implicit_resultset')); ?> ===DONE=== @@ -1093,4 +1094,11 @@ Function [ <internal%s> function oci_set_client_identifier ] { } } +Function [ <internal%s> function oci_get_implicit_resultset ] { + + - Parameters [1] { + Parameter #0 [ <required> $statement_resource ] + } +} + ===DONE=== |