php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29013 Multiple logons cause handles to become invalid
Submitted: 2004-07-05 09:38 UTC Modified: 2005-09-08 11:46 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:5 (83.3%)
Same OS:5 (83.3%)
From: cjbj at hotmail dot com Assigned: tony2001 (profile)
Status: Closed Package: OCI8 related
PHP Version: 5CVS, 4CVS (2004-10-10) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cjbj at hotmail dot com
New email:
PHP Version: OS:

 

 [2004-07-05 09:38 UTC] cjbj at hotmail dot com
Description:
------------
Multiple logons within the same request cause handles to become invalid and queries to fail.  

Also see: http://forums.oracle.com/forums/thread.jsp?forum=178&thread=251141

To reproduce, restart Apache and run the following file.

The same incorrect output occurs with ocilogon() inplace of ocinlogon().


Reproduce code:
---------------
  <?php
  ociinternaldebug(1);

  function qry(&$c, $s) {
      echo "<br>===&gt;BEGIN<br><br>";
      $rSth = OCIParse($c, $s);
      $rRet = OCIExecute($rSth);
      echo "<br>";
      while ($succ = OCIFetchInto($rSth, $row)) {
	foreach ($row as $item) {
	  echo ($item?htmlentities($item):'&nbsp;')." ";
	}
	echo "<br>\n";
      }
      echo "<br>===&gt;CLOSE<br><br>";
      ocifreestatement($rSth);
  }

  $statement1 = "select dname from dept";
  $statement2 = "select user from dual;";

  echo "<br>===&gt;OCINLogin #1<br><br>";
  $c1 = OCINlogon('scott', 'tiger', 'MYDB' );

  echo "<br>===&gt;Query first connection<br><br>";
  qry($c1, $statement1);

  echo "<br>===&gt;OCINLogin #2<br><br>";
  $c2 = OCINlogon('hr', 'hr', 'MYDB');

  echo "<br>===&gt;Re-query first connection<br><br>";
  qry($c1, $statement1);

  echo "<br>===&gt;Re-query first connection<br><br>";
  qry($c1, $statement2);

  ?>


Expected result:
----------------
Three queries are successfully completed.

Actual result:
--------------
  ===>OCINLogin #1

  OCIDebug: _oci_open_server new conn=0 dname=MYDB
  OCIDebug: _oci_open_session new sess=3 user=scott
  OCIDebug: oci_do_connect: id=4

  ===>Query first connection
  ===>BEGIN

  OCIDebug: oci_parse "select dname from dept" id=5 conn=4

  ACCOUNTING
  RESEARCH
  SALES
  OPERATIONS

  ===>CLOSE

  OCIDebug: START _oci_stmt_list_dtor: id=5 last_query="select dname from dept"
  OCIDebug: START _oci_column_hash_dtor: DNAME
  OCIDebug: END _oci_column_hash_dtor: DNAME
  OCIDebug: END _oci_stmt_list_dtor: id=5

  ===>OCINLogin #2

  OCIDebug: _oci_open_session new sess=6 user=hr
  OCIDebug: oci_do_connect: id=7

  ===>Re-query first connection

  ===>BEGIN

  OCIDebug: oci_parse "select dname from dept" id=8 conn=4

  Warning: ociexecute(): OCIStmtExecute: ORA-00942: table or view does not exist in c:\cj\php\cj\contest.php on line 13

  Warning: ocifetchinto(): OCIFetchInto: ORA-24374: define not done before fetch or execute and fetch in c:\cj\php\cj\contest.php on line 15

  ===>CLOSE

  OCIDebug: START _oci_stmt_list_dtor: id=8 last_query="select dname from dept"
  OCIDebug: END _oci_stmt_list_dtor: id=8

  ===>Re-query first connection

  ===>BEGIN

  OCIDebug: oci_parse "select user from dual;" id=9 conn=4

  Warning: ociexecute(): OCIStmtExecute: ORA-00911: invalid character in c:\cj\php\cj\contest.php on line 13

  Warning: ocifetchinto(): OCIFetchInto: ORA-24374: define not done before fetch or execute and fetch in c:\cj\php\cj\contest.php on line 15

  ===>CLOSE

  OCIDebug: START _oci_stmt_list_dtor: id=9 last_query="select user from dual;"
  OCIDebug: END _oci_stmt_list_dtor: id=9
  OCIDebug: START php_rshutdown_oci
  OCIDebug: END php_rshutdown_oci
  OCIDebug: START _oci_conn_list_dtor: id=4
  OCIDebug: nothing to do..
  OCIDebug: START _oci_close_session: logging-off sess=3
  OCIDebug: END _oci_conn_list_dtor: id=4
  OCIDebug: START _oci_conn_list_dtor: id=7
  OCIDebug: nothing to do..
  OCIDebug: START _oci_close_session: logging-off sess=6
  OCIDebug: END _oci_conn_list_dtor: id=7
  OCIDebug: START _oci_close_server: detaching conn=2 dbname=MYDB


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-13 05:32 UTC] cjbj at hotmail dot com
The given testcase has an extra semi-colon in the second query.  The new testcase below shows that the initial connection is getting associated with the second user.

