Skip to content
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

fix broken MySQL 8.1.0 build on macos-14 #1133

Merged
merged 3 commits into from
Aug 31, 2024
Merged

Conversation

shogo82148
Copy link
Owner

@shogo82148 shogo82148 commented Aug 31, 2024

https://github.com/shogo82148/actions-setup-mysql/actions/runs/10643017496/job/29509993834

2024-08-31T11:35:34.6179140Z In file included from /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:23:
2024-08-31T11:35:34.6280940Z In file included from /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.h:26:
2024-08-31T11:35:34.6383070Z In file included from /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/functional:515:
2024-08-31T11:35:34.6485190Z In file included from /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__algorithm/search.h:23:
2024-08-31T11:35:34.6614210Z /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__utility/pair.h:613:22: error: invalid operands to binary expression ('const Auth_id' and 'const MYSQL_LEX_CSTRING')
2024-08-31T11:35:34.6708000Z     return __x.first == __y.first && __x.second == __y.second;
2024-08-31T11:35:34.6809900Z            ~~~~~~~~~ ^  ~~~~~~~~~
2024-08-31T11:35:34.6928700Z /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__algorithm/find.h:34:41: note: in instantiation of function template specialization 'std::__1::operator==<const Auth_id, Auth_id, MYSQL_LEX_CSTRING, MYSQL_LEX_CSTRING>' requested here
2024-08-31T11:35:34.7029500Z     if (std::__invoke(__proj, *__first) == __value)
2024-08-31T11:35:34.7131060Z                                         ^
2024-08-31T11:35:34.7238040Z /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__algorithm/find.h:81:21: note: in instantiation of function template specialization 'std::__find_impl<std::__hash_map_iterator<std::__hash_iterator<std::__hash_node<std::__hash_value_type<Auth_id, Auth_id>, void *> *>>, std::__hash_map_iterator<std::__hash_iterator<std::__hash_node<std::__hash_value_type<Auth_id, Auth_id>, void *> *>>, std::pair<MYSQL_LEX_CSTRING, MYSQL_LEX_CSTRING>, std::__identity>' requested here
2024-08-31T11:35:34.7342350Z       __first, std::__find_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), __value, __proj));
2024-08-31T11:35:34.7443570Z                     ^
2024-08-31T11:35:34.7512550Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:6598:11: note: in instantiation of function template specialization 'std::find<std::__hash_map_iterator<std::__hash_iterator<std::__hash_node<std::__hash_value_type<Auth_id, Auth_id>, void *> *>>, std::pair<MYSQL_LEX_CSTRING, MYSQL_LEX_CSTRING>>' requested here
2024-08-31T11:35:34.7514430Z       if (find(role_it, role_end, *it) == role_end) {
2024-08-31T11:35:34.7514900Z           ^
2024-08-31T11:35:34.7516230Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:7434:6: note: candidate function not viable: no known conversion from 'const MYSQL_LEX_CSTRING' to 'const std::string' (aka 'const basic_string<char>') for 2nd argument
2024-08-31T11:35:34.7517520Z bool operator==(const Role_id &a, const std::string &b) {
2024-08-31T11:35:34.7517970Z      ^
2024-08-31T11:35:34.7519150Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:7444:6: note: candidate function not viable: no known conversion from 'const MYSQL_LEX_CSTRING' to 'const Auth_id_ref' (aka 'const pair<MYSQL_LEX_CSTRING, MYSQL_LEX_CSTRING>') for 2nd argument
2024-08-31T11:35:34.7520750Z bool operator==(const Role_id &a, const Auth_id_ref &b) {
2024-08-31T11:35:34.7521190Z      ^
2024-08-31T11:35:34.7522310Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:7463:6: note: candidate function not viable: no known conversion from 'const MYSQL_LEX_CSTRING' to 'const Role_id' (aka 'const Auth_id') for 2nd argument
2024-08-31T11:35:34.7523420Z bool operator==(const Role_id &a, const Role_id &b) {
2024-08-31T11:35:34.7523910Z      ^
2024-08-31T11:35:34.7525000Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:7486:6: note: candidate function not viable: no known conversion from 'const Auth_id' to 'const LEX_CSTRING' (aka 'const MYSQL_LEX_CSTRING') for 1st argument
2024-08-31T11:35:34.7526240Z bool operator==(const LEX_CSTRING &a, const LEX_CSTRING &b) {
2024-08-31T11:35:34.7526740Z      ^
2024-08-31T11:35:34.7527690Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/include/my_thread.h:150:13: note: candidate function not viable: no known conversion from 'const Auth_id' to 'const my_thread_handle' for 1st argument
2024-08-31T11:35:34.7528920Z inline bool operator==(const my_thread_handle &a, const my_thread_handle &b) {
2024-08-31T11:35:34.7529420Z             ^
2024-08-31T11:35:34.7530770Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:4623:6: note: candidate function not viable: no known conversion from 'const Auth_id' to 'const std::pair<Role_id, bool>' (aka 'const pair<Auth_id, bool>') for 1st argument
2024-08-31T11:35:34.7532140Z bool operator==(const std::pair<Role_id, bool> &rid, const Auth_id_ref &ref) {
2024-08-31T11:35:34.7532750Z      ^
2024-08-31T11:35:34.7533970Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:4628:6: note: candidate function not viable: no known conversion from 'const Auth_id' to 'const Auth_id_ref' (aka 'const pair<MYSQL_LEX_CSTRING, MYSQL_LEX_CSTRING>') for 1st argument
2024-08-31T11:35:34.7535280Z bool operator==(const Auth_id_ref &ref, const std::pair<Role_id, bool> &rid) {
2024-08-31T11:35:34.7535790Z      ^
2024-08-31T11:35:34.7537040Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:7440:6: note: candidate function not viable: no known conversion from 'const Auth_id' to 'const std::pair<Role_id, bool>' (aka 'const pair<Auth_id, bool>') for 1st argument
2024-08-31T11:35:34.7538320Z bool operator==(const std::pair<Role_id, bool> &a, const std::string &b) {
2024-08-31T11:35:34.7538810Z      ^
2024-08-31T11:35:34.7540110Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:7452:6: note: candidate function not viable: no known conversion from 'const Auth_id' to 'const Auth_id_ref' (aka 'const pair<MYSQL_LEX_CSTRING, MYSQL_LEX_CSTRING>') for 1st argument
2024-08-31T11:35:34.7541370Z bool operator==(const Auth_id_ref &a, const Role_id &b) { return b == a; }
2024-08-31T11:35:34.7541950Z      ^
2024-08-31T11:35:34.7543220Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:7454:6: note: candidate function not viable: no known conversion from 'const Auth_id' to 'const std::pair<const Role_id, const Role_id>' (aka 'const pair<const Auth_id, const Auth_id>') for 1st argument
2024-08-31T11:35:34.7544570Z bool operator==(const std::pair<const Role_id, const Role_id> &a,
2024-08-31T11:35:34.7545130Z      ^
2024-08-31T11:35:34.7546560Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/auth/sql_authorization.cc:7481:6: note: candidate function not viable: no known conversion from 'const Auth_id' to 'std::pair<const Role_id, std::pair<std::string, bool>> &' (aka 'pair<const Auth_id, pair<basic_string<char>, bool>> &') for 1st argument
2024-08-31T11:35:34.7547950Z bool operator==(std::pair<const Role_id, std::pair<std::string, bool>> &a,
2024-08-31T11:35:34.7548530Z      ^
2024-08-31T11:35:34.7549850Z /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include/c++/v1/__utility/pair.h:611:1: note: candidate template ignored: could not match 'const pair<_T1, _T2>' against 'const Auth_id'
2024-08-31T11:35:34.7551080Z operator==(const pair<_T1,_T2>& __x, const pair<_U1,_U2>& __y)
2024-08-31T11:35:34.7551580Z ^
2024-08-31T11:35:34.7552470Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/malloc_allocator.h:136:6: note: candidate template ignored: could not match 'const Malloc_allocator<T>' against 'const Auth_id'
2024-08-31T11:35:34.7553520Z bool operator==(const Malloc_allocator<T> &a1, const Malloc_allocator<T> &a2) {
2024-08-31T11:35:34.7554080Z      ^
2024-08-31T11:35:34.7554990Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/mem_root_allocator.h:142:6: note: candidate template ignored: could not match 'const Mem_root_allocator<T>' against 'const Auth_id'
2024-08-31T11:35:34.7555900Z bool operator==(const Mem_root_allocator<T> &a1,
2024-08-31T11:35:34.7556370Z      ^
2024-08-31T11:35:34.7557340Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/stateless_allocator.h:159:6: note: candidate template ignored: could not match 'const Stateless_allocator<T, ALLOC_FUN, DEALLOC_FUN>' against 'const Auth_id'
2024-08-31T11:35:34.7558510Z bool operator==(const Stateless_allocator<T, ALLOC_FUN, DEALLOC_FUN> &,
2024-08-31T11:35:34.7558970Z      ^
2024-08-31T11:35:34.7560020Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/memory/unique_ptr.h:447:6: note: candidate template ignored: could not match 'const memory::PFS_allocator<T>' against 'const Auth_id'
2024-08-31T11:35:34.7561080Z bool operator==(const memory::PFS_allocator<T> &lhs,
2024-08-31T11:35:34.7561480Z      ^
2024-08-31T11:35:34.7562480Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/memory/unique_ptr.h:459:6: note: candidate template ignored: could not match 'const memory::Unique_ptr<T1, A1>' against 'const Auth_id'
2024-08-31T11:35:34.7563540Z bool operator==(memory::Unique_ptr<T1, A1> const &lhs,
2024-08-31T11:35:34.7563980Z      ^
2024-08-31T11:35:34.7564980Z /Users/runner/work/_temp/mysql-server-mysql-8.1.0/sql/memory/unique_ptr.h:472:6: note: candidate template ignored: could not match 'const memory::Unique_ptr<T1, A1>' against 'const Auth_id'
2024-08-31T11:35:34.7566070Z bool operator==(memory::Unique_ptr<T1, A1> const &lhs, std::nullptr_t) {
2024-08-31T11:35:34.7566550Z      ^
2024-08-31T11:35:34.7567030Z 1 error generated.

Summary by CodeRabbit

  • New Features

    • Introduced support for C++20 compatibility, allowing developers to leverage new language features.
    • Added a new CMake option (WITH_EXPERIMENTAL_CPP20) for building with C++20 features.
  • Improvements

    • Enhanced thread safety by replacing volatile types with std::atomic.
    • Addressed compiler warnings and errors related to stricter C++20 standards.
    • Updated equality operator for std::pair involving Role_id types to align with new C++ standards.
  • Bug Fixes

    • Resolved ambiguity issues in comparison operators by marking them as const.

Copy link

coderabbitai bot commented Aug 31, 2024

Walkthrough

This patch updates the MySQL codebase to ensure compatibility with C++20 while retaining support for C++17. It addresses compiler warnings and errors due to stricter C++20 rules, modifies member functions to be const, replaces volatile types with std::atomic, and introduces a CMake option for experimental C++20 features. Additionally, it updates the equality operator for Role_id types to comply with new C++ standards.

Changes

Files Change Summary
components/keyrings/common/data/data.h, include/mysql/service_rules_table.h, plugin/keyring/digest.h, router/src/http/src/http_auth_backend.h, storage/innobase/include/dict0mem.h Updated comparison operators (operator==, operator!=) to be const in various classes and structs.
storage/perfschema/pfs_buffer_container.h Changed destructor definition for PFS_buffer_processor to use default implementation.
sql/auth/auth_internal.h, sql/auth/sql_authorization.cc Updated equality operator for std::pair involving Role_id types to align with new C++ standards.
CMakeLists.txt Introduced a new option WITH_EXPERIMENTAL_CPP20 for C++20 feature support and added compiler checks.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant CMake
    participant Compiler
    participant Codebase

    Developer->>CMake: Configure with C++20
    CMake->>Compiler: Check compiler version
    Compiler-->>CMake: Version supported
    CMake->>Codebase: Prepare for C++20
    Codebase->>Compiler: Compile with C++20 features
    Compiler-->>Codebase: Compilation successful
Loading

🐰 "In the code where bunnies hop,
C++20 brings a joyful stop!
With const and atoms, we play,
Making sure warnings stay away.
So let's leap with glee and cheer,
For a codebase bright and clear!" 🐇


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 467898c and 6147cfa.

Files selected for processing (1)
  • patches/mysql/8.1.0/prepare-the-codebase-for-c++20.patch (1 hunks)
Additional comments not posted (7)
patches/mysql/8.1.0/prepare-the-codebase-for-c++20.patch (7)

216-231: Ensure const Correctness in Operator Overloads

Making the equality operator const in the Data class is a crucial update for C++20 compatibility, ensuring that objects can be compared without modifying them. This change is correctly implemented.


296-327: Refactor Volatile to std::atomic for Thread Safety

Replacing volatile with std::atomic in the logging component is an excellent improvement for thread safety and correctness. This change aligns with modern C++ practices for managing concurrency.


338-369: Simplify PFS_engine_table_proxy Structure

The simplification of the PFS_engine_table_proxy structure by initializing members to nullptr is a good practice. It makes the code cleaner and more maintainable.


380-384: Add const to Operator Overloads

Adding const to operator overloads in the Cursor class is a minor but necessary change for const correctness.


393-397: Refactor Increment Function

Refactoring the increment function to use a more robust method rather than directly manipulating the counter is a good practice, especially in a multi-threaded environment.


562-572: Remove Unused Macro

Removing the unused in_range macro is a good cleanup. Keeping the codebase free of unused code reduces maintenance overhead and potential confusion.


602-662: Refactor Execution Context Methods

Moving the implementation of methods like notify_fork and shutdown out of the header file into a more appropriate location helps in reducing compilation dependencies and potentially hiding implementation details.

patches/mysql/8.1.0/prepare-the-codebase-for-c++20.patch Outdated Show resolved Hide resolved
patches/mysql/8.1.0/prepare-the-codebase-for-c++20.patch Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6147cfa and 0b290e8.

Files selected for processing (1)
  • patches/mysql/8.1.0/equality-operator-needs-to-be-updated.patch (1 hunks)
Additional comments not posted (2)
patches/mysql/8.1.0/equality-operator-needs-to-be-updated.patch (2)

26-26: Approved change in operator definition.

The modification from const Role_id to Role_id in the pair type definition is likely necessary to address the type mismatch issues highlighted in the PR. This change allows for modifications to the second element of the pair, which could be crucial for the equality comparisons.

Please verify that this change does not introduce side effects in other parts of the codebase where this operator is used.


39-39: Consistent change across files.

The modification from const Role_id to Role_id in the pair type definition here is consistent with the change made in auth_internal.h. This consistency is crucial for maintaining the integrity of the operator definitions across the codebase.

Please ensure that this change aligns with the expected behavior in all scenarios where this operator is used, particularly in complex equality comparisons.

@shogo82148 shogo82148 merged commit fc49b8d into main Aug 31, 2024
11 of 214 checks passed
@shogo82148 shogo82148 deleted the fix-broken-build-on-macos-14 branch August 31, 2024 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant