Commit d23bd2ec authored by Christopher Huhn's avatar Christopher Huhn
Browse files

Merge tag 'upstream/2.2.0'

Upstream version 2.2.0
parents 41f0c685 357f6446
--TEST--
oci8.default_prefetch ini option
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--INI--
oci8.default_prefetch=20
--FILE--
<?php
require(dirname(__FILE__)."/connect.inc");
// Initialize
$stmtarray = array(
"drop table default_prefetch_tab",
"create table default_prefetch_tab (id number, value number)",
"insert into default_prefetch_tab (id, value) values (1,1)",
"insert into default_prefetch_tab (id, value) values (1,1)",
"insert into default_prefetch_tab (id, value) values (1,1)",
);
oci8_test_sql_execute($c, $stmtarray);
// Run Test
$select_sql = "select * from default_prefetch_tab";
if (!($s = oci_parse($c, $select_sql))) {
die("oci_parse(select) failed!\n");
}
if (!oci_execute($s)) {
die("oci_execute(select) failed!\n");
}
var_dump(oci_fetch($s));
var_dump(oci_num_rows($s));
// Cleanup
$stmtarray = array(
"drop table default_prefetch_tab"
);
oci8_test_sql_execute($c, $stmtarray);
echo "Done\n";
?>
--EXPECT--
bool(true)
int(1)
Done
--TEST--
oci_fetch_all()
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
require(dirname(__FILE__)."/connect.inc");
// Initialize
$stmtarray = array(
"drop table fetch_all_tab",
"create table fetch_all_tab (id number, value number)",
"insert into fetch_all_tab (id, value) values (1,1)",
"insert into fetch_all_tab (id, value) values (1,1)",
"insert into fetch_all_tab (id, value) values (1,1)"
);
oci8_test_sql_execute($c, $stmtarray);
if (!($s = oci_parse($c, "select * from fetch_all_tab"))) {
die("oci_parse(select) failed!\n");
}
/* oci_fetch_all */
if (!oci_execute($s)) {
die("oci_execute(select) failed!\n");
}
var_dump(oci_fetch_all($s, $all));
var_dump($all);
/* ocifetchstatement */
if (!oci_execute($s)) {
die("oci_execute(select) failed!\n");
}
var_dump(ocifetchstatement($s, $all));
var_dump($all);
// Cleanup
$stmtarray = array(
"drop table fetch_all_tab"
);
oci8_test_sql_execute($c, $stmtarray);
echo "Done\n";
?>
--EXPECTF--
int(3)
array(2) {
["ID"]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "1"
[2]=>
string(1) "1"
}
["VALUE"]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "1"
[2]=>
string(1) "1"
}
}
int(3)
array(2) {
["ID"]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "1"
[2]=>
string(1) "1"
}
["VALUE"]=>
array(3) {
[0]=>
string(1) "1"
[1]=>
string(1) "1"
[2]=>
string(1) "1"
}
}
Done
--------------------------------------------------------------------
--------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2016 The PHP Group. All rights reserved.
--------------------------------------------------------------------
Copyright (c) 1999 - 2018 The PHP Group. All rights reserved.
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
......@@ -9,22 +9,22 @@ are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact group@php.net.
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
......@@ -41,27 +41,27 @@ are met:
"This product includes PHP software, freely available from
<http://www.php.net/software/>".
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
--------------------------------------------------------------------
This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.
The PHP Group can be contacted via Email at group@php.net.
For more information on the PHP Group and the PHP project,
For more information on the PHP Group and the PHP project,
please see <http://www.php.net>.
PHP includes the Zend Engine, freely available at
......
......@@ -11,14 +11,14 @@ Use 'pecl install oci8-2.0.12' to install for PHP 5.2 - PHP 5.6.
Use 'pecl install oci8-1.4.10' to install for PHP 4.3.9 - PHP 5.1.
The OCI8 extension needs to be linked with Oracle 12, 11, or 10.2
The OCI8 extension needs to be linked with Oracle 18, 12, 11, or 10.2
client libraries. These libraries are found in your database
installation, or in the free Oracle Instant Client from
http://www.oracle.com/technetwork/database/features/instant-client/
Install the 'Basic' or 'Basic Lite' Instant Client package. If
https://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html
Install the 'Basic' or 'Basic Light' Instant Client package. If
building from source, then also install the SDK package.
Oracle's standard cross-version connectivity applies. For example,
PHP OCI8 linked with Instant Client 11.2 can connect to Oracle
Database 9.2 onward. See Oracle's note "Oracle Client / Server
Oracle's standard cross-version interoperability applies. For
example, PHP OCI8 linked with Instant Client 11.2 can connect to
Oracle Database 9.2 onward. See Oracle's note "Oracle Client / Server
Interoperability Support" (ID 207303.1) for details.
......@@ -66,8 +66,8 @@ AC_DEFUN([AC_OCI8_ORACLE_VERSION],[
OCI8_ORACLE_VERSION=8.1
elif test -f $OCI8_LCS_BASE.1.0; then
OCI8_ORACLE_VERSION=8.0
elif test -f $OCI8_DIR/$OCI8_LIB_DIR/libclntsh.a; then
if test -f $OCI8_DIR/$OCI8_LIB_DIR/libcore4.a; then
elif test -f $OCI8_DIR/$OCI8_LIB_DIR/libclntsh.a; then
if test -f $OCI8_DIR/$OCI8_LIB_DIR/libcore4.a; then
OCI8_ORACLE_VERSION=8.0
else
OCI8_ORACLE_VERSION=8.1
......@@ -86,7 +86,7 @@ dnl support DTrace for extensions. Creating OCI8_INIT_DTRACE
dnl independently instead of using a refactored PHP_INIT_DTRACE allows
dnl OCI8 to be DTraced on versions of PHP where core PHP DTrace support
dnl isn't available.
dnl
dnl
AC_DEFUN([OCI8_INIT_DTRACE],[
ac_srcdir=[]PHP_EXT_SRCDIR([oci8])/
ac_bdir=[]PHP_EXT_BUILDDIR([oci8])/
......@@ -173,7 +173,7 @@ PHP_ARG_WITH(oci8, for Oracle Database OCI8 support,
Use --with-oci8=instantclient,/path/to/instant/client/lib
to use an Oracle Instant Client installation])
if test "$PHP_OCI8" != "no"; then
if test "$PHP_OCI8" != "no"; then
if test -z "$PHP_OCI8"; then
dnl --with-oci8=$ORACLE_HOME where ORACLE_HOME isn't set (or is mistyped) will match this case
......@@ -211,12 +211,12 @@ if test "$PHP_OCI8" != "no"; then
fi
dnl Check whether --enable-dtrace was set.
dnl To use DTrace with a PECL install, extract the OCI8 archive, phpize it, and set
dnl To use DTrace with a PECL install, extract the OCI8 archive, phpize it, and set
dnl PHP_DTRACE=yes before running configure
AC_MSG_CHECKING([OCI8 DTrace support])
oci8_do_dtrace="`echo $PHP_OCI8 | cut -d, -f3`"
if test "$PHP_DTRACE" = "yes" -o "$oci8_do_dtrace" = "dtrace" ; then
AC_MSG_RESULT([yes])
AC_MSG_RESULT([yes])
if test "$ext_shared" = "no"; then
AC_MSG_ERROR([For DTrace support OCI8 must be configured as a shared extension])
else
......@@ -242,7 +242,7 @@ if test "$PHP_OCI8" != "no"; then
AC_MSG_CHECKING([checking if we're on a 64-bit platform])
if test "$ac_cv_sizeof_long_int" = "4"; then
AC_MSG_RESULT([no])
PHP_OCI8_OH_LIBDIR=lib32
PHP_OCI8_OH_LIBDIR=lib32
PHP_OCI8_IC_LIBDIR_SUFFIX=""
else
AC_MSG_RESULT([yes])
......@@ -335,7 +335,7 @@ if test "$PHP_OCI8" != "no"; then
PHP_ADD_LIBRARY(clntsh, 1, OCI8_SHARED_LIBADD)
PHP_ADD_LIBPATH($OCI8_DIR/$OCI8_LIB_DIR, OCI8_SHARED_LIBADD)
PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c, $ext_shared)
PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c oci8_failover.c, $ext_shared)
AC_DEFINE(HAVE_OCI8,1,[Defined to 1 if the PHP OCI8 extension for Oracle Database is configured])
PHP_SUBST_OLD(OCI8_SHARED_LIBADD)
......@@ -406,7 +406,7 @@ if test "$PHP_OCI8" != "no"; then
AC_DEFINE(HAVE_OCI_INSTANT_CLIENT,1,[Defined to 1 if OCI8 configuration located Oracle's Instant Client libraries])
PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c, $ext_shared)
PHP_NEW_EXTENSION(oci8, oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c oci8_failover.c, $ext_shared)
AC_DEFINE(HAVE_OCI8,1,[Defined to 1 if the PHP OCI8 extension for Oracle Database is configured])
PHP_SUBST_OLD(OCI8_SHARED_LIBADD)
......
......@@ -45,7 +45,7 @@ if (PHP_OCI8 != "no") {
if (CHECK_HEADER_ADD_INCLUDE("oci.h", "CFLAGS_OCI8", oci8_inc_paths) &&
CHECK_LIB("oci.lib", "oci8", oci8_lib_paths))
{
EXTENSION('oci8', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c');
EXTENSION('oci8', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c oci8_failover.c');
AC_DEFINE('HAVE_OCI8', 1);
AC_DEFINE('HAVE_OCI_INSTANT_CLIENT', 1);
......@@ -80,7 +80,7 @@ if (PHP_OCI8_11G != "no") {
if (CHECK_HEADER_ADD_INCLUDE("oci.h", "CFLAGS_OCI8_11G", oci8_11g_inc_paths) &&
CHECK_LIB("oci.lib", "oci8_11g", oci8_11g_lib_paths))
{
EXTENSION('oci8_11g', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c', null, null, null, "ext\\oci8_11g")
EXTENSION('oci8_11g', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c oci8_failover.c', null, null, null, "ext\\oci8_11g")
AC_DEFINE('HAVE_OCI8', 1);
AC_DEFINE('HAVE_OCI_INSTANT_CLIENT', 1);
......@@ -115,7 +115,7 @@ if (PHP_OCI8_12C != "no") {
if (CHECK_HEADER_ADD_INCLUDE("oci.h", "CFLAGS_OCI8_12C", oci8_12c_inc_paths) &&
CHECK_LIB("oci.lib", "oci8_12c", oci8_12c_lib_paths))
{
EXTENSION('oci8_12c', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c', null, null, null, "ext\\oci8_12c")
EXTENSION('oci8_12c', 'oci8.c oci8_lob.c oci8_statement.c oci8_collection.c oci8_interface.c oci8_failover.c', null, null, null, "ext\\oci8_12c")
AC_DEFINE('HAVE_OCI8', 1);
AC_DEFINE('HAVE_OCI_INSTANT_CLIENT', 1);
......
......@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2016 The PHP Group |
| Copyright (c) 1997-2018 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
......@@ -21,7 +21,7 @@
| ZTS per process OCIPLogon by Harald Radi <harald.radi@nme.at> |
| |
| Redesigned by: Antony Dovgal <antony@zend.com> |
| Andi Gutmans <andi@zend.com> |
| Andi Gutmans <andi@php.net> |
| Wez Furlong <wez@omniti.com> |
+----------------------------------------------------------------------+
*/
......@@ -423,12 +423,15 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_client_info, 0, 0, 2)
ZEND_ARG_INFO(0, client_information)
ZEND_END_ARG_INFO()
#ifdef WAITIING_ORACLE_BUG_16695981_FIX
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_db_operation, 0, 0, 2)
ZEND_ARG_INFO(0, connection_resource)
ZEND_ARG_INFO(0, action)
ZEND_ARG_INFO(0, connection_resource)
ZEND_ARG_INFO(0, action)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_set_call_timeout, 0, 0, 2)
ZEND_ARG_INFO(0, connection_resource)
ZEND_ARG_INFO(0, call_timeout)
ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_password_change, 0, 0, 4)
ZEND_ARG_INFO(0, connection_resource_or_connection_string)
......@@ -504,6 +507,15 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_new_collection, 0, 0, 2)
ZEND_ARG_INFO(0, type_name)
ZEND_ARG_INFO(0, schema_name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_register_taf_callback, 0, 0, 1)
ZEND_ARG_INFO(0, connection_resource)
ZEND_ARG_INFO(0, function_name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_unregister_taf_callback, 0, 0, 1)
ZEND_ARG_INFO(0, connection_resource)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ LOB Method arginfo */
......@@ -663,9 +675,8 @@ PHP_FUNCTION(oci_statement_type);
PHP_FUNCTION(oci_num_rows);
PHP_FUNCTION(oci_set_prefetch);
PHP_FUNCTION(oci_set_client_identifier);
#ifdef WAITIING_ORACLE_BUG_16695981_FIX
PHP_FUNCTION(oci_set_db_operation);
#endif
PHP_FUNCTION(oci_set_call_timeout);
PHP_FUNCTION(oci_set_edition);
PHP_FUNCTION(oci_set_module_name);
PHP_FUNCTION(oci_set_action);
......@@ -701,6 +712,8 @@ PHP_FUNCTION(oci_collection_assign);
PHP_FUNCTION(oci_collection_size);
PHP_FUNCTION(oci_collection_max);
PHP_FUNCTION(oci_collection_trim);
PHP_FUNCTION(oci_register_taf_callback);
PHP_FUNCTION(oci_unregister_taf_callback);
/* }}} */
/* {{{ extension definition structures
......@@ -766,9 +779,8 @@ static const zend_function_entry php_oci_functions[] = {
PHP_FE(oci_new_descriptor, arginfo_oci_new_descriptor)
PHP_FE(oci_set_prefetch, arginfo_oci_set_prefetch)
PHP_FE(oci_set_client_identifier, arginfo_oci_set_client_identifier)
#ifdef WAITIING_ORACLE_BUG_16695981_FIX
PHP_FE(oci_set_db_operation, arginfo_oci_set_db_operation)
#endif
PHP_FE(oci_set_call_timeout, arginfo_oci_set_call_timeout)
PHP_FE(oci_set_edition, arginfo_oci_set_edition)
PHP_FE(oci_set_module_name, arginfo_oci_set_module_name)
PHP_FE(oci_set_action, arginfo_oci_set_action)
......@@ -783,6 +795,8 @@ static const zend_function_entry php_oci_functions[] = {
PHP_FE(oci_collection_max, arginfo_oci_collection_max)
PHP_FE(oci_collection_trim, arginfo_oci_collection_trim)
PHP_FE(oci_new_collection, arginfo_oci_new_collection)
PHP_FE(oci_register_taf_callback, arginfo_oci_register_taf_callback)
PHP_FE(oci_unregister_taf_callback, arginfo_oci_unregister_taf_callback)
PHP_FALIAS(oci_free_cursor, oci_free_statement, arginfo_oci_free_statement)
PHP_FALIAS(ocifreecursor, oci_free_statement, arginfo_oci_free_statement)
......@@ -1129,6 +1143,20 @@ PHP_MINIT_FUNCTION(oci)
REGISTER_LONG_CONSTANT("OCI_TEMP_CLOB",OCI_TEMP_CLOB, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_TEMP_BLOB",OCI_TEMP_BLOB, CONST_CS | CONST_PERSISTENT);
/* for Transparent Application Failover */
REGISTER_LONG_CONSTANT("OCI_FO_END", OCI_FO_END, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_ABORT", OCI_FO_ABORT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_REAUTH", OCI_FO_REAUTH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_BEGIN", OCI_FO_BEGIN, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_ERROR", OCI_FO_ERROR, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_NONE", OCI_FO_NONE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_SESSION", OCI_FO_SESSION, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_SELECT", OCI_FO_SELECT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_TXNAL", OCI_FO_TXNAL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("OCI_FO_RETRY", OCI_FO_RETRY, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
......@@ -1180,7 +1208,6 @@ PHP_MINFO_FUNCTION(oci)
php_info_print_table_row(2, "OCI8 DTrace Support", "disabled");
#endif
php_info_print_table_row(2, "OCI8 Version", PHP_OCI8_VERSION);
php_info_print_table_row(2, "Revision", "$Id: 59f993160cf983dd24bb391b68a65a17303d2dba $");
#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2)))
php_oci_client_get_version(ver, sizeof(ver));
......@@ -1375,6 +1402,8 @@ void php_oci_define_hash_dtor(zval *data)
define->name = NULL;
}
zval_ptr_dtor(&define->val);
efree(define);
}
/* }}} */
......@@ -1387,9 +1416,9 @@ void php_oci_bind_hash_dtor(zval *data)
{
php_oci_bind *bind = (php_oci_bind *) Z_PTR_P(data);
if (!Z_ISUNDEF(bind->parameter)) {
zval_ptr_dtor(&bind->parameter);
ZVAL_UNDEF(&bind->parameter);
if (!Z_ISUNDEF(bind->val)) {
zval_ptr_dtor(&bind->val);
ZVAL_UNDEF(&bind->val);
}
if (bind->array.elements) {
......@@ -1426,8 +1455,9 @@ void php_oci_column_hash_dtor(zval *data)
if (column->descid) {
if (GC_REFCOUNT(column->descid) == 1)
zend_list_close(column->descid);
else
GC_REFCOUNT(column->descid)--;
else {
GC_DELREF(column->descid);
}
}
if (column->data) {
......@@ -1508,7 +1538,7 @@ sb4 php_oci_error(OCIError *err_p, sword errstatus)
case OCI_ERROR:
errcode = php_oci_fetch_errmsg(err_p, errbuf, sizeof(errbuf));
if (errcode) {
php_error_docref(NULL, E_WARNING, "%s", errbuf, sizeof(errbuf));
php_error_docref(NULL, E_WARNING, "%s", errbuf);
} else {
php_error_docref(NULL, E_WARNING, "failed to fetch error message");
}
......@@ -1601,9 +1631,14 @@ void php_oci_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent, int exclus
zend_long session_mode = OCI_DEFAULT;
/* if a fourth parameter is handed over, it is the charset identifier (but is only used in Oracle 9i+) */
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|ssl", &username, &username_len, &password, &password_len, &dbname, &dbname_len, &charset, &charset_len, &session_mode) == FAILURE) {
return;
}
ZEND_PARSE_PARAMETERS_START(2, 5)
Z_PARAM_STRING(username, username_len)
Z_PARAM_STRING(password, password_len)
Z_PARAM_OPTIONAL
Z_PARAM_STRING(dbname, dbname_len)
Z_PARAM_STRING(charset, charset_len)
Z_PARAM_LONG(session_mode)
ZEND_PARSE_PARAMETERS_END();
#ifdef HAVE_OCI8_DTRACE
if (DTRACE_OCI8_CONNECT_ENTRY_ENABLED()) {
......@@ -1755,12 +1790,12 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
timestamp = time(NULL);
smart_str_append_unsigned_ex(&hashed_details, session_mode, 0);
smart_str_0(&hashed_details);
if (persistent) {
smart_str_appendl_ex(&hashed_details, "pc", sizeof("pc") - 1, 0);
}
smart_str_0(&hashed_details);
/* make it lowercase */
php_strtolower(ZSTR_VAL(hashed_details.s), ZSTR_LEN(hashed_details.s));
......@@ -1843,13 +1878,13 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
if ((tmp_val != NULL) && (Z_TYPE_P(tmp_val) == IS_RESOURCE)) {
tmp = Z_RES_VAL_P(tmp_val);
}
if ((tmp_val != NULL) && (tmp != NULL) &&
(ZSTR_LEN(tmp->hash_key) == ZSTR_LEN(hashed_details.s)) &&
(memcmp(ZSTR_VAL(tmp->hash_key), ZSTR_VAL(hashed_details.s),
ZSTR_LEN(tmp->hash_key)) == 0)) {
connection = tmp;
++GC_REFCOUNT(connection->id);
GC_ADDREF(connection->id);
}
} else {
PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection);
......@@ -1859,7 +1894,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
* decremented in the persistent helper
*/
if (OCI_G(old_oci_close_semantics)) {
++GC_REFCOUNT(connection->id);
GC_ADDREF(connection->id);
}
}
smart_str_free(&hashed_details);
......@@ -1870,7 +1905,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
} else {
/* we do not ping non-persistent connections */
smart_str_free(&hashed_details);
++GC_REFCOUNT(connection->id);
GC_ADDREF(connection->id);
return connection;
}
} /* is_open is true? */
......@@ -1930,6 +1965,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
connection = (php_oci_connection *) ecalloc(1, sizeof(php_oci_connection));
connection->hash_key = zend_string_dup(hashed_details.s, 0);
connection->is_persistent = 0;
ZVAL_UNDEF(&connection->taf_callback);
#ifdef HAVE_OCI8_DTRACE
connection->client_id = NULL;
#endif
......@@ -1944,6 +1980,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
return NULL;
}
connection->is_persistent = 1;
ZVAL_UNDEF(&connection->taf_callback);
#ifdef HAVE_OCI8_DTRACE
connection->client_id = NULL;
#endif
......@@ -1952,6 +1989,7 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
connection = (php_oci_connection *) ecalloc(1, sizeof(php_oci_connection));
connection->hash_key = zend_string_dup(hashed_details.s, 0);
connection->is_persistent = 0;
ZVAL_UNDEF(&connection->taf_callback);
#ifdef HAVE_OCI8_DTRACE
connection->client_id = NULL;
#endif
......@@ -2009,8 +2047,10 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
/* add to the appropriate hash */
if (connection->is_persistent) {
#if PHP_VERSION_ID < 70300
new_le.ptr = connection;
new_le.type = le_pconnection;
#endif
connection->used_this_request = 1;
PHP_OCI_REGISTER_RESOURCE(connection, le_pconnection);
......@@ -2019,9 +2059,13 @@ php_oci_connection *php_oci_do_connect_ex(char *username, int username_len, char
* refcount is decremented in the persistent helper
*/
if (OCI_G(old_oci_close_semantics)) {
++GC_REFCOUNT(connection->id);
GC_ADDREF(connection->id);
}
#if PHP_VERSION_ID < 70300
zend_hash_update_mem(&EG(persistent_list), connection->hash_key, (void *)&new_le, sizeof(zend_resource));
#else
zend_register_persistent_resource_ex(connection->hash_key, connection, le_pconnection);
#endif
OCI_G(num_persistent)++;
OCI_G(num_links)++;
} else if (!exclusive) {
......@@ -2225,6 +2269,15 @@ static int php_oci_connection_close(php_oci_connection *connection)
connection->client_id = NULL;
}
#endif /* HAVE_OCI8_DTRACE */
if (!Z_ISUNDEF(connection->taf_callback)) {
/* If it's NULL, then its value should be freed already */
if (!Z_ISNULL(connection->taf_callback)) {
zval_ptr_dtor(&connection->taf_callback);
}
ZVAL_UNDEF(&connection->taf_callback);
}
pefree(connection, connection->is_persistent);
connection = NULL;
OCI_G(in_call) = in_call_save;
......@@ -2304,7 +2357,6 @@ int php_oci_connection_release(php_oci_connection *connection)
connection->svc = NULL;
connection->server = NULL;
connection->session = NULL;
connection->id = NULL;
connection->is_attached = connection->is_open = connection->rb_on_disconnect = connection->used_this_request = 0;