[Commits] Rev 3157: Automatic merge with 5.2 in lp:maria/5.3

Michael Widenius monty at askmonty.org
Tue Aug 16 15:51:49 EEST 2011


At lp:maria/5.3

------------------------------------------------------------
revno: 3157 [merge]
revision-id: monty at askmonty.org-20110816125140-65efcwghbrlpk23l
parent: monty at askmonty.org-20110815191408-jo0wlbi2u869bl8z
parent: monty at askmonty.org-20110816102820-ijbw4f8grblridvz
committer: Michael Widenius <monty at askmonty.org>
branch nick: maria-5.3
timestamp: Tue 2011-08-16 15:51:40 +0300
message:
  Automatic merge with 5.2
modified:
  sql/mysql_priv.h               sp1f-mysql_priv.h-19700101030959-4fl65tqpop5zfgxaxkqotu2fa2ree5ci
  sql/sql_acl.cc                 sp1f-sql_acl.cc-19700101030959-c4hku3uqxzujthqnndeprbrhamqy6a4i
  sql/sql_class.cc               sp1f-sql_class.cc-19700101030959-rpotnweaff2pikkozh3butrf7mv3oero
  sql/sql_connect.cc             sp1f-sql_connect.cc-20070223111352-fhh5znxdfvzxuca7da3uu4olnwgkrm4n
  sql/sql_parse.cc               sp1f-sql_parse.cc-19700101030959-ehcre3rwhv5l3mlxqhaxg36ujenxnrcd
  storage/maria/ma_recovery.c    sp1f-recovery.c-20060427140636-kkuwrxyvjp42wmupdfbxuaro456oprrg
  storage/myisam/ha_myisam.cc    sp1f-ha_myisam.cc-19700101030959-7xzssylbn7zfz3nupnsw43wws6xlltsu
