~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_error.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
***********************************************************************/
43
43
 
44
 
#include "config.h"
 
44
#include <config.h>
45
45
 
46
46
#include <cstdio>
47
47
#include <stdarg.h>
91
91
    memset(session->warn_count, 0, sizeof(session->warn_count));
92
92
    if (force)
93
93
      session->total_warn_count= 0;
94
 
    session->warn_list.empty();
 
94
    session->warn_list.clear();
95
95
    session->row_count= 1; // by default point to row 1
96
96
  }
97
97
  return;
113
113
*/
114
114
 
115
115
DRIZZLE_ERROR *push_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
116
 
                          uint32_t code, const char *msg)
 
116
                            drizzled::error_t code, const char *msg)
117
117
{
118
118
  DRIZZLE_ERROR *err= 0;
119
119
 
120
 
  if (level == DRIZZLE_ERROR::WARN_LEVEL_NOTE &&
121
 
      !(session->options & OPTION_SQL_NOTES))
122
 
    return(0);
 
120
  if (level == DRIZZLE_ERROR::WARN_LEVEL_NOTE && !(session->options & OPTION_SQL_NOTES))
 
121
  {
 
122
    return NULL;
 
123
  }
123
124
 
124
125
  if (session->getQueryId() != session->getWarningQueryId())
125
126
    drizzle_reset_errors(session, 0);
127
128
 
128
129
  /* Abort if we are using strict mode and we are not using IGNORE */
129
130
  if ((int) level >= (int) DRIZZLE_ERROR::WARN_LEVEL_WARN &&
130
 
      session->really_abort_on_warning())
 
131
      session->abortOnWarning())
131
132
  {
132
133
    /* Avoid my_message() calling push_warning */
133
134
    bool no_warnings_for_error= session->no_warnings_for_error;
149
150
  {
150
151
    /* We have to use warn_root, as mem_root is freed after each query */
151
152
    if ((err= new (&session->warn_root) DRIZZLE_ERROR(session, code, level, msg)))
 
153
    {
152
154
      session->warn_list.push_back(err, &session->warn_root);
 
155
    }
153
156
  }
154
157
  session->warn_count[(uint32_t) level]++;
155
158
  session->total_warn_count++;
156
 
  return(err);
 
159
 
 
160
  return err;
157
161
}
158
162
 
159
163
/*
168
172
*/
169
173
 
170
174
void push_warning_printf(Session *session, DRIZZLE_ERROR::enum_warning_level level,
171
 
                         uint32_t code, const char *format, ...)
 
175
                         drizzled::error_t code, const char *format, ...)
172
176
{
173
177
  va_list args;
174
178
  char    warning[ERRMSGSIZE+20];
177
181
  vsnprintf(warning, sizeof(warning), format, args);
178
182
  va_end(args);
179
183
  push_warning(session, level, code, warning);
180
 
  return;
181
184
}
182
185
 
183
186
 
185
188
  Send all notes, errors or warnings to the client in a result set
186
189
 
187
190
  SYNOPSIS
188
 
    mysqld_show_warnings()
 
191
    show_warnings()
189
192
    session                     Thread handler
190
193
    levels_to_show      Bitmap for which levels to show
191
194
 
205
208
  { C_STRING_WITH_LEN("?") }
206
209
};
207
210
 
208
 
bool mysqld_show_warnings(Session *session,
209
 
                          bitset<DRIZZLE_ERROR::NUM_ERRORS> &levels_to_show)
 
211
bool show_warnings(Session *session,
 
212
                   bitset<DRIZZLE_ERROR::NUM_ERRORS> &levels_to_show)
210
213
{
211
214
  List<Item> field_list;
212
215
 
214
217
  field_list.push_back(new Item_return_int("Code",4, DRIZZLE_TYPE_LONG));
215
218
  field_list.push_back(new Item_empty_string("Message",DRIZZLE_ERRMSG_SIZE));
216
219
 
217
 
  if (session->client->sendFields(&field_list))
 
220
  if (session->getClient()->sendFields(&field_list))
218
221
    return true;
219
222
 
220
223
  DRIZZLE_ERROR *err;
221
 
  Select_Lex *sel= &session->lex->select_lex;
222
 
  Select_Lex_Unit *unit= &session->lex->unit;
 
224
  Select_Lex *sel= &session->getLex()->select_lex;
 
225
  Select_Lex_Unit *unit= &session->getLex()->unit;
223
226
  ha_rows idx= 0;
224
227
 
225
228
  unit->set_limit(sel);
226
229
 
227
 
  List_iterator_fast<DRIZZLE_ERROR> it(session->warn_list);
 
230
  List<DRIZZLE_ERROR>::iterator it(session->warn_list.begin());
228
231
  while ((err= it++))
229
232
  {
230
233
    /* Skip levels that the user is not interested in */
234
237
      continue;
235
238
    if (idx > unit->select_limit_cnt)
236
239
      break;
237
 
    session->client->store(warning_level_names[err->level].str,
238
 
                           warning_level_names[err->level].length);
239
 
    session->client->store((uint32_t) err->code);
240
 
    session->client->store(err->msg, strlen(err->msg));
241
 
    if (session->client->flush())
 
240
    session->getClient()->store(warning_level_names[err->level].str,
 
241
                                warning_level_names[err->level].length);
 
242
    session->getClient()->store((uint32_t) err->code);
 
243
    session->getClient()->store(err->msg, strlen(err->msg));
 
244
    if (session->getClient()->flush())
242
245
      return(true);
243
246
  }
244
247
  session->my_eof();