19 #include "rpl_record_old.h"
24 uchar *row_data,
const uchar *
record)
26 Field **p_field= table->field, *field;
27 int n_null_bytes= table->s->null_bytes;
30 my_ptrdiff_t
const rec_offset= record - table->record[0];
31 my_ptrdiff_t
const def_offset= table->s->default_values - table->record[0];
32 memcpy(row_data, record, n_null_bytes);
33 ptr= row_data+n_null_bytes;
35 for (i= 0 ; (field= *p_field) ; i++, p_field++)
37 if (bitmap_is_set(cols,i))
40 field->is_null(rec_offset) ? def_offset : rec_offset;
41 field->move_field_offset(offset);
42 ptr= field->pack(ptr, field->ptr);
43 field->move_field_offset(-offset);
46 return (static_cast<size_t>(ptr - row_data));
87 #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
90 TABLE *table, uint
const colcnt, uchar *record,
92 uchar
const **row_end, ulong *master_reclength,
95 DBUG_ASSERT(record && row);
96 my_ptrdiff_t
const offset= record - (uchar*) table->record[0];
97 size_t master_null_bytes= table->s->null_bytes;
99 if (colcnt != table->s->fields)
101 Field **fptr= &table->field[colcnt-1];
103 master_null_bytes= (*fptr)->last_null_byte();
104 while (master_null_bytes == Field::LAST_NULL_BYTE_UNDEF &&
105 fptr-- > table->field);
116 if (master_null_bytes == Field::LAST_NULL_BYTE_UNDEF)
117 master_null_bytes= 1;
120 DBUG_ASSERT(master_null_bytes <= table->s->null_bytes);
121 memcpy(record, row, master_null_bytes);
124 bitmap_set_all(rw_set);
126 Field **
const begin_ptr = table->field;
128 uchar
const *ptr= row + master_null_bytes;
129 Field **
const end_ptr= begin_ptr + colcnt;
130 for (field_ptr= begin_ptr ; field_ptr < end_ptr ; ++field_ptr)
132 Field *
const f= *field_ptr;
134 if (bitmap_is_set(cols, field_ptr - begin_ptr))
136 f->move_field_offset(offset);
137 ptr= f->
unpack(f->ptr, ptr);
138 f->move_field_offset(-offset);
140 DBUG_ASSERT(ptr != NULL);
143 bitmap_clear_bit(rw_set, field_ptr - begin_ptr);
147 if (master_reclength)
150 *master_reclength = (*field_ptr)->ptr - table->record[0];
152 *master_reclength = table->s->reclength;
166 for ( ; *field_ptr ; ++field_ptr)
168 uint32
const mask= NOT_NULL_FLAG | NO_DEFAULT_VALUE_FLAG;
170 DBUG_PRINT(
"debug", (
"flags = 0x%x, mask = 0x%x, flags & mask = 0x%x",
171 (*field_ptr)->flags, mask,
172 (*field_ptr)->flags & mask));
174 if (event_type == WRITE_ROWS_EVENT &&
175 ((*field_ptr)->flags & mask) == mask)
177 rli->
report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD,
178 "Field `%s` of table `%s`.`%s` "
179 "has no default value and cannot be NULL",
180 (*field_ptr)->field_name, table->s->db.str,
181 table->s->table_name.str);
182 error = ER_NO_DEFAULT_FOR_FIELD;
185 (*field_ptr)->set_default();