~ubuntu-branches/ubuntu/lucid/mysql-dfsg-5.1/lucid-security

« back to all changes in this revision

Viewing changes to sql/rpl_record.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 22:33:55 UTC
  • mto: (1.2.1) (37.1.1 lucid-security)
  • mto: This revision was merged to the branch mainline in revision 36.
  • Revision ID: package-import@ubuntu.com-20120222223355-ku1tb4r70osci6v2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2007 MySQL AB. All rights reserved.
 
1
/*
 
2
   Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
2
3
 
3
4
   This program is free software; you can redistribute it and/or modify
4
5
   it under the terms of the GNU General Public License as published by
11
12
 
12
13
   You should have received a copy of the GNU General Public License
13
14
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
16
*/
15
17
 
16
18
#include "mysql_priv.h"
17
19
#include "rpl_rli.h"
224
226
      /* Field...::unpack() cannot return 0 */
225
227
      DBUG_ASSERT(pack_ptr != NULL);
226
228
 
227
 
      if ((null_bits & null_mask) && f->maybe_null())
228
 
        f->set_null();
 
229
      if (null_bits & null_mask)
 
230
      {
 
231
        if (f->maybe_null())
 
232
        {
 
233
          DBUG_PRINT("debug", ("Was NULL; null mask: 0x%x; null bits: 0x%x",
 
234
                               null_mask, null_bits));
 
235
          /** 
 
236
            Calling reset just in case one is unpacking on top a 
 
237
            record with data. 
 
238
 
 
239
            This could probably go into set_null() but doing so, 
 
240
            (i) triggers assertion in other parts of the code at 
 
241
            the moment; (ii) it would make us reset the field,
 
242
            always when setting null, which right now doesn't seem 
 
243
            needed anywhere else except here.
 
244
 
 
245
            TODO: maybe in the future we should consider moving 
 
246
                  the reset to make it part of set_null. But then
 
247
                  the assertions triggered need to be 
 
248
                  addressed/revisited.
 
249
           */
 
250
          f->reset();
 
251
          f->set_null();
 
252
        }
 
253
        else
 
254
        {
 
255
          f->set_default();
 
256
          push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
 
257
                              ER_BAD_NULL_ERROR, ER(ER_BAD_NULL_ERROR),
 
258
                              f->field_name);
 
259
        }
 
260
      }
229
261
      else
230
262
      {
231
263
        f->set_notnull();
305
337
  @param table  Table whose record[0] buffer is prepared. 
306
338
  @param skip   Number of columns for which default/nullable check 
307
339
                should be skipped.
308
 
  @param check  Indicates if errors should be raised when checking 
309
 
                default/nullable field properties.
310
 
                
 
340
  @param check  Specifies if lack of default error needs checking.
 
341
 
311
342
  @returns 0 on success or a handler level error code
312
343
 */ 
313
 
int prepare_record(TABLE *const table, 
314
 
                   const uint skip, const bool check)
 
344
int prepare_record(TABLE *const table, const uint skip, const bool check)
315
345
{
316
346
  DBUG_ENTER("prepare_record");
317
347
 
318
 
  int error= 0;
319
348
  restore_record(table, s->default_values);
320
349
 
321
350
  /*
326
355
  if (skip >= table->s->fields || !check)
327
356
    DBUG_RETURN(0);
328
357
 
329
 
  /* Checking if exists default/nullable fields in the default values. */
330
 
 
331
 
  for (Field **field_ptr= table->field+skip ; *field_ptr ; ++field_ptr)
 
358
  /*
 
359
    For fields the extra fields on the slave, we check if they have a default.
 
360
    The check follows the same rules as the INSERT query without specifying an
 
361
    explicit value for a field not having the explicit default 
 
362
    (@c check_that_all_fields_are_given_values()).
 
363
  */
 
364
  for (Field **field_ptr= table->field+skip; *field_ptr; ++field_ptr)
332
365
  {
333
 
    uint32 const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG;
334
366
    Field *const f= *field_ptr;
335
 
 
336
 
    if (((f->flags & mask) == mask))
 
367
    if ((f->flags &  NO_DEFAULT_VALUE_FLAG) &&
 
368
        (f->real_type() != MYSQL_TYPE_ENUM))
337
369
    {
338
 
      my_error(ER_NO_DEFAULT_FOR_FIELD, MYF(0), f->field_name);
339
 
      error = HA_ERR_ROWS_EVENT_APPLY;
 
370
      f->set_default();
 
371
      push_warning_printf(current_thd,
 
372
                          MYSQL_ERROR::WARN_LEVEL_WARN,
 
373
                          ER_NO_DEFAULT_FOR_FIELD,
 
374
                          ER(ER_NO_DEFAULT_FOR_FIELD),
 
375
                          f->field_name);
340
376
    }
341
377
  }
342
378
 
343
 
  DBUG_RETURN(error);
 
379
  DBUG_RETURN(0);
344
380
}
345
381
 
346
382
#endif // HAVE_REPLICATION