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 namespace drizzled 00023 { 00024 00031 class Diagnostics_area 00032 { 00033 public: 00034 enum enum_diagnostics_status 00035 { 00037 DA_EMPTY= 0, 00039 DA_OK, 00041 DA_EOF, 00043 DA_ERROR, 00045 DA_DISABLED 00046 }; 00048 bool is_sent; 00050 bool can_overwrite_status; 00051 00052 void set_ok_status(Session *session, ha_rows affected_rows_arg, 00053 ha_rows found_rows_arg, uint64_t last_insert_id_arg, 00054 const char *message); 00055 void set_eof_status(Session *session); 00056 void set_error_status(drizzled::error_t sql_errno_arg, const char *message_arg); 00057 00058 void disable_status(); 00059 00060 void reset_diagnostics_area(); 00061 00062 bool is_set() const { return m_status != DA_EMPTY; } 00063 bool is_error() const { return m_status == DA_ERROR; } 00064 bool is_eof() const { return m_status == DA_EOF; } 00065 bool is_ok() const { return m_status == DA_OK; } 00066 bool is_disabled() const { return m_status == DA_DISABLED; } 00067 enum_diagnostics_status status() const { return m_status; } 00068 00069 const char *message() const; 00070 drizzled::error_t sql_errno() const; 00071 uint32_t server_status() const; 00072 ha_rows affected_rows() const; 00073 ha_rows found_rows() const; 00074 uint64_t last_insert_id() const; 00075 uint32_t total_warn_count() const; 00076 00077 Diagnostics_area() { reset_diagnostics_area(); } 00078 00079 private: 00081 char m_message[DRIZZLE_ERRMSG_SIZE]; 00086 drizzled::error_t m_sql_errno; 00087 00096 uint32_t m_server_status; 00097 00109 ha_rows m_affected_rows; 00114 ha_rows m_found_rows; 00120 uint64_t m_last_insert_id; 00122 uint32_t m_total_warn_count; 00123 enum_diagnostics_status m_status; 00128 }; 00129 00130 } /* namespace drizzled */ 00131