~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/db.cc

  • Committer: Brian Aker
  • Date: 2010-02-20 14:06:29 UTC
  • mto: (1273.19.18 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1309.
  • Revision ID: brian@gir.tangent.org-20100220140629-frivcnrrqk2h7nzb
Fixing charset return.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <drizzled/replication_services.h>
39
39
#include <drizzled/message/schema.pb.h>
40
40
#include "drizzled/sql_table.h"
 
41
#include "drizzled/plugin/storage_engine.h"
41
42
#include "drizzled/plugin/info_schema_table.h"
42
43
#include "drizzled/global_charset_info.h"
43
44
#include "drizzled/pthread_globals.h"
62
63
                                 TableList **dropped_tables);
63
64
static void mysql_change_db_impl(Session *session, LEX_STRING *new_db_name);
64
65
 
65
 
/**
66
 
  Return default database collation.
67
 
 
68
 
  @param session     Thread context.
69
 
  @param db_name Database name.
70
 
 
71
 
  @return CHARSET_INFO object. The operation always return valid character
72
 
    set, even if the database does not exist.
73
 
*/
74
 
 
75
 
const CHARSET_INFO *get_default_db_collation(const char *db_name)
76
 
{
77
 
  message::Schema db;
78
 
 
79
 
  get_database_metadata(db_name, db);
80
 
 
81
 
  /* If for some reason the db.opt file lacks a collation,
82
 
     we just return the default */
83
 
 
84
 
  if (db.has_collation())
85
 
  {
86
 
    const string buffer= db.collation();
87
 
    const CHARSET_INFO* cs= get_charset_by_name(buffer.c_str());
88
 
 
89
 
    if (!cs)
90
 
    {
91
 
      errmsg_printf(ERRMSG_LVL_ERROR,
92
 
                    _("Error while loading database options: '%s':"),db_name);
93
 
      errmsg_printf(ERRMSG_LVL_ERROR, ER(ER_UNKNOWN_COLLATION), buffer.c_str());
94
 
 
95
 
      return default_charset_info;
96
 
    }
97
 
 
98
 
    return cs;
99
 
  }
100
 
 
101
 
  return default_charset_info;
102
 
}
103
 
 
104
66
/* path is path to database, not schema file */
105
67
static int write_schema_file(const char *path, const message::Schema &db)
106
68
{
907
869
    }
908
870
  }
909
871
 
910
 
  db_default_cl= get_default_db_collation(new_db_file_name.str);
 
872
  db_default_cl= plugin::StorageEngine::getSchemaCollation(new_db_file_name.str);
911
873
 
912
874
  mysql_change_db_impl(session, &new_db_file_name);
913
875
  free(new_db_file_name.str);