-------------- next part --------------
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2011-07-21 22:55:08 +0000
+++ b/sql/mysql_priv.h	2011-08-16 12:51:40 +0000
@@ -943,6 +943,7 @@ inline bool check_merge_table_access(THD
 inline bool check_some_routine_access(THD *thd, const char *db,
                                       const char *name, bool is_proc)
 { return false; }
+#define decrease_user_connections(X) do { } while(0)       /* nothing */
 #endif /*NO_EMBEDDED_ACCESS_CHECKS*/
 
 bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
@@ -1176,7 +1177,9 @@ bool init_new_connection_handler_thread(
 void reset_mqh(LEX_USER *lu, bool get_them);
 bool check_mqh(THD *thd, uint check_command);
 void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
 void decrease_user_connections(USER_CONN *uc);
+#endif
 bool thd_init_client_charset(THD *thd, uint cs_number);
 inline bool is_supported_parser_charset(CHARSET_INFO *cs)
 {

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2011-07-21 12:50:25 +0000
+++ b/sql/sql_acl.cc	2011-08-16 12:51:40 +0000
@@ -6978,7 +6978,6 @@ bool check_routine_level_acl(THD *thd, c
 #undef HAVE_OPENSSL
 #ifdef NO_EMBEDDED_ACCESS_CHECKS
 #define initialized 0
-#define decrease_user_connections(X)        /* nothing */
 #define check_for_max_user_connections(X,Y)   0
 #define get_or_create_user_conn(A,B,C,D) 0
 #endif
@@ -8167,6 +8166,8 @@ bool acl_authenticate(THD *thd, uint con
        max_user_connections) &&
       check_for_max_user_connections(thd, thd->user_connect))
   {
+    /* Ensure we don't decrement thd->user_connections->connections twice */
+    thd->user_connect= 0;
     status_var_increment(denied_connections);
     DBUG_RETURN(1); // The error is set in check_for_max_user_connections()
   }
@@ -8207,12 +8208,7 @@ bool acl_authenticate(THD *thd, uint con
     if (mysql_change_db(thd, &mpvio.db, FALSE))
     {
       /* mysql_change_db() has pushed the error message. */
-      if (thd->user_connect)
-      {
-        status_var_increment(thd->status_var.access_denied_errors);
-        decrease_user_connections(thd->user_connect);
-        thd->user_connect= 0;
-      }
+      status_var_increment(thd->status_var.access_denied_errors);
       DBUG_RETURN(1);
     }
   }

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2011-07-11 21:00:44 +0000
+++ b/sql/sql_class.cc	2011-08-16 12:51:40 +0000
@@ -1095,6 +1095,11 @@ void THD::cleanup(void)
     lock=locked_tables; locked_tables=0;
     close_thread_tables(this);
   }
+  if (user_connect)
+  {
+    decrease_user_connections(user_connect);
+    user_connect= 0;                            // Safety
+  }
   wt_thd_destroy(&transaction.wt);
 
 #if defined(ENABLED_DEBUG_SYNC)

=== modified file 'sql/sql_connect.cc'
--- a/sql/sql_connect.cc	2011-07-21 12:50:25 +0000
+++ b/sql/sql_connect.cc	2011-08-16 12:51:40 +0000
@@ -49,6 +49,7 @@ int get_or_create_user_conn(THD *thd, co
 
   DBUG_ASSERT(user != 0);
   DBUG_ASSERT(host != 0);
+  DBUG_ASSERT(thd->user_connect == 0);
 
   user_len= strlen(user);
   temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1;
@@ -108,7 +109,7 @@ int get_or_create_user_conn(THD *thd, co
 
 int check_for_max_user_connections(THD *thd, USER_CONN *uc)
 {
-  int error=0;
+  int error= 1;
   DBUG_ENTER("check_for_max_user_connections");
 
   (void) pthread_mutex_lock(&LOCK_user_conn);
@@ -116,7 +117,6 @@ int check_for_max_user_connections(THD *
       max_user_connections < (uint) uc->connections)
   {
     my_error(ER_TOO_MANY_USER_CONNECTIONS, MYF(0), uc->user);
-    error=1;
     goto end;
   }
   time_out_user_resource_limits(thd, uc);
@@ -126,7 +126,6 @@ int check_for_max_user_connections(THD *
     my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user,
              "max_user_connections",
              (long) uc->user_resources.user_conn);
-    error= 1;
     goto end;
   }
   if (uc->user_resources.conn_per_hour &&
@@ -135,10 +134,10 @@ int check_for_max_user_connections(THD *
     my_error(ER_USER_LIMIT_REACHED, MYF(0), uc->user,
              "max_connections_per_hour",
              (long) uc->user_resources.conn_per_hour);
-    error=1;
     goto end;
   }
   uc->conn_per_hour++;
+  error= 0;
 
 end:
   if (error)
@@ -1028,8 +1027,17 @@ void end_connection(THD *thd)
 {
   NET *net= &thd->net;
   plugin_thdvar_cleanup(thd);
+
   if (thd->user_connect)
+  {
+    /*
+      We decrease this variable early to make it easy to log again quickly.
+      This code is not critical as we will in any case do this test
+      again in thd->cleanup()
+    */
     decrease_user_connections(thd->user_connect);
+    thd->user_connect= 0;
+  }
 
   if (thd->killed || (net->error && net->vio != 0))
   {

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2011-07-21 12:50:25 +0000
+++ b/sql/sql_parse.cc	2011-08-16 12:51:40 +0000
@@ -1132,12 +1132,15 @@ bool dispatch_command(enum enum_server_c
 
     /* Ensure we don't free security_ctx->user in case we have to revert */
     thd->security_ctx->user= 0;
+    thd->user_connect= 0;
 
     if (acl_authenticate(thd, 0, packet_length))
     {
       /* Free user if allocated by acl_authenticate */
       x_free(thd->security_ctx->user);
       *thd->security_ctx= save_security_ctx;
+      if (thd->user_connect)
+        decrease_user_connections(thd->user_connect);
       thd->user_connect= save_user_connect;
       thd->reset_db(save_db, save_db_length);
       thd->variables.character_set_client= save_character_set_client;

=== modified file 'storage/maria/ma_recovery.c'
--- a/storage/maria/ma_recovery.c	2011-06-24 17:43:31 +0000
+++ b/storage/maria/ma_recovery.c	2011-08-16 12:51:40 +0000
@@ -320,25 +320,32 @@ int maria_apply_log(LSN from_lsn, LSN en
   skip_DDLs= skip_DDLs_arg;
   skipped_undo_phase= 0;
 
+  trnman_init(max_trid_in_control_file);
+
   if (from_lsn == LSN_IMPOSSIBLE)
   {
     if (last_checkpoint_lsn == LSN_IMPOSSIBLE)
     {
       from_lsn= translog_first_lsn_in_log();
       if (unlikely(from_lsn == LSN_ERROR))
+      {
+        trnman_destroy();
         goto err;
+      }
     }
     else
     {
       from_lsn= parse_checkpoint_record(last_checkpoint_lsn);
       if (from_lsn == LSN_ERROR)
+      {
+        trnman_destroy();
         goto err;
+      }
     }
   }
 
   now= microsecond_interval_timer();
   in_redo_phase= TRUE;
-  trnman_init(max_trid_in_control_file);
   if (run_redo_phase(from_lsn, end_lsn, apply))
   {
     ma_message_no_user(0, "Redo phase failed");

=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc	2011-07-14 23:29:38 +0000
+++ b/storage/myisam/ha_myisam.cc	2011-08-16 12:51:40 +0000
@@ -123,6 +123,9 @@ static void mi_check_print_msg(HA_CHECK
   if (protocol->write())
     sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n",
                     msgbuf);
+  else if (thd->variables.log_warnings > 2)
+    sql_print_error("%s", msgbuf);
+
 #ifdef THREAD
   if (param->need_print_msg_lock)
     pthread_mutex_unlock(&param->print_msg_mutex);



More information about the commits mailing list