php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32361 connection oci_connect stay persist after process the php
Submitted: 2005-03-18 13:22 UTC Modified: 2005-12-20 18:40 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: diego dot veiga at embraer dot com dot br Assigned: tony2001 (profile)
Status: Closed Package: OCI8 related
PHP Version: 5CVS, 4CVS (2005-03-22) OS: Fedora3
Private report: No CVE-ID: None
 [2005-03-18 13:22 UTC] diego dot veiga at embraer dot com dot br
Description:
------------
machine 1:
Linux redhat 7.2 2.4.18 #4 Fri Apr 12 08:10:27 BRT 2002 i686 unknown
configure with php4.3.4 and apache 1.3.29
./configure  --with-dbtcp=/usr/src/dbtcp-0.1.17 --with-oci8=/ora8i/u01/app/oracle/product/8.1.6 --enable-track-vars
--enable-sigchild --enable-trans-sid --with-apache=/usr/src/apache_1.3.29 --with-unixODBC --enable-xslt --with-xslt-sa
blot=/usr/local --with-expat-dir=/usr/local --with-gd --enable-gd-native-ttf --with-jpeg-dir=/usr --with-zlib-dir=/usr
 --with-zlib=/usr/ --with-freetype-dir=/usr/local/include/freetype2 --with-png-dir=/usr --with-openssl=/usr/local/ssl
--with-config-file-path=/etc/php --sysconfdir=/etc/php --with-pdflib=/usr/local --without-mysql --with-tiff-dir=/usr -
-with-java=/usr/java/j2sdk1.4.0_03 --enable-shared --with-layout=GNU

machine 2:
Linux fedora3 2.6.9-i386-1 #3 SMP Thu Feb 17 16:06:06 BRST 2005 i686 i686 i386 GNU/Linux
configure with php5.0.2 and apache 1.3.33
./configure --with-dbtcp=/usr/src/dbtcp-0.1.18a --with-oci8=/ora8i/u01/app/oracle/product/8.1.6 --enable-sigchild
--enable-trans-sid --enable-track-vars --with-apxs=/usr/local/apache/sbin/apxs --with-unixODBC --enable-xsl --with-exp
at-dir=/usr/local/ --with-gd --enable-gd-native-ttf --with-jpeg-dir=/usr --with-zlib-dir=/usr --with-zlib=/usr --with-
freetype-dir=/usr/ --with-png-dir=/usr --with-openssl=/usr --with-config-file-path=/etc/php --sysconfdir=/etc/php --wi
th-pdflib=/usr/local --without-mysql --with-tiff-dir=/usr --with-java=/usr/java/j2sdk1.4.0_03 --enable-shared --with-l
ayout=GNU

version of oracle: client 8.1.6, server 8.1.7


both machine with the php and include...

Reproduce code:
---------------
include:

function SetDatabase( $database )
{
    case 'ORA_PROD' :
      global $ORACLEVARS;
      $ORACLEVARS['database'] = 'ORA_P';
      $ORACLEVARS['username'] = 'xxxxx';
      $ORACLEVARS['password'] = 'yyyyy';
    break;
}

function sql_connect_simple(){
  global $ORACLEVARS;
  if ( $ORACLEVARS['log'] )
    __log('CON:' . $ORACLEVARS['database']);

  //$ORACLEVARS['conn'] = OCILogon( $ORACLEVARS['username'], $ORACLEVARS['password'], $ORACLEVARS['database'] );
  $ORACLEVARS['conn'] = oci_connect( $ORACLEVARS['username'], $ORACLEVARS['password'], $ORACLEVARS['database'] );
}

function sql_query( $sql, $update = 0 ) {
    global $ORACLEVARS;
        if ( $ORACLEVARS['conn'] == 0 ) {
        __err('*** QUERY: NOT CONNECTED');
        return 0;
    }
    if ( $ORACLEVARS['log'] )
      __log('QUE:' . $sql);
        $handle = oci_parse( $ORACLEVARS['conn'], $sql );

    if ( ! $handle ) {
        __err('*** QUERY: PARSE ERROR');
        return 0;
    }

    if ( ! oci_execute( $handle, $ORACLEVARS['mode'] ) ) {
        __err('*** QUERY: EXECUTE ERROR');
        oci_free_statement($handle);
        return 0;
    }

    if ( $update ) {
        oci_free_statement($handle);
        $handle = 0;
    }
    $ORACLEVARS['dataset'][$handle] = 0;
    return $handle;
}

