From 65418ca9ad39e862d29875838e8824f758bd749a Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 8 Oct 2024 16:43:57 +0530 Subject: [PATCH] MDEV-34392 Inplace algorithm violates the foreign key constraint - Fix the compilation error in gcc-5 --- sql/table.h | 11 +++++++++-- storage/innobase/handler/ha_innodb.cc | 8 +++++++- storage/innobase/handler/handler0alter.cc | 7 +++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/sql/table.h b/sql/table.h index 45fd8c01d9e..ebcd38ee3a0 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1927,7 +1927,14 @@ public: DBUG_ASSERT(fields_nullable); DBUG_ASSERT(field < n_fields); size_t bit= size_t{field} + referenced * n_fields; - fields_nullable[bit / 8]|= (unsigned char)(1 << (bit % 8)); +#if defined __GNUC__ && __GNUC__ == 5 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wconversion" +#endif + fields_nullable[bit / 8]|= static_cast(1 << (bit % 8)); +#if defined __GNUC__ && __GNUC__ == 5 +# pragma GCC diagnostic pop +#endif } /** @@ -1944,7 +1951,7 @@ public: unsigned n_field= get_n_fields(); DBUG_ASSERT(field < n_field); size_t bit= size_t{field} + referenced * n_field; - return fields_nullable[bit / 8] & (1 << (bit % 8)); + return fields_nullable[bit / 8] & (1U << (bit % 8)); } } FOREIGN_KEY_INFO; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 37b2d9ad7bd..8797a936600 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12518,7 +12518,10 @@ create_table_info_t::create_foreign_keys() } } } - +#if defined __GNUC__ && __GNUC__ == 5 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wconversion" +#endif switch (fk->delete_opt) { case FK_OPTION_UNDEF: case FK_OPTION_RESTRICT: @@ -12560,6 +12563,9 @@ create_table_info_t::create_foreign_keys() ut_ad(0); break; } +#if defined __GNUC__ && __GNUC__ == 5 +# pragma GCC diagnostic pop +#endif } if (dict_foreigns_has_s_base_col(local_fk_set, table)) { diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 613ba560ab2..d477a2a936c 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -2807,6 +2807,10 @@ innobase_set_foreign_key_option( break; } +#if defined __GNUC__ && __GNUC__ == 5 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wconversion" +#endif switch (fk_key->update_opt) { case FK_OPTION_NO_ACTION: case FK_OPTION_RESTRICT: @@ -2823,6 +2827,9 @@ innobase_set_foreign_key_option( break; } +#if defined __GNUC__ && __GNUC__ == 5 +# pragma GCC diagnostic pop +#endif return(innobase_check_fk_option(foreign)); }