Drizzled Public API Documentation

sql_error.h
00001 /* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2008 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 
00021 
00022 #pragma once
00023 
00024 #include <drizzled/memory/sql_alloc.h>
00025 #include <drizzled/lex_string.h>
00026 
00027 #include <drizzled/error_t.h>
00028 
00029 #include <bitset>
00030 
00031 #include <drizzled/visibility.h>
00032 
00033 namespace drizzled
00034 {
00035 
00036 class DRIZZLE_ERROR: public memory::SqlAlloc
00037 {
00038 public:
00039   static const uint32_t NUM_ERRORS= 4;
00040   enum enum_warning_level {
00041     WARN_LEVEL_NOTE,
00042     WARN_LEVEL_WARN,
00043     WARN_LEVEL_ERROR,
00044     WARN_LEVEL_END
00045   };
00046 
00047   drizzled::error_t code;
00048   enum_warning_level level;
00049   char *msg;
00050 
00051   DRIZZLE_ERROR(Session *session,
00052                 drizzled::error_t code_arg,
00053                 enum_warning_level level_arg,
00054                 const char *msg_arg) :
00055     code(code_arg),
00056     level(level_arg)
00057   {
00058     if (msg_arg)
00059       set_msg(session, msg_arg);
00060   }
00061 
00062   void set_msg(Session *session, const char *msg_arg);
00063 };
00064 
00065 DRIZZLED_API DRIZZLE_ERROR *push_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
00066                             drizzled::error_t code, const char *msg);
00067 
00068 DRIZZLED_API void push_warning_printf(Session *session, DRIZZLE_ERROR::enum_warning_level level,
00069                          drizzled::error_t code, const char *format, ...);
00070 
00071 void drizzle_reset_errors(Session *session, bool force);
00072 bool show_warnings(Session *session, 
00073                    std::bitset<DRIZZLE_ERROR::NUM_ERRORS> &levels_to_show);
00074 
00075 extern const LEX_STRING warning_level_names[];
00076 
00077 } /* namespace drizzled */
00078