mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
7e5cf52c3e
Backporting BUG#43789 to mysql-5.1-bugteam The replication was generating corrupted data, warning messages on Valgrind and aborting on debug mode while replicating a "null" to "not null" field. Specifically the unpack_row routine, was considering the slave's table definition and trying to retrieve a field value, where there was nothing to be retrieved, ignoring the fact that the value was defined as "null" by the master. To fix the problem, we proceed as follows: 1 - If it is not STRICT sql_mode, implicit default values are used, regardless if it is multi-row or single-row statement. 2 - However, if it is STRICT mode, then a we do what follows: 2.1 If it is a transactional engine, we do a rollback on the first NULL that is to be set into a NOT NULL column and return an error. 2.2 If it is a non-transactional engine and it is the first row to be inserted with multi-row, we also return the error. Otherwise, we proceed with the execution, use implicit default values and print out warning messages. Unfortunately, the current patch cannot mimic the behavior showed by the master for updates on multi-tables and multi-row inserts. This happens because such statements are unfolded in different row events. For instance, considering the following updates and strict mode: (master) create table t1 (a int); create table t2 (a int not null); insert into t1 values (1); insert into t2 values (2); update t1, t2 SET t1.a=10, t2.a=NULL; t1 would have (10) and t2 would have (0) as this would be handled as a multi-row update. On the other hand, if we had the following updates: (master) create table t1 (a int); create table t2 (a int); (slave) create table t1 (a int); create table t2 (a int not null); (master) insert into t1 values (1); insert into t2 values (2); update t1, t2 SET t1.a=10, t2.a=NULL; On the master t1 would have (10) and t2 would have (NULL). On the slave, t1 would have (10) but the update on t1 would fail.
39 lines
1.5 KiB
C
39 lines
1.5 KiB
C
/* Copyright 2007 MySQL AB. All rights reserved.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#ifndef RPL_RECORD_H
|
|
#define RPL_RECORD_H
|
|
|
|
#include <rpl_reporting.h>
|
|
|
|
#if !defined(MYSQL_CLIENT)
|
|
size_t pack_row(TABLE* table, MY_BITMAP const* cols,
|
|
uchar *row_data, const uchar *data);
|
|
#endif
|
|
|
|
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
|
|
int unpack_row(Relay_log_info const *rli,
|
|
TABLE *table, uint const colcnt,
|
|
uchar const *const row_data, MY_BITMAP const *cols,
|
|
uchar const **const row_end, ulong *const master_reclength,
|
|
const bool abort_on_warning= TRUE, const bool first_row= TRUE);
|
|
|
|
// Fill table's record[0] with default values.
|
|
int prepare_record(TABLE *const table, const uint skip, const bool check,
|
|
const bool abort_on_warning= TRUE,
|
|
const bool first_row= TRUE);
|
|
#endif
|
|
|
|
#endif
|