Drizzled Public API Documentation

errors.cc
1 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2010 Monty Taylor
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; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <config.h>
22 
23 #include <plugin/error_dictionary/errors.h>
24 #include <drizzled/error/sql_state.h>
25 
26 namespace drizzle_plugin
27 {
28 
29 error_dictionary::Errors::Errors() :
30  drizzled::plugin::TableFunction("DATA_DICTIONARY", "ERRORS")
31 {
32  add_field("ERROR_CODE", drizzled::plugin::TableFunction::NUMBER);
33  add_field("ERROR_NAME");
34  add_field("ERROR_MESSAGE");
35  add_field("ERROR_SQL_STATE");
36 }
37 
38 error_dictionary::Errors::Generator::Generator(drizzled::Field **arg) :
39  drizzled::plugin::TableFunction::Generator(arg),
40  _error_map(drizzled::ErrorMap::get_error_message_map()),
41  _iter(drizzled::ErrorMap::get_error_message_map().begin())
42 { }
43 
44 bool error_dictionary::Errors::Generator::populate()
45 {
46  if (_iter == _error_map.end())
47  return false;
48 
49  push(uint64_t((*_iter).first));
50  push((*_iter).second.first);
51  push((*_iter).second.second);
52  push(drizzled::error::convert_to_sqlstate((*_iter).first));
53 
54  ++_iter;
55 
56  return true;
57 }
58 
59 }