~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/error.cc

  • Committer: Brian Aker
  • Date: 2011-02-04 23:02:48 UTC
  • mto: (2147.3.1 alter-table)
  • mto: This revision was merged to the branch mainline in revision 2148.
  • Revision ID: brian@tangent.org-20110204230248-fuub99d2y6gh514c
Remove current_session in building the error count.

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"));
426
330
  ADD_ERROR_MESSAGE(ER_WRONG_VALUE_COUNT_ON_ROW, N_("Column count doesn't match value count at row %ld"));
427
331
  ADD_ERROR_MESSAGE(ER_CANT_REOPEN_TABLE, N_("Can't reopen table: '%-.192s'"));
428
332
  ADD_ERROR_MESSAGE(ER_MIX_OF_GROUP_FUNC_AND_FIELDS, N_("Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause"));
 
333
  ADD_ERROR_MESSAGE(ER_NO_SUCH_TABLE, N_("Table '%-.192s.%-.192s' doesn't exist"));
429
334
  ADD_ERROR_MESSAGE(ER_SYNTAX_ERROR, N_("You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use"));
430
335
  ADD_ERROR_MESSAGE(ER_NET_PACKET_TOO_LARGE, N_("Got a packet bigger than 'max_allowed_packet' bytes"));
431
336
  ADD_ERROR_MESSAGE(ER_NET_PACKETS_OUT_OF_ORDER, N_("Got packets out of order"));
599
504
  ADD_ERROR_MESSAGE(ER_USE_SQL_BIG_RESULT, N_("Temporary table too large, rerun with SQL_BIG_RESULT."));
600
505
  ADD_ERROR_MESSAGE(ER_UNKNOWN_ENGINE_OPTION, N_("Unknown table engine option key/pair %s = %s."));
601
506
  ADD_ERROR_MESSAGE(ER_UNKNOWN_SCHEMA_OPTION, N_("Unknown schema engine option key/pair %s = %s."));
602
 
  ADD_ERROR_MESSAGE(ER_CARTESIAN_JOIN_ATTEMPTED, N_("Implicit cartesian join attempted."));
 
507
 
603
508
  ADD_ERROR_MESSAGE(ER_ADMIN_ACCESS, N_("Admin access not allowed from this username/IP address."));
604
509
 
605
510
  // User lock/barrier error messages
676
581
  ADD_ERROR_MESSAGE(ER_CORRUPT_CATALOG_DEFINITION, N_("Corrupt or invalid catalog definition for '%s' : '%s'."));
677
582
  ADD_ERROR_MESSAGE(ER_WRONG_NAME_FOR_CATALOG, N_("Invalid catalog name."));
678
583
  ADD_ERROR_MESSAGE(ER_USE_DATA_DICTIONARY, N_("Engine status is now stored in the data_dictionary tables, please use these instead."));
679
 
  ADD_ERROR_MESSAGE(ER_TRANSACTION_ALREADY_STARTED, N_("There is already a transaction in progress"));
680
584
 
681
585
}
682
586