~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_error.cc

  • Committer: Brian Aker
  • Date: 2009-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
***********************************************************************/
43
43
 
44
 
#include "config.h"
45
 
 
46
 
#include <stdarg.h>
47
 
 
 
44
#include <drizzled/server_includes.h>
48
45
#include <drizzled/session.h>
49
46
#include <drizzled/sql_base.h>
50
47
#include <drizzled/item/empty_string.h>
51
48
#include <drizzled/item/return_int.h>
52
 
#include <drizzled/plugin/client.h>
53
 
 
54
 
using namespace std;
55
 
 
56
 
namespace drizzled
57
 
{
58
49
 
59
50
/*
60
51
  Store a new message in an error object
83
74
 
84
75
void drizzle_reset_errors(Session *session, bool force)
85
76
{
86
 
  if (session->getQueryId() != session->getWarningQueryId() || force)
 
77
  if (session->query_id != session->warn_id || force)
87
78
  {
88
 
    session->setWarningQueryId(session->getQueryId());
 
79
    session->warn_id= session->query_id;
89
80
    free_root(&session->warn_root,MYF(0));
90
81
    memset(session->warn_count, 0, sizeof(session->warn_count));
91
82
    if (force)
120
111
      !(session->options & OPTION_SQL_NOTES))
121
112
    return(0);
122
113
 
123
 
  if (session->getQueryId() != session->getWarningQueryId())
 
114
  if (session->query_id != session->warn_id)
124
115
    drizzle_reset_errors(session, 0);
125
116
  session->got_warning= 1;
126
117
 
142
133
  }
143
134
 
144
135
  if (session->handle_error(code, msg, level))
145
 
    return NULL;
 
136
    return(NULL);
146
137
 
147
138
  if (session->warn_list.elements < session->variables.max_error_count)
148
139
  {
150
141
    if ((err= new (&session->warn_root) DRIZZLE_ERROR(session, code, level, msg)))
151
142
      session->warn_list.push_back(err, &session->warn_root);
152
143
  }
153
 
  session->warn_count[(uint32_t) level]++;
 
144
  session->warn_count[(uint) level]++;
154
145
  session->total_warn_count++;
155
146
  return(err);
156
147
}
204
195
  { C_STRING_WITH_LEN("?") }
205
196
};
206
197
 
207
 
bool mysqld_show_warnings(Session *session,
208
 
                          bitset<DRIZZLE_ERROR::NUM_ERRORS> &levels_to_show)
 
198
bool mysqld_show_warnings(Session *session, uint32_t levels_to_show)
209
199
{
210
200
  List<Item> field_list;
211
201
 
213
203
  field_list.push_back(new Item_return_int("Code",4, DRIZZLE_TYPE_LONG));
214
204
  field_list.push_back(new Item_empty_string("Message",DRIZZLE_ERRMSG_SIZE));
215
205
 
216
 
  if (session->client->sendFields(&field_list))
217
 
    return true;
 
206
  if (session->protocol->send_fields(&field_list,
 
207
                                 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
 
208
    return(true);
218
209
 
219
210
  DRIZZLE_ERROR *err;
220
 
  Select_Lex *sel= &session->lex->select_lex;
221
 
  Select_Lex_Unit *unit= &session->lex->unit;
 
211
  SELECT_LEX *sel= &session->lex->select_lex;
 
212
  SELECT_LEX_UNIT *unit= &session->lex->unit;
222
213
  ha_rows idx= 0;
 
214
  Protocol *protocol=session->protocol;
223
215
 
224
216
  unit->set_limit(sel);
225
217
 
227
219
  while ((err= it++))
228
220
  {
229
221
    /* Skip levels that the user is not interested in */
230
 
    if (! levels_to_show.test(err->level))
 
222
    if (!(levels_to_show & ((ulong) 1 << err->level)))
231
223
      continue;
232
224
    if (++idx <= unit->offset_limit_cnt)
233
225
      continue;
234
226
    if (idx > unit->select_limit_cnt)
235
227
      break;
236
 
    session->client->store(warning_level_names[err->level].str,
237
 
                           warning_level_names[err->level].length);
238
 
    session->client->store((uint32_t) err->code);
239
 
    session->client->store(err->msg, strlen(err->msg));
240
 
    if (session->client->flush())
 
228
    protocol->prepare_for_resend();
 
229
    protocol->store(warning_level_names[err->level].str,
 
230
                    warning_level_names[err->level].length, system_charset_info);
 
231
    protocol->store((uint32_t) err->code);
 
232
    protocol->store(err->msg, strlen(err->msg), system_charset_info);
 
233
    if (protocol->write())
241
234
      return(true);
242
235
  }
243
 
  session->my_eof();
 
236
  my_eof(session);
244
237
  return(false);
245
238
}
246
 
 
247
 
} /* namespace drizzled */