Description:
With valgrind, upgrade from 5.7 reports overlapping source and destination for a memcpy:
==21151== Source and destination overlap in memcpy(0x15f501f8, 0x15f501f8, 579)
==21151== at 0x6E5E04C: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1022)
==21151== by 0x28D256E: prepare_fields_and_keys(THD*, dd::Table const*, TABLE*, HA_CREATE_INFO*, Alter_info*, Alter_table_ctx*, unsigned int const&) (sql_table.cc:10921)
==21151== by 0x3A90502: dd::upgrade_57::migrate_table_to_dd(THD*, std::basic_string<char, std::char_traits<char>, Stateless_allocator<char, dd::String_type_alloc, My_free_functor> > const&, std::basic_string<char, std::char_traits<char>, Stateless_allocator<char, dd::String_type_alloc, My_free_functor> > const&, bool) (table.cc:1491)
==21151== by 0x3A915EC: dd::upgrade_57::migrate_plugin_table_to_dd(THD*) (table.cc:1667)
==21151== by 0x3A675CA: dd::upgrade_57::do_pre_checks_and_initialize_dd(THD*) (upgrade.cc:1083)
==21151== by 0x2ABE903: handle_bootstrap (bootstrap.cc:346)
==21151== by 0x4186CE9: pfs_spawn_thread (pfs.cc:2836)
==21151== by 0x706DE24: start_thread (in /usr/lib64/libpthread-2.17.so)
==21151== by 0x8CBE34C: clone (in /usr/lib64/libc-2.17.so)
==21151==
How to repeat:
Enable main.dd_upgrade_test for valgrind and run the test. Or run main.dd_schema_after_upgrade_debug with valgrind.
Suggested fix:
Call restore_record() (aka memcpy) only if table->record[0] != table->s->default_value in prepare_fields_and_keys().