From e97df7c4494645986f842f32779a2e9522a98e68 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Tue, 15 Aug 2023 17:12:04 +0200 Subject: [PATCH] [component/binlog_utils_udf] PS-8854: Convert binlog_utils_udf to a component with function auto-registration --- components/binlog_utils_udf/CMakeLists.txt | 33 +++ .../binlog_utils_udf/binlog_utils_udf.cc | 241 +++++++++--------- mysql-test/include/plugin.defs | 2 +- mysql-test/r/percona_binlog_utils_udf.result | 20 +- mysql-test/t/percona_binlog_utils_udf.test | 31 +-- plugin/binlog_utils_udf/CMakeLists.txt | 9 - 6 files changed, 160 insertions(+), 176 deletions(-) create mode 100644 components/binlog_utils_udf/CMakeLists.txt rename {plugin => components}/binlog_utils_udf/binlog_utils_udf.cc (82%) delete mode 100644 plugin/binlog_utils_udf/CMakeLists.txt diff --git a/components/binlog_utils_udf/CMakeLists.txt b/components/binlog_utils_udf/CMakeLists.txt new file mode 100644 index 000000000000..ec44a2f6f7f4 --- /dev/null +++ b/components/binlog_utils_udf/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright (c) 2023 Percona LLC and/or its affiliates. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +if(NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET AND NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN) + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) +endif() + +# We are not interesting in profiling tests. +DISABLE_MISSING_PROFILE_WARNING() + +MYSQL_ADD_COMPONENT(binlog_utils_udf + binlog_utils_udf.cc + LINK_LIBRARIES extra::rapidjson + MODULE_ONLY +) + +ADD_DEFINITIONS(-DMYSQL_SERVER) + +target_include_directories(component_binlog_utils_udf SYSTEM PRIVATE ${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR}) diff --git a/plugin/binlog_utils_udf/binlog_utils_udf.cc b/components/binlog_utils_udf/binlog_utils_udf.cc similarity index 82% rename from plugin/binlog_utils_udf/binlog_utils_udf.cc rename to components/binlog_utils_udf/binlog_utils_udf.cc index 29f5f7427256..c89ce1f00758 100644 --- a/plugin/binlog_utils_udf/binlog_utils_udf.cc +++ b/components/binlog_utils_udf/binlog_utils_udf.cc @@ -1,3 +1,19 @@ +/* Copyright (c) 2023 Percona LLC and/or its affiliates. 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include #include #include @@ -7,10 +23,10 @@ #include #include - -#include +#include #include +#include #include @@ -18,89 +34,12 @@ #include #include -namespace { - -bool binlog_utils_udf_initialized{false}; - -struct registry_service_releaser { - void operator()(SERVICE_TYPE(registry) * srv) const noexcept { - if (srv != nullptr) mysql_plugin_registry_release(srv); - } -}; -using registry_service_ptr = - std::unique_ptr; - -registry_service_ptr reg_srv{nullptr, registry_service_releaser{}}; - -struct component_sys_variable_register_releaser { - registry_service_ptr &parent; - void operator()(SERVICE_TYPE(component_sys_variable_register) * - srv) const noexcept { - if (parent && srv != nullptr) - parent->release(reinterpret_cast( - const_cast( - srv))); - } -}; -using component_sys_variable_register_ptr = - std::unique_ptr; - -component_sys_variable_register_ptr sys_var_srv{ - nullptr, component_sys_variable_register_releaser{reg_srv}}; - -int binlog_utils_udf_init(void *) { - DBUG_TRACE; - registry_service_ptr local_reg_srv{mysql_plugin_registry_acquire(), - registry_service_releaser{}}; - if (!local_reg_srv) return 1; - my_h_service acquired_service{nullptr}; - if (local_reg_srv->acquire("component_sys_variable_register", - &acquired_service) != 0) - return 1; - if (acquired_service == nullptr) return 1; - - reg_srv = std::move(local_reg_srv); - sys_var_srv.reset( - reinterpret_cast( - acquired_service)); - binlog_utils_udf_initialized = true; - return 0; -} - -int binlog_utils_udf_deinit(void *) { - DBUG_TRACE; - sys_var_srv.reset(); - reg_srv.reset(); - binlog_utils_udf_initialized = false; - return 0; -} - -struct st_mysql_daemon binlog_utils_udf_decriptor = { - MYSQL_DAEMON_INTERFACE_VERSION}; - -} // end of anonymous namespace +// defined as a macro because needed both raw and stringized +#define CURRENT_COMPONENT_NAME binlog_utils_udf +#define CURRENT_COMPONENT_NAME_STR BOOST_PP_STRINGIZE(CURRENT_COMPONENT_NAME) -/* - Plugin library descriptor -*/ - -mysql_declare_plugin(binlog_utils_udf){ - MYSQL_DAEMON_PLUGIN, - &binlog_utils_udf_decriptor, - "binlog_utils_udf", - PLUGIN_AUTHOR_ORACLE, - "Binlog utils UDF plugin", - PLUGIN_LICENSE_GPL, - binlog_utils_udf_init, /* Plugin Init */ - nullptr, /* Plugin check uninstall */ - binlog_utils_udf_deinit, /* Plugin Deinit */ - 0x0100 /* 1.0 */, - nullptr, /* status variables */ - nullptr, /* system variables */ - nullptr, /* config options */ - 0, /* flags */ -} mysql_declare_plugin_end; +REQUIRES_SERVICE_PLACEHOLDER(udf_registration); +REQUIRES_SERVICE_PLACEHOLDER(component_sys_variable_register); namespace { @@ -122,14 +61,14 @@ ext::string_view extract_sys_var_value(ext::string_view component_name, void *ptr = ub.first.data(); std::size_t length = ub.first.size() - 1; - if (sys_var_srv->get_variable(component_name.data(), variable_name.data(), - &ptr, &length) == 0) + if (mysql_service_component_sys_variable_register->get_variable( + component_name.data(), variable_name.data(), &ptr, &length) == 0) return {static_cast(ptr), length}; ub.second.resize(length + 1); ptr = ub.second.data(); - if (sys_var_srv->get_variable(component_name.data(), variable_name.data(), - &ptr, &length) != 0) + if (mysql_service_component_sys_variable_register->get_variable( + component_name.data(), variable_name.data(), &ptr, &length) != 0) throw std::runtime_error("Cannot get sys_var value"); if (ptr == nullptr) throw std::runtime_error("The value of sys_var is null"); @@ -333,11 +272,6 @@ class get_binlog_by_gtid_impl { get_binlog_by_gtid_impl(mysqlpp::udf_context &ctx) { DBUG_TRACE; - if (!binlog_utils_udf_initialized) - throw std::invalid_argument( - "This function requires binlog_utils_udf plugin which is not " - "installed."); - if (ctx.get_number_of_args() != 1) throw std::invalid_argument("Function requires exactly one argument"); ctx.mark_result_const(false); @@ -409,11 +343,6 @@ class get_last_gtid_from_binlog_impl { get_last_gtid_from_binlog_impl(mysqlpp::udf_context &ctx) { DBUG_TRACE; - if (!binlog_utils_udf_initialized) - throw std::invalid_argument( - "This function requires binlog_utils_udf plugin which is not " - "installed."); - if (ctx.get_number_of_args() != 1) throw std::invalid_argument("Function requires exactly one argument"); ctx.mark_result_const(false); @@ -455,11 +384,6 @@ class get_gtid_set_by_binlog_impl { get_gtid_set_by_binlog_impl(mysqlpp::udf_context &ctx) { DBUG_TRACE; - if (!binlog_utils_udf_initialized) - throw std::invalid_argument( - "This function requires binlog_utils_udf plugin which is not " - "installed."); - if (ctx.get_number_of_args() != 1) throw std::invalid_argument("Function requires exactly one argument"); ctx.mark_result_const(false); @@ -539,11 +463,6 @@ class get_binlog_by_gtid_set_impl { get_binlog_by_gtid_set_impl(mysqlpp::udf_context &ctx) { DBUG_TRACE; - if (!binlog_utils_udf_initialized) - throw std::invalid_argument( - "This function requires binlog_utils_udf plugin which is not " - "installed."); - if (ctx.get_number_of_args() != 1) throw std::invalid_argument("Function requires exactly one argument"); ctx.mark_result_const(false); @@ -625,11 +544,6 @@ class get_first_record_timestamp_by_binlog_impl { get_first_record_timestamp_by_binlog_impl(mysqlpp::udf_context &ctx) { DBUG_TRACE; - if (!binlog_utils_udf_initialized) - throw std::invalid_argument( - "This function requires binlog_utils_udf plugin which is not " - "installed."); - if (ctx.get_number_of_args() != 1) throw std::invalid_argument("Function requires exactly one argument"); ctx.mark_result_const(false); @@ -666,11 +580,6 @@ class get_last_record_timestamp_by_binlog_impl { get_last_record_timestamp_by_binlog_impl(mysqlpp::udf_context &ctx) { DBUG_TRACE; - if (!binlog_utils_udf_initialized) - throw std::invalid_argument( - "This function requires binlog_utils_udf plugin which is not " - "installed."); - if (ctx.get_number_of_args() != 1) throw std::invalid_argument("Function requires exactly one argument"); ctx.mark_result_const(false); @@ -700,15 +609,101 @@ get_last_record_timestamp_by_binlog_impl::calculate( } // end of anonymous namespace DECLARE_STRING_UDF(get_binlog_by_gtid_impl, get_binlog_by_gtid) - DECLARE_STRING_UDF(get_last_gtid_from_binlog_impl, get_last_gtid_from_binlog) - DECLARE_STRING_UDF(get_gtid_set_by_binlog_impl, get_gtid_set_by_binlog) - DECLARE_STRING_UDF(get_binlog_by_gtid_set_impl, get_binlog_by_gtid_set) - DECLARE_INT_UDF(get_first_record_timestamp_by_binlog_impl, get_first_record_timestamp_by_binlog) - DECLARE_INT_UDF(get_last_record_timestamp_by_binlog_impl, get_last_record_timestamp_by_binlog) + +struct udf_info { + const char *name; + Item_result return_type; + Udf_func_any func; + Udf_func_init init_func; + Udf_func_deinit deinit_func; +}; + +#define DECLARE_UDF_INFO(NAME, TYPE) \ + udf_info { #NAME, TYPE, (Udf_func_any)&NAME, &NAME##_init, &NAME##_deinit } + +static const std::array known_udfs{ + DECLARE_UDF_INFO(get_binlog_by_gtid, STRING_RESULT), + DECLARE_UDF_INFO(get_last_gtid_from_binlog, STRING_RESULT), + DECLARE_UDF_INFO(get_gtid_set_by_binlog, STRING_RESULT), + DECLARE_UDF_INFO(get_binlog_by_gtid_set, STRING_RESULT), + DECLARE_UDF_INFO(get_first_record_timestamp_by_binlog, INT_RESULT), + DECLARE_UDF_INFO(get_last_record_timestamp_by_binlog, INT_RESULT)}; + +#undef DECLARE_UDF_INFO + +using udf_bitset_type = + std::bitset::value>; +static udf_bitset_type registered_udfs; + +static constexpr std::size_t max_unregister_attempts = 10; +static constexpr auto unregister_sleep_interval = std::chrono::seconds(1); + +static mysql_service_status_t component_init() { + std::size_t index = 0U; + + index = 0U; + for (const auto &element : known_udfs) { + if (!registered_udfs.test(index)) { + if (mysql_service_udf_registration->udf_register( + element.name, element.return_type, element.func, + element.init_func, element.deinit_func) == 0) + registered_udfs.set(index); + } + ++index; + } + return registered_udfs.all() ? 0 : 1; +} + +static mysql_service_status_t component_deinit() { + int was_present = 0; + + std::size_t index = 0U; + + for (const auto &element : known_udfs) { + if (registered_udfs.test(index)) { + std::size_t attempt = 0; + mysql_service_status_t status = 0; + while (attempt < max_unregister_attempts && + (status = mysql_service_udf_registration->udf_unregister( + element.name, &was_present)) != 0 && + was_present != 0) { + std::this_thread::sleep_for(unregister_sleep_interval); + ++attempt; + } + if (status == 0) registered_udfs.reset(index); + } + ++index; + } + + return registered_udfs.none() ? 0 : 1; +} + +// clang-format off +BEGIN_COMPONENT_PROVIDES(CURRENT_COMPONENT_NAME) +END_COMPONENT_PROVIDES(); + +BEGIN_COMPONENT_REQUIRES(CURRENT_COMPONENT_NAME) + REQUIRES_SERVICE(udf_registration), + REQUIRES_SERVICE(component_sys_variable_register), +END_COMPONENT_REQUIRES(); + +BEGIN_COMPONENT_METADATA(CURRENT_COMPONENT_NAME) + METADATA("mysql.author", "Percona Corporation"), + METADATA("mysql.license", "GPL"), +END_COMPONENT_METADATA(); + +DECLARE_COMPONENT(CURRENT_COMPONENT_NAME, CURRENT_COMPONENT_NAME_STR) + component_init, + component_deinit, +END_DECLARE_COMPONENT(); +// clang-format on + +DECLARE_LIBRARY_COMPONENTS &COMPONENT_REF(CURRENT_COMPONENT_NAME) + END_DECLARE_LIBRARY_COMPONENTS diff --git a/mysql-test/include/plugin.defs b/mysql-test/include/plugin.defs index 9425286be19e..adbd2aba44ce 100644 --- a/mysql-test/include/plugin.defs +++ b/mysql-test/include/plugin.defs @@ -201,6 +201,6 @@ authentication_ldap_simple plugin_output_directory no AUTH_LDAP authentication_ldap_sasl plugin_output_directory no AUTH_LDAP_SASL authentication_ldap_sasl keyring_vault plugin_output_directory no KEYRING_VAULT_PLUGIN keyring_vault test_udf_wrappers plugin_output_directory no TEST_UDF_WRAPPERS_LIB -binlog_utils_udf plugin_output_directory no BINLOG_UTILS_UDF_LIB procfs plugin_output_directory no PROCFS_PLUGIN procfs component_encryption_udf plugin_output_directory no ENCRYPTION_UDF_COMPONENT +component_binlog_utils_udf plugin_output_directory no BINLOG_UTILS_UDF_LIB diff --git a/mysql-test/r/percona_binlog_utils_udf.result b/mysql-test/r/percona_binlog_utils_udf.result index 1b103de8c94e..23acf8757445 100644 --- a/mysql-test/r/percona_binlog_utils_udf.result +++ b/mysql-test/r/percona_binlog_utils_udf.result @@ -18,14 +18,11 @@ FLUSH BINARY LOGS; *** generating several binlogs *** checking if UDF works without loading the plugin -CREATE FUNCTION get_last_gtid_from_binlog RETURNS STRING SONAME "BINLOG_UTILS_UDF_LIB"; SELECT get_last_gtid_from_binlog(''); -ERROR HY000: Can't initialize function 'get_last_gtid_from_binlog'; This function requires binlog_utils_udf plugin which is not installed. -DROP FUNCTION get_last_gtid_from_binlog; +ERROR 42000: FUNCTION test.get_last_gtid_from_binlog does not exist +INSTALL COMPONENT 'file://component_binlog_utils_udf'; *** checking 'get_last_gtid_from_binlog()' function -INSTALL PLUGIN binlog_utils_udf SONAME 'BINLOG_UTILS_UDF_LIB'; -CREATE FUNCTION get_last_gtid_from_binlog RETURNS STRING SONAME "BINLOG_UTILS_UDF_LIB"; SELECT get_last_gtid_from_binlog(); ERROR HY000: Can't initialize function 'get_last_gtid_from_binlog'; Function requires exactly one argument SELECT get_last_gtid_from_binlog('blah', 'blah'); @@ -48,10 +45,8 @@ include/assert.inc ['GTID extracted via get_last_gtid_from_binlog() for stage 13 include/assert.inc ['GTID extracted via get_last_gtid_from_binlog() for stage 14 should match the recorded value'] include/assert.inc ['GTID extracted via get_last_gtid_from_binlog() for stage 15 should match the recorded value'] include/assert.inc ['GTID extracted via get_last_gtid_from_binlog() for stage 16 should match the recorded value'] -DROP FUNCTION get_last_gtid_from_binlog; *** checking 'get_binlog_by_gtid()' function -CREATE FUNCTION get_binlog_by_gtid RETURNS STRING SONAME "BINLOG_UTILS_UDF_LIB"; SELECT get_binlog_by_gtid(); ERROR HY000: Can't initialize function 'get_binlog_by_gtid'; Function requires exactly one argument SELECT get_binlog_by_gtid('blah', 'blah'); @@ -312,10 +307,8 @@ include/assert.inc ['binlog name extracted via get_binlog_by_gtid() for stage 16 include/assert.inc ['binlog name extracted via get_binlog_by_gtid() for stage 16, substage 14 should match the recorded value'] include/assert.inc ['binlog name extracted via get_binlog_by_gtid() for stage 16, substage 15 should match the recorded value'] include/assert.inc ['binlog name extracted via get_binlog_by_gtid() for stage 16, substage 16 should match the recorded value'] -DROP FUNCTION get_binlog_by_gtid; *** checking 'get_gtid_set_by_binlog()' function -CREATE FUNCTION get_gtid_set_by_binlog RETURNS STRING SONAME "BINLOG_UTILS_UDF_LIB"; SELECT get_gtid_set_by_binlog(); ERROR HY000: Can't initialize function 'get_gtid_set_by_binlog'; Function requires exactly one argument SELECT get_gtid_set_by_binlog('blah', 'blah'); @@ -338,10 +331,8 @@ include/assert.inc ['GTID set extracted via get_gtid_set_by_binlog() for stage 1 include/assert.inc ['GTID set extracted via get_gtid_set_by_binlog() for stage 14 should match the recorded value'] include/assert.inc ['GTID set extracted via get_gtid_set_by_binlog() for stage 15 should match the recorded value'] include/assert.inc ['GTID set extracted via get_gtid_set_by_binlog() for stage 16 should match the recorded value'] -DROP FUNCTION get_gtid_set_by_binlog; *** checking 'get_binlog_by_gtid_set()' function -CREATE FUNCTION get_binlog_by_gtid_set RETURNS STRING SONAME "BINLOG_UTILS_UDF_LIB"; SELECT get_binlog_by_gtid_set(); ERROR HY000: Can't initialize function 'get_binlog_by_gtid_set'; Function requires exactly one argument SELECT get_binlog_by_gtid_set('blah', 'blah'); @@ -1523,13 +1514,11 @@ include/assert.inc ['binlog name extracted via get_binlog_by_gtid_set() for (16, include/assert.inc ['binlog name extracted via get_binlog_by_gtid_set() for (16, 8)..(16, 8) should match the recorded value'] include/assert.inc ['binlog name extracted via get_binlog_by_gtid_set() for (16, 8)..(16, 16) should match the recorded value'] include/assert.inc ['binlog name extracted via get_binlog_by_gtid_set() for (16, 16)..(16, 16) should match the recorded value'] -DROP FUNCTION get_binlog_by_gtid_set; CREATE TEMPORARY TABLE loaded_ts( val VARCHAR(255) NOT NULL ) ENGINE=InnoDB; *** checking 'get_first_record_timestamp_by_binlog()' function -CREATE FUNCTION get_first_record_timestamp_by_binlog RETURNS INTEGER SONAME "BINLOG_UTILS_UDF_LIB"; SELECT get_first_record_timestamp_by_binlog(); ERROR HY000: Can't initialize function 'get_first_record_timestamp_by_binlog'; Function requires exactly one argument SELECT get_first_record_timestamp_by_binlog('blah', 'blah'); @@ -1584,10 +1573,8 @@ include/assert.inc ['first record timestamp extracted via get_first_record_times DELETE FROM loaded_ts; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/filtered_binlog_file' INTO TABLE loaded_ts; include/assert.inc ['first record timestamp extracted via get_first_record_timestamp_by_binlog() for stage 16 should match the value extracted via mysqlbinlog'] -DROP FUNCTION get_first_record_timestamp_by_binlog; *** checking 'get_last_record_timestamp_by_binlog()' function -CREATE FUNCTION get_last_record_timestamp_by_binlog RETURNS INTEGER SONAME "BINLOG_UTILS_UDF_LIB"; SELECT get_last_record_timestamp_by_binlog(); ERROR HY000: Can't initialize function 'get_last_record_timestamp_by_binlog'; Function requires exactly one argument SELECT get_last_record_timestamp_by_binlog('blah', 'blah'); @@ -1642,8 +1629,7 @@ include/assert.inc ['last record timestamp extracted via get_last_record_timesta DELETE FROM loaded_ts; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/filtered_binlog_file' INTO TABLE loaded_ts; include/assert.inc ['last record timestamp extracted via get_last_record_timestamp_by_binlog() for stage 16 should match the value extracted via mysqlbinlog'] -DROP FUNCTION get_last_record_timestamp_by_binlog; DROP TABLE loaded_ts; -UNINSTALL PLUGIN binlog_utils_udf; +UNINSTALL COMPONENT 'file://component_binlog_utils_udf'; DROP TABLE captured_gtid; DROP TABLE t1; diff --git a/mysql-test/t/percona_binlog_utils_udf.test b/mysql-test/t/percona_binlog_utils_udf.test index 58f60f1129af..f05a30bda002 100644 --- a/mysql-test/t/percona_binlog_utils_udf.test +++ b/mysql-test/t/percona_binlog_utils_udf.test @@ -84,19 +84,14 @@ while($stage <= $number_of_stages) --echo --echo *** checking if UDF works without loading the plugin ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -eval CREATE FUNCTION get_last_gtid_from_binlog RETURNS STRING SONAME "$BINLOG_UTILS_UDF_LIB"; --replace_result $binlog_file_name ---error ER_CANT_INITIALIZE_UDF +--error ER_SP_DOES_NOT_EXIST eval SELECT get_last_gtid_from_binlog('$binlog_file_name'); -DROP FUNCTION get_last_gtid_from_binlog; + +INSTALL COMPONENT 'file://component_binlog_utils_udf'; --echo --echo *** checking 'get_last_gtid_from_binlog()' function ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -eval INSTALL PLUGIN binlog_utils_udf SONAME '$BINLOG_UTILS_UDF_LIB'; ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -eval CREATE FUNCTION get_last_gtid_from_binlog RETURNS STRING SONAME "$BINLOG_UTILS_UDF_LIB"; --error ER_CANT_INITIALIZE_UDF SELECT get_last_gtid_from_binlog(); @@ -122,12 +117,9 @@ while($stage <= $number_of_stages) --inc $stage } -DROP FUNCTION get_last_gtid_from_binlog; --echo --echo *** checking 'get_binlog_by_gtid()' function ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -eval CREATE FUNCTION get_binlog_by_gtid RETURNS STRING SONAME "$BINLOG_UTILS_UDF_LIB"; --error ER_CANT_INITIALIZE_UDF SELECT get_binlog_by_gtid(); @@ -153,12 +145,9 @@ while($stage <= $number_of_stages) --inc $stage } -DROP FUNCTION get_binlog_by_gtid; --echo --echo *** checking 'get_gtid_set_by_binlog()' function ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -eval CREATE FUNCTION get_gtid_set_by_binlog RETURNS STRING SONAME "$BINLOG_UTILS_UDF_LIB"; --error ER_CANT_INITIALIZE_UDF SELECT get_gtid_set_by_binlog(); @@ -183,12 +172,9 @@ while($stage <= $number_of_stages) --inc $stage } -DROP FUNCTION get_gtid_set_by_binlog; --echo --echo *** checking 'get_binlog_by_gtid_set()' function ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -eval CREATE FUNCTION get_binlog_by_gtid_set RETURNS STRING SONAME "$BINLOG_UTILS_UDF_LIB"; --error ER_CANT_INITIALIZE_UDF SELECT get_binlog_by_gtid_set(); @@ -225,7 +211,6 @@ while($outer_index < $number_of_iterations) --inc $outer_index } -DROP FUNCTION get_binlog_by_gtid_set; # creating a temporary table which will be used for LOAD DATA LOCAL INFILE CREATE TEMPORARY TABLE loaded_ts( @@ -234,8 +219,6 @@ CREATE TEMPORARY TABLE loaded_ts( --echo --echo *** checking 'get_first_record_timestamp_by_binlog()' function ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -eval CREATE FUNCTION get_first_record_timestamp_by_binlog RETURNS INTEGER SONAME "$BINLOG_UTILS_UDF_LIB"; --error ER_CANT_INITIALIZE_UDF SELECT get_first_record_timestamp_by_binlog(); @@ -274,12 +257,10 @@ while($stage <= $number_of_stages) --inc $stage } -DROP FUNCTION get_first_record_timestamp_by_binlog; + --echo --echo *** checking 'get_last_record_timestamp_by_binlog()' function ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -eval CREATE FUNCTION get_last_record_timestamp_by_binlog RETURNS INTEGER SONAME "$BINLOG_UTILS_UDF_LIB"; --error ER_CANT_INITIALIZE_UDF SELECT get_last_record_timestamp_by_binlog(); @@ -318,13 +299,11 @@ while($stage <= $number_of_stages) --inc $stage } -DROP FUNCTION get_last_record_timestamp_by_binlog; # temporary table cleanup DROP TABLE loaded_ts; ---replace_result $BINLOG_UTILS_UDF_LIB BINLOG_UTILS_UDF_LIB -UNINSTALL PLUGIN binlog_utils_udf; +UNINSTALL COMPONENT 'file://component_binlog_utils_udf'; DROP TABLE captured_gtid; DROP TABLE t1; diff --git a/plugin/binlog_utils_udf/CMakeLists.txt b/plugin/binlog_utils_udf/CMakeLists.txt deleted file mode 100644 index 7f7876b7d04b..000000000000 --- a/plugin/binlog_utils_udf/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -MYSQL_ADD_PLUGIN(binlog_utils_udf - binlog_utils_udf.cc - MODULE_ONLY MODULE_OUTPUT_NAME "binlog_utils_udf" - LINK_LIBRARIES extra::rapidjson -) - -ADD_DEFINITIONS(-DMYSQL_SERVER) - -INCLUDE_DIRECTORIES(SYSTEM ${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})