~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Olaf van der Spek
  • Date: 2011-06-22 16:36:40 UTC
  • mto: This revision was merged to the branch mainline in revision 2347.
  • Revision ID: olafvdspek@gmail.com-20110622163640-pwub8fpyqfdvqek4
Refactor

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
char internal_table_name[2]= "*";
104
104
char empty_c_string[1]= {0};    /* used for not defined db */
105
105
 
106
 
const char * const Session::DEFAULT_WHERE= "field list";
 
106
const char* const Session::DEFAULT_WHERE= "field list";
107
107
 
108
108
uint64_t g_refresh_version = 1;
109
109
 
196
196
  mem_root(&impl_->mem_root),
197
197
  query(new std::string),
198
198
  scheduler(NULL),
199
 
  scheduler_arg(NULL),
200
199
  variables(impl_->variables),
201
200
  status_var(impl_->status_var),
202
201
  lock_id(&main_lock_id),
587
586
  disconnect();
588
587
}
589
588
 
590
 
bool Session::schedule(Session::shared_ptr &arg)
 
589
bool Session::schedule(const shared_ptr& arg)
591
590
{
592
591
  arg->scheduler= plugin::Scheduler::getScheduler();
593
592
  assert(arg->scheduler);
622
621
 
623
622
    /* Can't use my_error() since store_globals has not been called. */
624
623
    /* TODO replace will better error message */
625
 
    snprintf(error_message_buff, sizeof(error_message_buff),
626
 
             ER(ER_CANT_CREATE_THREAD), 1);
 
624
    snprintf(error_message_buff, sizeof(error_message_buff), ER(ER_CANT_CREATE_THREAD), 1);
627
625
    arg->client->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
628
 
 
629
626
    return true;
630
627
  }
631
 
 
632
628
  return false;
633
629
}
634
630
 
1024
1020
*/
1025
1021
 
1026
1022
 
1027
 
static int create_file(Session *session,
 
1023
static int create_file(Session& session,
1028
1024
                       fs::path &target_path,
1029
1025
                       file_exchange *exchange,
1030
1026
                       internal::io_cache_st *cache)
1031
1027
{
1032
1028
  fs::path to_file(exchange->file_name);
1033
 
  int file;
1034
1029
 
1035
1030
  if (not to_file.has_root_directory())
1036
1031
  {
1037
1032
    target_path= fs::system_complete(getDataHomeCatalog());
1038
 
    util::string::ptr schema(session->schema());
 
1033
    util::string::ptr schema(session.schema());
1039
1034
    if (not schema->empty())
1040
1035
    {
1041
1036
      int count_elements= 0;
1042
 
      for (fs::path::iterator iter= to_file.begin();
1043
 
           iter != to_file.end();
1044
 
           ++iter, ++count_elements)
1045
 
      { }
1046
 
 
 
1037
      for (fs::path::iterator it= to_file.begin(); it != to_file.end(); it++)
 
1038
        count_elements++;
1047
1039
      if (count_elements == 1)
1048
 
      {
1049
1040
        target_path /= *schema;
1050
 
      }
1051
1041
    }
1052
1042
    target_path /= to_file;
1053
1043
  }
1072
1062
    return -1;
1073
1063
  }
1074
1064
  /* Create the file world readable */
1075
 
  if ((file= internal::my_create(target_path.file_string().c_str(), 0666, O_WRONLY|O_EXCL, MYF(MY_WME))) < 0)
 
1065
  int file= internal::my_create(target_path.file_string().c_str(), 0666, O_WRONLY|O_EXCL, MYF(MY_WME));
 
1066
  if (file < 0)
1076
1067
    return file;
1077
1068
  (void) fchmod(file, 0666);                    // Because of umask()
1078
 
  if (cache->init_io_cache(file, 0L, internal::WRITE_CACHE, 0L, 1, MYF(MY_WME)))
 
1069
  if (cache->init_io_cache(file, 0, internal::WRITE_CACHE, 0L, 1, MYF(MY_WME)))
1079
1070
  {
1080
1071
    internal::my_close(file, MYF(0));
1081
1072
    internal::my_delete(target_path.file_string().c_str(), MYF(0));  // Delete file on error, it was just created
1142
1133
    return 1;
1143
1134
  }
1144
1135
 
1145
 
  if ((file= create_file(session, path, exchange, cache)) < 0)
 
1136
  if ((file= create_file(*session, path, exchange, cache)) < 0)
1146
1137
    return 1;
1147
1138
 
1148
1139
  return 0;
1346
1337
select_dump::prepare(List<Item> &, Select_Lex_Unit *u)
1347
1338
{
1348
1339
  unit= u;
1349
 
  return (int) ((file= create_file(session, path, exchange, cache)) < 0);
 
1340
  return (file= create_file(*session, path, exchange, cache)) < 0;
1350
1341
}
1351
1342
 
1352
1343