~jaypipes/drizzle/xa-transaction-log

« back to all changes in this revision

Viewing changes to drizzled/db.cc

  • Committer: Jay Pipes
  • Date: 2010-03-05 18:24:28 UTC
  • mfrom: (1273.1.51 staging)
  • Revision ID: jpipes@serialcoder-20100305182428-9m16fszbs3mvdhe0
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <drizzled/message/schema.pb.h>
40
40
#include "drizzled/sql_table.h"
41
41
#include "drizzled/plugin/storage_engine.h"
 
42
#include "drizzled/plugin/authorization.h"
42
43
#include "drizzled/global_charset_info.h"
43
44
#include "drizzled/pthread_globals.h"
44
45
#include "drizzled/charset.h"
604
605
 
605
606
bool mysql_change_db(Session *session, const std::string &new_db_name)
606
607
{
607
 
  LEX_STRING new_db_file_name;
608
 
  const CHARSET_INFO *db_default_cl;
609
608
 
610
609
  assert(not new_db_name.empty());
611
610
 
 
611
  if (not plugin::Authorization::isAuthorized(session->getSecurityContext(),
 
612
                                              new_db_name))
 
613
  {
 
614
    /* Error message is set in isAuthorized */
 
615
    return true;
 
616
  }
 
617
 
 
618
 
612
619
  /*
613
620
    Now we need to make a copy because check_db_name requires a
614
621
    non-constant argument. Actually, it takes database file name.
616
623
    TODO: fix check_db_name().
617
624
  */
618
625
 
 
626
  LEX_STRING new_db_file_name;
619
627
  new_db_file_name.length= new_db_name.length();
620
628
  new_db_file_name.str= (char *)malloc(new_db_name.length() + 1);
621
629
  if (new_db_file_name.str == NULL)
653
661
    return true;
654
662
  }
655
663
 
656
 
  db_default_cl= plugin::StorageEngine::getSchemaCollation(new_db_file_name.str);
657
 
 
658
664
  mysql_change_db_impl(session, &new_db_file_name);
659
665
  free(new_db_file_name.str);
660
666