MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:bar Date:May 24 2006 11:10am
Subject:bk commit into 5.0 tree (bar:1.2143) BUG#10979
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2143 06/05/24 16:10:25 bar@stripped +1 -0
  bug#10979 USE does not refresh db privilege changes if the same db is used in command.
  The problem happened because "mysql" didn't send mysql_select_db() if 
  the current active database was specified in USE.
  Now it always send mysql_select_db().
  Rebuilding of completion hash is skipped in the same db is used
  (for performance purposes).

  client/mysql.cc
    1.206 06/05/24 16:10:16 bar@stripped +38 -19
    bug#10979 USE does not refresh db privilege changes if the same db is used in command.
    The problem happened because "mysql" didn't send mysql_select_db() if 
    the current active database was specified in USE.
    Now it always send mysql_select_db().
    Rebuilding of completion hash is skipped in the same db is used
    (for performance purposes).

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bar
# Host:	bar.intranet.mysql.r18.ru
# Root:	/usr/home/bar/mysql-5.0.b10979

--- 1.205/client/mysql.cc	2006-05-11 18:14:03 +05:00
+++ 1.206/client/mysql.cc	2006-05-24 16:10:16 +05:00
@@ -2969,6 +2969,7 @@ static int
 com_use(String *buffer __attribute__((unused)), char *line)
 {
   char *tmp, buff[FN_REFLEN + 1];
+  int select_db;
 
   bzero(buff, sizeof(buff));
   strmov(buff, line);
@@ -2988,34 +2989,52 @@ com_use(String *buffer __attribute__((un
   if (!current_db || cmp_database(charset_info, current_db,tmp))
   {
     if (one_database)
+    {
       skip_updates= 1;
+      select_db= 0;    // don't do mysql_select_db()
+    }
     else
-    {
-      /*
-	reconnect once if connection is down or if connection was found to
-	be down during query
-      */
-      if (!connected && reconnect())
+      select_db= 2;    // do mysql_select_db() and build_completion_hash()
+  }
+  else
+  {
+    /*
+      USE to the current db specified.
+      We do need to send mysql_select_db() to make server
+      update database level privileges, which might
+      change since last USE (see bug#10979).
+      For performance purposes, we'll skip rebuilding of completion hash.
+    */
+    skip_updates= 0;
+    select_db= 1;      // do only mysql_select_db(), without completion
+  }
+
+  if (select_db)
+  {
+    /*
+      reconnect once if connection is down or if connection was found to
+      be down during query
+    */
+    if (!connected && reconnect())
       return opt_reconnect ? -1 : 1;                        // Fatal error
-      if (mysql_select_db(&mysql,tmp))
-      {
-	if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR)
-	  return put_error(&mysql);
+    if (mysql_select_db(&mysql,tmp))
+    {
+      if (mysql_errno(&mysql) != CR_SERVER_GONE_ERROR)
+        return put_error(&mysql);
 
-	if (reconnect())
+      if (reconnect())
         return opt_reconnect ? -1 : 1;                      // Fatal error
-	if (mysql_select_db(&mysql,tmp))
-	  return put_error(&mysql);
-      }
-      my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
-      current_db=my_strdup(tmp,MYF(MY_WME));
+      if (mysql_select_db(&mysql,tmp))
+        return put_error(&mysql);
+    }
+    my_free(current_db,MYF(MY_ALLOW_ZERO_PTR));
+    current_db=my_strdup(tmp,MYF(MY_WME));
 #ifdef HAVE_READLINE
+    if (select_db > 1)
       build_completion_hash(rehash, 1);
 #endif
-    }
   }
-  else
-    skip_updates= 0;
+
   put_info("Database changed",INFO_INFO);
   return 0;
 }
Thread
bk commit into 5.0 tree (bar:1.2143) BUG#10979bar24 May