Commit 357f6446 authored by Christopher Huhn's avatar Christopher Huhn 🥚
Browse files

New upstream version 2.2.0

parent 6c10b0d8
# Microsoft Developer Studio Project File - Name="oci8" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=oci8 - Win32 Release_TS
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "oci8.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "oci8.mak" CFG="oci8 - Win32 Release_TS"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "oci8 - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "oci8 - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "oci8 - Win32 Release_TS"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release_TS"
# PROP BASE Intermediate_Dir "Release_TS"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release_TS"
# PROP Intermediate_Dir "Release_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D ZTS=1 /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\\" /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "..\..\..\php_build\include\instantclient" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_OCI8=1 /D HAVE_OCI8_TEMP_LOB=1 /D HAVE_OCI8_ATTR_STATEMENT=1 /D COMPILE_DL_OCI8=1 /D PHP_OCI8_HAVE_COLLECTIONS=1 /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x406 /d "NDEBUG"
# ADD RSC /l 0x406 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386
# ADD LINK32 php4ts.lib oci.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_oci8.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\..\php_build\lib\instantclient" /libpath:"..\..\Release_TS_Inline"
!ELSEIF "$(CFG)" == "oci8 - Win32 Debug_TS"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Debug_TS"
# PROP BASE Intermediate_Dir "Debug_TS"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Debug_TS"
# PROP Intermediate_Dir "Debug_TS"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D ZTS=1 /YX /FD /c
# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\..\\" /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /I "..\..\..\php_build\include\instantclient" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FTP_EXPORTS" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_OCI8=1 /D HAVE_OCI8_TEMP_LOB=1 /D HAVE_OCI8_ATTR_STATEMENT=1 /D COMPILE_DL_OCI8=1 /D PHP_OCI8_HAVE_COLLECTIONS=1 /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x406 /d "NDEBUG"
# ADD RSC /l 0x406 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php5ts.lib /nologo /dll /machine:I386
# ADD LINK32 php4ts_debug.lib oci.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Debug_TS/php_oci8.dll" /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\lib\instantclient"
!ENDIF
# Begin Target
# Name "oci8 - Win32 Release_TS"
# Name "oci8 - Win32 Debug_TS"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\oci8.c
# End Source File
# Begin Source File
SOURCE=.\oci8_collection.c
# End Source File
# Begin Source File
SOURCE=.\oci8_interface.c
# End Source File
# Begin Source File
SOURCE=.\oci8_lob.c
# End Source File
# Begin Source File
SOURCE=.\oci8_statement.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\php_oci8.h
# End Source File
# Begin Source File
SOURCE=.\php_oci8_int.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
--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.
dnl
dnl $Id$
dnl
if test -z "$SED"; then
PHP_OCI8_SED="sed";
else
......@@ -70,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
......@@ -90,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])/
......@@ -177,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
......@@ -215,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
......@@ -246,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])
......@@ -339,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)
......@@ -410,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)
......
// $Id$
// vim:ft=javascript
if (PHP_OCI8 != "no" && PHP_OCI8_11G != "no") {
......@@ -46,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);
......@@ -81,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);
......@@ -116,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);
......
This diff is collapsed.
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
| 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 |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Stig Sæther Bakken <ssb@php.net> |
| Thies C. Arntzen <thies@thieso.net> |
| |
| Collection support by Andy Sautins <asautins@veripost.net> |
| Temporary LOB support by David Benson <dbenson@mancala.com> |
| ZTS per process OCIPLogon by Harald Radi <harald.radi@nme.at> |
| |
| Redesigned by: Antony Dovgal <antony@zend.com> |
| Andi Gutmans <andi@php.net> |
| Wez Furlong <wez@omniti.com> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "ext/standard/info.h"
#include "php_ini.h"
#if HAVE_OCI8
#include "php_oci8.h"
#include "php_oci8_int.h"
/* {{{ callback_fn()
OCI TAF callback function, calling userspace function */
sb4 callback_fn(void *svchp, void *envhp, void *fo_ctx, ub4 fo_type, ub4 fo_event)
{
/* Create zval */
zval retval, params[3];
php_oci_connection *connection = (php_oci_connection*)fo_ctx;
/* Default return value */
sb4 returnValue = 0;
/* Check if userspace callback function was unregistered */
if (Z_ISUNDEF(connection->taf_callback) || Z_ISNULL(connection->taf_callback)) {
return 0;
}
/* Initialize zval */
ZVAL_RES(&params[0], connection->id);
ZVAL_LONG(&params[1], fo_event);
ZVAL_LONG(&params[2], fo_type);
/* Call user function (if possible) */
if (call_user_function(EG(function_table), NULL, &connection->taf_callback, &retval, 3, params) == FAILURE) {
php_error_docref(NULL, E_WARNING, "Unable to call Oracle TAF callback function");
}
/* Set return value */
if (Z_TYPE(retval) == IS_LONG) {
returnValue = (sb4) Z_LVAL(retval);
}
/* Setting params[0] to null so resource isn't destroyed on zval_dtor */
ZVAL_NULL(&params[0]);
/* Cleanup */
zval_ptr_dtor(&retval);
zval_ptr_dtor(&params[0]);
zval_ptr_dtor(&params[1]);
zval_ptr_dtor(&params[2]);
return returnValue;
}
/* }}} */
/* {{{ php_oci_unregister_taf_callback()
Unregister the userspace callback function for Oracle TAF,
while keeping the OCI callback alive */
int php_oci_unregister_taf_callback(php_oci_connection *connection)
{
return php_oci_register_taf_callback(connection, NULL);
}
/* }}} */
/* {{{ php_oci_register_taf_callback()
Register a callback function for Oracle TAF */
int php_oci_register_taf_callback(php_oci_connection *connection, zval *callback)
{
sword errstatus;
int registered = 0;
/* temporary failover callback structure */
OCIFocbkStruct failover;
if (!callback) {
/* Unregister callback */
if (Z_ISUNDEF(connection->taf_callback) || Z_ISNULL(connection->taf_callback)) {
return 0; // Nothing to unregister
}
registered = 1;
zval_ptr_dtor(&connection->taf_callback);
ZVAL_NULL(&connection->taf_callback);
} else {
if (!Z_ISUNDEF(connection->taf_callback)) {
registered = 1;
if (!Z_ISNULL(connection->taf_callback)) {
zval_ptr_dtor(&connection->taf_callback);
ZVAL_NULL(&connection->taf_callback);
}
}
/* Set userspace callback function */
ZVAL_COPY(&connection->taf_callback, callback);
}
/* OCI callback function already registered */
if (registered) {
return 0;
}
/* set context */
failover.fo_ctx = connection;
/* set callback function */
failover.callback_function = &callback_fn;
/* do the registration */
PHP_OCI_CALL_RETURN(errstatus, OCIAttrSet, (connection->server, (ub4) OCI_HTYPE_SERVER, (void *) &failover, (ub4) 0, (ub4) OCI_ATTR_FOCBK, connection->err));
if (errstatus != OCI_SUCCESS) {
zval_ptr_dtor(&connection->taf_callback);
ZVAL_UNDEF(&connection->taf_callback);
connection->errcode = php_oci_error(connection->err, errstatus);
return 1;
}