~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error.cc

  • Committer: Brian Aker
  • Date: 2011-02-12 06:13:32 UTC
  • mto: This revision was merged to the branch mainline in revision 2161.
  • Revision ID: brian@tangent.org-20110212061332-a5dtetim82r6vvls
Merge in session up and out of sql_select.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 * Errors a drizzled can give you
23
23
 */
24
24
 
25
 
#include <config.h>
26
 
#include <drizzled/internal/my_sys.h>
27
 
#include <drizzled/definitions.h>
28
 
#include <drizzled/error.h>
29
 
#include <drizzled/gettext.h>
 
25
#include "config.h"
 
26
#include "drizzled/internal/my_sys.h"
 
27
#include "drizzled/definitions.h"
 
28
#include "drizzled/error.h"
 
29
#include "drizzled/gettext.h"
30
30
 
31
 
#include <drizzled/identifier.h>
 
31
#include "drizzled/identifier.h"
32
32
 
33
33
#include <boost/unordered_map.hpp>
34
34
#include <exception>
79
79
 
80
80
error_handler_func error_handler_hook= NULL;
81
81
 
82
 
namespace error {
83
 
 
84
 
void access(drizzled::identifier::User::const_reference user)
85
 
{
86
 
  std::string user_string;
87
 
  user.getSQLPath(user_string);
88
 
 
89
 
  my_error(ER_ACCESS_DENIED_ERROR, MYF(0), user_string.c_str(),
90
 
           user.hasPassword() ? ER(ER_YES) : ER(ER_NO));
91
 
92
 
 
93
 
void access(drizzled::identifier::User::const_reference user, drizzled::identifier::Schema::const_reference schema)
94
 
{
95
 
  std::string user_string;
96
 
  user.getSQLPath(user_string);
97
 
 
98
 
  std::string schema_string;
99
 
  schema.getSQLPath(schema_string);
100
 
 
101
 
  my_error(ER_DBACCESS_DENIED_ERROR, MYF(0), user_string.c_str(), schema_string.c_str());
102
 
103
 
 
104
 
void access(drizzled::identifier::User::const_reference user, drizzled::identifier::Table::const_reference table)
105
 
{
106
 
  std::string user_string;
107
 
  user.getSQLPath(user_string);
108
 
 
109
 
  std::string table_string;
110
 
  table.getSQLPath(table_string);
111
 
 
112
 
  my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0), user_string.c_str(), table_string.c_str());
113
 
114
 
 
115
 
static error::level_t _verbosity= error::ERROR;
116
 
static std::string _verbosity_strint;
117
 
 
118
 
const std::string &verbose_string()
119
 
{
120
 
  switch (_verbosity)
121
 
  {
122
 
  case error::INSPECT:
123
 
    {
124
 
      static std::string _arg= "INSPECT";
125
 
      return _arg;
126
 
    }
127
 
  case error::INFO:
128
 
    {
129
 
      static std::string _arg= "INFO";
130
 
      return _arg;
131
 
    }
132
 
  case error::WARN:
133
 
    {
134
 
      static std::string _arg= "WARN";
135
 
      return _arg;
136
 
    }
137
 
  case error::ERROR:
138
 
    {
139
 
      static std::string _arg= "ERROR";
140
 
      return _arg;
141
 
    }
142
 
  }
143
 
 
144
 
  abort();
145
 
}
146
 
 
147
 
error::level_t &verbosity()
148
 
{
149
 
  return _verbosity;
150
 
}
151
 
 
152
 
void check_verbosity(const std::string &arg)
153
 
{
154
 
  if (not arg.compare("INSPECT"))
155
 
  {
156
 
    _verbosity= error::INSPECT;
157
 
  }
158
 
  else if (not arg.compare("INFO"))
159
 
  {
160
 
    _verbosity= error::INFO;
161
 
  }
162
 
  else if (not arg.compare("WARN"))
163
 
  {
164
 
    _verbosity= error::WARN;
165
 
  }
166
 
  else if (not arg.compare("ERROR"))
167
 
  {
168
 
    _verbosity= error::ERROR;
169
 
  }
170
 
}
171
 
 
172
 
} // namespace error
173
 
 
174
82
/*
175
83
  WARNING!
176
84
  my_error family functions have to be used according following rules:
338
246
  ADD_ERROR_MESSAGE(ER_OUT_OF_RESOURCES, N_("Out of memory; check if drizzled or some other process uses all available memory; if not, you may have to use 'ulimit' to allow drizzled to use more memory or you can add more swap space"));
339
247
  ADD_ERROR_MESSAGE(ER_BAD_HOST_ERROR, N_("Can't get hostname for your address"));
340
248
  ADD_ERROR_MESSAGE(ER_HANDSHAKE_ERROR, N_("Bad handshake"));
341
 
 
342
 
  // Access error messages
343
 
  ADD_ERROR_MESSAGE(ER_DBACCESS_DENIED_ERROR, N_("Access denied for user '%s' to schema '%s'"));
344
 
  ADD_ERROR_MESSAGE(ER_TABLEACCESS_DENIED_ERROR, N_("Access denied for user '%s' to table '%s'"));
345
 
  ADD_ERROR_MESSAGE(ER_ACCESS_DENIED_ERROR, N_("Access denied for user '%s' (using password: %s)"));
346
 
 
 
249
  ADD_ERROR_MESSAGE(ER_DBACCESS_DENIED_ERROR, N_("Access denied for user '%-.48s'@'%-.64s' to schema '%-.192s'"));
 
250
  ADD_ERROR_MESSAGE(ER_ACCESS_DENIED_ERROR, N_("Access denied for user '%-.48s'@'%-.64s' (using password: %s)"));
347
251
  ADD_ERROR_MESSAGE(ER_NO_DB_ERROR, N_("No schema selected"));
348
252
  ADD_ERROR_MESSAGE(ER_UNKNOWN_COM_ERROR, N_("Unknown command"));
349
253
  ADD_ERROR_MESSAGE(ER_BAD_NULL_ERROR, N_("Column '%-.192s' cannot be null"));