-
Notifications
You must be signed in to change notification settings - Fork 509
PS-9823 fix: mysql_migrate_keyring won't work with PS's components (8.0) #5648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,103 +1,8 @@ | ||
|
|
||
| #ifndef PFS_STRING_INCLUDED | ||
| #define PFS_STRING_INCLUDED | ||
|
|
||
| #include <limits> | ||
| #include "my_sys.h" | ||
| #include "mysql/service_mysql_alloc.h" | ||
| #include "sql/psi_memory_key.h" | ||
|
|
||
| extern PSI_memory_key KEY_mem_keyring; | ||
|
|
||
| /** | ||
| Malloc_allocator is based on sql/malloc_allocator.h, but uses a fixed PSI key | ||
| instead | ||
| */ | ||
| template <class T = void *> | ||
| class Malloc_allocator { | ||
| // This cannot be const if we want to be able to swap. | ||
| PSI_memory_key m_key = KEY_mem_keyring; | ||
|
|
||
| public: | ||
| typedef T value_type; | ||
| typedef size_t size_type; | ||
| typedef ptrdiff_t difference_type; | ||
|
|
||
| typedef T *pointer; | ||
| typedef const T *const_pointer; | ||
|
|
||
| typedef T &reference; | ||
| typedef const T &const_reference; | ||
|
|
||
| pointer address(reference r) const { return &r; } | ||
| const_pointer address(const_reference r) const { return &r; } | ||
|
|
||
| explicit Malloc_allocator() {} | ||
|
|
||
| template <class U> | ||
| Malloc_allocator(const Malloc_allocator<U> &other [[maybe_unused]]) | ||
| : m_key(other.psi_key()) {} | ||
|
|
||
| template <class U> | ||
| Malloc_allocator &operator=(const Malloc_allocator<U> &other | ||
| [[maybe_unused]]) { | ||
| assert(m_key == other.psi_key()); // Don't swap key. | ||
| } | ||
|
|
||
| pointer allocate(size_type n, const_pointer hint [[maybe_unused]] = nullptr) { | ||
| if (n == 0) return nullptr; | ||
| if (n > max_size()) throw std::bad_alloc(); | ||
|
|
||
| pointer p = static_cast<pointer>( | ||
| my_malloc(m_key, n * sizeof(T), MYF(MY_WME | ME_FATALERROR))); | ||
| if (p == nullptr) throw std::bad_alloc(); | ||
| return p; | ||
| } | ||
|
|
||
| void deallocate(pointer p, size_type) { my_free(p); } | ||
|
|
||
| template <class U, class... Args> | ||
| void construct(U *p, Args &&... args) { | ||
| assert(p != nullptr); | ||
| try { | ||
| ::new ((void *)p) U(std::forward<Args>(args)...); | ||
| } catch (...) { | ||
| assert(false); // Constructor should not throw an exception. | ||
| } | ||
| } | ||
|
|
||
| void destroy(pointer p) { | ||
| assert(p != nullptr); | ||
| try { | ||
| p->~T(); | ||
| } catch (...) { | ||
| assert(false); // Destructor should not throw an exception | ||
| } | ||
| } | ||
|
|
||
| size_type max_size() const { | ||
| return std::numeric_limits<size_t>::max() / sizeof(T); | ||
| } | ||
|
|
||
| template <class U> | ||
| struct rebind { | ||
| typedef Malloc_allocator<U> other; | ||
| }; | ||
|
|
||
| PSI_memory_key psi_key() const { return m_key; } | ||
| }; | ||
|
|
||
| template <class T> | ||
| bool operator==(const Malloc_allocator<T> &a1, const Malloc_allocator<T> &a2) { | ||
| return a1.psi_key() == a2.psi_key(); | ||
| } | ||
|
|
||
| template <class T> | ||
| bool operator!=(const Malloc_allocator<T> &a1, const Malloc_allocator<T> &a2) { | ||
| return a1.psi_key() != a2.psi_key(); | ||
| } | ||
| #include <string> | ||
|
|
||
| using pfs_string = | ||
| std::basic_string<char, std::char_traits<char>, Malloc_allocator<char>>; | ||
| using pfs_string = std::string; | ||
|
|
||
| #endif // PFS_STRING_INCLUDED |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # | ||
| # Check if the variable KEYRING_PLUGIN is set | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # | ||
| if (!$KEYRING_PLUGIN) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| --skip keyring_file not available. | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # ==== Purpose ==== | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # | ||
| # Check if the provided library ('.so') can be successfully loaded with 'dlopen(..., RTLD_NOW)' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # | ||
| # ==== Usage ==== | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # | ||
| # --let $DLOPEN_CHECKER_LIBRARY_PATH = <path_to_the_library> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # --source include/keyring_tests/mats/dynamic_loading.inc | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # | ||
| # ==== Parameters ==== | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # | ||
| # DLOPEN_CHECKER_LIBRARY_PATH | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # Full path to the library that needs to be checked for unresolved symbols ('.so') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| # | ||
|
|
||
| --let $dlopen_checker_source = $MYSQL_TEST_DIR/std_data/dlopen_checker.cpp | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ clang-diagnostic-error ❌ |
||
| --let $dlopen_checker_binary = $MYSQL_TMP_DIR/dlopen_checker | ||
|
|
||
| --echo *** Building dlopen_checker utility | ||
| --exec g++ -std=c++17 -ldl -o $dlopen_checker_binary $dlopen_checker_source | ||
|
|
||
| --echo *** Checking for unresolved symbols | ||
| --replace_result $DLOPEN_CHECKER_LIBRARY_PATH <LIBRARY_PATH> | ||
| --exec $dlopen_checker_binary $DLOPEN_CHECKER_LIBRARY_PATH | ||
|
|
||
| --echo *** Deleting dlopen_checker utility | ||
| --remove_file $dlopen_checker_binary | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #include <cstdlib> | ||
| #include <iostream> | ||
| #include <memory> | ||
| #include <utility> | ||
|
|
||
| #include <dlfcn.h> | ||
|
|
||
| int main(int argc, char **argv) { | ||
| if (argc != 2) { | ||
| std::cerr << "Usage: " << argv[0] << " <path_to_library.so>\n"; | ||
| return 1; | ||
| } | ||
|
|
||
| const char *lib_path = argv[1]; | ||
| auto dl_closer{[](void *dl_handle) { | ||
| if (dl_handle != nullptr) dlclose(dl_handle); | ||
| }}; | ||
| using handle_guard = std::unique_ptr<void, decltype(dl_closer)>; | ||
| handle_guard handle{dlopen(lib_path, RTLD_NOW), std::move(dl_closer)}; | ||
| if (!handle) { | ||
| std::cerr << "dlopen() failed: " << dlerror() << '\n'; | ||
| return EXIT_FAILURE; | ||
| } | ||
|
|
||
| std::cout << "dlopen() succeeded: " << lib_path << '\n'; | ||
| return EXIT_SUCCESS; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| *** Building dlopen_checker utility | ||
| *** Checking for unresolved symbols | ||
| dlopen() succeeded: <LIBRARY_PATH> | ||
| *** Deleting dlopen_checker utility |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --source include/have_component_keyring_file.inc | ||
|
|
||
| --let $DLOPEN_CHECKER_LIBRARY_PATH = $KEYRING_FILE_COMPONENT_DIR/$KEYRING_FILE_COMPONENT | ||
| --source include/keyring_tests/mats/dynamic_loading.inc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| *** Building dlopen_checker utility | ||
| *** Checking for unresolved symbols | ||
| dlopen() succeeded: <LIBRARY_PATH> | ||
| *** Deleting dlopen_checker utility |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --source include/have_component_keyring_file.inc | ||
|
|
||
| --let $DLOPEN_CHECKER_LIBRARY_PATH = $KEYRING_KMIP_COMPONENT_DIR/$KEYRING_KMIP_COMPONENT | ||
| --source include/keyring_tests/mats/dynamic_loading.inc |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| *** Building dlopen_checker utility | ||
| *** Checking for unresolved symbols | ||
| dlopen() succeeded: <LIBRARY_PATH> | ||
| *** Deleting dlopen_checker utility |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --source include/have_component_keyring_file.inc | ||
|
|
||
| --let $DLOPEN_CHECKER_LIBRARY_PATH = $KEYRING_KMS_COMPONENT_DIR/$KEYRING_KMS_COMPONENT | ||
| --source include/keyring_tests/mats/dynamic_loading.inc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter name
cis too short, expected at least 2 characters