php:

            $SQL = '';
            $SQL .= ' SELECT ';
            $SQL .= '   NUM_BOL, ( ';
            $SQL .= '   SGL_COLC_BOL                        ||';
            $SQL .= '   TRIM(COD_PROJ_AENV)                 || ';
            $SQL .= '   \'-\' || ';
            $SQL .= '   TRIM(COD_CAP_A100)                  || \'-\' || ';
            $SQL .= '   IND_ALRT_BOL                        || ';
            $SQL .= '   TRIM(TO_CHAR(NUM_SEQ_BOL, \'000\')) || \'/\' || ';
            $SQL .= '   TRIM(TO_CHAR(NUM_REV_BOL, \'00\')) ';
            $SQL .= '   ) AS NUM_BOL_FORMTD, ';
            $SQL .= '   NUM_REV_BOL, ';
            $SQL .= '   DSC_TITL_BOL ';
            $SQL .= ' FROM ';
            $SQL .= '   CBS.CBS_BOLETIM';
            $SQL .= ' WHERE 1=1';
            $SQL .= '   AND ROWNUM <= ' . $P_QT;
            $SQL .= '   AND COD_PROJ_AENV = \'' . $P_STR_COD_PROJ_AENV . '\'';
            $SQL .= '   AND SGL_COLC_BOL in (\'SB\', \'BS\') ';
            $SQL .= ' ORDER BY ';
            $SQL .= '   NUM_BOL ';

            SetDatabase('ORA_P');
            sql_connect_simple();
            $RESULT = sql_query($SQL);



Expected result:
----------------
In php4.3.4
monitoring the status of connection with netstat the webserver connect and disconnect to the server ORA_P:

while true; do netstat | grep ORA_P; echo; sleep 1; done

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     TIME_WAIT

tcp        0      0 webserver:32896           ORA_P:1521     TIME_WAIT

tcp        0      0 webserver:32896           ORA_P:1521     TIME_WAIT

In 5.0.2
monitoring the status of connection with netstat the connection becomes persist after the page is process, it's only disconnect with the Oracle idle/time.
tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

tcp        0      0 webserver:32896           ORA_P:1521     ESTABLISHED

I need that the connection in php 5.0.2 become non persist connection with oracle.




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-21 17:45 UTC] diego dot veiga at embraer dot com dot br
I upgraded the php to 5.0.3 and reproduce the same error, it seems the oci_connect is working like the oci_pconnect. 

Does anybody has an idea?
 [2005-06-17 16:09 UTC] emiliano dot ticci at dada dot net
While waiting for an official fix I solved by commenting and decommenting some lines. This is my diff file for oci8.c (Php 5.0.4):

1103c1103
< #if 0
---
> /* #if 0 commented to avoid connection stay persist */
1109c1109
< #endif
---
> /* #endif */
3204a3205
>       /* Prevents a recursive call to this function (?)
3207a3209
>       */

I don't know if this could be a good solution, however it seems to work perfectly...

Sorry for my poor english.
 [2005-09-08 11:46 UTC] tony2001@php.net
The bug has been fixed in OCI8 v.1.1, which is available in CVS HEAD and PECL (use `pear install oci8-beta` to install it).
 [2005-12-20 14:04 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2005-12-20 16:14 UTC] diego dot veiga at embraer dot com dot br
Hi,

I just installed the latest cvs snapshot and executed the query but the connection continues persistent.
regards
 [2005-12-20 16:18 UTC] sniper@php.net
tony2001: Still not fixed..?
 [2005-12-20 16:23 UTC] tony2001@php.net
What web-server and MPM are you using?
What's your oracle server version?
 [2005-12-20 16:44 UTC] diego dot veiga at embraer dot com dot br
the same error with the latest cvs version.

Apache/1.3.33 (Unix) PHP/5.1.0-dev mod_ssl/2.8.22 OpenSSL/0.9.7a 

Oracle8i Enterprise Edition Release 8.1.7.4.0 - 64bit Production
With the Partitioning option
JServer Release 8.1.7.4.0 - 64bit Production
 [2005-12-20 16:50 UTC] tony2001@php.net
PHP/5.1.0-dev ??
I'm sure this is not the latest CVS.
 [2005-12-20 17:37 UTC] diego dot veiga at embraer dot com dot br
Hi,

now i downloaded the last cvs... 
this error is getting on my nervous!

after compiled the php 5.1.2-dev a lot of my includes and functions becomes to be invalid this error of redeclare function (ex. hash), i will need to change the code.

Can i copy only the folder of the oci  extension and recompile with the older php version (5.1.1)?
 [2005-12-20 17:47 UTC] tony2001@php.net
>functions becomes to be invalid this error of redeclare function (ex. hash
Use ./configure options to disable unwanted modules.
 [2005-12-20 18:25 UTC] diego dot veiga at embraer dot com dot br
Hi,

it works!
only an error in the:
Warning: ocilogoff() expects parameter 1 to be resource
this i take a look latter...

The page when it's loaded, connect and diconnect the dataserver.

thanks for your time...

PS: can i consider this fix in the next release of php?
 [2005-12-20 18:40 UTC] tony2001@php.net
>can i consider this fix in the next release of php?
Sure.
5.1.2 *IS* the next release.
And btw new OCI8 is available through PECL either.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Aug 25 21:01:26 2019 UTC