<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugzilla.globus.org/bugzilla/bugzilla.dtd">

<bugzilla version="3.2.3"
          urlbase="http://bugzilla.globus.org/bugzilla/"
          maintainer="bacon@mcs.anl.gov"
>

    <bug>
          <bug_id>7115</bug_id>
          
          <creation_ts>2010-12-21 18:07</creation_ts>
          <short_desc>MySQL &quot;No Database selected&quot; error</short_desc>
          <delta_ts>2011-04-21 16:36:09</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Replica Location</product>
          <component>RLS</component>
          <version>development</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          
          <priority>P3</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Smith">smithd@isi.edu</reporter>
          <assigned_to>deschon@isi.edu</assigned_to>
          <cc>mattias.ellert@fysast.uu.se</cc>
    
    <cc>schuler@isi.edu</cc>

      

      
          <long_desc isprivate="0">
            <who name="David Smith">smithd@isi.edu</who>
            <bug_when>2010-12-21 18:07:53</bug_when>
            <thetext>Database: MySQL 5.0.77
OS: CentOS 5.2 64-bit
ODBC Library: unixODBC 2.2.11
MySQL Driver: MySQL ODBC 3.51.27 (3.51.26 had the same problem as well)

We upgraded from 3.51.12 MySQL ODBC Driver to 3.51.27 and RLS reports &quot;DB error: [MySQL][ODBC 3.51 Driver][mysql-5.0.45-log]No database selected&quot; even though we have specified a Database parameter in the odbc.ini file that our globus-rls-server.conf refers to.

We resolved the problem locally by adding the &quot;USE &lt;db name&gt;&quot; MySQL command to the part of db.c that establishes the connection.

(inside of db_open, right after the db_open_mtx lock is released)

if(ismysql) {
    snprintf(buf, BIGBUF, &quot;USE %s&quot;,dbname);
    r = SQLExecDirect(h-&gt;stmt, (SQLCHAR *) buf, SQL_NTS);
    if (!SQLNODATAOK(r)) {
      odbcerr(r, SQL_HANDLE_DBC, h-&gt;dbc, errmsg);
      goto error;
    }
  }</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who name="">deschon@isi.edu</who>
            <bug_when>2011-01-31 13:14:49</bug_when>
            <thetext>The following changes have been checked in for GT 5.0.3:

Index: db.c
===================================================================
RCS file: /home/globdev/CVS/globus-packages/replica/rls/server/db.c,v
retrieving revision 1.21.2.1
diff -c -r1.21.2.1 db.c
*** db.c	26 May 2010 00:36:53 -0000	1.21.2.1
--- db.c	31 Jan 2011 20:09:24 -0000
***************
*** 159,167 ****
  {
    db_handle_t	*h;
    SQLRETURN	r;
    int		connected = 0;
-   static int	lrccounts = 0;
-   static int	rlicounts = 0;
    SWORD		len;
    int		i;
  
--- 159,166 ----
  {
    db_handle_t	*h;
    SQLRETURN	r;
+   char		buf[BIGBUF];
    int		connected = 0;
    SWORD		len;
    int		i;
  
***************
*** 229,234 ****
--- 228,242 ----
  
    globus_mutex_unlock(&amp;db_open_mtx);
  
+   if(ismysql) {
+     snprintf(buf, BIGBUF, &quot;USE %s&quot;,dbname);
+     r = SQLExecDirect(h-&gt;stmt, (SQLCHAR *) buf, SQL_NTS);
+     if (!SQLNODATAOK(r)) {
+       odbcerr(r, SQL_HANDLE_DBC, h-&gt;dbc, errmsg);
+       goto error;
+     }
+   }
+ 
    *hp = h;
    return GLOBUS_RLS_SUCCESS;</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who name="Mattias Ellert">mattias.ellert@fysast.uu.se</who>
            <bug_when>2011-04-21 11:40:56</bug_when>
            <thetext>This change must be reverted as soon as possible! It transforms a previously working RLS server into a non-working one. After updated to GT 5.0.3 the RLS server is no longer functional. If I revert to the GT 5.0.2 version it starts working again.

The MySQL ODBC driver is totally capable of using the right database if it is configured correctly. The workaround (for what seems to be a bad configuration) implemented here is just plain broken, since it forwards the ODBC database name directly to MySQL. The database names in ODBC and MySQL don&apos;t have to be the same (and if you use the default configuration template they are not), so with this change you are asking MySQL to use a non-existing database which of course makes the RLS server non-functional.

A patch that restores the RLS server to a working state is available here:
http://www.grid.tsl.uu.se/repos/globus/info/globus-rls-server-db.patch</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who name="">deschon@isi.edu</who>
            <bug_when>2011-04-21 16:36:09</bug_when>
            <thetext>The change has been reverted, as suggested by Mattias Ellert, and checked in for GT 5.0.4.</thetext>
          </long_desc>
      
      

    </bug>

</bugzilla>