~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to sql/sql_db.cc

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
643
643
    goto exit2;
644
644
  }
645
645
 
646
 
  VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
 
646
  pthread_mutex_lock(&LOCK_mysql_create_db);
647
647
 
648
648
  /* Check directory */
649
649
  path_len= build_table_filename(path, sizeof(path), db, "", "", 0);
753
753
  }
754
754
 
755
755
exit:
756
 
  VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
 
756
  pthread_mutex_unlock(&LOCK_mysql_create_db);
757
757
  start_waiting_global_read_lock(thd);
758
758
exit2:
759
759
  DBUG_RETURN(error);
784
784
  if ((error=wait_if_global_read_lock(thd,0,1)))
785
785
    goto exit2;
786
786
 
787
 
  VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
 
787
  pthread_mutex_lock(&LOCK_mysql_create_db);
788
788
 
789
789
  /* 
790
790
     Recreate db options file: /dbpath/.db.opt
829
829
  my_ok(thd, result);
830
830
 
831
831
exit:
832
 
  VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
 
832
  pthread_mutex_unlock(&LOCK_mysql_create_db);
833
833
  start_waiting_global_read_lock(thd);
834
834
exit2:
835
835
  DBUG_RETURN(error);
881
881
    goto exit2;
882
882
  }
883
883
 
884
 
  VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
 
884
  pthread_mutex_lock(&LOCK_mysql_create_db);
885
885
 
886
886
  /*
887
887
    This statement will be replicated as a statement, even when using
910
910
  }
911
911
  else
912
912
  {
913
 
    pthread_mutex_lock(&LOCK_open);
914
 
    remove_db_from_cache(db);
915
 
    pthread_mutex_unlock(&LOCK_open);
916
 
 
917
 
    
918
913
    error= -1;
919
914
    if ((deleted= mysql_rm_known_files(thd, dirp, db, path, 0,
920
915
                                       &dropped_tables)) >= 0)
922
917
      ha_drop_database(path);
923
918
      query_cache_invalidate1(db);
924
919
      (void) sp_drop_db_routines(thd, db); /* @todo Do not ignore errors */
 
920
#ifdef HAVE_EVENT_SCHEDULER
925
921
      Events::drop_schema_events(thd, db);
 
922
#endif
926
923
      error = 0;
927
924
    }
928
925
  }
1008
1005
    SELECT DATABASE() in the future). For this we free() thd->db and set
1009
1006
    it to 0.
1010
1007
  */
1011
 
  if (thd->db && !strcmp(thd->db, db))
 
1008
  if (thd->db && !strcmp(thd->db, db) && error == 0)
1012
1009
    mysql_change_db_impl(thd, NULL, 0, thd->variables.collation_server);
1013
 
  VOID(pthread_mutex_unlock(&LOCK_mysql_create_db));
 
1010
  pthread_mutex_unlock(&LOCK_mysql_create_db);
1014
1011
  start_waiting_global_read_lock(thd);
1015
1012
exit2:
1016
1013
  DBUG_RETURN(error);
1120
1117
        goto err;
1121
1118
      table_list->db= (char*) (table_list+1);
1122
1119
      table_list->table_name= strmov(table_list->db, db) + 1;
1123
 
      VOID(filename_to_tablename(file->name, table_list->table_name,
 
1120
      (void) filename_to_tablename(file->name, table_list->table_name,
1124
1121
                                 MYSQL50_TABLE_NAME_PREFIX_LENGTH +
1125
 
                                 strlen(file->name) + 1));
 
1122
                                 strlen(file->name) + 1);
 
1123
 
 
1124
      /* To be able to correctly look up the table in the table cache. */
 
1125
      if (lower_case_table_names)
 
1126
        my_casedn_str(files_charset_info, table_list->table_name);
 
1127
 
1126
1128
      table_list->alias= table_list->table_name;        // If lower_case_table_names=2
1127
1129
      table_list->internal_tmp_table= is_prefix(file->name, tmp_file_prefix);
1128
1130
      /* Link into list */
1928
1930
 
1929
1931
  /*
1930
1932
    Step7: drop the old database.
1931
 
    remove_db_from_cache(olddb) and query_cache_invalidate(olddb)
1932
 
    are done inside mysql_rm_db(), no needs to execute them again.
 
1933
    query_cache_invalidate(olddb) is done inside mysql_rm_db(), no need
 
1934
    to execute them again.
1933
1935
    mysql_rm_db() also "unuses" if we drop the current database.
1934
1936
  */
1935
1937
  error= mysql_rm_db(thd, old_db->str, 0, 1);