summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Jones <sixd@php.net>2008-04-18 00:05:27 +0000
committerChristopher Jones <sixd@php.net>2008-04-18 00:05:27 +0000
commit08eaa56798fba86a72a34e0919d2ce3511c544cb (patch)
tree6ed613484bad6429997406bea1d85a79eb00df73
parentde34e8700029fc2d380c485e98401829da9b4d6c (diff)
downloadphp-git-08eaa56798fba86a72a34e0919d2ce3511c544cb.tar.gz
MFH
Code: - Do scope-end release for oci_pconnect (oci8.old_oci_close_semantics=1 gives old behavior) - Fix session reuse with 10.2 client libs - Fix the Ping macro version check for 10.2 - Add type check associated with zend_list_find - Code connection re-organized for reuse - Format comments - WS changes - Prepare for new PECL release Tests: - Add new tests - Rationalize password tests - Revert use of __DIR__ so tests will work with PHP 5.2 - Update some skipifs to make tests more portable
-rw-r--r--ext/oci8/CREDITS2
-rw-r--r--ext/oci8/README22
-rw-r--r--ext/oci8/oci8.c601
-rw-r--r--ext/oci8/oci8_collection.c138
-rw-r--r--ext/oci8/oci8_interface.c43
-rw-r--r--ext/oci8/oci8_lob.c108
-rw-r--r--ext/oci8/oci8_statement.c180
-rw-r--r--ext/oci8/package2.xml45
-rw-r--r--ext/oci8/php_oci8.h9
-rw-r--r--ext/oci8/php_oci8_int.h14
-rw-r--r--ext/oci8/tests/bug43497.phpt11
-rw-r--r--ext/oci8/tests/bug43497_92.phpt303
-rw-r--r--ext/oci8/tests/bug44113.phpt5
-rw-r--r--ext/oci8/tests/drcp_cclass1.phpt4
-rw-r--r--ext/oci8/tests/drcp_connect1.phpt6
-rw-r--r--ext/oci8/tests/drcp_scope1.phpt1
-rw-r--r--ext/oci8/tests/drcp_scope2.phpt1
-rw-r--r--ext/oci8/tests/drcp_scope3.phpt61
-rw-r--r--ext/oci8/tests/drcp_scope4.phpt57
-rw-r--r--ext/oci8/tests/drcp_scope5.phpt63
-rw-r--r--ext/oci8/tests/password.phpt71
-rw-r--r--ext/oci8/tests/password_2.phpt32
-rw-r--r--ext/oci8/tests/password_new.phpt17
-rw-r--r--ext/oci8/tests/password_old.phpt25
-rw-r--r--ext/oci8/tests/pecl_bug10194_blob.phpt2
-rw-r--r--ext/oci8/tests/pecl_bug10194_blob_64.phpt2
-rw-r--r--ext/oci8/tests/testping.phpt2
27 files changed, 1231 insertions, 594 deletions
diff --git a/ext/oci8/CREDITS b/ext/oci8/CREDITS
index 18cad81c3e..4c1e0d05b7 100644
--- a/ext/oci8/CREDITS
+++ b/ext/oci8/CREDITS
@@ -1,2 +1,2 @@
OCI8
-Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson, Maxim Maletsky, Harald Radi, Antony Dovgal, Andi Gutmans, Wez Furlong
+Stig Bakken, Thies C. Arntzen, Andy Sautins, David Benson, Maxim Maletsky, Harald Radi, Antony Dovgal, Andi Gutmans, Wez Furlong, Christopher Jones, Oracle Corporation
diff --git a/ext/oci8/README b/ext/oci8/README
index 871a4501fb..cca3c40a97 100644
--- a/ext/oci8/README
+++ b/ext/oci8/README
@@ -207,10 +207,9 @@ these steps:
6.2.0 Important: if Oracle Database 11.1.0.6 with DRCP connections is
used, then the Oracle database patch for bug 6474441 must be
- applied (see section 6.5) or a workaround below used. Without
- this patch, "ORA-01000: maximum open cursors exceeded", "ORA-01001
- invalid cursor" or "ORA-01002 fetch out of sequence" errors may
- occur.
+ applied (see section 6.5). Without this patch, "ORA-01000:
+ maximum open cursors exceeded", "ORA-01001 invalid cursor" or
+ "ORA-01002 fetch out of sequence" errors may occur.
If the Oracle 11.1.0.6 database patch cannot be applied, one of
the following three workarounds can be used to disable statement
@@ -325,7 +324,20 @@ Changing a password over DRCP connections will fail with the error
"ORA-56609: Usage not supported with DRCP". This is an documented
restriction of Oracle Database 11g.
-6.4.2 LOGON Triggers can be used to set session properties
+6.4.2 Closing Connections
+
+With the PHP 5.3 OCI8 Beta extension, persistent connections can now
+be closed by the user, allowing greater control over connection
+resource usage. Persistent connections will now also be closed
+automatically when there is no PHP variable referencing them, such as
+at the end of scope of a PHP user function. This will rollback any
+uncommitted transaction. These changes to persistent connections make
+them behave similarly to non-persistent connections, simplifying the
+interface, allowing for greater application consistency and
+predictability. Use oci8.old_oci_close_semantics=1 to retain the
+historical behavior.
+
+6.4.3 LOGON Triggers can be used to set session properties
The patch for Oracle Database 11.1.0.6 bug 6474441 (see section 6.5)
allows PHP applications with DRCP connection to use a database LOGON
diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c
index 171e70c3a8..e9c13f7d27 100644
--- a/ext/oci8/oci8.c
+++ b/ext/oci8/oci8.c
@@ -27,13 +27,6 @@
*/
/* $Id$ */
-/* TODO
- *
- * file://localhost/www/docs/oci10/ociaahan.htm#423823 - implement lob_empty() with OCI_ATTR_LOBEMPTY
- *
- * get OCI_ATTR_CHARSET_ID attr of column to detect UTF string and multiply buffer in 4 times
- *
- */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -441,8 +434,9 @@ PHP_INI_END()
*/
/* {{{ php_oci_init_global_handles()
- Initialize global handles only when they are needed
-*/
+ *
+ * Initialize global handles only when they are needed
+ */
static void php_oci_init_global_handles(TSRMLS_D)
{
sword errcode;
@@ -488,8 +482,9 @@ oci_error:
} /* }}} */
/* {{{ php_oci_cleanup_global_handles()
- Free global handles (if they were initialized before)
-*/
+ *
+ * Free global handles (if they were initialized before)
+ */
static void php_oci_cleanup_global_handles(TSRMLS_D)
{
if (OCI_G(err)) {
@@ -504,8 +499,9 @@ static void php_oci_cleanup_global_handles(TSRMLS_D)
} /* }}} */
/* {{{ PHP_GINIT_FUNCTION
- Zerofill globals during module init
-*/
+ *
+ * Zerofill globals during module init
+ */
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5)
/* This check allows PECL builds from this file to be portable to older PHP releases */
static PHP_GINIT_FUNCTION(oci)
@@ -661,7 +657,6 @@ PHP_RINIT_FUNCTION(oci)
OCI_G(debug_mode) = 0; /* start "fresh" */
OCI_G(num_links) = OCI_G(num_persistent);
OCI_G(errcode) = 0;
- OCI_G(request_shutdown) = 0;
return SUCCESS;
}
@@ -686,7 +681,6 @@ PHP_MSHUTDOWN_FUNCTION(oci)
PHP_RSHUTDOWN_FUNCTION(oci)
{
/* Set this to indicate request shutdown for all further processing */
- OCI_G(request_shutdown) = 1;
#ifdef ZTS
zend_hash_apply_with_argument(&EG(regular_list), (apply_func_arg_t) php_oci_list_helper, (void *)le_descriptor TSRMLS_CC);
@@ -698,7 +692,10 @@ PHP_RSHUTDOWN_FUNCTION(oci)
}
#endif
- /* check persistent connections and do the necessary actions if needed. If persistent_helper is unable to process a pconnection because of a refcount, the processing would happen from np-destructor which is called when refcount goes to zero - php_oci_pconnection_list_np_dtor*/
+ /* Check persistent connections and do the necessary actions if needed. If persistent_helper is
+ * unable to process a pconnection because of a refcount, the processing would happen from
+ * np-destructor which is called when refcount goes to zero - php_oci_pconnection_list_np_dtor
+ */
zend_hash_apply(&EG(persistent_list), (apply_func_t) php_oci_persistent_helper TSRMLS_CC);
#ifdef ZTS
@@ -725,27 +722,31 @@ PHP_MINFO_FUNCTION(oci)
#if !defined(PHP_WIN32) && !defined(HAVE_OCI_INSTANT_CLIENT)
#ifdef PHP_OCI8_ORACLE_VERSION
- php_info_print_table_row(2, "Oracle Version", PHP_OCI8_ORACLE_VERSION );
+ php_info_print_table_row(2, "Oracle Version", PHP_OCI8_ORACLE_VERSION);
+#endif
+#ifdef PHP_OCI8_DIR
+ php_info_print_table_row(2, "Compile-time ORACLE_HOME", PHP_OCI8_DIR);
+#endif
+#ifdef PHP_OCI8_SHARED_LIBADD
+ php_info_print_table_row(2, "Libraries Used", PHP_OCI8_SHARED_LIBADD);
#endif
- php_info_print_table_row(2, "Compile-time ORACLE_HOME", PHP_OCI8_DIR );
- php_info_print_table_row(2, "Libraries Used", PHP_OCI8_SHARED_LIBADD );
#else
-# if defined(HAVE_OCI_INSTANT_CLIENT) && defined(OCI_MAJOR_VERSION) && defined(OCI_MINOR_VERSION)
+#if defined(HAVE_OCI_INSTANT_CLIENT) && defined(OCI_MAJOR_VERSION) && defined(OCI_MINOR_VERSION)
snprintf(buf, sizeof(buf), "%d.%d", OCI_MAJOR_VERSION, OCI_MINOR_VERSION);
php_info_print_table_row(2, "Oracle Instant Client Version", buf);
-# endif
+#endif
#endif
#ifdef HAVE_OCI8_TEMP_LOB
- php_info_print_table_row(2, "Temporary Lob support", "enabled" );
+ php_info_print_table_row(2, "Temporary Lob support", "enabled");
#else
- php_info_print_table_row(2, "Temporary Lob support", "disabled" );
+ php_info_print_table_row(2, "Temporary Lob support", "disabled");
#endif
#ifdef PHP_OCI8_HAVE_COLLECTIONS
- php_info_print_table_row(2, "Collections support", "enabled" );
+ php_info_print_table_row(2, "Collections support", "enabled");
#else
- php_info_print_table_row(2, "Collections support", "disabled" );
+ php_info_print_table_row(2, "Collections support", "disabled");
#endif
php_info_print_table_end();
@@ -757,7 +758,9 @@ PHP_MINFO_FUNCTION(oci)
/* list destructors {{{ */
/* {{{ php_oci_connection_list_dtor()
- Non-persistent connection destructor */
+ *
+ * Non-persistent connection destructor
+ */
static void php_oci_connection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
{
php_oci_connection *connection = (php_oci_connection *)entry->ptr;
@@ -769,7 +772,9 @@ static void php_oci_connection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_pconnection_list_dtor()
- Persistent connection destructor */
+ *
+ * Persistent connection destructor
+ */
static void php_oci_pconnection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
{
php_oci_connection *connection = (php_oci_connection *)entry->ptr;
@@ -781,48 +786,67 @@ static void php_oci_pconnection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_pconnection_list_np_dtor()
- Non-Persistent destructor for persistent connection - This gets invoked when
- the refcount of this goes to zero in the regular list */
+ *
+ * Non-Persistent destructor for persistent connection - This gets invoked when
+ * the refcount of this goes to zero in the regular list
+ */
static void php_oci_pconnection_list_np_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
{
php_oci_connection *connection = (php_oci_connection *)entry->ptr;
+ zend_rsrc_list_entry *le;
- /* We currently handle only session-pool using connections. TODO: Handle non-sessionpool connections as well */
- if (connection && connection->using_spool && !connection->is_stub) {
- zend_rsrc_list_entry *le;
+ /*
+ * We cannot get connection as NULL or as a stub in this function. This is the function that
+ * turns a pconnection to a stub
+ *
+ * If oci_password_change() changed the password of a persistent connection, close the
+ * connection and remove it from the persistent connection cache. This means subsequent scripts
+ * will be prevented from being able to present the old (now invalid) password to a usable
+ * connection to the database; they must use the new password.
+ *
+ * Check for conditions that warrant removal of the hash entry
+ */
- if (!connection->is_open) {
- /* Remove the hash entry if present */
- if ((zend_hash_find(&EG(persistent_list), connection->hash_key, strlen(connection->hash_key)+1, (void **) &le)== SUCCESS) && (le->type == le_pconnection) && (le->ptr == connection)) {
- zend_hash_del(&EG(persistent_list), connection->hash_key, strlen(connection->hash_key)+1);
- }
- else {
- php_oci_connection_close(connection TSRMLS_CC);
- }
+ if (!connection->is_open ||
+ connection->passwd_changed ||
+ (PG(connection_status) & PHP_CONNECTION_TIMEOUT) ||
+ OCI_G(in_call)) {
+
+ /* Remove the hash entry if present */
+ if ((zend_hash_find(&EG(persistent_list), connection->hash_key, strlen(connection->hash_key)+1, (void **) &le)== SUCCESS) && (le->type == le_pconnection) && (le->ptr == connection)) {
+ zend_hash_del(&EG(persistent_list), connection->hash_key, strlen(connection->hash_key)+1);
+ }
+ else {
+ php_oci_connection_close(connection TSRMLS_CC);
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__);
- }
+ if (OCI_G(debug_mode)) {
+ php_printf ("OCI8 DEBUG L1: np_dtor cleaning up: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__);
}
- else if (OCI_G(request_shutdown)){
- /* Release the connection to underlying pool - same steps
- * as the persistent helper. If we do this
- * unconditionally, we would change existing behavior
- * regarding out-of-scope pconnects. In future, we can
- * enable this through a new flag
- */
- php_oci_connection_release(connection TSRMLS_CC);
+ }
+ 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
+ * semantics. With the PECL OCI 1.3.x extensions, we release pconnections when oci_close
+ * takes the refcount to zero.
+ *
+ * If oci_old_close_semantics is set, we artifically bump up the refcount and decremented
+ * only at request shutdown.
+ */
+ 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__);
- }
+ if (OCI_G(debug_mode)) {
+ php_printf ("OCI8 DEBUG L1: np_dtor releasing: (%p) at (%s:%d) \n", connection, __FILE__, __LINE__);
}
}
} /* }}} */
/* {{{ php_oci_statement_list_dtor()
- Statement destructor */
+ *
+ * Statement destructor
+ */
static void php_oci_statement_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
{
php_oci_statement *statement = (php_oci_statement *)entry->ptr;
@@ -830,7 +854,9 @@ static void php_oci_statement_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_descriptor_list_dtor()
- Descriptor destructor */
+ *
+ * Descriptor destructor
+ */
static void php_oci_descriptor_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
{
php_oci_descriptor *descriptor = (php_oci_descriptor *)entry->ptr;
@@ -839,7 +865,9 @@ static void php_oci_descriptor_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
#ifdef PHP_OCI8_HAVE_COLLECTIONS
/* {{{ php_oci_collection_list_dtor()
- Collection destructor */
+ *
+ * Collection destructor
+ */
static void php_oci_collection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
{
php_oci_collection *collection = (php_oci_collection *)entry->ptr;
@@ -849,10 +877,12 @@ static void php_oci_collection_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
/* }}} */
-/* hash destructors {{{ */
+/* Hash Destructors {{{ */
/* {{{ php_oci_define_hash_dtor()
- Define hash destructor */
+ *
+ * Define hash destructor
+ */
void php_oci_define_hash_dtor(void *data)
{
php_oci_define *define = (php_oci_define *) data;
@@ -867,7 +897,9 @@ void php_oci_define_hash_dtor(void *data)
/* }}} */
/* {{{ php_oci_bind_hash_dtor()
- Bind hash destructor */
+ *
+ * Bind hash destructor
+ */
void php_oci_bind_hash_dtor(void *data)
{
php_oci_bind *bind = (php_oci_bind *) data;
@@ -889,7 +921,9 @@ void php_oci_bind_hash_dtor(void *data)
/* }}} */
/* {{{ php_oci_column_hash_dtor()
- Column hash destructor */
+ *
+ * Column hash destructor
+ */
void php_oci_column_hash_dtor(void *data)
{
php_oci_out_column *column = (php_oci_out_column *) data;
@@ -914,7 +948,9 @@ void php_oci_column_hash_dtor(void *data)
/* }}} */
/* {{{ php_oci_descriptor_flush_hash_dtor()
- Flush descriptors on commit */
+ *
+ * Flush descriptors on commit
+ */
void php_oci_descriptor_flush_hash_dtor(void *data)
{
php_oci_descriptor *descriptor = *(php_oci_descriptor **)data;
@@ -929,7 +965,9 @@ void php_oci_descriptor_flush_hash_dtor(void *data)
/* }}} */
/* {{{ php_oci_descriptor_delete_from_hash()
- Delete descriptor from the hash */
+ *
+ * Delete descriptor from the hash
+ */
int php_oci_descriptor_delete_from_hash(void *data, void *id TSRMLS_DC)
{
php_oci_descriptor *descriptor = *(php_oci_descriptor **)data;
@@ -945,7 +983,9 @@ int php_oci_descriptor_delete_from_hash(void *data, void *id TSRMLS_DC)
/* }}} */
/* {{{ php_oci_error()
- Fetch & print out error message if we get an error */
+ *
+ * Fetch & print out error message if we get an error
+ */
sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC)
{
text *errbuf = (text *)NULL;
@@ -996,7 +1036,9 @@ sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC)
/* }}} */
/* {{{ php_oci_fetch_errmsg()
- Fetch error message into the buffer from the error handle provided */
+ *
+ * Fetch error message into the buffer from the error handle provided
+ */
sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC)
{
sb4 error_code = 0;
@@ -1022,7 +1064,9 @@ sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_fetch_sqltext_offset()
- Compute offset in the SQL statement */
+ *
+ * Compute offset in the SQL statement
+ */
int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, ub2 *error_offset TSRMLS_DC)
{
*sqltext = NULL;
@@ -1047,7 +1091,9 @@ int php_oci_fetch_sqltext_offset(php_oci_statement *statement, text **sqltext, u
} /* }}} */
/* {{{ php_oci_do_connect()
- Connect wrapper */
+ *
+ * Connect wrapper
+ */
void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclusive)
{
php_oci_connection *connection;
@@ -1076,7 +1122,10 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus
} /* }}} */
/* {{{ php_oci_do_connect_ex()
- * The real connect function. Allocates all the resources needed, establishes the connection and returns the result handle (or NULL) */
+ *
+ * The real connect function. Allocates all the resources needed, establishes the connection and
+ * returns the result handle (or NULL)
+ */
php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, char *dbname, int dbname_len, char *charset, long session_mode, int persistent, int exclusive TSRMLS_DC)
{
zend_rsrc_list_entry *le;
@@ -1102,14 +1151,16 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Privileged connect is disabled. Enable oci8.privileged_connect to be able to connect as SYSOPER or SYSDBA");
return NULL;
}
- /* Disable privileged connections in Safe Mode (N.b. safe mode has been removed in PHP 6 anyway) */
+ /* Disable privileged connections in Safe Mode (N.b. safe mode has been removed in PHP
+ * 6 anyway)
+ */
if (PG(safe_mode)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Privileged connect is disabled in Safe Mode");
return NULL;
}
- /* Increase security by not caching privileged
- * oci_pconnect() connections. The connection becomes
- * equivalent to oci_connect() or oci_new_connect().
+
+ /* Increase security by not caching privileged oci_pconnect() connections. The
+ * connection becomes equivalent to oci_connect() or oci_new_connect().
*/
persistent = 0;
break;
@@ -1119,9 +1170,8 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
break;
}
- /* We cannot use the new session create logic (OCISessionGet from
- * client-side session pool) when privileged connect or password
- * change is attempted. TODO: Remove this once OCI provides
+ /* We cannot use the new session create logic (OCISessionGet from client-side session pool) when
+ * privileged connect or password change is attempted. TODO: Remove this once OCI provides
* capability
*/
if ((session_mode == OCI_SYSOPER) || (session_mode == OCI_SYSDBA) || (new_password_len)) {
@@ -1224,11 +1274,10 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
}
} /* }}} */
- /* 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 connection is released to its underlying private session pool.
- * We currently do not have stub support for non-persistent conns.
+ /* 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
+ * connection is released to its underlying private session pool. We currently do not have
+ * stub support for non-persistent conns.
*
* TODO: put in negative code for non-persistent stubs
*/
@@ -1249,17 +1298,20 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
if (connection->is_persistent) {
int rsrc_type;
- /* check connection liveness in the following order:
+ /* Check connection liveness in the following order:
* 1) always check OCI_ATTR_SERVER_STATUS
* 2) see if it's time to ping it
* 3) ping it if needed
*/
if (php_oci_connection_status(connection TSRMLS_CC)) {
- /* only ping if:
+ /* Only ping if:
+ *
* 1) next_ping > 0, which means that ping_interval is not -1 (aka "Off")
- * 2) current_timestamp > next_ping, which means "it's time to check if it's still alive"
+ *
+ * 2) current_timestamp > next_ping, which means "it's time to check if it's
+ * still alive"
*/
- if ( !ping_done && (*(connection->next_pingp) > 0) && (timestamp >= *(connection->next_pingp)) && !php_oci_connection_ping(connection TSRMLS_CC) ) {
+ if (!ping_done && (*(connection->next_pingp) > 0) && (timestamp >= *(connection->next_pingp)) && !php_oci_connection_ping(connection TSRMLS_CC)) {
/* server died */
} else {
php_oci_connection *tmp;
@@ -1273,6 +1325,14 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
/* do nothing */
} else {
connection->rsrc_id = zend_list_insert(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);
+ }
}
smart_str_free_ex(&hashed_details, 0);
return connection;
@@ -1287,20 +1347,27 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
}
} /* is_open is true? */
- /* Server died - connection not usable. The is_open=true can also fall through to here, if ping fails */
+ /* Server died - connection not usable. The is_open=true can also fall through to here,
+ * if ping fails
+ */
if (persistent){
int rsrc_type;
connection->is_open = 0;
connection->used_this_request = 1;
- /* 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)) {
+ /* 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) {
le->ptr = NULL;
}
zend_hash_del(&EG(persistent_list), hashed_details.c, hashed_details.len+1);
} else {
+ /* We only remove the hash entry. The resource and the list entry with its pointer
+ * to the resource are still intact
+ */
zend_hash_del(&EG(regular_list), hashed_details.c, hashed_details.len+1);
}
@@ -1315,8 +1382,8 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
}
}
- /* Check if we have reached max_persistent. If so, try to remove a few
- * timed-out connections. As a last resort, return a non-persistent connection.
+ /* Check if we have reached max_persistent. If so, try to remove a few timed-out connections. As
+ * a last resort, return a non-persistent connection.
*/
if (persistent) {
zend_bool alloc_non_persistent = 0;
@@ -1347,13 +1414,14 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
connection->is_persistent = 0;
}
- /* {{{ Get the session pool that suits this connection request from the
- * persistent list. This step is only for non-persistent connections as
- * persistent connections have private session pools. Non-persistent conns
- * use shared session pool to allow for optimizations such as caching the
- * physical connection (for DRCP) even when the non-persistent php connection
- * is destroyed.
- * TODO: Unconditionally do this once OCI provides extended OCISessionGet capability */
+ /* {{{ Get the session pool that suits this connection request from the persistent list. This
+ * step is only for non-persistent connections as persistent connections have private session
+ * pools. Non-persistent conns use shared session pool to allow for optimizations such as
+ * caching the physical connection (for DRCP) even when the non-persistent php connection is
+ * destroyed.
+ *
+ * TODO: Unconditionally do this once OCI provides extended OCISessionGet capability
+ */
if (use_spool && !connection->is_persistent) {
if ((session_pool = php_oci_get_spool(username, username_len, password, password_len, dbname, dbname_len, charsetid ? charsetid:charsetid_nls_lang TSRMLS_CC))==NULL)
{
@@ -1365,7 +1433,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
connection->idle_expiry = (OCI_G(persistent_timeout) > 0) ? (timestamp + OCI_G(persistent_timeout)) : 0;
- /* mark password as unchanged by PHP during the duration of the database session */
+ /* Mark password as unchanged by PHP during the duration of the database session */
connection->passwd_changed = 0;
smart_str_free_ex(&hashed_details, 0);
@@ -1378,8 +1446,10 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
}
#endif
- /* Old session creation semantics when session pool cannot be used Eg: privileged connect/password change */
- if ( !use_spool) {
+ /* Old session creation semantics when session pool cannot be used Eg: privileged
+ * connect/password change
+ */
+ if (!use_spool) {
if (php_oci_old_create_session(connection, dbname, dbname_len, username, username_len, password, password_len, new_password, new_password_len, session_mode TSRMLS_CC)) {
php_oci_connection_close(connection TSRMLS_CC);
return NULL;
@@ -1392,7 +1462,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
}
}
- /* mark it as open */
+ /* Mark it as open */
connection->is_open = 1;
/* add to the appropriate hash */
@@ -1401,6 +1471,14 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
new_le.type = le_pconnection;
connection->used_this_request = 1;
connection->rsrc_id = zend_list_insert(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_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)++;
} else if (!exclusive) {
@@ -1429,16 +1507,17 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
/* }}} */
/* {{{ php_oci_connection_ping()
- * Ping connection. Uses OCIPing() or OCIServerVersion() depending on the Oracle Client version */
+ *
+ * Ping connection. Uses OCIPing() or OCIServerVersion() depending on the Oracle Client version
+ */
static int php_oci_connection_ping(php_oci_connection *connection TSRMLS_DC)
{
- /* Use OCIPing instead of OCIServerVersion. If OCIPing returns
- * ORA-1010 (invalid OCI operation) such as from Pre-10.1 servers,
- * the error is still from the server and we would have
- * successfully performed a roundtrip and validated the
- * connection. Use OCIServerVersion for Pre-10.2 clients
+ /* Use OCIPing instead of OCIServerVersion. If OCIPing returns ORA-1010 (invalid OCI operation)
+ * such as from Pre-10.1 servers, the error is still from the server and we would have
+ * successfully performed a roundtrip and validated the connection. Use OCIServerVersion for
+ * Pre-10.2 clients
*/
-#if ( (OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2)) ) /* OCIPing available 10.2 onwards */
+#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));
#else
char version[256];
@@ -1466,7 +1545,9 @@ static int php_oci_connection_ping(php_oci_connection *connection TSRMLS_DC)
/* }}} */
/* {{{ php_oci_connection_status()
- Check connection status (pre-ping check) */
+ *
+ * Check connection status (pre-ping check)
+ */
static int php_oci_connection_status(php_oci_connection *connection TSRMLS_DC)
{
ub4 ss = 0;
@@ -1485,7 +1566,9 @@ static int php_oci_connection_status(php_oci_connection *connection TSRMLS_DC)
/* }}} */
/* {{{ php_oci_connection_rollback()
- Rollback connection */
+ *
+ * Rollback connection
+ */
int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC)
{
PHP_OCI_CALL_RETURN(connection->errcode, OCITransRollback, (connection->svc, connection->err, (ub4) 0));
@@ -1500,7 +1583,9 @@ int php_oci_connection_rollback(php_oci_connection *connection TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_connection_commit()
- Commit connection */
+ *
+ * Commit connection
+ */
int php_oci_connection_commit(php_oci_connection *connection TSRMLS_DC)
{
PHP_OCI_CALL_RETURN(connection->errcode, OCITransCommit, (connection->svc, connection->err, (ub4) 0));
@@ -1515,42 +1600,21 @@ int php_oci_connection_commit(php_oci_connection *connection TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_connection_close()
- Close the connection and free all its resources */
+ *
+ * Close the connection and free all its resources
+ */
static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC)
{
int result = 0;
zend_bool in_call_save = OCI_G(in_call);
- if (connection->descriptors) {
- zend_hash_destroy(connection->descriptors);
- efree(connection->descriptors);
- }
-
- if (connection->svc) {
- /* rollback outstanding transactions */
- if (connection->needs_commit) {
- if (php_oci_connection_rollback(connection TSRMLS_CC)) {
- /* rollback failed */
- result = 1;
- }
- }
+ if (!connection->is_stub) {
+ /* Release resources associated with connection */
+ php_oci_connection_release(connection TSRMLS_CC);
}
- if (!connection->is_stub && connection->svc && connection->is_open) {
- /* Update the next_ping in the connection. Needed also for non-peristent because non-persistent DRCP caches connection underneath */
- if (OCI_G(ping_interval) >= 0) {
- *(connection->next_pingp) = time(NULL) + OCI_G(ping_interval);
- } else {
- /* ping_interval is -1 */
- *(connection->next_pingp) = 0;
- }
-
- /* Use OCISessionRelease for session pool connections */
- if (connection->using_spool) {
- PHP_OCI_CALL(OCISessionRelease, (connection->svc, connection->err, NULL,0, (ub4) 0));
- } else {
+ if (!connection->using_spool && connection->svc) {
PHP_OCI_CALL(OCISessionEnd, (connection->svc, connection->err, connection->session, (ub4) 0));
- }
}
if (connection->err) {
@@ -1605,14 +1669,19 @@ static int php_oci_connection_close(php_oci_connection *connection TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_connection_release()
- Release the connection to its session pool. This looks similar to php_oci_connection_close, but the latter is used for connections that are to be terminated. The latter was not overloaded for "release" because of too many callers */
+ *
+ * Release the connection's resources. This involves freeing descriptors and rolling back
+ * transactions, setting timeout-related parameters etc. For session-pool using connections, the
+ * underlying connection is released to its session pool.
+ */
int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC)
{
int result = 0;
zend_bool in_call_save = OCI_G(in_call);
+ time_t timestamp = time(NULL);
- if (connection->is_stub || !connection->using_spool) {
- return 0; /* Not our concern */
+ if (connection->is_stub) {
+ return 0;
}
if (connection->descriptors) {
@@ -1631,32 +1700,56 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC)
}
}
- /* Release the session */
- if (connection->svc) {
+ if (OCI_G(persistent_timeout) > 0) {
+ connection->idle_expiry = timestamp + OCI_G(persistent_timeout);
+ }
+
+ /* We may have half-cooked connections to clean up */
+ if (connection->next_pingp) {
if (OCI_G(ping_interval) >= 0) {
- *(connection->next_pingp) = time(NULL) + OCI_G(ping_interval);
+ *(connection->next_pingp) = timestamp + OCI_G(ping_interval);
} else {
/* ping_interval is -1 */
*(connection->next_pingp) = 0;
}
-
- PHP_OCI_CALL(OCISessionRelease, (connection->svc, connection->err, NULL,
- 0, result ? OCI_SESSRLS_DROPSESS : OCI_DEFAULT));
}
- /* It no longer has relation with the database session. However authinfo and env are cached */
- connection->svc = NULL;
- connection->server = NULL;
- connection->session = NULL;
+ /* Release the session (stubs are filtered out at the beginning)*/
+ if (connection->using_spool) {
+ ub4 rlsMode = OCI_DEFAULT;
- connection->is_attached = connection->is_open = connection->needs_commit = 0;
- connection->is_stub = 1;
+ if (result) {
+ rlsMode |= OCI_SESSRLS_DROPSESS;
+ }
- /* Cut the link between the connection structure and the time_t structure allocated within the OCI session */
- connection->next_pingp = NULL;
+ /* Sessions for non-persistent connections should be dropped. For 11 and above, the session
+ * pool has its own mechanism for doing so for purity NEW connections. We need to do so
+ * explicitly for 10.2 and earlier.
+ */
+#if (!(OCI_MAJOR_VERSION >= 11))
+ if (!connection->is_persistent) {
+ rlsMode |= OCI_SESSRLS_DROPSESS;
+ }
+#endif
+
+ if (connection->svc) {
+ PHP_OCI_CALL(OCISessionRelease, (connection->svc, connection->err, NULL,
+ 0, rlsMode));
+ }
+ /* It no longer has relation with the database session. However authinfo and env are
+ * cached
+ */
+ connection->svc = NULL;
+ connection->server = NULL;
+ connection->session = NULL;
- if (!connection->is_persistent) {
- OCI_G(num_links)--; /* Support for "connection" stubs - future use */
+ connection->is_attached = connection->is_open = connection->needs_commit = connection->used_this_request = 0;
+ connection->is_stub = 1;
+
+ /* Cut the link between the connection structure and the time_t structure allocated within
+ * the OCI session
+ */
+ connection->next_pingp = NULL;
}
OCI_G(in_call) = in_call_save;
@@ -1664,7 +1757,9 @@ int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_password_change()
- Change password for the user with the username given */
+ *
+ * Change password for the user with the username given
+ */
int php_oci_password_change(php_oci_connection *connection, char *user, int user_len, char *pass_old, int pass_old_len, char *pass_new, int pass_new_len TSRMLS_DC)
{
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));
@@ -1679,7 +1774,9 @@ int php_oci_password_change(php_oci_connection *connection, char *user, int user
} /* }}} */
/* {{{ php_oci_server_get_version()
- Get Oracle server version */
+ *
+ * Get Oracle server version
+ */
int php_oci_server_get_version(php_oci_connection *connection, char **version TSRMLS_DC)
{
char version_buff[256];
@@ -1697,7 +1794,9 @@ int php_oci_server_get_version(php_oci_connection *connection, char **version TS
} /* }}} */
/* {{{ php_oci_column_to_zval()
- Convert php_oci_out_column struct into zval */
+ *
+ * Convert php_oci_out_column struct into zval
+ */
int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSRMLS_DC)
{
php_oci_descriptor *descriptor;
@@ -1779,7 +1878,9 @@ 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 */
+ *
+ * Fetch the next row from the given statement
+ */
void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args)
{
zval *z_statement, *array;
@@ -1875,9 +1976,7 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg
}
if (expected_args > 2) {
- /* only for ocifetchinto BC
- * in all other cases we return array, not long
- */
+ /* Only for ocifetchinto BC. In all other cases we return array, not long */
REPLACE_ZVAL_VALUE(&array, return_value, 1); /* copy return_value to given reference */
zval_dtor(return_value);
RETURN_LONG(statement->ncolumns);
@@ -1886,81 +1985,25 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg
/* }}} */
/* {{{ php_oci_persistent_helper()
- Helper function to close/rollback persistent connections at the end of request. A return value of 1 indicates that the connection is to be destroyed */
+ *
+ * Helper function to close/rollback persistent connections at the end of request. A return value of
+ * 1 indicates that the connection is to be destroyed
+ */
static int php_oci_persistent_helper(zend_rsrc_list_entry *le TSRMLS_DC)
{
time_t timestamp;
php_oci_connection *connection;
- int rsrc_type;
timestamp = time(NULL);
- /* pconnection stubs are also counted as they have private session pools */
+ /* Persistent connection stubs are also counted as they have private session pools */
if (le->type == le_pconnection) {
connection = (php_oci_connection *)le->ptr;
- if (connection->using_spool && (connection == zend_list_find(connection->rsrc_id, &rsrc_type)) && rsrc_type == le_pconnection){
- /* Do nothing - keep the connection as some one is referring to it. TODO: We should ideally have this for non-session_pool connections as well */
+ if (!connection->used_this_request && OCI_G(persistent_timeout) != -1) {
if (OCI_G(debug_mode)) {
- php_printf ("OCI8 DEBUG L1: persistent_helper skipping : (%p) at (%s:%d) \n", connection, __FILE__, __LINE__);
+ php_printf ("OCI8 DEBUG L1: persistent_helper processing for timeout: (%p stub=%d) at (%s:%d) \n", connection, connection->is_stub, __FILE__, __LINE__);
}
- }
- else if (connection->used_this_request) {
- if (OCI_G(debug_mode)) {
- php_printf ("OCI8 DEBUG L1: persistent_helper processing : (%p stub=%d) at (%s:%d) \n", connection, connection->is_stub, __FILE__, __LINE__);
- }
-
- if ((PG(connection_status) & PHP_CONNECTION_TIMEOUT) || OCI_G(in_call)) {
- return ZEND_HASH_APPLY_REMOVE;
- }
-
- /* Helps remove bad connections from the persistent list */
- if (!connection->is_open && !connection->is_stub) {
- return ZEND_HASH_APPLY_REMOVE;
- }
-
- if (connection->descriptors) {
- zend_hash_destroy(connection->descriptors);
- efree(connection->descriptors);
- connection->descriptors = NULL;
- }
-
- if (connection->needs_commit) {
- php_oci_connection_rollback(connection TSRMLS_CC);
- }
-
- /* If oci_password_change() changed the password of a
- * persistent connection, close the connection and remove
- * it from the persistent connection cache. This means
- * subsequent scripts will be prevented from being able to
- * present the old (now invalid) password to a usable
- * connection to the database; they must use the new
- * password.
- */
- if (connection->passwd_changed) {
- return ZEND_HASH_APPLY_REMOVE;
- }
-
- if (OCI_G(persistent_timeout) > 0) {
- connection->idle_expiry = timestamp + OCI_G(persistent_timeout);
- }
-
- if (!connection->is_stub) {
- if (OCI_G(ping_interval) >= 0) {
- *(connection->next_pingp) = timestamp + OCI_G(ping_interval);
- } else {
- /* ping_interval is -1 */
- *(connection->next_pingp) = 0;
- }
-
- /* Release all session pool-using persistent connections at the end of the request */
- if (connection->using_spool && php_oci_connection_release(connection TSRMLS_CC)) {
- return ZEND_HASH_APPLY_REMOVE;
- }
- }
-
- connection->used_this_request = 0;
- } else if (OCI_G(persistent_timeout) != -1) {
if (connection->idle_expiry < timestamp) {
/* connection has timed out */
return ZEND_HASH_APPLY_REMOVE;
@@ -1971,7 +2014,9 @@ static int php_oci_persistent_helper(zend_rsrc_list_entry *le TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_create_spool()
- Create(alloc + Init) Session pool for the given dbname and charsetid */
+ *
+ * Create(alloc + Init) Session pool for the given dbname and charsetid
+ */
static php_oci_spool *php_oci_create_spool(char *username, int username_len, char *password, int password_len, char *dbname, int dbname_len, char *hash_key, int hash_key_len, int charsetid TSRMLS_DC)
{
php_oci_spool *session_pool = NULL;
@@ -1982,8 +2027,9 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
session_pool = (php_oci_spool *) calloc(1, sizeof(php_oci_spool));
/* Populate key if passed */
- if (hash_key_len)
+ if (hash_key_len) {
session_pool->spool_hash_key = zend_strndup(hash_key, hash_key_len);
+ }
/* Create the session pool's env */
if (!(session_pool->env = php_oci_create_env(charsetid TSRMLS_CC))) {
@@ -2000,10 +2046,9 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
goto exit_create_spool;
}
- /* allocate the session pool error handle - This only for use in the
- * destructor, as there is a 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
+ /* Allocate the session pool error handle - This only for use in the destructor, as there is a
+ * 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));
@@ -2013,15 +2058,15 @@ static php_oci_spool *php_oci_create_spool(char *username, int username_len, cha
goto exit_create_spool;
}
-/* Disable RLB as we'd mostly have single-connection pools */
-#if (OCI_MAJOR_VERSION > 10 )
+/* Disable RLB as we mostly have single-connection pools */
+#if (OCI_MAJOR_VERSION > 10)
poolmode = OCI_SPC_NO_RLB | OCI_SPC_HOMOGENEOUS;
#else
poolmode = OCI_SPC_HOMOGENEOUS;
#endif
- /* Create the homogeneous session pool - We have different session pools
- * for every different username, password, charset and dbname.
+ /* 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));
@@ -2058,9 +2103,10 @@ exit_create_spool:
} /* }}} */
/* {{{ php_oci_get_spool()
- Get Session pool for the given dbname and charsetid from the persistent
- list. Function called for non-persistent connections.
-*/
+ *
+ * Get Session pool for the given dbname and charsetid from the persistent list. Function called for
+ * non-persistent connections.
+ */
static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *password, int password_len, char *dbname, int dbname_len, int charsetid TSRMLS_DC)
{
smart_str spool_hashed_details = {0};
@@ -2080,7 +2126,9 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
}
smart_str_appendl_ex(&spool_hashed_details, "**", sizeof("**") - 1, 0);
- smart_str_appendl_ex(&spool_hashed_details, dbname, dbname_len, 0);
+ if (dbname_len) {
+ smart_str_appendl_ex(&spool_hashed_details, dbname, dbname_len, 0);
+ }
smart_str_appendl_ex(&spool_hashed_details, "**", sizeof("**") - 1, 0);
smart_str_append_unsigned_ex(&spool_hashed_details, charsetid, 0);
@@ -2091,7 +2139,7 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
php_strtolower(spool_hashed_details.c, spool_hashed_details.len);
/* }}} */
- if (zend_hash_find(&EG(persistent_list),spool_hashed_details.c, spool_hashed_details.len+1, (void **)&spool_out_le) == FAILURE ) {
+ if (zend_hash_find(&EG(persistent_list),spool_hashed_details.c, spool_hashed_details.len+1, (void **)&spool_out_le) == FAILURE) {
session_pool = php_oci_create_spool(username, username_len, password, password_len, dbname, dbname_len, spool_hashed_details.c, spool_hashed_details.len, charsetid TSRMLS_CC);
@@ -2105,7 +2153,7 @@ static php_oci_spool *php_oci_get_spool(char *username, int username_len, char *
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 &&
- memcmp(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key, spool_hashed_details.c, spool_hashed_details.len) == 0 ) {
+ memcmp(((php_oci_spool *)(spool_out_le->ptr))->spool_hash_key, spool_hashed_details.c, spool_hashed_details.len) == 0) {
/* retrieve the cached session pool */
session_pool = (php_oci_spool *)(spool_out_le->ptr);
}
@@ -2122,7 +2170,9 @@ exit_get_spool:
} /* }}} */
/* {{{ php_oci_create_env()
-Create the OCI environment choosing the correct function for the OCI version */
+ *
+ * Create the OCI environment choosing the correct function for the OCI version
+ */
static OCIEnv *php_oci_create_env(ub2 charsetid TSRMLS_DC)
{
OCIEnv *retenv = NULL;
@@ -2162,7 +2212,10 @@ static OCIEnv *php_oci_create_env(ub2 charsetid TSRMLS_DC)
}/* }}} */
/* {{{ php_oci_old_create_session()
- This function is to be deprecated in future in favour of OCISessionGet which is used in php_oci_do_connect_ex */
+ *
+ * This function is to be deprecated in future in favour of OCISessionGet which is used in
+ * php_oci_do_connect_ex
+ */
static int php_oci_old_create_session(php_oci_connection *connection, char *dbname, int dbname_len, char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, int session_mode TSRMLS_DC)
{
if (OCI_G(debug_mode)) {
@@ -2324,11 +2377,13 @@ static int php_oci_old_create_session(php_oci_connection *connection, char *dbna
} /* }}} */
/* {{{ php_oci_create_session()
- Create session using client-side session pool - new norm */
+ *
+ * Create session using client-side session pool - new norm
+ */
static int php_oci_create_session(php_oci_connection *connection, php_oci_spool *session_pool, char *dbname, int dbname_len, char *username, int username_len, char *password, int password_len, char *new_password, int new_password_len, int session_mode TSRMLS_DC)
{
php_oci_spool *actual_spool = NULL;
-#if (OCI_MAJOR_VERSION > 10 )
+#if (OCI_MAJOR_VERSION > 10)
ub4 purity = -2; /* Illegal value to initialize */
#endif
time_t timestamp = time(NULL);
@@ -2342,9 +2397,9 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool
connection->env = actual_spool->env;
- /* Do this upfront so that connection close on an error would know
- * that this is a session pool connection. Failure to do this
- * would result in crashes in error scenarios */
+ /* Do this upfront so that connection close on an error would know that this is a session pool
+ * connection. Failure to do this would result in crashes in error scenarios
+ */
if (!connection->using_spool) {
connection->using_spool = 1;
}
@@ -2357,9 +2412,9 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool
}
}
- /* 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 */
+ /* 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));
@@ -2380,7 +2435,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 )
+#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)));
if (OCI_G(errcode) != OCI_SUCCESS) {
@@ -2411,14 +2466,11 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool
php_printf ("OCI8 DEBUG L1: (numopen=%d)(numbusy=%d) at (%s:%d) \n", numopen, numbusy, __FILE__, __LINE__);
} /* }}} */
- /* 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 good one. In non-RAC, we always get a
- * brand new connection at the end of the loop and in RAC, we
- * can get a good connection from a different instance before
- * flushing out all bad ones. We do not need to ping brand new
- * connections.
+ /* 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
+ * good one. In non-RAC, we always get a brand new connection at the end of the loop and in
+ * RAC, we can get a good connection from a different instance before flushing out all bad
+ * ones. We do not need to ping brand new connections.
*/
do {
/* Continue to use the global error handle as the connection is closed when an error occurs */
@@ -2427,8 +2479,8 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool
if (OCI_G(errcode) != OCI_SUCCESS) {
php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
- /* Session creation returns OCI_SUCCESS_WITH_INFO when
- * user's password has expired, but is still usable.
+ /* Session creation returns OCI_SUCCESS_WITH_INFO when user's password has expired, but
+ * is still usable.
*/
if (OCI_G(errcode) != OCI_SUCCESS_WITH_INFO) {
@@ -2488,7 +2540,9 @@ static int php_oci_create_session(php_oci_connection *connection, php_oci_spool
} /* }}} */
/* {{{ php_oci_spool_list_dtor()
- Session pool destructor function */
+ *
+ * Session pool destructor function
+ */
static void php_oci_spool_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
{
php_oci_spool *session_pool = (php_oci_spool *)entry->ptr;
@@ -2501,7 +2555,9 @@ static void php_oci_spool_list_dtor(zend_rsrc_list_entry *entry TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_spool_close()
- Destroys the OCI Session Pool */
+ *
+ * Destroys the OCI Session Pool
+ */
static void php_oci_spool_close(php_oci_spool *session_pool TSRMLS_DC)
{
if (session_pool->poolname_len) {
@@ -2529,10 +2585,11 @@ static void php_oci_spool_close(php_oci_spool *session_pool TSRMLS_DC)
} /* }}} */
/* {{{ php_oci_ping_init()
- Initializes the next_ping time as a context value in the
- connection. We now use OCIContext{Get,Set}Value to store the
- next_ping because we need to support ping for non-persistent DRCP
- connections */
+ *
+ * Initializes the next_ping time as a context value in the connection. We now use
+ * OCIContext{Get,Set}Value to store the next_ping because we need to support ping for
+ * non-persistent DRCP connections
+ */
static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TSRMLS_DC)
{
time_t *next_pingp = NULL;
@@ -2572,7 +2629,9 @@ static sword php_oci_ping_init(php_oci_connection *connection, OCIError *errh TS
#ifdef ZTS
/* {{{ php_oci_list_helper()
- Helper function to destroy data on thread shutdown in ZTS mode */
+ *
+ * Helper function to destroy data on thread shutdown in ZTS mode
+ */
static int php_oci_list_helper(zend_rsrc_list_entry *le, void *le_type TSRMLS_DC)
{
int type = (int) le_type;
diff --git a/ext/oci8/oci8_collection.c b/ext/oci8/oci8_collection.c
index 0475bd2136..7308ddd4ce 100644
--- a/ext/oci8/oci8_collection.c
+++ b/ext/oci8/oci8_collection.c
@@ -42,7 +42,7 @@
#include "php_oci8.h"
#include "php_oci8_int.h"
-/* {{{ php_oci_collection_create()
+/* {{{ php_oci_collection_create()
Create and return connection handle */
php_oci_collection * php_oci_collection_create(php_oci_connection *connection, char *tdo, int tdo_len, char *schema, int schema_len TSRMLS_DC)
{
@@ -87,7 +87,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c
}
/* describe TDO */
- PHP_OCI_CALL_RETURN(connection->errcode, OCIDescribeAny,
+ PHP_OCI_CALL_RETURN(connection->errcode, OCIDescribeAny,
(
connection->svc,
connection->err,
@@ -112,7 +112,7 @@ php_oci_collection * php_oci_collection_create(php_oci_connection *connection, c
}
/* get the collection type code of the attribute */
- PHP_OCI_CALL_RETURN(connection->errcode, OCIAttrGet,
+ PHP_OCI_CALL_RETURN(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(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(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(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(connection->errcode, OCIAttrGet,
(
(dvoid*) parmp2,
(ub4) OCI_DTYPE_PARAM,
@@ -201,16 +201,16 @@ 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(connection->errcode, OCIObjectNew,
(
- connection->env,
- connection->err,
- connection->svc,
- OCI_TYPECODE_TABLE,
- collection->tdo,
- (dvoid *)0,
- OCI_DURATION_DEFAULT,
- TRUE,
+ connection->env,
+ connection->err,
+ connection->svc,
+ OCI_TYPECODE_TABLE,
+ collection->tdo,
+ (dvoid *)0,
+ OCI_DURATION_DEFAULT,
+ TRUE,
(dvoid **) &(collection->collection)
)
);
@@ -236,7 +236,7 @@ CLEANUP:
return NULL;
} /* }}} */
-/* {{{ php_oci_collection_size()
+/* {{{ php_oci_collection_size()
Return size of the collection */
int php_oci_collection_size(php_oci_collection *collection, sb4 *size TSRMLS_DC)
{
@@ -252,7 +252,7 @@ int php_oci_collection_size(php_oci_collection *collection, sb4 *size TSRMLS_DC)
return 0;
} /* }}} */
-/* {{{ php_oci_collection_max()
+/* {{{ php_oci_collection_max()
Return max number of elements in the collection */
int php_oci_collection_max(php_oci_collection *collection, long *max TSRMLS_DC)
{
@@ -264,7 +264,7 @@ int php_oci_collection_max(php_oci_collection *collection, long *max TSRMLS_DC)
return 0;
} /* }}} */
-/* {{{ php_oci_collection_trim()
+/* {{{ php_oci_collection_trim()
Trim collection to the given number of elements */
int php_oci_collection_trim(php_oci_collection *collection, long trim_size TSRMLS_DC)
{
@@ -280,7 +280,7 @@ int php_oci_collection_trim(php_oci_collection *collection, long trim_size TSRML
return 0;
} /* }}} */
-/* {{{ php_oci_collection_append_null()
+/* {{{ php_oci_collection_append_null()
Append NULL element to the end of the collection */
int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC)
{
@@ -298,7 +298,7 @@ int php_oci_collection_append_null(php_oci_collection *collection TSRMLS_DC)
return 0;
} /* }}} */
-/* {{{ php_oci_collection_append_date()
+/* {{{ php_oci_collection_append_date()
Append DATE element to the end of the collection (use "DD-MON-YY" format) */
int php_oci_collection_append_date(php_oci_collection *collection, char *date, int date_len TSRMLS_DC)
{
@@ -316,7 +316,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(connection->errcode, OCICollAppend,
(
connection->env,
connection->err,
@@ -345,7 +345,7 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe
php_oci_connection *connection = collection->connection;
#if (PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 10)
- /* minimum PHP version ext/oci8/config.m4 accepts is 4.3.9 */
+ /* minimum PHP version ext/oci8/config.m4 accepts is 4.3.9 */
element_double = strtod(number, NULL);
#else
/* zend_strtod was introduced in PHP 4.3.10 */
@@ -360,7 +360,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(connection->errcode, OCICollAppend,
(
connection->env,
connection->err,
@@ -379,7 +379,7 @@ int php_oci_collection_append_number(php_oci_collection *collection, char *numbe
return 0;
} /* }}} */
-/* {{{ php_oci_collection_append_string()
+/* {{{ php_oci_collection_append_string()
Append STRING to the end of the collection */
int php_oci_collection_append_string(php_oci_collection *collection, char *element, int element_len TSRMLS_DC)
{
@@ -395,7 +395,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(connection->errcode, OCICollAppend,
(
connection->env,
connection->err,
@@ -414,7 +414,7 @@ int php_oci_collection_append_string(php_oci_collection *collection, char *eleme
return 0;
} /* }}} */
-/* {{{ php_oci_collection_append()
+/* {{{ php_oci_collection_append()
Append wrapper. Appends any supported element to the end of the collection */
int php_oci_collection_append(php_oci_collection *collection, char *element, int element_len TSRMLS_DC)
{
@@ -431,17 +431,17 @@ int php_oci_collection_append(php_oci_collection *collection, char *element, int
return php_oci_collection_append_string(collection, element, element_len TSRMLS_CC);
break;
- case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED SHORT */
- case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED LONG */
- case OCI_TYPECODE_REAL : /* REAL */
- case OCI_TYPECODE_DOUBLE : /* DOUBLE */
- case OCI_TYPECODE_INTEGER : /* INT */
- case OCI_TYPECODE_SIGNED16 : /* SHORT */
- case OCI_TYPECODE_SIGNED32 : /* LONG */
- case OCI_TYPECODE_DECIMAL : /* DECIMAL */
- case OCI_TYPECODE_FLOAT : /* FLOAT */
- case OCI_TYPECODE_NUMBER : /* NUMBER */
- case OCI_TYPECODE_SMALLINT : /* SMALLINT */
+ case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED SHORT */
+ case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED LONG */
+ case OCI_TYPECODE_REAL : /* REAL */
+ case OCI_TYPECODE_DOUBLE : /* DOUBLE */
+ case OCI_TYPECODE_INTEGER : /* INT */
+ case OCI_TYPECODE_SIGNED16 : /* SHORT */
+ case OCI_TYPECODE_SIGNED32 : /* LONG */
+ case OCI_TYPECODE_DECIMAL : /* DECIMAL */
+ case OCI_TYPECODE_FLOAT : /* FLOAT */
+ case OCI_TYPECODE_NUMBER : /* NUMBER */
+ case OCI_TYPECODE_SMALLINT : /* SMALLINT */
return php_oci_collection_append_number(collection, element, element_len TSRMLS_CC);
break;
@@ -454,7 +454,7 @@ int php_oci_collection_append(php_oci_collection *collection, char *element, int
return 1;
} /* }}} */
-/* {{{ php_oci_collection_element_get()
+/* {{{ php_oci_collection_element_get()
Get the element with the given index */
int php_oci_collection_element_get(php_oci_collection *collection, long index, zval **result_element TSRMLS_DC)
{
@@ -468,7 +468,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(connection->errcode, OCICollGetElem,
(
connection->env,
connection->err,
@@ -529,17 +529,17 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z
}
break;
- case OCI_TYPECODE_UNSIGNED16: /* UNSIGNED SHORT */
- case OCI_TYPECODE_UNSIGNED32: /* UNSIGNED LONG */
- case OCI_TYPECODE_REAL: /* REAL */
- case OCI_TYPECODE_DOUBLE: /* DOUBLE */
- case OCI_TYPECODE_INTEGER: /* INT */
- case OCI_TYPECODE_SIGNED16: /* SHORT */
- case OCI_TYPECODE_SIGNED32: /* LONG */
- case OCI_TYPECODE_DECIMAL: /* DECIMAL */
- case OCI_TYPECODE_FLOAT: /* FLOAT */
- case OCI_TYPECODE_NUMBER: /* NUMBER */
- case OCI_TYPECODE_SMALLINT: /* SMALLINT */
+ case OCI_TYPECODE_UNSIGNED16: /* UNSIGNED SHORT */
+ case OCI_TYPECODE_UNSIGNED32: /* UNSIGNED LONG */
+ case OCI_TYPECODE_REAL: /* REAL */
+ case OCI_TYPECODE_DOUBLE: /* DOUBLE */
+ case OCI_TYPECODE_INTEGER: /* INT */
+ case OCI_TYPECODE_SIGNED16: /* SHORT */
+ case OCI_TYPECODE_SIGNED32: /* LONG */
+ case OCI_TYPECODE_DECIMAL: /* DECIMAL */
+ case OCI_TYPECODE_FLOAT: /* FLOAT */
+ case OCI_TYPECODE_NUMBER: /* NUMBER */
+ case OCI_TYPECODE_SMALLINT: /* SMALLINT */
{
double double_number;
@@ -567,7 +567,7 @@ int php_oci_collection_element_get(php_oci_collection *collection, long index, z
return 1;
} /* }}} */
-/* {{{ php_oci_collection_element_set_null()
+/* {{{ php_oci_collection_element_set_null()
Set the element with the given index to NULL */
int php_oci_collection_element_set_null(php_oci_collection *collection, long index TSRMLS_DC)
{
@@ -585,7 +585,7 @@ int php_oci_collection_element_set_null(php_oci_collection *collection, long ind
return 0;
} /* }}} */
-/* {{{ php_oci_collection_element_set_date()
+/* {{{ php_oci_collection_element_set_date()
Change element's value to the given DATE */
int php_oci_collection_element_set_date(php_oci_collection *collection, long index, char *date, int date_len TSRMLS_DC)
{
@@ -603,7 +603,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(connection->errcode, OCICollAssignElem,
(
connection->env,
connection->err,
@@ -633,7 +633,7 @@ int php_oci_collection_element_set_number(php_oci_collection *collection, long i
php_oci_connection *connection = collection->connection;
#if (PHP_MAJOR_VERSION == 4 && PHP_MINOR_VERSION == 3 && PHP_RELEASE_VERSION < 10)
- /* minimum PHP version ext/oci8/config.m4 accepts is 4.3.9 */
+ /* minimum PHP version ext/oci8/config.m4 accepts is 4.3.9 */
element_double = strtod(number, NULL);
#else
/* zend_strtod was introduced in PHP 4.3.10 */
@@ -648,7 +648,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(connection->errcode, OCICollAssignElem,
(
connection->env,
connection->err,
@@ -684,7 +684,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(connection->errcode, OCICollAssignElem,
(
connection->env,
connection->err,
@@ -721,17 +721,17 @@ int php_oci_collection_element_set(php_oci_collection *collection, long index, c
return php_oci_collection_element_set_string(collection, index, value, value_len TSRMLS_CC);
break;
- case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED SHORT */
- case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED LONG */
- case OCI_TYPECODE_REAL : /* REAL */
- case OCI_TYPECODE_DOUBLE : /* DOUBLE */
- case OCI_TYPECODE_INTEGER : /* INT */
- case OCI_TYPECODE_SIGNED16 : /* SHORT */
- case OCI_TYPECODE_SIGNED32 : /* LONG */
- case OCI_TYPECODE_DECIMAL : /* DECIMAL */
- case OCI_TYPECODE_FLOAT : /* FLOAT */
- case OCI_TYPECODE_NUMBER : /* NUMBER */
- case OCI_TYPECODE_SMALLINT : /* SMALLINT */
+ case OCI_TYPECODE_UNSIGNED16 : /* UNSIGNED SHORT */
+ case OCI_TYPECODE_UNSIGNED32 : /* UNSIGNED LONG */
+ case OCI_TYPECODE_REAL : /* REAL */
+ case OCI_TYPECODE_DOUBLE : /* DOUBLE */
+ case OCI_TYPECODE_INTEGER : /* INT */
+ case OCI_TYPECODE_SIGNED16 : /* SHORT */
+ case OCI_TYPECODE_SIGNED32 : /* LONG */
+ case OCI_TYPECODE_DECIMAL : /* DECIMAL */
+ case OCI_TYPECODE_FLOAT : /* FLOAT */
+ case OCI_TYPECODE_NUMBER : /* NUMBER */
+ case OCI_TYPECODE_SMALLINT : /* SMALLINT */
return php_oci_collection_element_set_number(collection, index, value, value_len TSRMLS_CC);
break;
@@ -744,7 +744,7 @@ int php_oci_collection_element_set(php_oci_collection *collection, long index, c
return 1;
} /* }}} */
-/* {{{ php_oci_collection_assign()
+/* {{{ php_oci_collection_assign()
Assigns a value to the collection from another collection */
int php_oci_collection_assign(php_oci_collection *collection_dest, php_oci_collection *collection_from TSRMLS_DC)
{
diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c
index 22de0f3a10..dd3a8e30bd 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -442,8 +442,7 @@ PHP_FUNCTION(oci_lob_seek)
}
PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
-
-
+
if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) {
RETURN_FALSE;
}
@@ -453,9 +452,9 @@ PHP_FUNCTION(oci_lob_seek)
descriptor->lob_current_position += offset;
break;
case PHP_OCI_SEEK_END:
- if (descriptor->lob_size + offset >= 0) {
+ if ((descriptor->lob_size + offset) >= 0) {
descriptor->lob_current_position = descriptor->lob_size + offset;
- }
+ }
else {
descriptor->lob_current_position = 0;
}
@@ -464,8 +463,7 @@ PHP_FUNCTION(oci_lob_seek)
default:
descriptor->lob_current_position = (offset > 0) ? offset : 0;
break;
- }
-
+ }
RETURN_TRUE;
}
/* }}} */
@@ -505,7 +503,7 @@ PHP_FUNCTION(oci_lob_write)
zval **tmp, *z_descriptor = getThis();
php_oci_descriptor *descriptor;
int data_len;
- long write_len = 0;
+ long write_len = 0;
ub4 bytes_written;
char *data;
@@ -861,7 +859,8 @@ PHP_FUNCTION(oci_lob_export)
{
zval **tmp, *z_descriptor = getThis();
php_oci_descriptor *descriptor;
- char *filename, *buffer;
+ char *filename;
+ char *buffer;
int filename_len;
long start = -1, length = -1, block_length;
php_stream *stream;
@@ -1026,7 +1025,7 @@ PHP_FUNCTION(oci_lob_close)
RETURN_TRUE;
}
/* }}} */
-#endif
+#endif
/* {{{ proto object oci_new_descriptor(resource connection [, int type])
Initialize a new empty descriptor LOB/FILE (LOB is default) */
@@ -1249,7 +1248,7 @@ PHP_FUNCTION(oci_field_type_raw)
{
php_oci_out_column *column;
- column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+ column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
if (column) {
RETURN_LONG(column->data_type);
}
@@ -1455,7 +1454,7 @@ PHP_FUNCTION(oci_fetch_all)
efree(columns);
efree(outarrs);
- }
+ }
RETURN_LONG(rows);
}
@@ -1519,17 +1518,15 @@ PHP_FUNCTION(oci_free_statement)
Disconnect from database */
PHP_FUNCTION(oci_close)
{
- /* oci_close for pconnect (if old_oci_close_semantics not set) would
- * release the connection back to the client-side session pool (and to the
+ /* oci_close for pconnect (if old_oci_close_semantics not set) would
+ * release the connection back to the client-side session pool (and to the
* server-side pool if Database Resident Connection Pool is being used).
* Subsequent pconnects in the same script are not guaranteed to get the
- * same database session. When a persistent connection goes out-of-scope,
- * the connection is not released to the session pool and is kept in the Plist
+ * same database session.
*/
zval *z_connection;
php_oci_connection *connection;
- int dummy_type = -1;
if (OCI_G(old_oci_close_semantics)) {
/* do nothing to keep BC */
@@ -1543,16 +1540,6 @@ PHP_FUNCTION(oci_close)
PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
zend_list_delete(connection->rsrc_id);
- /* If refcount has fallen to zero(resource id removed from the list),
- * Release the OCI session associated with this connection structure back
- * to the underlying pool. The connection would be cached in the plist as a
- * stub
- */
- if(connection->is_persistent && connection->using_spool && !zend_list_find(connection->rsrc_id, &dummy_type)) {
-
- php_oci_connection_release(connection TSRMLS_CC);
- }
-
ZVAL_NULL(z_connection);
RETURN_TRUE;
@@ -1728,7 +1715,7 @@ PHP_FUNCTION(oci_password_change)
int user_len, pass_old_len, pass_new_len, dbname_len;
php_oci_connection *connection;
- /* Disable in Safe Mode */
+ /* Disable in Safe Mode */
if (PG(safe_mode)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "is disabled in Safe Mode");
RETURN_FALSE;
@@ -2188,7 +2175,7 @@ PHP_FUNCTION(oci_new_collection)
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s", &z_connection, &tdo, &tdo_len, &schema, &schema_len) == FAILURE) {
return;
}
-
+
PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
if ( (collection = php_oci_collection_create(connection, tdo, tdo_len, schema, schema_len TSRMLS_CC)) ) {
diff --git a/ext/oci8/oci8_lob.c b/ext/oci8/oci8_lob.c
index 1b1aff8148..7002d2cf6e 100644
--- a/ext/oci8/oci8_lob.c
+++ b/ext/oci8/oci8_lob.c
@@ -75,8 +75,8 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ
PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIDescriptorAlloc, (connection->env, (dvoid*)&(descriptor->descriptor), descriptor->type, (size_t) 0, (dvoid **) 0));
if (OCI_G(errcode) != OCI_SUCCESS) {
- connection->errcode = php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
- PHP_OCI_HANDLE_ERROR(connection, connection->errcode);
+ OCI_G(errcode) = php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
+ PHP_OCI_HANDLE_ERROR(connection, OCI_G(errcode));
efree(descriptor);
return NULL;
}
@@ -103,7 +103,7 @@ php_oci_descriptor *php_oci_lob_create (php_oci_connection *connection, long typ
} /* }}} */
-/* {{{ php_oci_lob_get_length()
+/* {{{ php_oci_lob_get_length()
Get length of the LOB. The length is cached so we don't need to ask Oracle every time */
int php_oci_lob_get_length (php_oci_descriptor *descriptor, ub4 *length TSRMLS_DC)
{
@@ -223,7 +223,7 @@ static inline int php_oci_lob_calculate_buffer(php_oci_descriptor *descriptor, l
}
/* }}} */
-/* {{{ php_oci_lob_read()
+/* {{{ php_oci_lob_read()
Read specified portion of the LOB into the buffer */
int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long initial_offset, char **data, ub4 *data_len TSRMLS_DC)
{
@@ -257,7 +257,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
if (length <= 0) {
return 0;
}
-
+
if (initial_offset > length) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be less than size of the LOB");
return 1;
@@ -334,16 +334,16 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
connection->svc,
connection->err,
descriptor->descriptor,
- (oraub8 *)&bytes_read, /* IN/OUT bytes toread/read */
- (oraub8 *)&chars_read, /* IN/OUT chars toread/read */
- (oraub8) offset + 1, /* offset (starts with 1) */
+ (oraub8 *)&bytes_read, /* IN/OUT bytes toread/read */
+ (oraub8 *)&chars_read, /* IN/OUT chars toread/read */
+ (oraub8) offset + 1, /* offset (starts with 1) */
(dvoid *) bufp,
- (oraub8) buffer_size, /* size of buffer */
+ (oraub8) buffer_size, /* size of buffer */
OCI_FIRST_PIECE,
(dvoid *)&ctx,
- (OCICallbackLobRead2) php_oci_lob_callback, /* callback... */
- (ub2) descriptor->charset_id, /* The character set ID of the buffer data. */
- (ub1) descriptor->charset_form /* The character set form of the buffer data. */
+ (OCICallbackLobRead2) php_oci_lob_callback, /* callback... */
+ (ub2) descriptor->charset_id, /* The character set ID of the buffer data. */
+ (ub1) descriptor->charset_form /* The character set form of the buffer data. */
)
);
@@ -367,14 +367,14 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
connection->svc,
connection->err,
descriptor->descriptor,
- &bytes_read, /* IN/OUT bytes toread/read */
- offset + 1, /* offset (starts with 1) */
+ &bytes_read, /* IN/OUT bytes toread/read */
+ offset + 1, /* offset (starts with 1) */
(dvoid *) bufp,
- (ub4) buffer_size, /* size of buffer */
+ (ub4) buffer_size, /* size of buffer */
(dvoid *)&ctx,
- (OCICallbackLobRead) php_oci_lob_callback, /* callback... */
- (ub2) descriptor->charset_id, /* The character set ID of the buffer data. */
- (ub1) descriptor->charset_form /* The character set form of the buffer data. */
+ (OCICallbackLobRead) php_oci_lob_callback, /* callback... */
+ (ub2) descriptor->charset_id, /* The character set ID of the buffer data. */
+ (ub1) descriptor->charset_form /* The character set form of the buffer data. */
)
);
@@ -394,7 +394,7 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
return 1;
}
- descriptor->lob_current_position = (int)offset;
+ 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));
@@ -414,11 +414,11 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long ini
return 0;
} /* }}} */
-/* {{{ php_oci_lob_write()
+/* {{{ php_oci_lob_write()
Write data to the LOB */
int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, int data_len, ub4 *bytes_written TSRMLS_DC)
{
- OCILobLocator *lob = (OCILobLocator *) descriptor->descriptor;
+ OCILobLocator *lob = (OCILobLocator *) descriptor->descriptor;
php_oci_connection *connection = (php_oci_connection *) descriptor->connection;
ub4 lob_length;
@@ -439,19 +439,19 @@ 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(connection->errcode, OCILobWrite,
(
- connection->svc,
- connection->err,
- lob,
- (ub4 *)&data_len,
- (ub4) offset + 1,
- (dvoid *) data,
- (ub4) data_len,
- OCI_ONE_PIECE,
- (dvoid *)0,
- (OCICallbackLobWrite) 0,
- (ub2) descriptor->charset_id,
+ connection->svc,
+ connection->err,
+ lob,
+ (ub4 *)&data_len,
+ (ub4) offset + 1,
+ (dvoid *) data,
+ (ub4) data_len,
+ OCI_ONE_PIECE,
+ (dvoid *)0,
+ (OCICallbackLobWrite) 0,
+ (ub2) descriptor->charset_id,
(ub1) descriptor->charset_form
)
);
@@ -477,7 +477,7 @@ int php_oci_lob_write (php_oci_descriptor *descriptor, ub4 offset, char *data, i
return 0;
} /* }}} */
-/* {{{ php_oci_lob_set_buffering()
+/* {{{ php_oci_lob_set_buffering()
Turn buffering off/onn for this particular LOB */
int php_oci_lob_set_buffering (php_oci_descriptor *descriptor, int on_off TSRMLS_DC)
{
@@ -545,7 +545,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(connection->errcode, OCILobCopy,
(
connection->svc,
connection->err,
@@ -566,7 +566,7 @@ int php_oci_lob_copy (php_oci_descriptor *descriptor_dest, php_oci_descriptor *d
return 0;
} /* }}} */
-/* {{{ php_oci_lob_close()
+/* {{{ php_oci_lob_close()
Close LOB */
int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC)
{
@@ -589,7 +589,7 @@ int php_oci_lob_close (php_oci_descriptor *descriptor TSRMLS_DC)
return 0;
} /* }}} */
-/* {{{ php_oci_temp_lob_close()
+/* {{{ php_oci_temp_lob_close()
Close Temporary LOB */
int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC)
{
@@ -617,7 +617,7 @@ int php_oci_temp_lob_close (php_oci_descriptor *descriptor TSRMLS_DC)
} /* }}} */
-/* {{{ php_oci_lob_flush()
+/* {{{ php_oci_lob_flush()
Flush buffers for the LOB (only if they have been used) */
int php_oci_lob_flush(php_oci_descriptor *descriptor, long flush_flag TSRMLS_DC)
{
@@ -710,20 +710,20 @@ 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(connection->errcode,
OCILobWrite,
(
- connection->svc,
- connection->err,
- lob,
- &loblen,
- offset,
- (dvoid *) &buf,
- loblen,
- OCI_ONE_PIECE,
- (dvoid *)0,
- (OCICallbackLobWrite) 0,
- (ub2) descriptor->charset_id,
+ connection->svc,
+ connection->err,
+ lob,
+ &loblen,
+ offset,
+ (dvoid *) &buf,
+ loblen,
+ OCI_ONE_PIECE,
+ (dvoid *)0,
+ (OCICallbackLobWrite) 0,
+ (ub2) descriptor->charset_id,
(ub1) descriptor->charset_form
)
);
@@ -844,7 +844,7 @@ int php_oci_lob_erase (php_oci_descriptor *descriptor, long offset, ub4 length,
return 0;
} /* }}} */
-/* {{{ php_oci_lob_is_equal()
+/* {{{ php_oci_lob_is_equal()
Compare two LOB descriptors and figure out if they are pointing to the same LOB */
int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descriptor *descriptor_second, boolean *result TSRMLS_DC)
{
@@ -862,12 +862,12 @@ int php_oci_lob_is_equal (php_oci_descriptor *descriptor_first, php_oci_descript
return 0;
} /* }}} */
-/* {{{ php_oci_lob_write_tmp()
+/* {{{ php_oci_lob_write_tmp()
Create temporary LOB and write data to it */
int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, ub1 type, char *data, int data_len TSRMLS_DC)
{
php_oci_connection *connection = descriptor->connection;
- OCILobLocator *lob = descriptor->descriptor;
+ OCILobLocator *lob = descriptor->descriptor;
ub4 bytes_written = 0;
switch (type) {
@@ -885,7 +885,7 @@ int php_oci_lob_write_tmp (php_oci_descriptor *descriptor, ub1 type, char *data,
return 1;
}
- PHP_OCI_CALL_RETURN(connection->errcode, OCILobCreateTemporary,
+ PHP_OCI_CALL_RETURN(connection->errcode, OCILobCreateTemporary,
(
connection->svc,
connection->err,
diff --git a/ext/oci8/oci8_statement.c b/ext/oci8/oci8_statement.c
index 4d4004a44b..91533f6aa7 100644
--- a/ext/oci8/oci8_statement.c
+++ b/ext/oci8/oci8_statement.c
@@ -41,7 +41,7 @@
#include "php_oci8.h"
#include "php_oci8_int.h"
-/* {{{ php_oci_statement_create()
+/* {{{ 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)
{
@@ -62,7 +62,7 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha
if (query_len > 0) {
#if HAVE_OCI_STMT_PREPARE2
- PHP_OCI_CALL_RETURN(connection->errcode, OCIStmtPrepare2,
+ PHP_OCI_CALL_RETURN(connection->errcode, OCIStmtPrepare2,
(
connection->svc,
&(statement->stmt),
@@ -124,7 +124,7 @@ php_oci_statement *php_oci_statement_create (php_oci_connection *connection, cha
/* {{{ 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)
-{
+{
ub4 prefetch = size;
if (size < 1) {
@@ -144,7 +144,7 @@ int php_oci_statement_set_prefetch(php_oci_statement *statement, long size TSRML
}
/* }}} */
-/* {{{ php_oci_statement_fetch()
+/* {{{ php_oci_statement_fetch()
Fetch a row from the statement */
int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC)
{
@@ -192,7 +192,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,
- OCIStmtGetPieceInfo,
+ OCIStmtGetPieceInfo,
(
statement->stmt,
statement->err,
@@ -233,7 +233,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(statement->errcode, OCIStmtFetch, (statement->stmt, statement->err, nrows, OCI_FETCH_NEXT, OCI_DEFAULT));
if (piecewisecols) {
for (i = 0; i < statement->ncolumns; i++) {
@@ -275,7 +275,7 @@ int php_oci_statement_fetch(php_oci_statement *statement, ub4 nrows TSRMLS_DC)
}
/* }}} */
-/* {{{ php_oci_statement_get_column()
+/* {{{ php_oci_statement_get_column()
Get column from the result set */
php_oci_out_column *php_oci_statement_get_column(php_oci_statement *statement, long column_index, char *column_name, int column_name_len TSRMLS_DC)
{
@@ -323,7 +323,7 @@ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **buf
php_oci_statement *nested_stmt;
TSRMLS_FETCH();
- nested_stmt = php_oci_statement_create(outcol->statement->connection, NULL, 0 TSRMLS_CC);
+ nested_stmt = php_oci_statement_create(outcol->statement->connection, NULL, 0 TSRMLS_CC);
if (!nested_stmt) {
return OCI_ERROR;
}
@@ -341,7 +341,7 @@ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **buf
}
break;
case SQLT_RDD:
- case SQLT_BLOB:
+ case SQLT_BLOB:
case SQLT_CLOB:
case SQLT_BFILE: {
php_oci_descriptor *descr;
@@ -377,7 +377,7 @@ sb4 php_oci_define_callback(dvoid *ctx, OCIDefine *define, ub4 iter, dvoid **buf
}
/* }}} */
-/* {{{ php_oci_statement_execute()
+/* {{{ php_oci_statement_execute()
Execute statement */
int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
{
@@ -421,8 +421,8 @@ 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
+ if (statement->last_query) {
+ /* if we execute refcursors we don't have a query and
we don't want to execute!!! */
if (statement->binds) {
@@ -464,7 +464,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
if (statement->errcode != OCI_SUCCESS) {
statement->errcode = php_oci_error(statement->err, statement->errcode TSRMLS_CC);
PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode);
- return 1;
+ return 1;
}
statement->ncolumns = colcount;
@@ -476,7 +476,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
efree(statement->columns);
/* out of memory */
return 1;
- }
+ }
/* get column */
PHP_OCI_CALL_RETURN(statement->errcode, OCIParamGet, ((dvoid *)statement->stmt, OCI_HTYPE_STMT, statement->err, (dvoid**)&param, counter));
@@ -507,7 +507,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
return 1;
}
- /* get character set id */
+ /* 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));
if (statement->errcode != OCI_SUCCESS) {
@@ -524,7 +524,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
PHP_OCI_CALL(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;
+ return 1;
}
outcol->storage_size4 = outcol->data_size;
@@ -584,9 +584,9 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
dynamic = OCI_DYNAMIC_FETCH;
break;
- case SQLT_RDD: /* ROWID */
- case SQLT_BLOB: /* binary LOB */
- case SQLT_CLOB: /* character LOB */
+ case SQLT_RDD: /* ROWID */
+ case SQLT_BLOB: /* binary LOB */
+ case SQLT_CLOB: /* character LOB */
case SQLT_BFILE: /* binary file LOB */
outcol->statement = statement; /* parent handle */
@@ -649,7 +649,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(statement->errcode,
OCIDefineByPos,
(
statement->stmt, /* IN/OUT handle to the requested SQL query */
@@ -667,10 +667,10 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
);
} else {
- PHP_OCI_CALL_RETURN(statement->errcode,
+ PHP_OCI_CALL_RETURN(statement->errcode,
OCIDefineByPos,
(
- statement->stmt, /* IN/OUT handle to the requested SQL query */
+ statement->stmt, /* IN/OUT handle to the requested SQL query */
(OCIDefine **)&outcol->oci_define, /* IN/OUT pointer to a pointer to a define handle */
statement->err, /* IN/OUT An error handle */
counter, /* IN position in the select list */
@@ -695,11 +695,11 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
/* additional OCIDefineDynamic() call */
switch (outcol->data_type) {
case SQLT_RSET:
- case SQLT_RDD:
- case SQLT_BLOB:
+ case SQLT_RDD:
+ case SQLT_BLOB:
case SQLT_CLOB:
case SQLT_BFILE:
- PHP_OCI_CALL_RETURN(statement->errcode,
+ PHP_OCI_CALL_RETURN(statement->errcode,
OCIDefineDynamic,
(
outcol->oci_define,
@@ -718,7 +718,7 @@ int php_oci_statement_execute(php_oci_statement *statement, ub4 mode TSRMLS_DC)
}
/* }}} */
-/* {{{ php_oci_statement_cancel()
+/* {{{ php_oci_statement_cancel()
Cancel statement */
int php_oci_statement_cancel(php_oci_statement *statement TSRMLS_DC)
{
@@ -727,11 +727,11 @@ int php_oci_statement_cancel(php_oci_statement *statement TSRMLS_DC)
} /* }}} */
-/* {{{ php_oci_statement_free()
+/* {{{ php_oci_statement_free()
Destroy statement handle and free associated resources */
void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC)
{
- if (statement->stmt) {
+ if (statement->stmt) {
#if HAVE_OCI_STMT_PREPARE2
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));
@@ -778,7 +778,7 @@ void php_oci_statement_free(php_oci_statement *statement TSRMLS_DC)
OCI_G(num_statements)--;
} /* }}} */
-/* {{{ php_oci_bind_pre_exec()
+/* {{{ php_oci_bind_pre_exec()
Helper function */
int php_oci_bind_pre_exec(void *data TSRMLS_DC)
{
@@ -786,13 +786,13 @@ int php_oci_bind_pre_exec(void *data TSRMLS_DC)
/* reset all bind stuff to a normal state..-. */
- bind->indicator = 0;
+ bind->indicator = 0;
return 0;
}
/* }}} */
-/* {{{ php_oci_bind_post_exec()
+/* {{{ php_oci_bind_post_exec()
Helper function */
int php_oci_bind_post_exec(void *data TSRMLS_DC)
{
@@ -898,19 +898,19 @@ int php_oci_bind_post_exec(void *data TSRMLS_DC)
}
/* }}} */
-/* {{{ php_oci_bind_by_name()
+/* {{{ php_oci_bind_by_name()
Bind zval to the given placeholder */
int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len, zval* var, long maxlength, long type TSRMLS_DC)
{
-#ifdef PHP_OCI8_HAVE_COLLECTIONS
+#ifdef PHP_OCI8_HAVE_COLLECTIONS
php_oci_collection *bind_collection = NULL;
#endif
php_oci_descriptor *bind_descriptor = NULL;
- php_oci_statement *bind_statement = NULL;
- dvoid *oci_desc = NULL;
- /* dvoid *php_oci_collection = NULL; */
- OCIStmt *oci_stmt = NULL;
- dvoid *bind_data = NULL;
+ php_oci_statement *bind_statement = NULL;
+ dvoid *oci_desc = NULL;
+ /* dvoid *php_oci_collection = NULL; */
+ OCIStmt *oci_stmt = NULL;
+ dvoid *bind_data = NULL;
php_oci_bind bind, *old_bind, *bindp;
int mode = OCI_DATA_AT_EXEC;
sb4 value_sz = -1;
@@ -1001,7 +1001,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
break;
}
- if (value_sz == 0) {
+ if (value_sz == 0) {
value_sz = 1;
}
@@ -1024,25 +1024,25 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
bindp->statement = oci_stmt;
bindp->parent_statement = statement;
bindp->zval = var;
- zval_add_ref(&var);
+ zval_add_ref(&var);
- PHP_OCI_CALL_RETURN(statement->errcode,
+ PHP_OCI_CALL_RETURN(statement->errcode,
OCIBindByName,
(
- statement->stmt, /* statement handle */
- (OCIBind **)&bindp->bind, /* bind hdl (will alloc) */
- statement->err, /* error handle */
- (text*) name, /* placeholder name */
- name_len, /* placeholder length */
- (dvoid *)bind_data, /* in/out data */
+ statement->stmt, /* statement handle */
+ (OCIBind **)&bindp->bind, /* bind hdl (will alloc) */
+ statement->err, /* error handle */
+ (text*) name, /* placeholder name */
+ name_len, /* placeholder length */
+ (dvoid *)bind_data, /* in/out data */
value_sz, /* PHP_OCI_MAX_DATA_SIZE, */ /* max size of input/output data */
- (ub2)type, /* in/out data type */
- (dvoid *)&bindp->indicator, /* indicator (ignored) */
- (ub2 *)0, /* size array (ignored) */
- (ub2 *)&bindp->retcode, /* return code (ignored) */
- (ub4)0, /* maxarr_len (PL/SQL only?) */
- (ub4 *)0, /* actual array size (PL/SQL only?) */
- mode /* mode */
+ (ub2)type, /* in/out data type */
+ (dvoid *)&bindp->indicator, /* indicator (ignored) */
+ (ub2 *)0, /* size array (ignored) */
+ (ub2 *)&bindp->retcode, /* return code (ignored) */
+ (ub4)0, /* maxarr_len (PL/SQL only?) */
+ (ub4 *)0, /* actual array size (PL/SQL only?) */
+ mode /* mode */
)
);
@@ -1053,7 +1053,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(statement->errcode, OCIBindDynamic,
(
bindp->bind,
statement->err,
@@ -1074,7 +1074,7 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
#ifdef PHP_OCI8_HAVE_COLLECTIONS
if (type == SQLT_NTY) {
/* Bind object */
- PHP_OCI_CALL_RETURN(statement->errcode, OCIBindObject,
+ PHP_OCI_CALL_RETURN(statement->errcode, OCIBindObject,
(
bindp->bind,
statement->err,
@@ -1097,17 +1097,17 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, int name_len,
return 0;
} /* }}} */
-/* {{{ php_oci_bind_in_callback()
+/* {{{ php_oci_bind_in_callback()
Callback used when binding LOBs and VARCHARs */
sb4 php_oci_bind_in_callback(
- dvoid *ictxp, /* context pointer */
- OCIBind *bindp, /* bind handle */
- ub4 iter, /* 0-based execute iteration value */
- ub4 index, /* index of current array for PL/SQL or row index for SQL */
- dvoid **bufpp, /* pointer to data */
- ub4 *alenp, /* size after value/piece has been read */
- ub1 *piecep, /* which piece */
- dvoid **indpp) /* indicator value */
+ dvoid *ictxp, /* context pointer */
+ OCIBind *bindp, /* bind handle */
+ ub4 iter, /* 0-based execute iteration value */
+ ub4 index, /* index of current array for PL/SQL or row index for SQL */
+ dvoid **bufpp, /* pointer to data */
+ ub4 *alenp, /* size after value/piece has been read */
+ ub1 *piecep, /* which piece */
+ dvoid **indpp) /* indicator value */
{
php_oci_bind *phpbind;
zval *val;
@@ -1124,9 +1124,9 @@ sb4 php_oci_bind_in_callback(
*bufpp = 0;
*alenp = -1;
*indpp = (dvoid *)&phpbind->indicator;
- } else if ((phpbind->descriptor == 0) && (phpbind->statement == 0)) {
+ } else if ((phpbind->descriptor == 0) && (phpbind->statement == 0)) {
/* "normal string bind */
- convert_to_string(val);
+ convert_to_string(val);
*bufpp = Z_STRVAL_P(val);
*alenp = Z_STRLEN_P(val);
@@ -1136,7 +1136,7 @@ sb4 php_oci_bind_in_callback(
*bufpp = phpbind->statement;
*alenp = -1; /* seems to be allright */
*indpp = (dvoid *)&phpbind->indicator;
- } else {
+ } else {
/* descriptor bind */
*bufpp = phpbind->descriptor;
*alenp = -1; /* seems to be allright */
@@ -1151,15 +1151,15 @@ sb4 php_oci_bind_in_callback(
/* {{{ php_oci_bind_out_callback()
Callback used when binding LOBs and VARCHARs */
sb4 php_oci_bind_out_callback(
- dvoid *octxp, /* context pointer */
- OCIBind *bindp, /* bind handle */
- ub4 iter, /* 0-based execute iteration value */
- ub4 index, /* index of current array for PL/SQL or row index for SQL */
- dvoid **bufpp, /* pointer to data */
- ub4 **alenpp, /* size after value/piece has been read */
- ub1 *piecep, /* which piece */
- dvoid **indpp, /* indicator value */
- ub2 **rcodepp) /* return code */
+ dvoid *octxp, /* context pointer */
+ OCIBind *bindp, /* bind handle */
+ ub4 iter, /* 0-based execute iteration value */
+ ub4 index, /* index of current array for PL/SQL or row index for SQL */
+ dvoid **bufpp, /* pointer to data */
+ ub4 **alenpp, /* size after value/piece has been read */
+ ub1 *piecep, /* which piece */
+ dvoid **indpp, /* indicator value */
+ ub2 **rcodepp) /* return code */
{
php_oci_bind *phpbind;
zval *val;
@@ -1199,7 +1199,7 @@ sb4 php_oci_bind_out_callback(
Z_STRVAL_P(val) = ecalloc(1, Z_STRLEN_P(phpbind->zval) + 1);
/* XXX we assume that zend-zval len has 4 bytes */
- *alenpp = (ub4*) &Z_STRLEN_P(phpbind->zval);
+ *alenpp = (ub4*) &Z_STRLEN_P(phpbind->zval);
*bufpp = Z_STRVAL_P(phpbind->zval);
*piecep = OCI_ONE_PIECE;
*rcodepp = &phpbind->retcode;
@@ -1211,7 +1211,7 @@ sb4 php_oci_bind_out_callback(
}
/* }}} */
-/* {{{ php_oci_statement_get_column_helper()
+/* {{{ php_oci_statement_get_column_helper()
Helper function to get column by name and index */
php_oci_out_column *php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAMETERS, int need_data)
{
@@ -1277,7 +1277,7 @@ int php_oci_statement_get_type(php_oci_statement *statement, ub2 *type TSRMLS_DC
return 0;
} /* }}} */
-/* {{{ php_oci_statement_get_numrows()
+/* {{{ php_oci_statement_get_numrows()
Get the number of rows fetched to the clientside (NOT the number of rows in the result set) */
int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows TSRMLS_DC)
{
@@ -1298,7 +1298,7 @@ int php_oci_statement_get_numrows(php_oci_statement *statement, ub4 *numrows TSR
return 0;
} /* }}} */
-/* {{{ php_oci_bind_array_by_name()
+/* {{{ 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)
{
@@ -1363,15 +1363,15 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
bindp->array.type = type;
zval_add_ref(&var);
- PHP_OCI_CALL_RETURN(statement->errcode,
- OCIBindByName,
+ PHP_OCI_CALL_RETURN(statement->errcode,
+ OCIBindByName,
(
statement->stmt,
(OCIBind **)&bindp->bind,
statement->err,
(text *)name,
name_len,
- (dvoid *) bindp->array.elements,
+ (dvoid *) bindp->array.elements,
(sb4) bind->array.max_length,
type,
(dvoid *)bindp->array.indicators,
@@ -1394,7 +1394,7 @@ int php_oci_bind_array_by_name(php_oci_statement *statement, char *name, int nam
return 0;
} /* }}} */
-/* {{{ php_oci_bind_array_helper_string()
+/* {{{ 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)
{
@@ -1432,7 +1432,7 @@ php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length,
for (i = 0; i < bind->array.current_length; i++) {
if (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE) {
convert_to_string_ex(entry);
- bind->array.element_lengths[i] = Z_STRLEN_PP(entry);
+ bind->array.element_lengths[i] = Z_STRLEN_PP(entry);
if (Z_STRLEN_PP(entry) == 0) {
bind->array.indicators[i] = -1;
}
@@ -1445,7 +1445,7 @@ php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length,
zend_hash_internal_pointer_reset(hash);
for (i = 0; i < max_table_length; i++) {
if ((i < bind->array.current_length) && (zend_hash_get_current_data(hash, (void **) &entry) != FAILURE)) {
- int element_length;
+ int element_length;
convert_to_string_ex(entry);
element_length = (maxlength > Z_STRLEN_PP(entry)) ? Z_STRLEN_PP(entry) : maxlength;
@@ -1463,7 +1463,7 @@ php_oci_bind *php_oci_bind_array_helper_string(zval* var, long max_table_length,
return bind;
} /* }}} */
-/* {{{ php_oci_bind_array_helper_number()
+/* {{{ 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)
{
@@ -1501,7 +1501,7 @@ php_oci_bind *php_oci_bind_array_helper_number(zval* var, long max_table_length
return bind;
} /* }}} */
-/* {{{ php_oci_bind_array_helper_double()
+/* {{{ 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)
{
@@ -1539,7 +1539,7 @@ php_oci_bind *php_oci_bind_array_helper_double(zval* var, long max_table_length
return bind;
} /* }}} */
-/* {{{ php_oci_bind_array_helper_date()
+/* {{{ 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)
{
diff --git a/ext/oci8/package2.xml b/ext/oci8/package2.xml
index b38924a49f..9ac8b494c2 100644
--- a/ext/oci8/package2.xml
+++ b/ext/oci8/package2.xml
@@ -6,8 +6,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
<name>oci8</name>
<channel>pecl.php.net</channel>
<summary>OCI8 functions</summary>
- <description>These functions allow you to access Oracle database servers using
-the Oracle Call Interface (OCI8).
+ <description>These functions allow you to access Oracle database servers using the Oracle Call Interface (OCI8).
</description>
<lead>
<name>Antony Dovgal</name>
@@ -19,13 +18,13 @@ the Oracle Call Interface (OCI8).
<name>Wez Furlong</name>
<user>wez</user>
<email>wez@php.net</email>
- <active>yes</active>
+ <active>no</active>
</lead>
<lead>
<name>Andi Gutmans</name>
<user>andi</user>
<email>andi@zend.com</email>
- <active>yes</active>
+ <active>no</active>
</lead>
<lead>
<name>Christopher Jones</name>
@@ -33,26 +32,25 @@ the Oracle Call Interface (OCI8).
<email>sixd@php.net</email>
<active>yes</active>
</lead>
- <date>2007-10-05</date>
- <time>10:00:00</time>
+
+ <date>2008-04-17</date>
+ <time>16:00:00</time>
<version>
- <release>1.3.1</release>
- <api>1.3.1</api>
+ <release>1.3.2</release>
+ <api>1.3.2</api>
</version>
<stability>
<release>beta</release>
<api>beta</api>
</stability>
<license uri="http://www.php.net/license">PHP</license>
- <notes>Fixed bug #44113 (New collection creation can fail with OCI-22303)
-Fixed bug #42841 (Crash with REF CURSORS when statement caching enabled)
-Fixed bug #42496 (Cursor leak selecting LOBs
-Fixed bug #43497 (Temporary LOB leak)
-Fixed PECL bug #12431 (ping functionality is broken)
-Allow compilation with 64bit Instant Client RPMs
-Allow -with-oci8=instantclient with no directory specified look for RPM install
+ <notes>
Refine DRCP connection pooling functionality
+Do scope-end release for oci_pconnect (oci8.old_oci_close_semantics=1 gives old behavior)
+Fixed bug #44372 (compilation with Oracle 10gR1 libraries)
+Fixed PECL bug #12431 (PEAR install using x86_64 RPM builds)
+Allow builds with PHP 4.3.9 onwards
</notes>
<contents>
<dir name="/">
@@ -79,6 +77,10 @@ Refine DRCP connection pooling functionality
<file name="array_bind_int.phpt" role="test" />
<file name="array_bind_str1.phpt" role="test" />
<file name="array_bind_str.phpt" role="test" />
+ <file name="bind_char_1.phpt" role="test" />
+ <file name="bind_char_2.phpt" role="test" />
+ <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_long.phpt" role="test" />
<file name="bind_long_raw.phpt" role="test" />
@@ -98,14 +100,20 @@ Refine DRCP connection pooling functionality
<file name="bug38173.phpt" role="test" />
<file name="bug40078.phpt" role="test" />
<file name="bug40415.phpt" role="test" />
+ <file name="bug41069.phpt" role="test" />
<file name="bug42134.phpt" role="test" />
<file name="bug42173.phpt" role="test" />
<file name="bug42496_1.phpt" role="test" />
<file name="bug42496_2.phpt" role="test" />
<file name="bug42841.phpt" role="test" />
+ <file name="bug43492_2.phpt" role="test" />
<file name="bug43492.phpt" role="test" />
+ <file name="bug43497_92.phpt" role="test" />
<file name="bug43497.phpt" role="test" />
+ <file name="bug44008.phpt" role="test" />
<file name="bug44113.phpt" role="test" />
+ <file name="bug44206.phpt" role="test" />
+ <file name="bug6109.phpt" role="test" />
<file name="close.phpt" role="test" />
<file name="coll_001.phpt" role="test" />
<file name="coll_002_func.phpt" role="test" />
@@ -168,6 +176,7 @@ Refine DRCP connection pooling functionality
<file name="define.phpt" role="test" />
<file name="descriptors.phpt" role="test" />
<file name="details.inc" role="test" />
+ <file name="drcp_cclass1.phpt" role="test" />
<file name="drcp_characterset.phpt" role="test" />
<file name="drcp_conn_close1.phpt" role="test" />
<file name="drcp_conn_close2.phpt" role="test" />
@@ -180,6 +189,9 @@ Refine DRCP connection pooling functionality
<file name="drcp_privileged.phpt" role="test" />
<file name="drcp_scope1.phpt" role="test" />
<file name="drcp_scope2.phpt" 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="drop_table.inc" role="test" />
<file name="drop_type.inc" role="test" />
<file name="error1.phpt" role="test" />
@@ -192,6 +204,7 @@ Refine DRCP connection pooling functionality
<file name="fetch_all3.phpt" role="test" />
<file name="fetch_all.phpt" role="test" />
<file name="fetch_array.phpt" role="test" />
+ <file name="fetch_assoc.php" role="test" />
<file name="fetch_assoc.phpt" role="test" />
<file name="fetch_into1.phpt" role="test" />
<file name="fetch_into2.phpt" role="test" />
@@ -261,6 +274,7 @@ Refine DRCP connection pooling functionality
<file name="password_new.phpt" role="test" />
<file name="password_old.phpt" role="test" />
<file name="password.phpt" role="test" />
+ <file name="pecl_bug10194_blob_64.phpt" role="test" />
<file name="pecl_bug10194_blob.phpt" role="test" />
<file name="pecl_bug10194.phpt" role="test" />
<file name="pecl_bug8816.phpt" role="test" />
@@ -277,6 +291,7 @@ Refine DRCP connection pooling functionality
<file name="statement_type_old.phpt" role="test" />
<file name="statement_type.phpt" role="test" />
<file name="test.gif" role="test" />
+ <file name="testping.phpt" role="test" />
<file name="test.txt" role="test" />
<file name="uncommitted.phpt" role="test" />
<file name="xmltype_01.phpt" role="test" />
diff --git a/ext/oci8/php_oci8.h b/ext/oci8/php_oci8.h
index 2b4ca2b44d..9646f96b44 100644
--- a/ext/oci8/php_oci8.h
+++ b/ext/oci8/php_oci8.h
@@ -36,16 +36,17 @@
#endif
-/*
+/*
* The version of the OCI8 extension.
*/
#ifdef PHP_OCI8_VERSION
/* The definition of PHP_OCI8_VERSION changed in PHP 5.3 and building
- * this code with PHP 5.2 and earlier (i.e. from PECL) might conflict
+ * this code with PHP 5.2 and earlier (e.g. when using OCI8 from PECL)
+ * will conflict.
*/
#undef PHP_OCI8_VERSION
#endif
-#define PHP_OCI8_VERSION "1.3.1 Beta"
+#define PHP_OCI8_VERSION "1.3.2 Beta"
extern zend_module_entry oci8_module_entry;
#define phpext_oci8_ptr &oci8_module_entry
@@ -70,5 +71,3 @@ PHP_MINFO_FUNCTION(oci);
* c-basic-offset: 4
* End:
*/
-
-
diff --git a/ext/oci8/php_oci8_int.h b/ext/oci8/php_oci8_int.h
index 2331f08fa9..13e3149c4f 100644
--- a/ext/oci8/php_oci8_int.h
+++ b/ext/oci8/php_oci8_int.h
@@ -257,13 +257,22 @@ typedef struct { /* php_oci_out_column {{{ */
OCI_G(in_call) = 0; \
} while (0)
+/* 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
+ * reopened by the next PHP OCI8 connect command. This is most useful
+ * for persistent connections. The error number list is not
+ * exclusive. The error number comparisons and the
+ * OCI_ATTR_SERVER_STATUS check are done for maximum cross-version
+ * compatibility. In the far future, only the attribute check will be
+ * needed.
+ */
#define PHP_OCI_HANDLE_ERROR(connection, errcode) \
do { \
switch (errcode) { \
case 1013: \
zend_bailout(); \
break; \
- case 22: \
+ case 22: \
case 378: \
case 602: \
case 603: \
@@ -286,7 +295,7 @@ typedef struct { /* php_oci_out_column {{{ */
(connection)->is_open = 0; \
break; \
default: \
- { /* do both numeric checks (above) and the status check for maximum version compatibility */ \
+ { \
ub4 serverStatus = OCI_SERVER_NORMAL; \
PHP_OCI_CALL(OCIAttrGet, ((dvoid *)(connection)->server, OCI_HTYPE_SERVER, (dvoid *)&serverStatus, \
(ub4 *)0, OCI_ATTR_SERVER_STATUS, (connection)->err)); \
@@ -461,7 +470,6 @@ ZEND_BEGIN_MODULE_GLOBALS(oci) /* {{{ */
zend_bool old_oci_close_semantics; /* old_oci_close_semantics flag (to determine the way oci_close() should behave) */
int shutdown; /* in shutdown flag */
- int request_shutdown; /* in request shutdown flag */
OCIEnv *env; /* global environment handle */
diff --git a/ext/oci8/tests/bug43497.phpt b/ext/oci8/tests/bug43497.phpt
index 908fe58972..0fc6a97b35 100644
--- a/ext/oci8/tests/bug43497.phpt
+++ b/ext/oci8/tests/bug43497.phpt
@@ -1,7 +1,16 @@
--TEST--
Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory)
--SKIPIF--
-<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
+<?php
+if (!extension_loaded('oci8')) die ("skip no oci8 extension");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$ov = preg_match('/Oracle Version => 9/', $phpinfo);
+if ($ov === 1) {
+ die ("skip expected output only valid for Oracle clients from 10g onwards");
+}
+?>
--FILE--
<?php
diff --git a/ext/oci8/tests/bug43497_92.phpt b/ext/oci8/tests/bug43497_92.phpt
new file mode 100644
index 0000000000..e2cb1ce486
--- /dev/null
+++ b/ext/oci8/tests/bug43497_92.phpt
@@ -0,0 +1,303 @@
+--TEST--
+Bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory)
+--SKIPIF--
+<?php
+if (!extension_loaded('oci8')) die ("skip no oci8 extension");
+ob_start();
+phpinfo(INFO_MODULES);
+$phpinfo = ob_get_clean();
+$ov = preg_match('/Oracle Version => 9.2/', $phpinfo);
+if ($ov !== 1) {
+ die ("skip expected output only valid for Oracle 9.2 clients");
+}
+?>
+--FILE--
+<?php
+
+require dirname(__FILE__).'/connect.inc';
+
+function sessionid($c) // determines and returns current session ID
+{
+ $query = "select sid from v\$session where audsid = userenv('sessionid')";
+
+ $stmt = oci_parse($c, $query);
+
+ if (oci_execute($stmt, OCI_DEFAULT)) {
+ $row = oci_fetch($stmt);
+ return oci_result($stmt, 1);
+ }
+
+ return null;
+}
+
+
+function templobs($c, $sid) // returns number of temporary LOBs
+{
+ $query = "select abstract_lobs from v\$temporary_lobs where sid = " . $sid;
+
+ $stmt = oci_parse($c, $query);
+
+ if (oci_execute($stmt, OCI_DEFAULT)) {
+ $row = oci_fetch($stmt);
+ $val = oci_result($stmt, 1);
+ oci_free_statement($stmt);
+ return $val;
+ }
+ return null;
+}
+
+
+// Read all XML data using explicit LOB locator
+function readxmltab_ex($c)
+{
+ $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab");
+
+ $cntchk = 0;
+ if (oci_execute($stmt)) {
+ while ($result = oci_fetch_array($stmt, OCI_NUM)) {
+ $result[0]->free(); // cleanup properly
+ ++$cntchk;
+ }
+ }
+ echo "Loop count check = $cntchk\n";
+}
+
+// Read all XML data using explicit LOB locator but without freeing the temp lobs
+function readxmltab_ex_nofree($c)
+{
+ $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab");
+
+ $cntchk = 0;
+ if (oci_execute($stmt)) {
+ while ($result = oci_fetch_array($stmt, OCI_NUM)) {
+ ++$cntchk;
+ }
+ }
+ echo "Loop count check = $cntchk\n";
+}
+
+// Read all XML data using implicit LOB locator
+function readxmltab_im($c)
+{
+ $stmt = oci_parse($c, "select extract(xml, '/').getclobval() from bug43497_tab");
+
+ $cntchk = 0;
+ if (oci_execute($stmt)) {
+ while ($result = oci_fetch_array($stmt, OCI_NUM+OCI_RETURN_LOBS)) {
+ ++$cntchk;
+ }
+ }
+ echo "Loop count check = $cntchk\n";
+}
+
+function createxmltab($c) // create table w/ field of XML type
+{
+ @dropxmltab($c);
+ $stmt = oci_parse($c, "create table bug43497_tab (id number primary key, xml xmltype)");
+ oci_execute($stmt);
+}
+
+function dropxmltab($c) // delete table
+{
+ $stmt = oci_parse($c, "drop table bug43497_tab");
+ oci_execute($stmt);
+}
+
+
+function fillxmltab($c)
+{
+ for ($id = 1; $id <= 100; $id++) {
+
+ // create an XML element string with random data
+ $s = "<data>";
+ for ($j = 0; $j < 128; $j++) {
+ $s .= rand();
+ }
+ $s .= "</data>\n";
+ for ($j = 0; $j < 4; $j++) {
+ $s .= $s;
+ }
+ $data = "<?xml version=\"1.0\"?><records>" . $s . "</records>";
+
+ // insert XML data into database
+
+ $stmt = oci_parse($c, "insert into bug43497_tab(id, xml) values (:id, sys.xmltype.createxml(:xml))");
+ oci_bind_by_name($stmt, ":id", $id);
+ $clob = oci_new_descriptor($c, OCI_D_LOB);
+ oci_bind_by_name($stmt, ":xml", $clob, -1, OCI_B_CLOB);
+ $clob->writetemporary($data);
+ oci_execute($stmt);
+
+ $clob->close();
+ $clob->free();
+ }
+}
+
+
+// Initialize
+
+createxmltab($c);
+fillxmltab($c);
+
+// Run Test
+
+$sid = sessionid($c);
+
+echo "Explicit LOB use\n";
+for ($i = 1; $i <= 10; $i++) {
+ echo "\nRun = " . $i . "\n";
+ echo "Temporary LOBs = " . templobs($c, $sid) . "\n";
+ readxmltab_ex($c);
+}
+
+echo "\nImplicit LOB use\n";
+for ($i = 1; $i <= 10; $i++) {
+ echo "\nRun = " . $i . "\n";
+ echo "Temporary LOBs = " . templobs($c, $sid) . "\n";
+ readxmltab_im($c);
+}
+
+echo "\nExplicit LOB with no free (i.e. a temp lob leak)\n";
+for ($i = 1; $i <= 10; $i++) {
+ echo "\nRun = " . $i . "\n";
+ echo "Temporary LOBs = " . templobs($c, $sid) . "\n";
+ readxmltab_ex_nofree($c);
+}
+
+
+
+// Cleanup
+
+dropxmltab($c);
+
+oci_close($c);
+
+echo "Done\n";
+?>
+--EXPECT--
+Explicit LOB use
+
+Run = 1
+Temporary LOBs = 0
+Loop count check = 100
+
+Run = 2
+Temporary LOBs = 100
+Loop count check = 100
+
+Run = 3
+Temporary LOBs = 200
+Loop count check = 100
+
+Run = 4
+Temporary LOBs = 300
+Loop count check = 100
+
+Run = 5
+Temporary LOBs = 400
+Loop count check = 100
+
+Run = 6
+Temporary LOBs = 500
+Loop count check = 100
+
+Run = 7
+Temporary LOBs = 600
+Loop count check = 100
+
+Run = 8
+Temporary LOBs = 700
+Loop count check = 100
+
+Run = 9
+Temporary LOBs = 800
+Loop count check = 100
+
+Run = 10
+Temporary LOBs = 900
+Loop count check = 100
+
+Implicit LOB use
+
+Run = 1
+Temporary LOBs = 1000
+Loop count check = 100
+
+Run = 2
+Temporary LOBs = 1100
+Loop count check = 100
+
+Run = 3
+Temporary LOBs = 1200
+Loop count check = 100
+
+Run = 4
+Temporary LOBs = 1300
+Loop count check = 100
+
+Run = 5
+Temporary LOBs = 1400
+Loop count check = 100
+
+Run = 6
+Temporary LOBs = 1500
+Loop count check = 100
+
+Run = 7
+Temporary LOBs = 1600
+Loop count check = 100
+
+Run = 8
+Temporary LOBs = 1700
+Loop count check = 100
+
+Run = 9
+Temporary LOBs = 1800
+Loop count check = 100
+
+Run = 10
+Temporary LOBs = 1900
+Loop count check = 100
+
+Explicit LOB with no free (i.e. a temp lob leak)
+
+Run = 1
+Temporary LOBs = 2000
+Loop count check = 100
+
+Run = 2
+Temporary LOBs = 2100
+Loop count check = 100
+
+Run = 3
+Temporary LOBs = 2200
+Loop count check = 100
+
+Run = 4
+Temporary LOBs = 2300
+Loop count check = 100
+
+Run = 5
+Temporary LOBs = 2400
+Loop count check = 100
+
+Run = 6
+Temporary LOBs = 2500
+Loop count check = 100
+
+Run = 7
+Temporary LOBs = 2600
+Loop count check = 100
+
+Run = 8
+Temporary LOBs = 2700
+Loop count check = 100
+
+Run = 9
+Temporary LOBs = 2800
+Loop count check = 100
+
+Run = 10
+Temporary LOBs = 2900
+Loop count check = 100
+Done \ No newline at end of file
diff --git a/ext/oci8/tests/bug44113.phpt b/ext/oci8/tests/bug44113.phpt
index 646f09b7c7..d6c2978635 100644
--- a/ext/oci8/tests/bug44113.phpt
+++ b/ext/oci8/tests/bug44113.phpt
@@ -5,7 +5,7 @@ Bug #44113 (New collection creation can fail with OCI-22303)
--FILE--
<?php
-require dirname(__FILE__).'/connect.inc';
+require(dirname(__FILE__).'/connect.inc');
// Initialization
@@ -22,8 +22,7 @@ foreach ($stmtarray as $stmt) {
// The test can take some time to complete and can exceed PHP's test
// timout limit on slow networks.
-for ($x = 0; $x < 70000; $x++)
-{
+for ($x = 0; $x < 70000; $x++) {
if (!($var = oci_new_collection($c, 'BUG44113_LIST_T'))) {
print "Failed new collection creation on $x\n";
break;
diff --git a/ext/oci8/tests/drcp_cclass1.phpt b/ext/oci8/tests/drcp_cclass1.phpt
index a37f4b37d7..068331e5a9 100644
--- a/ext/oci8/tests/drcp_cclass1.phpt
+++ b/ext/oci8/tests/drcp_cclass1.phpt
@@ -3,14 +3,14 @@ DRCP: Test setting connection class inline
--SKIPIF--
<?php
if (!extension_loaded('oci8')) die ("skip no oci8 extension");
-require(__DIR__."/details.inc");
+require(dirname(__FILE__)."/details.inc");
if (!$test_drcp) die("skip testing DRCP connection class only works in DRCP mode");
if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
?>
--FILE--
<?php
-require(__DIR__."/details.inc");
+require(dirname(__FILE__)."/details.inc");
// Initialization
diff --git a/ext/oci8/tests/drcp_connect1.phpt b/ext/oci8/tests/drcp_connect1.phpt
index aa7fab274c..bf619a4efd 100644
--- a/ext/oci8/tests/drcp_connect1.phpt
+++ b/ext/oci8/tests/drcp_connect1.phpt
@@ -1,11 +1,7 @@
--TEST--
DRCP: oci_connect()
--SKIPIF--
-<?php
-if (!extension_loaded('oci8')) die("skip no oci8 extension");
-require(dirname(__FILE__)."/details.inc");
-if (!$test_drcp) die("skip expected test results are only valid for DRCP Mode");
-?>
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--INI--
oci8.connection_class=test
oci8.old_oci_close_semantics=0
diff --git a/ext/oci8/tests/drcp_scope1.phpt b/ext/oci8/tests/drcp_scope1.phpt
index 01b0a4271e..57f1abe327 100644
--- a/ext/oci8/tests/drcp_scope1.phpt
+++ b/ext/oci8/tests/drcp_scope1.phpt
@@ -19,6 +19,7 @@ require dirname(__FILE__)."/details.inc";
// Create the table
$c = oci_new_connect($user,$password,$dbase);
+@drcp_drop_table($c);
drcp_create_table($c);
// OCI_NEW_CONNECT
diff --git a/ext/oci8/tests/drcp_scope2.phpt b/ext/oci8/tests/drcp_scope2.phpt
index cb5dcd1ac1..b72e00dbb0 100644
--- a/ext/oci8/tests/drcp_scope2.phpt
+++ b/ext/oci8/tests/drcp_scope2.phpt
@@ -19,6 +19,7 @@ require dirname(__FILE__)."/details.inc";
// Create the table
$c = oci_new_connect($user,$password,$dbase);
+@drcp_drop_table($c);
drcp_create_table($c);
// OCI_NEW_CONNECT
diff --git a/ext/oci8/tests/drcp_scope3.phpt b/ext/oci8/tests/drcp_scope3.phpt
new file mode 100644
index 0000000000..b448a518ad
--- /dev/null
+++ b/ext/oci8/tests/drcp_scope3.phpt
@@ -0,0 +1,61 @@
+--TEST--
+DRCP: oci_pconnect() with scope end when oci8.old_oci_close_semantics ON
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--INI--
+oci8.old_oci_close_semantics=1
+--FILE--
+<?php
+
+require dirname(__FILE__)."/drcp_functions.inc";
+require dirname(__FILE__)."/details.inc";
+
+// The test opens a connection within function1 and updates a table
+// (without committing). Another connection is opened from function
+// 2, and the table queried. When function1 ends, the connection from
+// function1 is not closed, so the updated value will be seen in
+// function2. Also the table can't be dropped because an uncommitted
+// transaction exists.
+
+// Create the table
+$c = oci_new_connect($user,$password,$dbase);
+@drcp_drop_table($c);
+drcp_create_table($c);
+
+echo "This is with a OCI_PCONNECT\n";
+function1($user,$password,$dbase);
+
+// Should return the OLD value
+function2($user,$password,$dbase);
+
+// This is the first scope for the script
+
+function function1($user,$password,$dbase)
+{
+ var_dump($c = oci_pconnect($user,$password,$dbase));
+ drcp_update_table($c);
+}
+
+// This is the second scope
+
+function function2($user,$password,$dbase)
+{
+ var_dump($c = oci_pconnect($user,$password,$dbase));
+ drcp_select_value($c);
+}
+
+drcp_drop_table($c);
+oci_close($c);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+This is with a OCI_PCONNECT
+resource(%d) of type (oci8 persistent connection)
+Update done-- DEPT value has been set to NEWDEPT
+resource(%d) of type (oci8 persistent connection)
+The value of DEPT for id 105 is NEWDEPT
+
+Warning: oci_execute(): ORA-00054: %s
+Done \ No newline at end of file
diff --git a/ext/oci8/tests/drcp_scope4.phpt b/ext/oci8/tests/drcp_scope4.phpt
new file mode 100644
index 0000000000..07110bca0e
--- /dev/null
+++ b/ext/oci8/tests/drcp_scope4.phpt
@@ -0,0 +1,57 @@
+--TEST--
+DRCP: oci_pconnect() with scope end when oci8.old_oci_close_semantics OFF
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--INI--
+oci8.old_oci_close_semantics=0
+--FILE--
+<?php
+
+require dirname(__FILE__)."/drcp_functions.inc";
+require dirname(__FILE__)."/details.inc";
+
+// The test opens a connection within function1 and updates a table
+// (without committing). Another connection is opened from function
+// 2, and the table queried. When function1 ends, the txn is rolled
+// back and hence the updated value will not be reflected in function2
+
+// Create the table
+$c = oci_new_connect($user,$password,$dbase);
+@drcp_drop_table($c);
+drcp_create_table($c);
+
+echo "This is with a OCI_PCONNECT\n";
+function1($user,$password,$dbase);
+
+// Should return the OLD value
+function2($user,$password,$dbase);
+
+// This is the first scope for the script
+
+function function1($user,$password,$dbase)
+{
+ var_dump($c = oci_pconnect($user,$password,$dbase));
+ drcp_update_table($c);
+}
+
+// This is the second scope
+
+function function2($user,$password,$dbase)
+{
+ var_dump($c = oci_pconnect($user,$password,$dbase));
+ drcp_select_value($c);
+}
+
+drcp_drop_table($c);
+oci_close($c);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+This is with a OCI_PCONNECT
+resource(%d) of type (oci8 persistent connection)
+Update done-- DEPT value has been set to NEWDEPT
+resource(%d) of type (oci8 persistent connection)
+The value of DEPT for id 105 is HR
+Done
diff --git a/ext/oci8/tests/drcp_scope5.phpt b/ext/oci8/tests/drcp_scope5.phpt
new file mode 100644
index 0000000000..832e6aa8cb
--- /dev/null
+++ b/ext/oci8/tests/drcp_scope5.phpt
@@ -0,0 +1,63 @@
+--TEST--
+DRCP: oci_pconnect() with scope end when oci8.old_oci_close_semantics ON
+--SKIPIF--
+<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
+--INI--
+oci8.old_oci_close_semantics=1
+--FILE--
+<?php
+
+require dirname(__FILE__)."/drcp_functions.inc";
+require dirname(__FILE__)."/details.inc";
+
+// Similar to drcp_scope3.phpt but does a commit before end of
+// function2, allowing the table to be dropped cleanly at the end.
+
+// The test opens a connection within function1 and updates a table
+// (without committing). Another connection is opened from function
+// 2, and the table queried. When function1 ends, the connection from
+// function1 is not closed, so the updated value will be seen in
+// function2. Also the table can't be dropped because an uncommitted
+// transaction exists.
+
+// Create the table
+$c = oci_new_connect($user,$password,$dbase);
+@drcp_drop_table($c);
+drcp_create_table($c);
+
+echo "This is with a OCI_PCONNECT\n";
+function1($user,$password,$dbase);
+
+// Should return the OLD value
+function2($user,$password,$dbase);
+
+// This is the first scope for the script
+
+function function1($user,$password,$dbase)
+{
+ var_dump($c = oci_pconnect($user,$password,$dbase));
+ drcp_update_table($c);
+}
+
+// This is the second scope
+
+function function2($user,$password,$dbase)
+{
+ var_dump($c = oci_pconnect($user,$password,$dbase));
+ drcp_select_value($c);
+ oci_commit($c);
+}
+
+drcp_drop_table($c);
+oci_close($c);
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+This is with a OCI_PCONNECT
+resource(%d) of type (oci8 persistent connection)
+Update done-- DEPT value has been set to NEWDEPT
+resource(%d) of type (oci8 persistent connection)
+The value of DEPT for id 105 is NEWDEPT
+Done \ No newline at end of file
diff --git a/ext/oci8/tests/password.phpt b/ext/oci8/tests/password.phpt
index c9ef4c5387..7133d8bae8 100644
--- a/ext/oci8/tests/password.phpt
+++ b/ext/oci8/tests/password.phpt
@@ -1,28 +1,75 @@
--TEST--
-oci_password_change()
+oci_password_change() for non-persistent connections
--SKIPIF--
-<?php
-if (!extension_loaded('oci8')) die("skip no oci8 extension");
-require dirname(__FILE__)."/details.inc";
+<?php
+if (!extension_loaded('oci8')) die("skip no oci8 extension");
+require(dirname(__FILE__)."/details.inc");
+if (empty($dbase)) die ("skip requires database connection string be set");
+if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
if ($test_drcp) die("skip password change not supported in DRCP Mode");
?>
--FILE--
<?php
-require dirname(__FILE__)."/connect.inc";
+require(dirname(__FILE__)."/details.inc");
+
+// Create a user we can stuff around with and not affect subsequent tests
+$c0 = oci_connect($user, $password, $dbase);
+$stmts = array(
+ "drop user testuser",
+ "begin
+ execute immediate 'create user testuser identified by testuserpwd';
+ execute immediate 'grant connect, create session to testuser';
+ end;");
+foreach ($stmts as $sql) {
+ $s = oci_parse($c0, $sql);
+ @oci_execute($s);
+}
+
+// Connect and change the password
+$c1 = oci_connect("testuser", "testuserpwd", $dbase);
+var_dump($c1);
+$rn1 = (int)$c1;
+
+oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2");
-$new_password = "test";
-var_dump(oci_password_change($dbase, $user, $password, $new_password));
+// Second connect should return a new resource because the hash string will be different from $c1
+$c2 = oci_connect("testuser", "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);
+var_dump($c3);
+$rn3 = (int)$c3;
+
+// Connections should differ
+if ($rn1 == $rn2) {
+ echo "First and second connections share a resource: Not OK\n";
+ var_dump($c1);
+}
+else {
+ echo "First and second connections are different: OK\n";
+}
-if (!empty($dbase)) {
- var_dump($new_c = ocilogon($user,$new_password,$dbase));
+// Connections should be the same
+if ($rn1 == $rn3) {
+ echo "First and third connections share a resource: OK\n";
}
else {
- var_dump($new_c = ocilogon($user,$new_password));
+ echo "First and third connections are different: Not OK\n";
+ var_dump($c1);
+ var_dump($c2);
}
-var_dump(oci_password_change($dbase, $user, $new_password, $password));
+// Clean up
+oci_close($c1);
+oci_close($c2);
+oci_close($c3);
+// Clean up
+$s = oci_parse($c0, "drop user cascade testuser");
+@oci_execute($s);
echo "Done\n";
@@ -31,4 +78,6 @@ echo "Done\n";
resource(%d) of type (oci8 connection)
resource(%d) of type (oci8 connection)
resource(%d) of type (oci8 connection)
+First and second connections are different: OK
+First and third connections share a resource: OK
Done
diff --git a/ext/oci8/tests/password_2.phpt b/ext/oci8/tests/password_2.phpt
index 3ee2db5b40..71423e717b 100644
--- a/ext/oci8/tests/password_2.phpt
+++ b/ext/oci8/tests/password_2.phpt
@@ -4,6 +4,7 @@ oci_password_change() for persistent connections
<?php
if (!extension_loaded('oci8')) die("skip no oci8 extension");
require(dirname(__FILE__)."/details.inc");
+if (empty($dbase)) die ("skip requires database connection string be set");
if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user");
if ($test_drcp) die("skip password change not supported in DRCP Mode");
?>
@@ -28,34 +29,19 @@ foreach ($stmts as $sql) {
// Connect (persistent) and change the password
$c1 = oci_pconnect("testuser", "testuserpwd", $dbase);
var_dump($c1);
-
-ob_start();
-var_dump($c1);
-$r1 = ob_get_clean();
-preg_match("/resource\(([0-9]*)\) of.*/", $r1, $matches);
-$rn1 = $matches[0]; /* resource number */
+$rn1 = (int)$c1;
oci_password_change($c1, "testuser", "testuserpwd", "testuserpwd2");
// Second connect should return a new resource because the hash string will be different from $c1
$c2 = oci_pconnect("testuser", "testuserpwd2", $dbase);
var_dump($c2);
-
-ob_start();
-var_dump($c2);
-$r2 = ob_get_clean();
-preg_match("/resource\(([0-9]*)\) of.*/", $r2, $matches);
-$rn2 = $matches[0]; /* resource number */
+$rn2 = (int)$c2;
// Despite using the old password this connect should succeed and return the original resource
$c3 = oci_pconnect("testuser", "testuserpwd", $dbase);
var_dump($c3);
-
-ob_start();
-var_dump($c3);
-$r3 = ob_get_clean();
-preg_match("/resource\(([0-9]*)\) of.*/", $r3, $matches);
-$rn3 = $matches[0]; /* resource number */
+$rn3 = (int)$c3;
// Connections should differ
if ($rn1 == $rn2) {
@@ -77,10 +63,12 @@ else {
}
// Clean up
-// Can't drop a user that is connected and can't close a persistent
-// connection. So this test will leave the dummy user around, but the
-// schema will not be usable..
-$s = oci_parse($c0, "revoke connect, create session from testuser");
+oci_close($c1);
+oci_close($c2);
+oci_close($c3);
+
+// Clean up
+$s = oci_parse($c0, "drop user cascade testuser");
@oci_execute($s);
echo "Done\n";
diff --git a/ext/oci8/tests/password_new.phpt b/ext/oci8/tests/password_new.phpt
index 1de3cb4c96..e8642abca7 100644
--- a/ext/oci8/tests/password_new.phpt
+++ b/ext/oci8/tests/password_new.phpt
@@ -3,8 +3,23 @@ oci_password_change()
--SKIPIF--
<?php
if (!extension_loaded('oci8')) die("skip no oci8 extension");
-require dirname(__FILE__)."/details.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 10g client libraries
+// connecting to Oracle Database 11.1.0.6 (Oracle bug 6277160)
+$sv = oci_server_version($c);
+$sv = preg_match('/11.1/', $sv, $matches);
+if ($sv === 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 10/', $phpinfo);
+ if ($iv === 1) {
+ die ("skip test known to fail using Oracle 10gR2 client libs connecting to Oracle 11.1 (6277160)");
+ }
+}
?>
--FILE--
<?php
diff --git a/ext/oci8/tests/password_old.phpt b/ext/oci8/tests/password_old.phpt
index 7a2df841e7..157bdebcaa 100644
--- a/ext/oci8/tests/password_old.phpt
+++ b/ext/oci8/tests/password_old.phpt
@@ -3,8 +3,23 @@ ocipasswordchange()
--SKIPIF--
<?php
if (!extension_loaded('oci8')) die("skip no oci8 extension");
-require dirname(__FILE__)."/details.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 10g client libraries
+// connecting to Oracle Database 11.1.0.6 (Oracle bug 6277160)
+$sv = oci_server_version($c);
+$sv = preg_match('/11.1/', $sv, $matches);
+if ($sv === 1) {
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $phpinfo = ob_get_clean();
+ $iv = preg_match('/Oracle .*Version => 10/', $phpinfo);
+ if ($iv === 1) {
+ die ("skip test known to fail using Oracle 10gR2 client libs connecting to Oracle 11.1 (6277160)");
+ }
+}
?>
--FILE--
<?php
@@ -12,7 +27,7 @@ if ($test_drcp) die("skip password change not supported in DRCP Mode");
require dirname(__FILE__)."/connect.inc";
$new_password = "test";
-var_dump(ocipasswordchange($c, $user, $password, $new_password));
+var_dump(ocipasswordchange($dbase, $user, $password, $new_password));
if (!empty($dbase)) {
var_dump($new_c = ocilogon($user,$new_password,$dbase));
@@ -21,14 +36,14 @@ else {
var_dump($new_c = ocilogon($user,$new_password));
}
-var_dump(ocipasswordchange($new_c, $user, $new_password, $password));
+var_dump(ocipasswordchange($dbase, $user, $new_password, $password));
echo "Done\n";
?>
--EXPECTF--
-bool(true)
resource(%d) of type (oci8 connection)
-bool(true)
+resource(%d) of type (oci8 connection)
+resource(%d) of type (oci8 connection)
Done
diff --git a/ext/oci8/tests/pecl_bug10194_blob.phpt b/ext/oci8/tests/pecl_bug10194_blob.phpt
index 092f7d085b..4c6aa4f1c9 100644
--- a/ext/oci8/tests/pecl_bug10194_blob.phpt
+++ b/ext/oci8/tests/pecl_bug10194_blob.phpt
@@ -3,7 +3,7 @@ PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside
--SKIPIF--
<?php
if (!extension_loaded('oci8')) die("skip no oci8 extension");
-if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only");
+if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
?>
--INI--
memory_limit=3M
diff --git a/ext/oci8/tests/pecl_bug10194_blob_64.phpt b/ext/oci8/tests/pecl_bug10194_blob_64.phpt
index 9b98989f38..433d586a4e 100644
--- a/ext/oci8/tests/pecl_bug10194_blob_64.phpt
+++ b/ext/oci8/tests/pecl_bug10194_blob_64.phpt
@@ -3,7 +3,7 @@ PECL Bug #10194 (segfault in Instant Client when memory_limit is reached inside
--SKIPIF--
<?php
if (!extension_loaded('oci8')) die("skip no oci8 extension");
-if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
?>
--INI--
memory_limit=6M
diff --git a/ext/oci8/tests/testping.phpt b/ext/oci8/tests/testping.phpt
index 1556d81d1e..a0d65a30c3 100644
--- a/ext/oci8/tests/testping.phpt
+++ b/ext/oci8/tests/testping.phpt
@@ -7,7 +7,7 @@ oci8.ping_interval=0
--FILE--
<?php
-require(__DIR__.'/details.inc');
+require(dirname(__FILE__).'/details.inc');
for ($i = 0; $i < 2; $i++) {
if (!empty($dbase)) {