~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_error.cc

  • Committer: Brian Aker
  • Date: 2008-07-10 19:37:55 UTC
  • mfrom: (51.1.67 remove-dbug)
  • Revision ID: brian@tangent.org-20080710193755-f5g761uieqa3wxmt
Merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
  This is used to in group_concat() to register how many warnings we actually
50
50
  got after the query has been executed.
51
51
*/
52
 
 
53
52
void MYSQL_ERROR::set_msg(THD *thd, const char *msg_arg)
54
53
{
55
54
  msg= strdup_root(&thd->warn_root, msg_arg);
56
55
}
57
56
 
58
 
 
59
57
/*
60
58
  Reset all warnings for the thread
61
59
 
72
70
 
73
71
void mysql_reset_errors(THD *thd, bool force)
74
72
{
75
 
  DBUG_ENTER("mysql_reset_errors");
76
73
  if (thd->query_id != thd->warn_id || force)
77
74
  {
78
75
    thd->warn_id= thd->query_id;
83
80
    thd->warn_list.empty();
84
81
    thd->row_count= 1; // by default point to row 1
85
82
  }
86
 
  DBUG_VOID_RETURN;
 
83
  return;
87
84
}
88
85
 
89
86
 
105
102
                          uint code, const char *msg)
106
103
{
107
104
  MYSQL_ERROR *err= 0;
108
 
  DBUG_ENTER("push_warning");
109
 
  DBUG_PRINT("enter", ("code: %d, msg: %s", code, msg));
110
105
 
111
106
  if (level == MYSQL_ERROR::WARN_LEVEL_NOTE &&
112
107
      !(thd->options & OPTION_SQL_NOTES))
113
 
    DBUG_RETURN(0);
 
108
    return(0);
114
109
 
115
110
  if (thd->query_id != thd->warn_id)
116
111
    mysql_reset_errors(thd, 0);
134
129
  }
135
130
 
136
131
  if (thd->handle_error(code, msg, level))
137
 
    DBUG_RETURN(NULL);
 
132
    return(NULL);
138
133
 
139
134
  if (thd->warn_list.elements < thd->variables.max_error_count)
140
135
  {
144
139
  }
145
140
  thd->warn_count[(uint) level]++;
146
141
  thd->total_warn_count++;
147
 
  DBUG_RETURN(err);
 
142
  return(err);
148
143
}
149
144
 
150
145
/*
163
158
{
164
159
  va_list args;
165
160
  char    warning[ERRMSGSIZE+20];
166
 
  DBUG_ENTER("push_warning_printf");
167
 
  DBUG_PRINT("enter",("warning: %u", code));
168
161
  
169
162
  va_start(args,format);
170
163
  vsnprintf(warning, sizeof(warning), format, args);
171
164
  va_end(args);
172
165
  push_warning(thd, level, code, warning);
173
 
  DBUG_VOID_RETURN;
 
166
  return;
174
167
}
175
168
 
176
169
 
186
179
    Takes into account the current LIMIT
187
180
 
188
181
  RETURN VALUES
189
 
    FALSE ok
190
 
    TRUE  Error sending data to client
 
182
    false ok
 
183
    true  Error sending data to client
191
184
*/
192
185
 
193
186
const LEX_STRING warning_level_names[]=
201
194
bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
202
195
{  
203
196
  List<Item> field_list;
204
 
  DBUG_ENTER("mysqld_show_warnings");
205
197
 
206
198
  field_list.push_back(new Item_empty_string("Level", 7));
207
199
  field_list.push_back(new Item_return_int("Code",4, MYSQL_TYPE_LONG));
209
201
 
210
202
  if (thd->protocol->send_fields(&field_list,
211
203
                                 Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
212
 
    DBUG_RETURN(TRUE);
 
204
    return(true);
213
205
 
214
206
  MYSQL_ERROR *err;
215
207
  SELECT_LEX *sel= &thd->lex->select_lex;
235
227
    protocol->store((uint32) err->code);
236
228
    protocol->store(err->msg, strlen(err->msg), system_charset_info);
237
229
    if (protocol->write())
238
 
      DBUG_RETURN(TRUE);
 
230
      return(true);
239
231
  }
240
232
  my_eof(thd);
241
 
  DBUG_RETURN(FALSE);
 
233
  return(false);
242
234
}