-----------
The OCI8 extension allows you to access Oracle databases. It can be
-built using Oracle 9.2, 10.2 or 11.1 client libraries, and allows
-Oracle's standard cross-version connectivity. This release can be
-used with PHP versions 4.3.9 to 5.x.
+built using Oracle 9.2, 10.2, 11.1 or 11.2 client libraries, and
+allows Oracle's standard cross-version connectivity. This release can
+be used with PHP versions 4.3.9 to 5.x.
The OCI8 extension is not related to, or used by, PDO_OCI, the PHP
Data Objects (PDO) extension for Oracle.
The bug is specific to Oracle 11.1.0.6 with DRCP connections. The
issues it fixes do not affect connections using Oracle's dedicated
(the default connection mode) or shared servers. They do not affect
-earlier versions of Oracle. The bug is intended to be fixed in Oracle
-Database 11.1.0.7 (as yet unreleased).
+earlier versions of Oracle. The bug is fixed in Oracle Database
+11.1.0.7.
ZEND_ARG_INFO(0, number_of_rows)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_client_identifier, 0, 0, 2)
+ ZEND_ARG_INFO(0, connection_resource)
+ ZEND_ARG_INFO(0, client_identifier)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_edition, 0, 0, 1)
+ ZEND_ARG_INFO(0, edition_name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_module_name, 0, 0, 2)
+ ZEND_ARG_INFO(0, connection_resource)
+ ZEND_ARG_INFO(0, module_name)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_action, 0, 0, 2)
+ ZEND_ARG_INFO(0, connection_resource)
+ ZEND_ARG_INFO(0, action)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_client_info, 0, 0, 2)
+ ZEND_ARG_INFO(0, connection_resource)
+ ZEND_ARG_INFO(0, client_information)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_password_change, 0, 0, 4)
ZEND_ARG_INFO(0, connection_resource_or_connection_string)
ZEND_ARG_INFO(0, username)
#define arginfo_oci_num_fields NULL
#define arginfo_oci_parse NULL
#define arginfo_oci_set_prefetch NULL
+#define arginfo_oci_set_client_identifier NULL
+#define arginfo_oci_set_edition NULL
+#define arginfo_oci_set_module_name NULL
+#define arginfo_oci_set_action NULL
+#define arginfo_oci_set_client_info NULL
#define arginfo_oci_password_change NULL
#define arginfo_oci_new_cursor NULL
#define arginfo_oci_result NULL
PHP_FUNCTION(oci_statement_type);
PHP_FUNCTION(oci_num_rows);
PHP_FUNCTION(oci_set_prefetch);
+PHP_FUNCTION(oci_set_client_identifier);
+PHP_FUNCTION(oci_set_edition);
+PHP_FUNCTION(oci_set_module_name);
+PHP_FUNCTION(oci_set_action);
+PHP_FUNCTION(oci_set_client_info);
PHP_FUNCTION(oci_password_change);
PHP_FUNCTION(oci_lob_save);
PHP_FUNCTION(oci_lob_import);
PHP_FE(oci_rollback, arginfo_oci_rollback)
PHP_FE(oci_new_descriptor, arginfo_oci_new_descriptor)
PHP_FE(oci_set_prefetch, arginfo_oci_set_prefetch)
+ PHP_FE(oci_set_client_identifier, arginfo_oci_set_client_identifier)
+ PHP_FE(oci_set_edition, arginfo_oci_set_edition)
+ PHP_FE(oci_set_module_name, arginfo_oci_set_module_name)
+ PHP_FE(oci_set_action, arginfo_oci_set_action)
+ PHP_FE(oci_set_client_info, arginfo_oci_set_client_info)
PHP_FE(oci_password_change, arginfo_oci_password_change)
PHP_FE(oci_free_collection, arginfo_oci_free_collection)
PHP_FE(oci_collection_append, arginfo_oci_collection_append)
REGISTER_LONG_CONSTANT("OCI_CRED_EXT",PHP_OCI_CRED_EXT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_DESCRIBE_ONLY",OCI_DESCRIBE_ONLY, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_COMMIT_ON_SUCCESS",OCI_COMMIT_ON_SUCCESS, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("OCI_NO_AUTO_COMMIT",OCI_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_EXACT_FETCH",OCI_EXACT_FETCH, CONST_CS | CONST_PERSISTENT);
/* for $LOB->seek() */
OCI_G(debug_mode) = 0; /* start "fresh" */
OCI_G(num_links) = OCI_G(num_persistent);
OCI_G(errcode) = 0;
+ OCI_G(edition) = NULL;
return SUCCESS;
}
*/
zend_hash_apply(&EG(persistent_list), (apply_func_t) php_oci_persistent_helper TSRMLS_CC);
+ if (OCI_G(edition)) {
+ efree(OCI_G(edition));
+ }
+
return SUCCESS;
}
}
smart_str_appendl_ex(&hashed_details, "**", sizeof("**") - 1, 0);
+ /* Add edition attribute to the hash */
+ if (OCI_G(edition)){
+ smart_str_appendl_ex(&hashed_details, OCI_G(edition), strlen(OCI_G(edition)), 0);
+ }
+ smart_str_appendl_ex(&hashed_details, "**", sizeof("**") - 1, 0);
+
if (password_len) {
ulong password_hash;
password_hash = zend_inline_hash_func(password, password_len);
php_oci_spool *session_pool = NULL;
zend_bool iserror = 0;
ub4 poolmode = OCI_DEFAULT; /* Mode to be passed to OCISessionPoolCreate */
+ OCIAuthInfo *spoolAuth = NULL;
/*Allocate sessionpool out of persistent memory */
session_pool = (php_oci_spool *) calloc(1, sizeof(php_oci_spool));
poolmode = OCI_SPC_HOMOGENEOUS;
#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));
+
+ 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 {{{ */
+ 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)));
+
+ 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)));
+
+ 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)));
+
+ 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.
*/
session_pool = NULL;
}
+ if (spoolAuth) {
+ PHP_OCI_CALL(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__);
}
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);
+ /* Add edition attribute to the hash */
+ if (OCI_G(edition)){
+ smart_str_appendl_ex(&spool_hashed_details, OCI_G(edition), strlen(OCI_G(edition)), 0);
+ }
+ smart_str_appendl_ex(&spool_hashed_details, "**", sizeof("**") - 1, 0);
if (password_len) {
ulong password_hash;
password_hash = zend_inline_hash_func(password, password_len);
smart_str_append_unsigned_ex(&spool_hashed_details, charsetid, 0);
- /* Session Pool Hash Key : oci8spool***username**hashedpassword**dbname**charset */
+ /* Session Pool Hash Key : oci8spool***username**edition**hashedpassword**dbname**charset */
smart_str_0(&spool_hashed_details);
php_strtolower(spool_hashed_details.c, spool_hashed_details.len);
}
}/* }}} */
+ /* 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)));
+
+ if (OCI_G(errcode) != OCI_SUCCESS) {
+ php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ return 1;
+ }
+ }
+#endif /* }}} */
+
+ /* 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)));
+
+ if (OCI_G(errcode) != OCI_SUCCESS) {
+ php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ return 1;
+ }
+#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)));
}
/* }}} */
+/* {{{ proto bool oci_set_client_identifier(resource connection, string value)
+ Sets the client identifier attribute on the connection */
+PHP_FUNCTION(oci_set_client_identifier)
+{
+ zval *z_connection;
+ php_oci_connection *connection;
+ char *client_id;
+ long client_id_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_id, &client_id_len) == FAILURE) {
+ return;
+ }
+
+ 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)));
+
+ if (OCI_G(errcode) != OCI_SUCCESS) {
+ php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_edition(string value)
+ Sets the edition attribute for all subsequent connections created */
+PHP_FUNCTION(oci_set_edition)
+{
+#if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2)))
+ char *edition;
+ long edition_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &edition, &edition_len) == FAILURE) {
+ return;
+ }
+
+ if (OCI_G(edition)) {
+ efree(OCI_G(edition));
+ OCI_G(edition) = NULL;
+ }
+
+ if (edition) {
+ OCI_G(edition) = (char *)safe_emalloc(edition_len+1, sizeof(text), 0);
+ memcpy(OCI_G(edition), edition, edition_len);
+ OCI_G(edition)[edition_len] = '\0';
+ }
+
+ RETURN_TRUE;
+#else
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+ RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_module_name(resource connection, string value)
+ Sets the module attribute on the connection */
+PHP_FUNCTION(oci_set_module_name)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+ zval *z_connection;
+ php_oci_connection *connection;
+ char *module;
+ long module_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &module, &module_len) == FAILURE) {
+ return;
+ }
+
+ 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)));
+
+ if (OCI_G(errcode) != OCI_SUCCESS) {
+ php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+#else
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+ RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_action(resource connection, string value)
+ Sets the action attribute on the connection */
+PHP_FUNCTION(oci_set_action)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+ zval *z_connection;
+ php_oci_connection *connection;
+ char *action;
+ long action_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &action, &action_len) == FAILURE) {
+ return;
+ }
+
+ 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)));
+
+ if (OCI_G(errcode) != OCI_SUCCESS) {
+ php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+#else
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+ RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto bool oci_set_client_info(resource connection, string value)
+ Sets the client info attribute on the connection */
+PHP_FUNCTION(oci_set_client_info)
+{
+#if (OCI_MAJOR_VERSION >= 10)
+ zval *z_connection;
+ php_oci_connection *connection;
+ char *client_info;
+ long client_info_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_info, &client_info_len) == FAILURE) {
+ return;
+ }
+
+ 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)));
+
+ if (OCI_G(errcode) != OCI_SUCCESS) {
+ php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+#else
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
+ RETURN_FALSE;
+#endif
+}
+/* }}} */
+
/* {{{ proto bool oci_password_change(resource connection, string username, string old_password, string new_password)
Changes the password of an account */
PHP_FUNCTION(oci_password_change)
statement->parent_stmtid = 0;
zend_list_addref(statement->connection->rsrc_id);
- if (OCI_G(default_prefetch) > 0) {
+ if (OCI_G(default_prefetch) >= 0) {
php_oci_statement_set_prefetch(statement, OCI_G(default_prefetch) TSRMLS_CC);
}
{
ub4 prefetch = size;
- if (size < 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of rows has to be greater than or equal to 1");
+ if (size < 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of rows to be prefetched has to be greater than or equal to 0");
return 1;
}
we don't want to execute!!! */
if (statement->binds) {
- zend_hash_apply(statement->binds, (apply_func_t) php_oci_bind_pre_exec TSRMLS_CC);
+ int result = 0;
+ zend_hash_apply_with_argument(statement->binds, (apply_func_arg_t) php_oci_bind_pre_exec, (void *)&result TSRMLS_CC);
+ if (result) {
+ return 1;
+ }
}
/* execute statement */
/* {{{ php_oci_bind_pre_exec()
Helper function */
-int php_oci_bind_pre_exec(void *data TSRMLS_DC)
+int php_oci_bind_pre_exec(void *data, void *result TSRMLS_DC)
{
php_oci_bind *bind = (php_oci_bind *) data;
+ *(int *)result = 0;
+ switch (bind->type) {
+ case SQLT_NTY:
+ case SQLT_BFILEE:
+ case SQLT_CFILEE:
+ case SQLT_CLOB:
+ case SQLT_BLOB:
+ case SQLT_RDD:
+ if (Z_TYPE_P(bind->zval) != IS_OBJECT) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+ *(int *)result = 1;
+ }
+ break;
+
+ case SQLT_INT:
+ case SQLT_NUM:
+ if (Z_TYPE_P(bind->zval) == IS_RESOURCE || Z_TYPE_P(bind->zval) == IS_OBJECT) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+ *(int *)result = 1;
+ }
+ break;
+
+ case SQLT_LBI:
+ case SQLT_BIN:
+ case SQLT_LNG:
+ case SQLT_AFC:
+ case SQLT_CHR:
+ if (Z_TYPE_P(bind->zval) == IS_RESOURCE || Z_TYPE_P(bind->zval) == IS_OBJECT) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+ *(int *)result = 1;
+ }
+ break;
+
+ case SQLT_RSET:
+ if (Z_TYPE_P(bind->zval) != IS_RESOURCE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+ *(int *)result = 1;
+ }
+ break;
+ }
+
/* reset all bind stuff to a normal state..-. */
bind->indicator = 0;
case SQLT_INT:
case SQLT_NUM:
+ if (Z_TYPE_P(var) == IS_RESOURCE || Z_TYPE_P(var) == IS_OBJECT) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+ return 1;
+ }
convert_to_long(var);
bind_data = (ub4 *)&Z_LVAL_P(var);
value_sz = sizeof(ub4);
case SQLT_LNG:
case SQLT_AFC:
case SQLT_CHR: /* SQLT_CHR is the default value when type was not specified */
+ if (Z_TYPE_P(var) == IS_RESOURCE || Z_TYPE_P(var) == IS_OBJECT) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+ return 1;
+ }
if (Z_TYPE_P(var) != IS_NULL) {
convert_to_string(var);
}
break;
case SQLT_RSET:
+ if (Z_TYPE_P(var) != IS_RESOURCE) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid variable used for bind");
+ return 1;
+ }
PHP_OCI_ZVAL_TO_STATEMENT_EX(var, bind_statement);
value_sz = sizeof(void*);
bindp->statement = oci_stmt;
bindp->parent_statement = statement;
bindp->zval = var;
+ bindp->type = type;
zval_add_ref(&var);
PHP_OCI_CALL_RETURN(statement->errcode,
<name>oci8</name>
<channel>pecl.php.net</channel>
<summary>Extension for Oracle Database</summary>
- <description>This extension allows you to access Oracle databases using the Oracle Call Interface (OCI8). It can be built with PHP 4.3.9 to 5.x. It can be linked with Oracle 9.2, 10.2 or 11.1 client libraries.
+ <description>This extension allows you to access Oracle databases using the Oracle Call Interface (OCI8). It can be built with PHP 4.3.9 to 5.x. It can be linked with Oracle 9.2, 10.2, 11.1, or 11.2 client libraries.
</description>
<lead>
<name>Christopher Jones</name>
<active>no</active>
</lead>
- <date>2009-03-16</date>
- <time>10:00:00</time>
+ <date>2009-10-06</date>
+ <time>15:00:00</time>
<version>
- <release>1.3.5</release>
- <api>1.3.4</api>
+ <release>1.4.0</release>
+ <api>1.4.0</api>
</version>
<stability>
- <release>stable</release>
- <api>stable</api>
+ <release>alpha</release>
+ <api>alpha</api>
</stability>
<license uri="http://www.php.net/license">PHP</license>
- <notes>Fixed Bug #47243 (Crash at end of request shutdown on Windows)
-Fixed Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure)
-Fixed Bug #46623 (phpinfo doesn't show compile time ORACLE_HOME with phpize)
-Fixed bug #45458 (Numeric keys for associative arrays are not handled properly) Note: not fixed when building with PHP 4 due to lack of PHP internal helper.
-Fixed PECL Bug #16035 (oci_connect without ORACLE_HOME defined causes segfault)
-Fixed PECL Bug #15988 (sqlnet.ora isn't read with older Oracle libraries)
-Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Instant Client RPM install)
+ <notes>
+ 1. Introduce connection attribute functions:
+
+ oci_set_module_name
+ oci_set_action
+ oci_set_client_info
+ oci_set_client_identifier
+
+ These set values that are visible/used by the database. They
+ are useful for tracing, authentication and auditing.
+
+ 2. Introduce connection attribute function:
+
+ oci_set_edition
+
+ Oracle 11g R2 "editions" allow multiple versions of DB objects
+ to exist at one time. By setting different editions, two
+ different versions of an application can run concurrently,
+ making upgrading easier and faster.
+
+ 3. Set the DRIVER_NAME attribute of Oracle Database 11gR2
+ connections to aid application tracing. The value used is to
+ "PHP OCI8" followed by the OCI8 version number. Note the
+ version number may get truncated in DB views such as
+ v$session_connect_info.
+
+ 4. Allow the oci_set_prefetch value to be 0. This is important in
+ some cases using REF CURSORS in Oracle 11gR2.
+
+ 5. Introduce OCI_NO_AUTO_COMMIT as an alias for the OCI_DEFAULT
+ constant (which is not the default value) used by oci_execute().
+
+ 6. Generate an error if an invalid resource type is used in
+ oci_bind_by_name
</notes>
<contents>
<dir name="/">
<file name="bind_char_3.phpt" role="test" />
<file name="bind_char_4.phpt" role="test" />
<file name="bind_empty.phpt" role="test" />
+ <file name="bind_error.phpt" role="test" />
<file name="bind_long.phpt" role="test" />
<file name="bind_long_raw.phpt" role="test" />
<file name="bind_raw.phpt" role="test" />
<file name="coll_019.phpt" role="test" />
<file name="commit_old.phpt" role="test" />
<file name="commit.phpt" role="test" />
+ <file name="conn_attr_1.phpt" role="test" />
+ <file name="conn_attr_2.phpt" role="test" />
+ <file name="conn_attr_3.phpt" role="test" />
+ <file name="conn_attr_4.phpt" role="test" />
+ <file name="conn_attr_5.phpt" role="test" />
+ <file name="conn_attr.inc" role="test" />
<file name="connect_1_old.phpt" role="test" />
<file name="connect_1.phpt" role="test" />
<file name="connect.inc" role="test" />
<file name="drcp_scope3.phpt" role="test" />
<file name="drcp_scope4.phpt" role="test" />
<file name="drcp_scope5.phpt" role="test" />
+ <file name="driver_name.phpt" role="test" />
<file name="drop_table.inc" role="test" />
<file name="drop_type.inc" role="test" />
+ <file name="edition_1.phpt" role="test" />
+ <file name="edition_2.phpt" role="test" />
<file name="error1.phpt" role="test" />
<file name="error2.phpt" role="test" />
<file name="error_old.phpt" role="test" />
<file name="pecl_bug10194_blob.phpt" role="test" />
<file name="pecl_bug10194.phpt" role="test" />
<file name="pecl_bug16035.phpt" role="test" />
+ <file name="pecl_bug16842.phpt" role="test" />
<file name="pecl_bug8816.phpt" role="test" />
<file name="persistent.phpt" role="test" />
<file name="prefetch_old.phpt" role="test" />
<file name="prefetch.phpt" role="test" />
<file name="privileged_connect1.phpt" role="test" />
<file name="privileged_connect.phpt" role="test" />
+ <file name="refcur_prefetch_1.phpt" role="test" />
+ <file name="refcur_prefetch_2.phpt" role="test" />
+ <file name="refcur_prefetch_3.phpt" role="test" />
<file name="reflection1.phpt" role="test" />
<file name="reflection2.phpt" role="test" />
<file name="rowid_bind.phpt" role="test" />
<file name="test.txt" role="test" />
<file name="uncommitted.phpt" role="test" />
<file name="xmltype_01.phpt" role="test" />
+ <file name="xmltype_02.phpt" role="test" />
</dir> <!-- //tests -->
<file name="config.m4" role="src" />
<file name="config.w32" role="src" />
</extsrcrelease>
<changelog>
+<release>
+ <version>
+ <release>1.3.5</release>
+ <api>1.3.4</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.php.net/license">PHP</license>
+ <notes>
+Fixed Bug #47243 (Crash at end of request shutdown on Windows)
+Fixed Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure)
+Fixed Bug #46623 (phpinfo doesn't show compile time ORACLE_HOME with phpize)
+Fixed bug #45458 (Numeric keys for associative arrays are not handled properly) Note: not fixed when building with PHP 4 due to lack of PHP internal helper.
+Fixed PECL Bug #16035 (oci_connect without ORACLE_HOME defined causes segfault)
+Fixed PECL Bug #15988 (sqlnet.ora isn't read with older Oracle libraries)
+Fixed PECL Bug #14268 (Allow "pecl install oci8" command to "autodetect" an Instant Client RPM install)
+ </notes>
+</release>
+
<release>
<version>
<release>1.3.4</release>
#error Invalid value for PHP_OCI_CRED_EXT
#endif
+/*
+ * Name passed to Oracle for tracing. Note some DB views only show
+ * the first nine characters of the driver name.
+ */
+#define PHP_OCI8_DRIVER_NAME "PHP OCI8 " PHP_OCI8_VERSION
+
/* }}} */
typedef struct { /* php_oci_spool {{{ */
dvoid *descriptor; /* used for binding of LOBS etc */
OCIStmt *statement; /* used for binding REFCURSORs */
php_oci_statement *parent_statement; /* pointer to the parent statement */
+ ub2 type; /* bind type */
struct {
void *elements;
sb2 *indicators;
int php_oci_statement_execute (php_oci_statement *, ub4 TSRMLS_DC);
int php_oci_statement_cancel (php_oci_statement * TSRMLS_DC);
void php_oci_statement_free (php_oci_statement * TSRMLS_DC);
-int php_oci_bind_pre_exec(void *data TSRMLS_DC);
+int php_oci_bind_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 **);
zend_bool in_call;
char *connection_class;
zend_bool events;
+ char *edition;
ZEND_END_MODULE_GLOBALS(oci) /* }}} */
#ifdef ZTS
--- /dev/null
+--TEST--
+Test some oci_bind_by_name error conditions
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--FILE--
+<?php
+
+require(dirname(__FILE__).'/connect.inc');
+
+$drop = "drop table bind_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+$create = "create table bind_test(name varchar(10))";
+$statement = oci_parse($c, $create);
+oci_execute($statement);
+
+
+echo "Insert value\n";
+
+$name = 'abc';
+$stmt = oci_parse($c, "insert into bind_test values (:name)");
+oci_bind_by_name($stmt, ":name", $name, 10, SQLT_CHR);
+var_dump(oci_execute($stmt));
+
+echo "Test 1 - Assign a resource to the bind variable and execute \n";
+$name=$c;
+var_dump(oci_execute($stmt));
+
+echo "Test 2 - Re-bind a resource\n";
+oci_bind_by_name($stmt, ":name", $c);
+var_dump(oci_execute($stmt));
+var_dump($c);
+
+// Use a connection resource instead of a ROWID.
+echo "Test 3 - Resource mismatch !!\n";
+$stmt = oci_parse($c, "update bind_test set name='xyz' returning rowid into :r_id");
+oci_bind_by_name($stmt, ":r_id", $c);
+var_dump(oci_execute($stmt));
+
+// Clean up
+
+$drop = "drop table bind_test";
+$statement = oci_parse($c, $drop);
+@oci_execute($statement);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+Insert value
+bool(true)
+Test 1 - Assign a resource to the bind variable and execute
+
+Warning: oci_execute(): Invalid variable used for bind in %s on line %d
+bool(false)
+Test 2 - Re-bind a resource
+
+Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
+
+Warning: oci_execute(): Invalid variable used for bind in %s on line %d
+bool(false)
+resource(%d) of type (oci8 connection)
+Test 3 - Resource mismatch !!
+
+Warning: oci_bind_by_name(): Invalid variable used for bind in %s on line %d
+
+Warning: oci_execute(): ORA-01008: %s on line %d
+bool(false)
+Done
--TEST--
-oci_commit()/oci_rollback()
+Test OCI_NO_AUTO_COMMIT constant
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
-require dirname(__FILE__)."/connect.inc";
-require dirname(__FILE__).'/create_table.inc';
+require(dirname(__FILE__)."/connect.inc");
+require(dirname(__FILE__).'/create_table.inc');
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+$insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)";
if (!($s = oci_parse($c, $insert_sql))) {
die("oci_parse(insert) failed!\n");
}
+/* check with OCI_NO_AUTO_COMMIT mode */
+for ($i = 0; $i<3; $i++) {
+ if (!oci_execute($s, OCI_NO_AUTO_COMMIT)) {
+ die("oci_execute(insert) failed!\n");
+ }
+}
+
for ($i = 0; $i<3; $i++) {
if (!oci_execute($s, OCI_DEFAULT)) {
die("oci_execute(insert) failed!\n");
}
}
+
var_dump(oci_rollback($c));
-$select_sql = "SELECT * FROM ".$schema.$table_name."";
+$select_sql = "select * from ".$schema.$table_name."";
if (!($select = oci_parse($c, $select_sql))) {
die("oci_parse(select) failed!\n");
die("oci_execute(select) failed!\n");
}
-$insert_sql = "INSERT INTO ".$schema.$table_name." (id, value) VALUES (1,1)";
+$insert_sql = "insert into ".$schema.$table_name." (id, value) values (1,1)";
if (!($s = oci_parse($c, $insert_sql))) {
die("oci_parse(insert) failed!\n");
var_dump($all);
-require dirname(__FILE__).'/drop_table.inc';
+require(dirname(__FILE__).'/drop_table.inc');
echo "Done\n";
?>
---EXPECT--
+--EXPECTF--
bool(true)
int(0)
array(5) {
- ["ID"]=>
+ [%u|b%"ID"]=>
array(0) {
}
- ["VALUE"]=>
+ [%u|b%"VALUE"]=>
array(0) {
}
- ["BLOB"]=>
+ [%u|b%"BLOB"]=>
array(0) {
}
- ["CLOB"]=>
+ [%u|b%"CLOB"]=>
array(0) {
}
- ["STRING"]=>
+ [%u|b%"STRING"]=>
array(0) {
}
}
bool(true)
int(4)
array(5) {
- ["ID"]=>
+ [%u|b%"ID"]=>
array(4) {
[0]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[1]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[2]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[3]=>
- string(1) "1"
+ %string|unicode%(1) "1"
}
- ["VALUE"]=>
+ [%u|b%"VALUE"]=>
array(4) {
[0]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[1]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[2]=>
- string(1) "1"
+ %string|unicode%(1) "1"
[3]=>
- string(1) "1"
+ %string|unicode%(1) "1"
}
- ["BLOB"]=>
+ [%u|b%"BLOB"]=>
array(4) {
[0]=>
NULL
[3]=>
NULL
}
- ["CLOB"]=>
+ [%u|b%"CLOB"]=>
array(4) {
[0]=>
NULL
[3]=>
NULL
}
- ["STRING"]=>
+ [%u|b%"STRING"]=>
array(4) {
[0]=>
NULL
--- /dev/null
+<?php
+
+require(dirname(__FILE__)."/connect.inc");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11\.2|12)\./', $sv, $matches);
+if ($sv == 1) {
+ // 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",
+ "create edition myedition",
+ "create edition myedition1 as child of myedition",
+ "grant use on edition myedition to testuser",
+ "grant use on edition myedition1 to testuser",
+ );
+}
+else {
+ // Server is Pre 11.2
+ $stmtarray = array(
+ "drop user testuser cascade",
+ "create user testuser identified by testuser",
+ "grant connect,resource,dba to testuser",
+ );
+}
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $m = oci_error($s);
+ if (!in_array($m['code'], array( // ignore expected errors
+ 942 // table or view does not exist
+ , 2289 // sequence does not exist
+ , 4080 // trigger does not exist
+ , 38802 // edition does not exist
+ ))) {
+ echo "Error:" . $stmt . PHP_EOL . $m['message'] . PHP_EOL;
+ if ($m['code'] == 38807) {
+ echo "You appear to already have an edition in use that prevents this PHP test from running. Query DBA_EDITIONS to see existing editions.". PHP_EOL;
+ }
+ die;
+ }
+ }
+}
+
+function get_attr($conn,$attr)
+{
+ $sel_stmt="select " .$attr. " from v\$session where sid =
+ (select sid from v\$session where audsid =
+ sys_context('userenv','sessionid')) order by 1";
+ $s2 = oci_parse($conn,$sel_stmt);
+ oci_execute($s2,OCI_DEFAULT);
+ while (oci_fetch($s2)) {
+ echo "The value of ".$attr ." is ".oci_result($s2,1)."\n";
+ }
+}
+
+/* Pass $conn_type=1 for a connection with oci_connect()
+ Pass $conn_type=2 for ooci_pconnect
+ Default will give a oci_new_connect */
+
+function get_conn($conn_type)
+{
+ $user = 'testuser';
+ $password = 'testuser';
+ $dbase = $GLOBALS['dbase'];
+ switch($conn_type) {
+ case 1:
+ echo "Testing with oci_connect()\n";
+ return(oci_connect($user,$password,$dbase));
+ break;
+ case 2:
+ echo "Testing with oci_pconnect()\n";
+ return(oci_pconnect($user,$password,$dbase));
+ break;
+ default:
+ echo "Testing with oci_new_connect()\n";
+ return(oci_new_connect($user,$password,$dbase));
+ break;
+ }
+}
+
+function set_attr($conn,$attr,$sufix)
+{
+ if (!strcmp($attr,'MODULE'))
+ $r = oci_set_module_name($conn,'PHP TEST'.$sufix);
+ else if (!strcmp($attr,'ACTION'))
+ $r = oci_set_action($conn,'TASK'.$sufix);
+ else if (!strcmp($attr,'CLIENT_INFO'))
+ $r = oci_set_client_info($conn,'INFO1'.$sufix);
+ else if (!strcmp($attr,'CLIENT_IDENTIFIER'))
+ $r = oci_set_client_identifier($conn,'ID00'.$sufix);
+ else
+ echo "Pass one of the above four attibutes!!!\n";
+ if ($r) {
+ echo "Value of $attr has been set successfully\n";
+ }
+
+ //Do a round-trip here
+ oci_server_version($conn);
+ return $r;
+}
+
+function set_edit_attr($value)
+{
+ $r = oci_set_edition($value);
+ if ($r) {
+ echo " The value of edition has been successfully set\n";
+ }
+ return $r;
+}
+
+function get_edit_attr ($conn) {
+ $sel_stmt = "select sys_context('USERENV', 'CURRENT_EDITION_NAME') from dual";
+ $s2 = oci_parse($conn,$sel_stmt);
+ oci_execute($s2,OCI_DEFAULT);
+ while (oci_fetch($s2)) {
+ echo "The value of current EDITION is ".oci_result($s2,1)."\n";
+ }
+}
+
+function get_sys_attr($conn,$attr)
+{
+ $sel_stmt="select " .$attr. " from v\$session where sid =
+ (select sid from v\$session where audsid = sys_context('userenv','sessionid')) order by 1";
+ $s2 = oci_parse($conn,$sel_stmt);
+ oci_execute($s2,OCI_DEFAULT);
+ while (oci_fetch($s2)) {
+ echo "The value of ".$attr ." is ".oci_result($s2,1)."\n";
+ }
+}
+
+function clean_up($c) {
+ $stmtarray = array(
+ "drop user testuser cascade",
+ "drop edition myedition1",
+ "drop edition myedition",
+ );
+
+ foreach ($stmtarray as $stmt) {
+ $s = oci_parse($c, $stmt);
+ @oci_execute($s);
+ }
+}
--- /dev/null
+--TEST--
+Set and get of connection attributes with all types of connections.
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.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");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater client ");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater server");
+}
+
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+
+$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
+
+echo"**Test 1.1 - Default values for the attributes **************\n";
+$c = get_conn(1);
+foreach($attr_array as $attr) {
+ get_attr($c,$attr);
+}
+
+echo"**Test 1.2 - Set and get values for the attributes **************\n";
+
+// With oci_connect, oci_pconnect, oci_new_connect
+
+$conn1 = get_conn(1); //oci_connect()
+foreach($attr_array as $attr) {
+ set_attr($conn1,$attr,1);
+ get_attr($conn1,$attr);
+}
+
+$conn2 = get_conn(2); //oci_pconnect()
+foreach($attr_array as $attr) {
+ set_attr($conn2,$attr,2);
+ get_attr($conn2,$attr);
+}
+
+$conn3 = get_conn(3); //oci_new_connect()
+foreach($attr_array as $attr) {
+ set_attr($conn3,$attr,3);
+ get_attr($conn3,$attr);
+}
+
+// clean up
+oci_close($conn1);
+oci_close($conn2);
+oci_close($conn3);
+clean_up($c);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+**Test 1.1 - Default values for the attributes **************
+Testing with oci_connect()
+The value of MODULE is %s
+The value of ACTION is
+The value of CLIENT_INFO is
+The value of CLIENT_IDENTIFIER is
+**Test 1.2 - Set and get values for the attributes **************
+Testing with oci_connect()
+Value of MODULE has been set successfully
+The value of MODULE is PHP TEST1
+Value of ACTION has been set successfully
+The value of ACTION is TASK1
+Value of CLIENT_INFO has been set successfully
+The value of CLIENT_INFO is INFO11
+Value of CLIENT_IDENTIFIER has been set successfully
+The value of CLIENT_IDENTIFIER is ID001
+Testing with oci_pconnect()
+Value of MODULE has been set successfully
+The value of MODULE is PHP TEST2
+Value of ACTION has been set successfully
+The value of ACTION is TASK2
+Value of CLIENT_INFO has been set successfully
+The value of CLIENT_INFO is INFO12
+Value of CLIENT_IDENTIFIER has been set successfully
+The value of CLIENT_IDENTIFIER is ID002
+Testing with oci_new_connect()
+Value of MODULE has been set successfully
+The value of MODULE is PHP TEST3
+Value of ACTION has been set successfully
+The value of ACTION is TASK3
+Value of CLIENT_INFO has been set successfully
+The value of CLIENT_INFO is INFO13
+Value of CLIENT_IDENTIFIER has been set successfully
+The value of CLIENT_IDENTIFIER is ID003
+Done
--- /dev/null
+--TEST--
+Set and get of connection attributes across persistent connections and sysdba connection.
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.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");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--INI--
+oci8.privileged_connect = On
+--FILE--
+
+<?php
+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));
+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));
+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'));
+foreach($attr_array as $attr) {
+ get_attr($pc2,$attr);
+}
+
+oci_close($pc1);
+oci_close($pc2);
+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));
+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) {
+ set_attr($sys_c1,'ACTION',10);
+ get_sys_attr($sys_c1,'ACTION');
+ get_attr($pc2,'ACTION');
+ oci_close($sys_c1);
+}
+
+clean_up($c);
+
+echo "Done\n";
+?>
+--EXPECTF--
+**Set values using pconnect-1**
+resource(%d) of type (oci8 persistent connection)
+Value of MODULE has been set successfully
+Value of ACTION has been set successfully
+Value of CLIENT_INFO has been set successfully
+Value of CLIENT_IDENTIFIER has been set successfully
+
+**Get values using pconnect-2**
+resource(%d) of type (oci8 persistent connection)
+The value of MODULE is PHP TEST100
+The value of ACTION is TASK100
+The value of CLIENT_INFO is INFO1100
+The value of CLIENT_IDENTIFIER is ID00100
+
+**Get values using pconnect-3**
+resource(%d) of type (oci8 persistent connection)
+The value of MODULE is %s
+The value of ACTION is
+The value of CLIENT_INFO is
+The value of CLIENT_IDENTIFIER is
+
+**Re-open a pconnect()**
+resource(%d) of type (oci8 persistent connection)
+The value of MODULE is PHP TEST100
+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
+bool(false)
+Done
--- /dev/null
+--TEST--
+Set and get of connection attributes with oci_close().
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.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");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+
+echo"**Test Set and get values for the attributes with oci_close() ************\n";
+// With oci_connect ,oci_pconnect ,oci_new_connect
+
+var_dump($conn1 = get_conn(1)); //oci_connect()
+set_attr($conn1,'ACTION',1);
+get_attr($conn1,'ACTION');
+oci_close($conn1);
+
+// Open another connect and verify the value.
+var_dump($conn1 = get_conn(1)); //oci_connect()
+get_attr($conn1,'ACTION');
+oci_close($conn1);
+
+var_dump($pconn1 = get_conn(2)); //oci_pconnect()
+set_attr($pconn1,'MODULE',2);
+get_attr($pconn1,'MODULE');
+oci_close($pconn1);
+
+// Open another connect and verify the value.
+var_dump($pconn1 = get_conn(2)); //oci_pconnect()
+get_attr($pconn1,'MODULE');
+oci_close($pconn1);
+
+var_dump($nconn1 = get_conn(3)); //oci_new_connect()
+set_attr($nconn1,'CLIENT_INFO',3);
+set_attr($nconn1,'CLIENT_IDENTIFIER',3);
+get_attr($nconn1,'CLIENT_INFO');
+get_attr($nconn1,'CLIENT_IDENTIFIER');
+oci_close($nconn1);
+
+// Open another connect and verify the value.
+var_dump($nconn1 = get_conn(3)); //oci_new_connect()
+get_attr($nconn1,'CLIENT_INFO');
+get_attr($nconn1,'CLIENT_IDENTIFIER');
+oci_close($nconn1);
+
+clean_up($c);
+echo "Done\n";
+
+?>
+--EXPECTF--
+**Test Set and get values for the attributes with oci_close() ************
+Testing with oci_connect()
+resource(%d) of type (oci8 connection)
+Value of ACTION has been set successfully
+The value of ACTION is TASK1
+Testing with oci_connect()
+resource(%d) of type (oci8 connection)
+The value of ACTION is
+Testing with oci_pconnect()
+resource(%d) of type (oci8 persistent connection)
+Value of MODULE has been set successfully
+The value of MODULE is PHP TEST2
+Testing with oci_pconnect()
+resource(%d) of type (oci8 persistent connection)
+The value of MODULE is PHP TEST2
+Testing with oci_new_connect()
+resource(%d) of type (oci8 connection)
+Value of CLIENT_INFO has been set successfully
+Value of CLIENT_IDENTIFIER has been set successfully
+The value of CLIENT_INFO is INFO13
+The value of CLIENT_IDENTIFIER is ID003
+Testing with oci_new_connect()
+resource(%d) of type (oci8 connection)
+The value of CLIENT_INFO is
+The value of CLIENT_IDENTIFIER is
+Done
--- /dev/null
+--TEST--
+Set and get of connection attributes with errors.
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.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");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+
+$user='testuser';
+$password='testuser';
+$attr_array = array('MODULE','ACTION','CLIENT_INFO','CLIENT_IDENTIFIER');
+
+echo"**Test Negative cases************\n";
+
+echo "\nInvalid Connection resource\n";
+$nc1=NULL;
+// Invalid connection handle.
+var_dump(oci_set_action($nc1,$nc1));
+
+// Variable instead of a connection resource.
+echo "\nInvalid Connection resource 2\n";
+$str1= 'not a conn';
+var_dump(oci_set_client_info($str1,$str1));
+
+// Setting an Invalid value.
+echo "\nInvalid Value \n";
+$c1=oci_connect($user,$password,$dbase);
+var_dump(oci_set_action($c1,$c1));
+
+// Setting values multiple times.
+echo "\nSet Values multiple times \n";
+var_dump(oci_set_action($c1,'ACTION1'));
+var_dump(oci_set_action($c1,'ACTION1'));
+var_dump(oci_set_action($c1,'ACTION2'));
+var_dump(oci_set_action($c1,'ACTION1'));
+get_attr($c1,'ACTION');
+
+// Testing with different types of values
+echo "\nSetting to different values \n";
+$values_array = array(1000,NULL,'this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!this is a very huge string with a length > 64 !!!!!');
+
+foreach($values_array as $val ) {
+ oci_set_module_name($c1,$val);
+ oci_set_client_identifier($c1,$val);
+ oci_set_client_info($c1,$val);
+ $r = oci_set_action($c1,$val);
+ if ($r) {
+ echo "Values set succesfully to $val\n";
+ foreach($attr_array as $attr) {
+ get_attr($c1,$attr);
+ }
+ }
+}
+
+clean_up($c);
+echo "Done\n";
+?>
+--EXPECTF--
+**Test Negative cases************
+
+Invalid Connection resource
+
+Warning: oci_set_action() expects parameter 1 to be resource, null given in %s on line %d
+NULL
+
+Invalid Connection resource 2
+
+Warning: oci_set_client_info() expects parameter 1 to be resource, %s given in %s on line %d
+NULL
+
+Invalid Value
+
+Warning: oci_set_action() expects parameter 2 to be %s, resource given in %s on line %d
+NULL
+
+Set Values multiple times
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+The value of ACTION is ACTION1
+
+Setting to different values
+Values set succesfully to 1000
+The value of MODULE is 1000
+The value of ACTION is 1000
+The value of CLIENT_INFO is 1000
+The value of CLIENT_IDENTIFIER is 1000
+Values set succesfully to
+The value of MODULE is
+The value of ACTION is
+The value of CLIENT_INFO is
+The value of CLIENT_IDENTIFIER is
+
+Warning: oci_set_module_name(): ORA-24960: %s OCI_ATTR_MODULE %s on line %d
+
+Warning: oci_set_client_identifier(): ORA-24960: %s OCI_ATTR_CLIENT_IDENTIFIER %s on line %d
+
+Warning: oci_set_client_info(): ORA-24960: %s OCI_ATTR_CLIENT_INFO %s on line %d
+
+Warning: oci_set_action(): ORA-24960: %s OCI_ATTR_ACTION %s on line %d
+Done
--- /dev/null
+--TEST--
+Set and get connection attributes with scope end.
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.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");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release 1[012]\./', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 1[012]\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 10g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 10g or greater version of server");
+}
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/conn_attr.inc");
+
+echo"**Test - Set and get values for the attributes with scope end ************\n";
+
+// Set the attributes in one scope and verify the values from another scope.
+set_scope();
+
+echo "Get the Values from a different scope \n";
+get_scope();
+
+function set_scope() {
+ $conn1 = get_conn(1);
+ set_attr($conn1,'CLIENT_INFO',50);
+ set_attr($conn1,'CLIENT_IDENTIFIER',50);
+ $conn2 = get_conn(3);
+ set_attr($conn2,'ACTION',50);
+ $conn3 = get_conn(2);
+ set_attr($conn3,'MODULE',50);
+
+}
+
+function get_scope() {
+ $conn1 = get_conn(1);
+ get_attr($conn1,'CLIENT_INFO');
+ get_attr($conn1,'CLIENT_IDENTIFIER');
+ $conn2 = get_conn(3);
+ get_attr($conn2,'ACTION');
+ $conn3 = get_conn(2);
+ get_attr($conn3,'MODULE');
+}
+clean_up($c);
+echo "Done";
+?>
+--EXPECTF--
+**Test - Set and get values for the attributes with scope end ************
+Testing with oci_connect()
+Value of CLIENT_INFO has been set successfully
+Value of CLIENT_IDENTIFIER has been set successfully
+Testing with oci_new_connect()
+Value of ACTION has been set successfully
+Testing with oci_pconnect()
+Value of MODULE has been set successfully
+Get the Values from a different scope
+Testing with oci_connect()
+The value of CLIENT_INFO is
+The value of CLIENT_IDENTIFIER is
+Testing with oci_new_connect()
+The value of ACTION is
+Testing with oci_pconnect()
+The value of MODULE is PHP TEST50
+Done
ob_start();
phpinfo(INFO_MODULES);
$phpinfo = ob_get_clean();
-$iv = preg_match('/Oracle .*Version => 11/', $phpinfo);
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
if ($iv !== 1) {
- die ("skip expected output only valid when using Oracle 11g client libraries");
+ die ("skip expected output only valid when using Oracle 11gR2+ client libraries");
}
?>
--FILE--
OCI8 DEBUG: OCIEnvNlsCreate at (%s:%d)
OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
+OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
+OCI8 DEBUG: OCIAttrSet at (%s:%d)
+OCI8 DEBUG: OCIAttrSet at (%s:%d)
OCI8 DEBUG: OCISessionPoolCreate at (%s:%d)
OCI8 DEBUG: OCIAttrSet at (%s:%d)
+OCI8 DEBUG: OCIHandleFree at (%s:%d)
OCI8 DEBUG L1: create_spool: (%s:%d)
OCI8 DEBUG L1: using shared pool: (%s:%d)
OCI8 DEBUG: OCIHandleAlloc at (%s:%d)
OCI8 DEBUG: OCIAttrSet at (%s:%d)
OCI8 DEBUG: OCIAttrGet at (%s:%d)
OCI8 DEBUG: OCIAttrGet at (%s:%d)
-OCI8 DEBUG L1: (%s:%d)
+OCI8 DEBUG L1: (numopen=0)(numbusy=0) at (%s:%d)
OCI8 DEBUG: OCISessionGet at (%s:%d)
OCI8 DEBUG: OCIAttrGet at (%s:%d)
OCI8 DEBUG: OCIAttrGet at (%s:%d)
--- /dev/null
+--TEST--
+Verify that the Driver Name attribute is set
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
+if ($test_drcp) die("skip as Output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11.2|12)/', $sv, $matches);
+
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => (11.2|12)\./', $phpinfo);
+ if ($iv != 1) {
+ die ("skip test expected to work only with Oracle 11g or greater version of client");
+ }
+}
+else {
+ die ("skip test expected to work only with Oracle 11g or greater version of server");
+}
+
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/connect.inc");
+
+echo"**Test 1.1 - Default values for the attribute **************\n";
+get_attr($c);
+oci_close($c);
+
+echo"\n***Test 1.2 - Get the values from different connections **************\n";
+// with oci_pconnect()
+echo "Testing with oci_pconnect()\n";
+$pc1=oci_pconnect($user,$password,$dbase);
+get_attr($pc1);
+oci_close($pc1);
+
+echo "Testing with oci_new_connect()\n";
+$nc1=oci_new_connect($user,$password,$dbase);
+get_attr($nc1);
+oci_close($nc1);
+echo "Done\n";
+
+function get_attr($conn)
+{
+ $sel_stmt = "select client_driver
+ from v\$session_connect_info sci, v\$session s
+ where sci.client_driver is not null
+ and sci.sid = s.sid
+ and s.audsid = userenv('SESSIONID')";
+ $s2 = oci_parse($conn,$sel_stmt);
+ oci_execute($s2,OCI_DEFAULT);
+ oci_fetch($s2);
+ echo "The value of DRIVER_NAME is ".oci_result($s2,1)."\n";
+}
+
+?>
+--EXPECT--
+**Test 1.1 - Default values for the attribute **************
+The value of DRIVER_NAME is PHP OCI8
+
+***Test 1.2 - Get the values from different connections **************
+Testing with oci_pconnect()
+The value of DRIVER_NAME is PHP OCI8
+Testing with oci_new_connect()
+The value of DRIVER_NAME is PHP OCI8
+Done
--- /dev/null
+--TEST--
+Basic test for setting Oracle 11gR2 "edition" attribute
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys"))
+ die("skip needs to be run as a DBA user");
+if ($test_drcp)
+ die("skip as Output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11\.2|12)/', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => (11\.2|12)/', $phpinfo);
+ if ($iv != 1) {
+ die ("skip tests a feature that works only with Oracle 11gR2 or greater version of client");
+ }
+}
+else {
+ die ("skip tests a feature that works only with Oracle 11gR2 or greater version of server");
+}
+
+?>
+--FILE--
+<?php
+
+/* In 11.2, there can only be one child edition. So this test will
+ * fail to create the necessary editions if a child edition exists
+ * already
+ */
+
+require(dirname(__FILE__)."/conn_attr.inc");
+
+function select_fn($conn) {
+ $s = oci_parse($conn,"select * from view_ed");
+ oci_execute($s);
+ while ($row = oci_fetch_row($s)) {
+ var_dump($row);
+ }
+}
+/* Create a editon MYEDITION
+ create a view view_ed in MYEDITION1.
+ create the same view 'view_ed' with a different definition in MYEDITION.
+ select from both the editions and verify the contents. */
+
+set_edit_attr('MYEDITION');
+$conn = oci_connect('testuser','testuser',$dbase);
+if ($conn === false) {
+ $m = oci_error();
+ die("Error:" . $m['message']);
+}
+
+$stmtarray = array(
+ "drop table edit_tab",
+ "create table edit_tab (name varchar2(10),age number,job varchar2(50), salary number)",
+ "insert into edit_tab values('mike',30,'Senior engineer',200)",
+ "insert into edit_tab values('juan',25,'engineer',100)",
+ "create or replace editioning view view_ed as select name,age,job from edit_tab",
+);
+
+foreach ($stmtarray as $stmt) {
+ $s = oci_parse($conn, $stmt);
+ @oci_execute($s);
+}
+
+// Check the current edition of the DB and the contents of view_ed.
+get_edit_attr($conn);
+select_fn($conn);
+
+// Create a different version of view_ed in MYEDITION1.
+set_edit_attr('MYEDITION1');
+$conn2 = oci_new_connect('testuser','testuser',$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);
+
+// Check the current edition of the DB and the contents of view_ed.
+get_edit_attr($conn2);
+select_fn($conn2);
+
+// Verify the contents in MYEDITION EDITION.
+echo "version of view_ed in MYEDITION \n";
+get_edit_attr($conn);
+select_fn($conn);
+
+clean_up($c);
+
+oci_close($conn);
+oci_close($conn2);
+echo "Done\n";
+
+?>
+--EXPECTF--
+The value of edition has been successfully set
+The value of current EDITION is MYEDITION
+array(3) {
+ [0]=>
+ %unicode|string%(%d) "mike"
+ [1]=>
+ %unicode|string%(%d) "30"
+ [2]=>
+ %unicode|string%(%d) "Senior engineer"
+}
+array(3) {
+ [0]=>
+ %unicode|string%(%d) "juan"
+ [1]=>
+ %unicode|string%(%d) "25"
+ [2]=>
+ %unicode|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"
+ [1]=>
+ %unicode|string%(%d) "30"
+ [2]=>
+ %unicode|string%(%d) "Senior engineer"
+ [3]=>
+ %unicode|string%(%d) "200"
+}
+array(4) {
+ [0]=>
+ %unicode|string%(%d) "juan"
+ [1]=>
+ %unicode|string%(%d) "25"
+ [2]=>
+ %unicode|string%(%d) "engineer"
+ [3]=>
+ %unicode|string%(%d) "100"
+}
+version of view_ed in MYEDITION
+The value of current EDITION is MYEDITION
+array(3) {
+ [0]=>
+ %unicode|string%(%d) "mike"
+ [1]=>
+ %unicode|string%(%d) "30"
+ [2]=>
+ %unicode|string%(%d) "Senior engineer"
+}
+array(3) {
+ [0]=>
+ %unicode|string%(%d) "juan"
+ [1]=>
+ %unicode|string%(%d) "25"
+ [2]=>
+ %unicode|string%(%d) "engineer"
+}
+Done
--- /dev/null
+--TEST--
+Set and check Oracle 11gR2 "edition" attribute
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys"))
+ die("skip needs to be run as a DBA user");
+if ($test_drcp)
+ die("skip as Output might vary with DRCP");
+
+$sv = oci_server_version($c);
+$sv = preg_match('/Release (11\.2|12)/', $sv, $matches);
+if ($sv == 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => (11\.2|12)/', $phpinfo);
+ if ($iv != 1) {
+ die ("skip tests a feature that works only with Oracle 11gR2 or greater version of client");
+ }
+}
+else {
+ die ("skip tests a feature that works only with Oracle 11gR2 or greater version of server");
+}
+
+?>
+--FILE--
+<?php
+
+/* In 11.2, there can only be one child edition. So this test will
+ * fail to create the necessary editions if a child edition exists
+ * already
+ */
+
+require(dirname(__FILE__)."/conn_attr.inc");
+
+$user = 'testuser';
+$password = 'testuser';
+
+echo"**Test 1.1 - Default value for the attribute **************\n";
+get_edit_attr($c);
+
+echo"\n\n**Test 1.2 - Set a value and get the same with different connections *********\n";
+set_edit_attr('MYEDITION');
+
+// With oci_connect, oci_pconnect, oci_new_connect
+$conn1 = get_conn(1);
+get_edit_attr($conn1);
+
+//pconnect
+$conn2 = get_conn(2);
+get_edit_attr($conn2);
+
+//new_connect
+$conn3 = get_conn(3);
+get_edit_attr($conn3);
+
+oci_close($conn1);
+
+// With a oci_pconnect with a different charset.
+$pc1 = oci_pconnect($user,$password,$dbase,"utf8");
+get_edit_attr($pc1);
+oci_close($pc1);
+
+
+echo"\n\n**Test 1.3 change the value and verify with existing conenctions.*********\n";
+set_edit_attr('MYEDITION1');
+get_edit_attr($conn2);
+get_edit_attr($conn3); // Old value
+oci_close($conn2);
+oci_close($conn3);
+
+//open a new connection and get the edition value . This will have the updated value.
+$c3 = get_conn(3); //oci_new_connect()
+get_edit_attr($c3);
+
+$c4 = get_conn(2); //oci_pconnect()
+get_edit_attr($c4);
+
+$c5 = get_conn(1); //oci_connect()
+get_edit_attr($c5);
+
+oci_close($c3);
+oci_close($c4);
+oci_close($c5);
+
+echo "\n\n**Test 1.4 - with different type of values *********\n";
+$values_array = array(123,NULL,'NO EDITION','edition name which has more than thirty chars!!!edition name which has more than thirty chars!!!');
+foreach ($values_array as $val ) {
+ set_edit_attr($val);
+ $c1 = get_conn(1); //oci_connect()
+ if ($c1) {
+ get_edit_attr($c1);
+ oci_close($c1);
+ }
+}
+
+echo "\n\n**Test 1.5 - Negative case with an invalid string value. *********\n";
+$c1 = get_conn(3);
+$r = set_edit_attr($c1);
+
+echo"\n\n**Test 1.6 - Set Multiple times.*****\n";
+set_edit_attr('MYEDITION');
+set_edit_attr('MYEDITION1');
+$c1 = get_conn(1);
+get_edit_attr($c1);
+oci_close($c1);
+
+echo "\n\n**Test 1.7 - Test with ALTER SESSION statement to change the edition *******\n";
+// Set the edition value to MYEDITION. open a conn .get the value.
+// execute the alter system set edition ='MYEDITION' .get the value .
+// set it back to MYEDITION using oci_set_edition. and get the value.
+
+set_edit_attr('MYEDITION');
+$c1 = get_conn(3);
+echo "get the value set to MYEDITION with oci_set_edition \n";
+get_edit_attr($c1);
+
+$alter_stmt = "alter session set edition = MYEDITION1";
+$s = oci_parse($c1,$alter_stmt);
+oci_execute($s);
+oci_commit($c1);
+echo "Get the value set to MYEDITION1 with alter session\n";
+get_edit_attr($c1);
+
+echo " Get the value with a new connection \n";
+$c2 = get_conn(1);
+get_edit_attr($c2);
+
+echo " Set the value back using oci-set_edition\n";
+set_edit_attr('MYEDITION');
+get_edit_attr($c2);
+
+echo " Get the value with a new conenction \n";
+$c3 = get_conn(1);
+get_edit_attr($c3);
+
+oci_close($c1);
+oci_close($c2);
+oci_close($c3);
+
+
+echo "\n\n**Test 1.8 - Test setting the attribute with scope ends*******\n";
+set_scope();
+get_scope();
+
+clean_up($c);
+echo "Done\n";
+
+
+function set_scope() {
+ $r = set_edit_attr('MYEDITION1');
+}
+
+function get_scope() {
+ $sc1 = oci_connect($GLOBALS['user'],$GLOBALS['password'],$GLOBALS['dbase']);
+ if ($sc1 === false) {
+ $m = oci_error();
+ die("Error:" . $m['message']);
+ }
+ get_edit_attr($sc1);
+ oci_close($sc1);
+}
+?>
+--EXPECTF--
+**Test 1.1 - Default value for the attribute **************
+The value of current EDITION is ORA$BASE
+
+
+**Test 1.2 - Set a value and get the same with different connections *********
+ The value of edition has been successfully set
+Testing with oci_connect()
+The value of current EDITION is MYEDITION
+Testing with oci_pconnect()
+The value of current EDITION is MYEDITION
+Testing with oci_new_connect()
+The value of current EDITION is MYEDITION
+The value of current EDITION is MYEDITION
+
+
+**Test 1.3 change the value and verify with existing conenctions.*********
+ The value of edition has been successfully set
+The value of current EDITION is MYEDITION
+The value of current EDITION is MYEDITION
+Testing with oci_new_connect()
+The value of current EDITION is MYEDITION1
+Testing with oci_pconnect()
+The value of current EDITION is MYEDITION1
+Testing with oci_connect()
+The value of current EDITION is MYEDITION1
+
+
+**Test 1.4 - with different type of values *********
+ The value of edition has been successfully set
+Testing with oci_connect()
+
+Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
+ The value of edition has been successfully set
+Testing with oci_connect()
+The value of current EDITION is ORA$BASE
+ The value of edition has been successfully set
+Testing with oci_connect()
+
+Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
+ The value of edition has been successfully set
+Testing with oci_connect()
+
+Warning: oci_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
+
+
+**Test 1.5 - Negative case with an invalid string value. *********
+Testing with oci_new_connect()
+
+Warning: oci_new_connect(): ORA-38801: %s ORA_EDITION in %s on line %d
+ The value of edition has been successfully set
+
+
+**Test 1.6 - Set Multiple times.*****
+ The value of edition has been successfully set
+ The value of edition has been successfully set
+Testing with oci_connect()
+The value of current EDITION is MYEDITION1
+
+
+**Test 1.7 - Test with ALTER SESSION statement to change the edition *******
+ The value of edition has been successfully set
+Testing with oci_new_connect()
+get the value set to MYEDITION with oci_set_edition
+The value of current EDITION is MYEDITION
+Get the value set to MYEDITION1 with alter session
+The value of current EDITION is MYEDITION1
+ Get the value with a new connection
+Testing with oci_connect()
+The value of current EDITION is MYEDITION
+ Set the value back using oci-set_edition
+ The value of edition has been successfully set
+The value of current EDITION is MYEDITION
+ Get the value with a new conenction
+Testing with oci_connect()
+The value of current EDITION is MYEDITION
+
+
+**Test 1.8 - Test setting the attribute with scope ends*******
+ The value of edition has been successfully set
+The value of current EDITION is MYEDITION1
+Done
+
--- /dev/null
+--TEST--
+Prefetch with REF cursor. Test different values for prefetch with oci_set_prefetch().
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+ $sv = oci_server_version($c);
+ $sv = preg_match('/Release 1[012]\./', $sv, $matches);
+ if ($sv != 1) {
+ die ("skip expected output only valid when using Oracle 10g or greater server");
+ }
+}
+else {
+ die ("skip expected output only valid when using Oracle 11.2 or greater client");
+}
+?>
+--FILE--
+<?php
+require(dirname(__FILE__)."/connect.inc");
+
+// Creates the necessary package and tables.
+$stmtarray = array(
+ "DROP TABLE refcurtest",
+ "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))",
+ "CREATE or REPLACE PACKAGE refcurpkg is
+ type refcursortype is ref cursor;
+ procedure open_ref_cur(cur1 out refcursortype);
+ procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2);
+ end refcurpkg;",
+ "CREATE or REPLACE PACKAGE body refcurpkg is
+ procedure open_ref_cur(cur1 out refcursortype) is
+ begin
+ open cur1 for select * from refcurtest order by c1;
+ end open_ref_cur;
+ procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,
+ c2 out varchar2) is
+ begin
+ fetch cur1 into c1,c2;
+ end fetch_ref_cur;
+ end refcurpkg;"
+ );
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ if ($msg['code'] != 942) {
+ echo $msg['message'],"\n";
+ }
+ }
+}
+
+// Insert 500 rows into the table.
+$insert_sql = "INSERT INTO refcurtest (c1, c2) VALUES (:c1,:c2)";
+if (!($s = oci_parse($c, $insert_sql))) {
+ die("oci_parse(insert) failed!\n");
+}
+
+for ($i = 0; $i<=500; $i++) {
+ $val2 = 'test'.$i;
+ oci_bind_by_name($s,':c1',$i);
+ oci_bind_by_name($s,':c2',$val2);
+ if (!oci_execute($s)) {
+ die("oci_execute(insert) failed!\n");
+ }
+}
+
+// Various values for prefetch
+$pref = array(0,1,501,499,250,12345,-12345,-1);
+foreach($pref as $value) {
+ echo"-----------------------------------------------\n";
+ echo "Test with Prefetch value set to $value \n";
+ echo"-----------------------------------------------\n";
+ $cur1 = oci_new_cursor($c);
+ fetch_frm_php($c,$cur1,$value);
+ fetch_frm_plsql($c,$cur1);
+}
+
+
+// This function sets the prefetch count to the given $value and fetches one row .
+
+function fetch_frm_php($c,$cur1,$value) {
+ $sql1 = "begin refcurpkg.open_ref_cur(:cur1); end;";
+ $s1 = oci_parse($c,$sql1);
+ if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql1) failed!\n");
+ }
+ oci_execute($s1);
+ oci_set_prefetch($cur1,$value);
+ oci_execute($cur1);
+ echo "Fetch Row from PHP\n";
+ var_dump(oci_fetch_row($cur1));
+}
+
+// This function calls the fetch_ref_cur procedure to get the values from the REF cur.
+
+function fetch_frm_plsql($c,$cur1) {
+ $sql2 = "begin refcurpkg.fetch_ref_cur(:curs1,:c1,:c2); end;";
+ $s2 = oci_parse($c,$sql2);
+ if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+ }
+ if (!oci_bind_by_name($s2,":c1",$c1,SQLT_INT)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+ }
+ if (!oci_bind_by_name($s2,":c2",$c2,SQLT_AFC)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+ }
+ oci_execute($s2);
+ echo "Fetch Row from PL/SQL\n";
+ var_dump($c1);
+ var_dump($c2);
+}
+
+// Clean up here
+
+$stmtarray = array(
+ "drop package refcurpkg",
+ "drop table refcurtest"
+);
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ echo $msg['message'],"\n";
+ }
+}
+oci_close($c);
+echo "Done\n";
+?>
+--EXPECTF--
+-----------------------------------------------
+Test with Prefetch value set to 0
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "1"
+%unicode|string%(%d) "test1"
+-----------------------------------------------
+Test with Prefetch value set to 1
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "2"
+%unicode|string%(%d) "test2"
+-----------------------------------------------
+Test with Prefetch value set to 501
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+
+Warning: oci_execute(): ORA-01002: %s
+ORA-06512: at "SYSTEM.REFCURPKG", line %d
+ORA-06512: at line %d in %s on line %d
+Fetch Row from PL/SQL
+NULL
+NULL
+-----------------------------------------------
+Test with Prefetch value set to 499
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "500"
+%unicode|string%(%d) "test500"
+-----------------------------------------------
+Test with Prefetch value set to 250
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "251"
+%unicode|string%(%d) "test251"
+-----------------------------------------------
+Test with Prefetch value set to 12345
+-----------------------------------------------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+
+Warning: oci_execute(): ORA-01002: %s
+ORA-06512: at "SYSTEM.REFCURPKG", line %d
+ORA-06512: at line %d in %s on line %d
+Fetch Row from PL/SQL
+NULL
+NULL
+-----------------------------------------------
+Test with Prefetch value set to -12345
+-----------------------------------------------
+
+Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+-----------------------------------------------
+Test with Prefetch value set to -1
+-----------------------------------------------
+
+Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Done
--- /dev/null
+--TEST--
+Prefetch with REF cursor. Test No 2
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+ $sv = oci_server_version($c);
+ $sv = preg_match('/Release 1[012]\./', $sv, $matches);
+ if ($sv != 1) {
+ die ("skip expected output only valid when using Oracle 10g or greater server");
+ }
+}
+else {
+ die ("skip expected output only valid when using Oracle 11.1 or greater client");
+}
+?>
+--FILE--
+<?php
+require dirname(__FILE__)."/connect.inc";
+
+// Creates the necessary package and tables.
+$stmtarray = array(
+ "DROP TABLE refcurtest",
+ "CREATE TABLE refcurtest (c1 NUMBER, c2 VARCHAR(20))",
+ "CREATE or REPLACE PACKAGE refcurpkg is
+ type refcursortype is ref cursor;
+ procedure open_ref_cur(cur1 out refcursortype);
+ procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,c2 out varchar2);
+ end refcurpkg;",
+ "CREATE or REPLACE PACKAGE body refcurpkg is
+ procedure open_ref_cur(cur1 out refcursortype) is
+ begin
+ open cur1 for select * from refcurtest order by c1;
+ end open_ref_cur;
+ procedure fetch_ref_cur(cur1 in refcursortype, c1 out number,
+ c2 out varchar2) is
+ begin
+ fetch cur1 into c1,c2;
+ end fetch_ref_cur;
+ end refcurpkg;"
+ );
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ if ($msg['code'] != 942) {
+ echo $msg['message'],"\n";
+ }
+ }
+}
+
+// Insert 500 rows into the table.
+$insert_sql = "INSERT INTO refcurtest (c1, c2) VALUES (:c1,:c2)";
+if (!($s = oci_parse($c, $insert_sql))) {
+ die("oci_parse(insert) failed!\n");
+}
+
+for ($i = 0; $i <= 500; $i++) {
+ $val2 = 'test'.$i;
+ oci_bind_by_name($s,':c1',$i);
+ oci_bind_by_name($s,':c2',$val2);
+ if (!oci_execute($s)) {
+ die("oci_execute(insert) failed!\n");
+ }
+}
+
+// Steps to Fetch from PHP . For every sub-test,the cursor is bound and then executed.
+
+$sql1 = "begin refcurpkg.open_ref_cur(:cur1); end;";
+$s1 = oci_parse($c,$sql1);
+$cur1 = oci_new_cursor($c);
+if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql1) failed!\n");
+}
+
+
+// Steps to Fetch from PL/SQL . For every sub-test,the cursor is bound and then executed.
+
+$sql2 = "begin refcurpkg.fetch_ref_cur(:curs1,:c1,:c2); end;";
+$s2 = oci_parse($c,$sql2);
+if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+}
+if (!oci_bind_by_name($s2,":c1",$c1,SQLT_INT)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+}
+if (!oci_bind_by_name($s2,":c2",$c2,SQLT_AFC)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+}
+
+
+echo "------Test 1- Check Roundtrips with prefetch 0 and 5 -----------\n";
+oci_execute($s1);
+oci_execute($cur1);
+$initial_rt = print_roundtrips($c);
+oci_set_prefetch($cur1,0);
+for ($i = 0;$i<5;$i++) {
+ var_dump(oci_fetch_row($cur1));
+}
+
+$cnt = (print_roundtrips($c) - $initial_rt);
+echo "Number of roundtrips made with prefetch count 0 for 5 rows is $cnt\n";
+
+$initial_rt = print_roundtrips($c);
+oci_set_prefetch($cur1,5);
+for ($i = 0;$i<5;$i++) {
+ var_dump(oci_fetch_row($cur1));
+}
+
+$cnt = (print_roundtrips($c) - $initial_rt );
+echo "Number of roundtrips made with prefetch count 5 for 5 rows is $cnt\n";
+
+echo "------Test 2 - Set Prefetch before PL/SQL fetch ----------\n";
+// Fetch from PHP
+$cur1 = oci_new_cursor($c);
+if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql1) failed!\n");
+}
+
+echo "Fetch Row from PHP\n";
+oci_execute($s1);
+oci_execute($cur1);
+var_dump(oci_fetch_row($cur1));
+oci_set_prefetch($cur1,5);
+
+// Fetch from PL/SQL
+if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+}
+oci_execute($s2);
+echo "Fetch Row from PL/SQL\n";
+var_dump($c1);
+var_dump($c2);
+
+echo "------Test 3 - Set Prefetch after PL/SQL fetch ----------\n";
+$cur1 = oci_new_cursor($c);
+// Fetch from PL/SQL
+if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+}
+oci_execute($s2);
+echo "Fetch Row from PL/SQL\n";
+var_dump($c1);
+var_dump($c2);
+
+// Fetch from PHP
+echo "Fetch Row from PHP\n";
+if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql1) failed!\n");
+}
+oci_set_prefetch($cur1,5);
+oci_execute($s1);
+oci_execute($cur1);
+var_dump(oci_fetch_row($cur1));
+
+echo "------Test 4- Overwrite prefetch-----------\n";
+// Fetch from PHP
+$cur1 = oci_new_cursor($c);
+if (!oci_bind_by_name($s1,":cur1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql1) failed!\n");
+}
+echo "Fetch Row from PHP\n";
+oci_execute($s1);
+oci_execute($cur1);
+var_dump(oci_fetch_row($cur1));
+oci_set_prefetch($cur1,5);
+oci_set_prefetch($cur1,0);
+oci_set_prefetch($cur1,100);
+
+// Fetch from PL/SQL
+if (!oci_bind_by_name($s2,":curs1",$cur1,-1,SQLT_RSET)) {
+ die("oci_bind_by_name(sql2) failed!\n");
+}
+oci_execute($s2);
+echo "Fetch Row from PL/SQL\n";
+var_dump($c1);
+var_dump($c2);
+
+
+function print_roundtrips($c) {
+ $sql_stmt = "select value from v\$mystat a,v\$statname c where
+ a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'";
+ $s = oci_parse($c,$sql_stmt);
+ oci_define_by_name($s,"VALUE",$value);
+ oci_execute($s);
+ oci_fetch($s);
+ return $value;
+}
+
+// Clean up here
+
+$stmtarray = array(
+ "drop package refcurpkg",
+ "drop table refcurtest"
+);
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ echo $msg['message'],"\n";
+ }
+}
+
+oci_close($c);
+echo "Done\n";
+?>
+--EXPECTF--
+------Test 1- Check Roundtrips with prefetch 0 and 5 -----------
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "1"
+ [1]=>
+ %unicode|string%(%d) "test1"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "2"
+ [1]=>
+ %unicode|string%(%d) "test2"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "3"
+ [1]=>
+ %unicode|string%(%d) "test3"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "4"
+ [1]=>
+ %unicode|string%(%d) "test4"
+}
+Number of roundtrips made with prefetch count 0 for 5 rows is 6
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "5"
+ [1]=>
+ %unicode|string%(%d) "test5"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "6"
+ [1]=>
+ %unicode|string%(%d) "test6"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "7"
+ [1]=>
+ %unicode|string%(%d) "test7"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "8"
+ [1]=>
+ %unicode|string%(%d) "test8"
+}
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "9"
+ [1]=>
+ %unicode|string%(%d) "test9"
+}
+Number of roundtrips made with prefetch count 5 for 5 rows is 2
+------Test 2 - Set Prefetch before PL/SQL fetch ----------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+------Test 3 - Set Prefetch after PL/SQL fetch ----------
+
+Warning: oci_execute(): ORA-01001: %s
+ORA-06512: at "SYSTEM.REFCURPKG", line %d
+ORA-06512: at line %d in %s on line %d
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+------Test 4- Overwrite prefetch-----------
+Fetch Row from PHP
+array(2) {
+ [0]=>
+ %unicode|string%(%d) "0"
+ [1]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row from PL/SQL
+%unicode|string%(%d) "101"
+%unicode|string%(%d) "test101"
+Done
--- /dev/null
+--TEST--
+Prefetch with Nested cursors with INI setting.
+--INI--
+oci8.default_prefetch=5
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension");
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/connect.inc");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$iv = preg_match('/Oracle .*Version => (11\.2|12\.)/', $phpinfo);
+if ($iv == 1) {
+ $sv = oci_server_version($c);
+ $sv = preg_match('/Release (11\.2|12\.)/', $sv, $matches);
+ if ($sv != 1) {
+ die ("skip expected output only valid when using Oracle 11.2 or greater server");
+ }
+}
+else {
+ die ("skip expected output only valid when using Oracle 11.2 or greater client");
+}
+
+?>
+--FILE--
+<?php
+require dirname(__FILE__)."/connect.inc";
+
+//Create tables here
+$stmtarray = array(
+ "drop table nescurtest",
+ "create table nescurtest(c1 varchar2(10))"
+);
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ if ($msg['code'] !=942) {
+ echo $msg['message'],"\n";
+ }
+ }
+}
+// Insert 500 rows into the table.
+$insert_sql = "INSERT INTO nescurtest (c1) VALUES (:c1)";
+if (!($s = oci_parse($c, $insert_sql))) {
+ die("oci_parse(insert) failed!\n");
+}
+
+for ($i = 0; $i<=500; $i++) {
+ $val2 = 'test'.$i;
+ oci_bind_by_name($s,':c1',$val2);
+ if (!oci_execute($s)) {
+ die("oci_execute(insert) failed!\n");
+ }
+}
+
+echo"-----------------------------------------------\n";
+echo "Test with Nested Cursors\n";
+echo"-----------------------------------------------\n";
+$cur1 = oci_new_cursor($c);
+$sqlstmt = "select cursor(select * from nescurtest) curs1 from dual";
+$s = oci_parse($c,$sqlstmt);
+oci_execute($s);
+$data = oci_fetch_array($s);
+oci_execute($data['CURS1']);
+
+// Calculate round-trips
+$initial_rt = print_roundtrips($c);
+for ($i = 0;$i<10;$i++) {
+ echo "Fetch Row using Nested cursor Query\n";
+ var_dump(oci_fetch_row($data['CURS1']));
+}
+
+$cnt = (print_roundtrips($c) - $initial_rt);
+echo "Number of roundtrips made with prefetch count 5 for 10 rows is $cnt\n";
+
+function print_roundtrips($c) {
+ $sql_stmt = "select value from v\$mystat a,v\$statname c where
+ a.statistic#=c.statistic# and c.name='SQL*Net roundtrips to/from client'";
+ $s = oci_parse($c,$sql_stmt);
+ oci_define_by_name($s,"VALUE",$value);
+ oci_execute($s);
+ oci_fetch($s);
+ return $value;
+}
+
+// Clean up here
+
+$stmtarray = array(
+ "drop table nescurtest"
+);
+
+foreach($stmtarray as $stmt) {
+ $s = oci_parse($c,$stmt);
+ $r = @oci_execute($s);
+ if (!$r) {
+ $msg = oci_error($s);
+ echo $msg['message'],"\n";
+ }
+}
+oci_close($c);
+echo "Done\n";
+?>
+--EXPECTF--
+-----------------------------------------------
+Test with Nested Cursors
+-----------------------------------------------
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test0"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test1"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test2"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test3"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test4"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test5"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test6"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test7"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test8"
+}
+Fetch Row using Nested cursor Query
+array(1) {
+ [0]=>
+ %unicode|string%(%d) "test9"
+}
+Number of roundtrips made with prefetch count 5 for 10 rows is 3
+Done
reflection::export(new reflectionfunction('ocicollsize'));
reflection::export(new reflectionfunction('ocicollmax'));
reflection::export(new reflectionfunction('ocicolltrim'));
+reflection::export(new reflectionfunction('oci_set_edition'));
+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'));
?>
===DONE===
}
}
+Function [ <internal%s> function oci_set_edition ] {
+
+ - Parameters [1] {
+ Parameter #0 [ <required> $edition_name ]
+ }
+}
+
+Function [ <internal%s> function oci_set_module_name ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $connection_resource ]
+ Parameter #1 [ <required> $module_name ]
+ }
+}
+
+Function [ <internal%s> function oci_set_action ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $connection_resource ]
+ Parameter #1 [ <required> $action ]
+ }
+}
+
+Function [ <internal%s> function oci_set_client_info ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $connection_resource ]
+ Parameter #1 [ <required> $client_information ]
+ }
+}
+
+Function [ <internal%s> function oci_set_client_identifier ] {
+
+ - Parameters [2] {
+ Parameter #0 [ <required> $connection_resource ]
+ Parameter #1 [ <required> $client_identifier ]
+ }
+}
+
===DONE===