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 #pragma once 00021 00022 #include <drizzled/base.h> 00023 #include <drizzled/error_t.h> 00024 #include <drizzled/sql_error.h> 00025 #include <drizzled/sql_list.h> 00026 00027 namespace drizzled { 00028 00035 class Diagnostics_area 00036 { 00037 public: 00038 enum enum_diagnostics_status 00039 { 00041 DA_EMPTY= 0, 00043 DA_OK, 00045 DA_EOF, 00047 DA_ERROR, 00049 DA_DISABLED 00050 }; 00052 bool is_sent; 00054 bool can_overwrite_status; 00055 00056 void set_ok_status(Session *session, ha_rows affected_rows_arg, 00057 ha_rows found_rows_arg, uint64_t last_insert_id_arg, 00058 const char *message); 00059 void set_eof_status(Session *session); 00060 void set_error_status(drizzled::error_t sql_errno_arg, const char *message_arg); 00061 00062 void disable_status(); 00063 00064 void reset_diagnostics_area(); 00065 00066 bool is_set() const { return m_status != DA_EMPTY; } 00067 bool is_error() const { return m_status == DA_ERROR; } 00068 bool is_eof() const { return m_status == DA_EOF; } 00069 bool is_ok() const { return m_status == DA_OK; } 00070 bool is_disabled() const { return m_status == DA_DISABLED; } 00071 enum_diagnostics_status status() const { return m_status; } 00072 00073 const char *message() const; 00074 drizzled::error_t sql_errno() const; 00075 uint32_t server_status() const; 00076 ha_rows affected_rows() const; 00077 ha_rows found_rows() const; 00078 uint64_t last_insert_id() const; 00079 uint32_t total_warn_count() const; 00080 00081 std::list<DRIZZLE_ERROR*> m_warn_list; 00082 00083 Diagnostics_area() { reset_diagnostics_area(); } 00084 00085 private: 00087 char m_message[DRIZZLE_ERRMSG_SIZE]; 00092 drizzled::error_t m_sql_errno; 00093 00102 uint32_t m_server_status; 00103 00115 ha_rows m_affected_rows; 00120 ha_rows m_found_rows; 00126 uint64_t m_last_insert_id; 00128 uint32_t m_total_warn_count; 00129 enum_diagnostics_status m_status; 00134 }; 00135 00136 } /* namespace drizzled */ 00137