Skip to content

Commit e7af040

Browse files
author
Venkatesh Duggirala
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents de921a8 + d113759 commit e7af040

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

mysql-test/extra/rpl_tests/rpl_extra_col_slave.test

+8
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,16 @@ if (`SELECT UPPER(LEFT($engine_type, 3)) != 'NDB'`)
430430
# they are declared without DEFAULT clause.
431431

432432
sync_slave_with_master;
433+
--replace_column 4 CURRENT_TIMESTAMP
433434
select * from t9;
434435

436+
# Bug #22916743 RBR DOES NOT USE DEFAULT CURRENT_TIMESTAMP FOR EXTRA COLUMN
437+
# ON SLAVE
438+
--let $assert_text= The values of column 'd' should have non-zero timetsamp.
439+
--let $assert_cond= [SELECT COUNT(*) AS Val FROM t9 WHERE d = "0000-00-00 00:00:00", Val, 1] = 0
440+
--source include/assert.inc
441+
# End of test for Bug #22916743
442+
435443
# todo: fix Bug #43992 slave sql thread can't tune own sql_mode ...
436444
# and add/restore waiting for stop test
437445

mysql-test/suite/rpl/r/rpl_extra_col_slave_innodb.result

+4-3
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,10 @@ set @b1 = concat(@b1,@b1);
212212
INSERT INTO t9 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
213213
select * from t9;
214214
a b c d e f g h i
215-
1 b1b1b1b1b1b1b1b1 Kyle 0000-00-00 00:00:00 0 NULL NULL
216-
2 b1b1b1b1b1b1b1b1 JOE 0000-00-00 00:00:00 0 NULL NULL
217-
3 b1b1b1b1b1b1b1b1 QA 0000-00-00 00:00:00 0 NULL NULL
215+
1 b1b1b1b1b1b1b1b1 Kyle CURRENT_TIMESTAMP 0 NULL NULL
216+
2 b1b1b1b1b1b1b1b1 JOE CURRENT_TIMESTAMP 0 NULL NULL
217+
3 b1b1b1b1b1b1b1b1 QA CURRENT_TIMESTAMP 0 NULL NULL
218+
include/assert.inc [The values of column 'd' should have non-zero timetsamp.]
218219
DROP TABLE t9;
219220
*** Create t10 on slave ***
220221
STOP SLAVE;

mysql-test/suite/rpl/r/rpl_extra_col_slave_myisam.result

+4-3
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,10 @@ set @b1 = concat(@b1,@b1);
212212
INSERT INTO t9 () VALUES(1,@b1,'Kyle'),(2,@b1,'JOE'),(3,@b1,'QA');
213213
select * from t9;
214214
a b c d e f g h i
215-
1 b1b1b1b1b1b1b1b1 Kyle 0000-00-00 00:00:00 0 NULL NULL
216-
2 b1b1b1b1b1b1b1b1 JOE 0000-00-00 00:00:00 0 NULL NULL
217-
3 b1b1b1b1b1b1b1b1 QA 0000-00-00 00:00:00 0 NULL NULL
215+
1 b1b1b1b1b1b1b1b1 Kyle CURRENT_TIMESTAMP 0 NULL NULL
216+
2 b1b1b1b1b1b1b1b1 JOE CURRENT_TIMESTAMP 0 NULL NULL
217+
3 b1b1b1b1b1b1b1b1 QA CURRENT_TIMESTAMP 0 NULL NULL
218+
include/assert.inc [The values of column 'd' should have non-zero timetsamp.]
218219
DROP TABLE t9;
219220
*** Create t10 on slave ***
220221
STOP SLAVE;

sql/rpl_record.cc

+30-3
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,30 @@ int prepare_record(TABLE *const table, const MY_BITMAP *cols, const bool check)
504504
*/
505505

506506
DBUG_PRINT_BITSET("debug", "cols: %s", cols);
507+
/**
508+
Save a reference to the original write set bitmaps.
509+
We will need this to restore the bitmaps at the end.
510+
*/
511+
MY_BITMAP *old_write_set= table->write_set;
512+
/**
513+
Just to be sure that tmp_set is currently not in use as
514+
the read_set already.
515+
*/
516+
DBUG_ASSERT(table->write_set != &table->tmp_set);
517+
/* set the temporary write_set */
518+
table->column_bitmaps_set_no_signal(table->read_set,
519+
&table->tmp_set);
520+
/**
521+
Set table->write_set bits for all the columns as they
522+
will be checked in set_default() function.
523+
*/
524+
bitmap_set_all(table->write_set);
525+
507526
for (Field **field_ptr= table->field; *field_ptr; ++field_ptr)
508527
{
509-
if ((uint) (field_ptr - table->field) >= cols->n_bits ||
510-
!bitmap_is_set(cols, field_ptr - table->field))
511-
{
528+
uint field_index= (uint) (field_ptr - table->field);
529+
if (field_index >= cols->n_bits || !bitmap_is_set(cols, field_index))
530+
{
512531
Field *const f= *field_ptr;
513532
if ((f->flags & NO_DEFAULT_VALUE_FLAG) &&
514533
(f->real_type() != MYSQL_TYPE_ENUM))
@@ -520,9 +539,17 @@ int prepare_record(TABLE *const table, const MY_BITMAP *cols, const bool check)
520539
ER(ER_NO_DEFAULT_FOR_FIELD),
521540
f->field_name);
522541
}
542+
else if (f->has_insert_default_function())
543+
{
544+
f->set_default();
545+
}
523546
}
524547
}
525548

549+
/* set the write_set back to original*/
550+
table->column_bitmaps_set_no_signal(table->read_set,
551+
old_write_set);
552+
526553
DBUG_RETURN(0);
527554
}
528555

0 commit comments

Comments
 (0)