Mantis Bugtracker
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002880 [Quercus] major always 08-29-08 00:05 09-05-08 15:59
Reporter koreth View Status public  
Assigned To nam
Priority high Resolution fixed  
Status closed   Product Version 3.2.1
Summary 0002880: MySQL code assumes only one database name is ever used
Description Say you have two MySQL servers at 1.2.3.4 and 1.2.3.5. Each one has a few databases (catalogs), no overlap in database names.

<?php
$conn = mysql_connect('1.2.3.4', 'myuser', 'mypass');
mysql_select_db('some_db', $conn);
$conn2 = mysql_connect('1.2.3.5', 'myuser', 'mypass');

The above code will successfully connect to the 1.2.3.4 server and switch to the some_db database. But then the second mysql_connect() will fail with an "Unknown database 'some_db'" exception because the MySQL code is caching the last selected database name and sticking it on the end of the JDBC URL it uses to connect to the second database.
Additional Information
Attached Files

- Relationships

- Notes
(0003371)
koreth
08-29-08 14:37

My hacky patch which probably breaks something else but at least makes the problem stop happening is to just comment out the line of code that records the database name:

--- a/modules/quercus/src/com/caucho/quercus/lib/db/Mysqli.java
+++ b/modules/quercus/src/com/caucho/quercus/lib/db/Mysqli.java
@@ -922,7 +922,7 @@ public class Mysqli extends JdbcConnectionResource {
     try {
       if (isConnected()) {
         String catalog = dbname.toString();
- getEnv().getQuercus().setSpecial("mysql.catalog", catalog);
+ //getEnv().getQuercus().setSpecial("mysql.catalog", catalog);
        
         validateConnection().setCatalog(catalog);
 
(0003399)
nam
09-05-08 15:59

php/1457
 

- Issue History
Date Modified Username Field Change
08-29-08 00:05 koreth New Issue
08-29-08 08:38 emil Priority normal => high
08-29-08 14:37 koreth Note Added: 0003371
09-04-08 13:59 nam Status new => assigned
09-04-08 13:59 nam Assigned To  => nam
09-05-08 15:59 nam Status assigned => closed
09-05-08 15:59 nam Note Added: 0003399
09-05-08 15:59 nam Resolution open => fixed
09-05-08 15:59 nam Fixed in Version  => 3.2.1


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
32 total queries executed.
28 unique queries executed.
Powered by Mantis Bugtracker