Home » Database » MDB2 » Bug #3576
oci8 - connect() params totally broken
Details
| Submitted | 2005-02-24 14:18 UTC |
|---|---|
| From | sbeam at onsetcorps dot net |
| Status | No Feedback |
| Package | MDB2 |
| PHP Version | 5.0.3 |
| OS | linux |
| Roadmaps | (Not assigned) |
Comments
[2005-02-24 14:18 UTC] sbeam at onsetcorps dot net
Description:
------------
Passing of params in oci8::connect() was totally b0rked. DNSParse() was working fine, but connect() was assembling the parameters to pass to _doConnect() wrong.
Also in _doConnect(), $sid was being set to hostspec, not the actual DB/TNSNAME.
So that in _doConnect, OCI*Logon was actually being called like this
> OCILogon(database_name, password, hostdef)
which of course won't work.
Attached patch fixes the problem.
Using last stable release, beta.
Reproduce code:
---------------
--- MDB2-2.0.0beta2/MDB2/Driver/oci8.php 2004-04-23 13:06:46.000000000 -0400
+++ /usr/local/share/pear/MDB2/Driver/oci8.php 2005-02-24 09:02:14.196104158 -0500
@@ -242,8 +242,8 @@
'extension '.$this->phptype.' is not compiled into PHP');
}
- if (isset($this->dsn['hostspec'])) {
- $sid = $this->dsn['hostspec'];
+ if (isset($this->database_name)) {
+ $sid = $this->database_name;
} else {
$sid = getenv('ORACLE_SID');
}
@@ -259,7 +259,7 @@
$function = ($persistent ? 'OCIPLogon' : 'OCINLogon');
$connection = @$function($username, $password, $sid);
if (!$connection) {
- $connection = $this->raiseError();
+ $connection = $this->raiseError("connection failure in {$function}()");
}
return $connection;
}
@@ -284,9 +284,12 @@
$this->_close();
}
- if ($this->database_name) {
+ if (!$this->database_name) {
+ $this->raiseError('no databse specified!');
+ }
+ else {
$database_name = $this->options['database_name_prefix'].$this->database_name;
- $connection = $this->_doConnect($database_name, $this->dsn['password'], $this->options['persistent']);
+ $connection = $this->_doConnect($this->dsn['username'], $this->dsn['password'], $this->options['persistent']);
if (MDB2::isError($connection)) {
return $connection;
}
@@ -515,7 +518,7 @@
}
}
} else {
- return $this->raiseError();
+ return $this->raiseError('could not prepare statement');
}
}
for (reset($descriptors), $descriptor = 0;
[2005-02-24 15:29 UTC] sbeam at onsetcorps dot net
Just found this bug,
http://pear.php.net/bugs/bug.php?id=2532
But don't understand what the problem is there, Oracle can either use a TNSNAME to connect to or, if not provided, it will connect to the user's default tablespace. Users should know if they are connecting to a given TNSNAME or not, which they usually are. So, the same way as DB::connect did, _doConnect() should just send the $db string per normal if is is in the DSN...
[2005-02-24 21:34 UTC] smith at backendmedia dot com
The point is that there is also a createDatabase() method and there is also a setDatabase() method etc. This kind of stuff works radically different on other RDBMS and the approach taken provides a way to make Oracle behave more or less the same. I also added $this->options['emulate_database'] to this disable this behavior. As such I recommend you take a look at CVS and let me know if this works for you?
[2005-03-17 17:13 UTC] smith at backendmedia dot com
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.