~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_db.cc

  • Committer: Brian Aker
  • Date: 2008-10-20 03:40:03 UTC
  • mto: (492.3.21 drizzle-clean-code)
  • mto: This revision was merged to the branch mainline in revision 530.
  • Revision ID: brian@tangent.org-20081020034003-t2dcnl0ayr2ymm8k
THD -> Session rename

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
static TYPELIB deletable_extentions=
37
37
{array_elements(del_exts)-1,"del_exts", del_exts, NULL};
38
38
 
39
 
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
 
39
static long mysql_rm_known_files(Session *thd, MY_DIR *dirp,
40
40
                                 const char *db, const char *path, uint32_t level, 
41
41
                                 TableList **dropped_tables);
42
42
         
43
43
static bool rm_dir_w_symlink(const char *org_path, bool send_error);
44
 
static void mysql_change_db_impl(THD *thd,
 
44
static void mysql_change_db_impl(Session *thd,
45
45
                                 LEX_STRING *new_db_name,
46
46
                                 const CHARSET_INFO * const new_db_charset);
47
47
 
133
133
  Helper function to write a query to binlog used by mysql_rm_db()
134
134
*/
135
135
 
136
 
static inline void write_to_binlog(THD *thd, char *query, uint32_t q_len,
 
136
static inline void write_to_binlog(Session *thd, char *query, uint32_t q_len,
137
137
                                   char *db, uint32_t db_len)
138
138
{
139
139
  Query_log_event qinfo(thd, query, q_len, 0, 0);
334
334
  1     Could not create file or write to it.  Error sent through my_error()
335
335
*/
336
336
 
337
 
static bool write_db_opt(THD *thd, const char *path, const char *name, HA_CREATE_INFO *create)
 
337
static bool write_db_opt(Session *thd, const char *path, const char *name, HA_CREATE_INFO *create)
338
338
{
339
339
  bool error= true;
340
340
  drizzle::Schema db;
374
374
 
375
375
*/
376
376
 
377
 
bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
 
377
bool load_db_opt(Session *thd, const char *path, HA_CREATE_INFO *create)
378
378
{
379
379
  bool error=1;
380
380
  drizzle::Schema db;
453
453
    true    Failed to retrieve options
454
454
*/
455
455
 
456
 
bool load_db_opt_by_name(THD *thd, const char *db_name,
 
456
bool load_db_opt_by_name(Session *thd, const char *db_name,
457
457
                         HA_CREATE_INFO *db_create_info)
458
458
{
459
459
  char db_opt_path[FN_REFLEN];
479
479
    set, even if the database does not exist.
480
480
*/
481
481
 
482
 
const CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name)
 
482
const CHARSET_INFO *get_default_db_collation(Session *thd, const char *db_name)
483
483
{
484
484
  HA_CREATE_INFO db_info;
485
485
 
524
524
 
525
525
*/
526
526
 
527
 
int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, bool silent)
 
527
int mysql_create_db(Session *thd, char *db, HA_CREATE_INFO *create_info, bool silent)
528
528
{
529
529
  char   path[FN_REFLEN+16];
530
530
  char   tmp_query[FN_REFLEN+16];
674
674
 
675
675
/* db-name is already validated when we come here */
676
676
 
677
 
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
 
677
bool mysql_alter_db(Session *thd, const char *db, HA_CREATE_INFO *create_info)
678
678
{
679
679
  char path[FN_REFLEN+16];
680
680
  long result=1;
760
760
    ERROR Error
761
761
*/
762
762
 
763
 
bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
 
763
bool mysql_rm_db(Session *thd,char *db,bool if_exists, bool silent)
764
764
{
765
765
  long deleted=0;
766
766
  int error= false;
930
930
  thd MUST be set when calling this function!
931
931
*/
932
932
 
933
 
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
 
933
static long mysql_rm_known_files(Session *thd, MY_DIR *dirp, const char *db,
934
934
                                 const char *org_path, uint32_t level,
935
935
                                 TableList **dropped_tables)
936
936
{
1092
1092
  @param new_db_charset Character set of the new database.
1093
1093
*/
1094
1094
 
1095
 
static void mysql_change_db_impl(THD *thd,
 
1095
static void mysql_change_db_impl(Session *thd,
1096
1096
                                 LEX_STRING *new_db_name,
1097
1097
                                 const CHARSET_INFO * const new_db_charset)
1098
1098
{
1099
 
  /* 1. Change current database in THD. */
 
1099
  /* 1. Change current database in Session. */
1100
1100
 
1101
1101
  if (new_db_name == NULL)
1102
1102
  {
1103
1103
    /*
1104
 
      THD::set_db() does all the job -- it frees previous database name and
 
1104
      Session::set_db() does all the job -- it frees previous database name and
1105
1105
      sets the new one.
1106
1106
    */
1107
1107
 
1110
1110
  else if (new_db_name == &INFORMATION_SCHEMA_NAME)
1111
1111
  {
1112
1112
    /*
1113
 
      Here we must use THD::set_db(), because we want to copy
 
1113
      Here we must use Session::set_db(), because we want to copy
1114
1114
      INFORMATION_SCHEMA_NAME constant.
1115
1115
    */
1116
1116
 
1119
1119
  else
1120
1120
  {
1121
1121
    /*
1122
 
      Here we already have a copy of database name to be used in THD. So,
1123
 
      we just call THD::reset_db(). Since THD::reset_db() does not releases
 
1122
      Here we already have a copy of database name to be used in Session. So,
 
1123
      we just call Session::reset_db(). Since Session::reset_db() does not releases
1124
1124
      the previous database name, we should do it explicitly.
1125
1125
    */
1126
1126
 
1153
1153
                                  "length" is set to 0.
1154
1154
*/
1155
1155
 
1156
 
static void backup_current_db_name(THD *thd,
 
1156
static void backup_current_db_name(Session *thd,
1157
1157
                                   LEX_STRING *saved_db_name)
1158
1158
{
1159
1159
  if (!thd->db)
1224
1224
                          @@collation_server, but the operation will fail;
1225
1225
 
1226
1226
                        - user privileges will not be checked
1227
 
                          (THD::db_access however is updated);
 
1227
                          (Session::db_access however is updated);
1228
1228
 
1229
1229
                          TODO: is this really the intention?
1230
1230
                                (see sp-security.test).
1237
1237
  @details The function checks that the database name corresponds to a
1238
1238
  valid and existent database, checks access rights and changes the current
1239
1239
  database with database attributes (@@collation_database session variable,
1240
 
  THD::db_access).
 
1240
  Session::db_access).
1241
1241
 
1242
1242
  This function is not the only way to switch the database that is
1243
1243
  currently employed. When the replication slave thread switches the
1257
1257
    @retval true  Error
1258
1258
*/
1259
1259
 
1260
 
bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
 
1260
bool mysql_change_db(Session *thd, const LEX_STRING *new_db_name, bool force_switch)
1261
1261
{
1262
1262
  LEX_STRING new_db_file_name;
1263
1263
  const CHARSET_INFO *db_default_cl;
1367
1367
  }
1368
1368
 
1369
1369
  /*
1370
 
    NOTE: in mysql_change_db_impl() new_db_file_name is assigned to THD
1371
 
    attributes and will be freed in THD::~THD().
 
1370
    NOTE: in mysql_change_db_impl() new_db_file_name is assigned to Session
 
1371
    attributes and will be freed in Session::~Session().
1372
1372
  */
1373
1373
 
1374
1374
  db_default_cl= get_default_db_collation(thd, new_db_file_name.str);
1399
1399
                                  the function suceeded)
1400
1400
*/
1401
1401
 
1402
 
bool mysql_opt_change_db(THD *thd,
 
1402
bool mysql_opt_change_db(Session *thd,
1403
1403
                         const LEX_STRING *new_db_name,
1404
1404
                         LEX_STRING *saved_db_name,
1405
1405
                         bool force_switch,