Testcase:

<?php
  function qry(&$c, $s) {
      echo "===&gt;BEGIN<br>";
      $rSth = OCIParse($c, $s);
      $rRet = OCIExecute($rSth);
      echo "<br>";
      while ($succ = OCIFetchInto($rSth, $row)) {
        foreach ($row as $item) {
          echo ($item?htmlentities($item):'&nbsp;')." ";
        }
        echo "<br>\n";
      }
      echo "===&gt;CLOSE<br><br>";
      ocifreestatement($rSth);
  }

  $statement1 = "select user from dual";

  echo "===&gt;OCINLogin #1: Connect as SCOTT<br>";
  $c1 = OCINlogon('scott', 'tiger', 'F10D' );

  echo "===&gt;Query first connection<br>";
  qry($c1, $statement1);

  echo "===&gt;OCINLogin #2: Connect as HR<br>";
  $c2 = OCINlogon('hr', 'hr', 'F10D');

  echo "===&gt;Re-query first connection<br>";
  qry($c1, $statement1);

?>

Actual Output:

===>OCINLogin #1: Connect as SCOTT
===>Query first connection
===>BEGIN

SCOTT
===>CLOSE

===>OCINLogin #2: Connect as HR
===>Re-query first connection
===>BEGIN

HR
===>CLOSE


Expected output is similar with the usernames in this order: SCOTT, SCOTT
 [2004-10-10 17:02 UTC] tony2001@php.net
Chris, is it important to have different users in your example?
Tested under 1 user (but using ociNlogin();) and it works fine.
 [2004-10-12 05:38 UTC] cjbj at hotmail dot com
The "business requirement" comes from the original report in
http://forums.oracle.com/forums/thread.jsp?forum=178&thread=251141

I don't think the way $c1 is impacted by the second login is obvious
or nice behavior.

I feel the problem is related to some of the common OCI8 connection
issues due to the caching and reuse of handles.  It would be nice to
resolve these issues.

There is no Oracle-OCI reason why two users can't be connected at one
time.  I think it should be allowed in PHP.  But if you think the
PHP-OCI8 interface should not support concurrent connections, can a
PHP error be generated at the time of the second OCINLogin()?
 [2004-10-12 07:20 UTC] tony2001@php.net
No, of course you should able to connect to Oracle from PHP using different logins. 
My question should be read in this way: "are you able to reproduce it under 1 user, but with different connections, because I was too lazy to create a new user in Oracle?".
Btw, I've already created additional user and tested your code - your example works perfectly for me.
 [2004-10-14 10:11 UTC] cjbj at hotmail dot com
Using one user would make it harder to demonstrate the 
problem. Sorry I didn't include create user scripts etc.

I retested with 4.3.10-dev and 5.0.3-dev binaries of a few 
minutes ago. I am using W2K with Oracle 9.2 client libraries.
I am still seeing the usernames printed as SCOTT and HR, 
which is "incorrect".
 [2004-10-17 06:51 UTC] tony2001@php.net
I can see the problem now. 
Will look at it closer a bit later..
 [2005-02-25 16:04 UTC] goetten at gmail dot com
Hy

I'm having the following problem:

Warning: ociexecute(): OCIStmtExecute: ORA-03106: fatal two-task communication protocol error in /var/www/html/helpdesk/migracao/view.php on line 10

Warning: ocifetchinto(): OCIFetchInto: ORA-24374: define not done before fetch or execute and fetch in /var/www/html/helpdesk/migracao/view.php on line 12

These errors are in a simple query. Is it about the bug on php?

thank's
 [2005-04-04 14:58 UTC] bugs dot php dot net at matveyev dot net
On my system, I noticed that the appearance of the bug depends on the way of starting my .php file.
If I start the script from bash, it works okay.
If I start the script directly from cron, it produces the error described here.
So, I solved my problem starting it from cron with such a string:
"su - user -c "/path/to/script.php"
 [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).
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Jul 07 05:05:44 2022 UTC