~drizzle-trunk/drizzle/development

575.4.6 by Monty Taylor
Removed my_getwd.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
20
1122.2.10 by Monty Taylor
Fixed all of the include guards.
21
#ifndef DRIZZLED_DB_H
22
#define DRIZZLED_DB_H
575.4.6 by Monty Taylor
Removed my_getwd.
23
1089.10.1 by Stewart Smith
fix SHOW CREATE DATABASE for default collation. Move database metadata reading code around to be a bit more sane.
24
namespace drizzled { namespace message { class Schema; } }
25
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
26
class NormalisedDatabaseName;
27
1235.4.14 by Stewart Smith
use message::Schema in mysql_create_db instead of HA_CREATE_INFO
28
bool mysql_create_db(Session *session, const NormalisedDatabaseName &database_name, drizzled::message::Schema *schema_message, bool is_if_not_exists);
1235.4.16 by Stewart Smith
use Schema proto for ALTER DATABASE/SCHEMA as well. Fix 'ALTER DATABASE COLLATE = foo'. Remove now obsolete fill_schema_message. HA_CREATE_INFO is no longer used in CREATE or ALTER SCHEMA.
29
bool mysql_alter_db(Session *session, const NormalisedDatabaseName &database_name, drizzled::message::Schema *schema_message);
1235.4.3 by Stewart Smith
make DROP DATABASE/DROP SCHEMA use NormalisedDatabaseName instead of check_db_name()
30
bool mysql_rm_db(Session *session, const NormalisedDatabaseName &database_name, bool if_exists);
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
31
bool mysql_change_db(Session *session, const NormalisedDatabaseName &new_db_name, bool force_switch);
575.4.6 by Monty Taylor
Removed my_getwd.
32
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
33
bool check_db_dir_existence(const char *db_name);
1089.10.1 by Stewart Smith
fix SHOW CREATE DATABASE for default collation. Move database metadata reading code around to be a bit more sane.
34
int get_database_metadata(const char *dbname, drizzled::message::Schema *db);
35
1014.3.1 by Brian Aker
Simplify the calling stack for getting schema collation. We need to extend
36
const CHARSET_INFO *get_default_db_collation(const char *db_name);
811.1.2 by Stewart Smith
remove existing db.opt implementation.
37
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
38
class NonNormalisedDatabaseName
39
{
40
private:
41
  std::string database_name;
42
43
  /* Copying a NonNormalisedDatabaseName is always wrong, it's
44
     immutable and should be passed by reference */
45
  NonNormalisedDatabaseName(const NonNormalisedDatabaseName&);
46
1235.4.4 by Stewart Smith
add more protection from misuse to NormalisedDatabaseName and NonNormalisedDatabaseName
47
  NonNormalisedDatabaseName operator=(const NonNormalisedDatabaseName&);
48
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
49
public:
1235.4.4 by Stewart Smith
add more protection from misuse to NormalisedDatabaseName and NonNormalisedDatabaseName
50
  explicit NonNormalisedDatabaseName(const std::string db) :
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
51
    database_name(db)
1235.4.24 by Stewart Smith
small style fix
52
  {
53
  }
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
54
55
  const std::string &to_string(void) const
1235.4.24 by Stewart Smith
small style fix
56
  {
57
    return database_name;
58
  }
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
59
};
60
61
class NormalisedDatabaseName
62
{
63
private:
64
  char* database_name;
65
66
  /* Copying a NormalisedDatabaseName is always wrong, it's
67
     immutable and should be passed by reference */
68
  NormalisedDatabaseName(const NormalisedDatabaseName&);
1235.4.4 by Stewart Smith
add more protection from misuse to NormalisedDatabaseName and NonNormalisedDatabaseName
69
  NormalisedDatabaseName operator=(const NormalisedDatabaseName&);
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
70
71
public:
1235.4.4 by Stewart Smith
add more protection from misuse to NormalisedDatabaseName and NonNormalisedDatabaseName
72
  explicit NormalisedDatabaseName(const NonNormalisedDatabaseName &dbname);
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
73
74
  ~NormalisedDatabaseName();
75
76
  const std::string to_string() const
1235.4.24 by Stewart Smith
small style fix
77
  {
78
    std::string tmp(database_name);
79
    return tmp;
80
  }
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
81
1235.4.25 by Stewart Smith
for NormalisedDatabaseName s/is_valid/isValid/ to conform to style guide.
82
  bool isValid() const;
1235.4.2 by Stewart Smith
start using a set of classes for database names, enforcing type safety when converting from what user entered to a normalised form.
83
};
84
1235.4.18 by Stewart Smith
replace check_db_dir_existence() with class DatabasePathName and a ::exists() method.
85
class DatabasePathName
86
{
87
private:
88
  std::string database_path;
1235.4.20 by Stewart Smith
add some extra protection to DatabasePathName.
89
90
  /* Copying a DatabasePathName is always wrong, it's
91
     immutable and should be passed by reference. */
92
  DatabasePathName(const DatabasePathName&);
93
  DatabasePathName operator=(const DatabasePathName&);
94
1235.4.18 by Stewart Smith
replace check_db_dir_existence() with class DatabasePathName and a ::exists() method.
95
public:
96
  explicit DatabasePathName(const NormalisedDatabaseName &database_name);
97
98
  const std::string to_string() const
1235.4.24 by Stewart Smith
small style fix
99
  {
100
    return database_path;
101
  }
1235.4.18 by Stewart Smith
replace check_db_dir_existence() with class DatabasePathName and a ::exists() method.
102
103
  bool exists() const;
104
};
105
1122.2.10 by Monty Taylor
Fixed all of the include guards.
106
#endif /* DRIZZLED_DB_H */