登录
首页 >  数据库 >  MySQL

MySQL 源码阅读 —— 问题 expanded from macro MYSQL_VERSION_MAJOR

来源:SegmentFault

时间:2023-02-24 20:44:17 343浏览 收藏

你在学习数据库相关的知识吗?本文《MySQL 源码阅读 —— 问题 expanded from macro MYSQL_VERSION_MAJOR》,主要介绍的内容就涉及到MySQL、数据库、MacOS、C++、源码分析,如果你想提升自己的开发能力,就不要错过这篇文章,大家要知道编程理论基础和实战操作都是不可或缺的哦!

问题描述

在执行
Building C object storage/myisam/CMakeFiles/myisam.dir/mi_rfirst.c.o
In file included from /path/to/mysql-5.7.35/storage/perfschema/cursor_by_account.cc:28:
In file included from /path/to/mysql-5.7.35/include/my_global.h:57:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/math.h:309:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/type_traits:417:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/cstddef:37:
/path/to/mysql-5.7.35/version:1:1: error: expected unqualified-id
MYSQL_VERSION_MAJOR=5
^
/path/to/mysql-5.7.35/include/my_config.h:404:29: note: expanded from macro 'MYSQL_VERSION_MAJOR'
#define MYSQL_VERSION_MAJOR 5
                            ^

原因排查

通过 Homebrew 的 mysql@5.7.rb,找到了一个 PATCH。

在 MySQL 的 Commit 记录 Bug #31466846 RENAME THE VERSION FILE TO MYSQL_VERSION 找到了答案:

Bug #31466846 RENAME THE VERSION FILE TO MYSQL_VERSION
With new versions of boost, the build is broken on windows.
 is a header file which is part of C++11, but on win we
include our own VERSION instead, and the build breaks.

The solution is 'git mv VERSION MYSQL_VERSION', and adapt
cmake code accordingly.

Change-Id: I5211cf41fa83e879a25d4110dbb8933cd58da2f9
 8.0
 mysql-cluster-8.0.26  mysql-cluster-8.0.25 mysql-cluster-8.0.24 mysql-cluster-8.0.23 mysql-cluster-8.0.22 mysql-8.0.26 mysql-8.0.25 mysql-8.0.24 mysql-8.0.23 mysql-8.0.22
Tor Didriksen committed on 10 Jun 2020 
1 parent 6653b43 commit 51675ddb41661163c23e802a3e5eedb1344ce023

大概意思是:

diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake
index 43d731e..3031258 100644
--- a/cmake/mysql_version.cmake
+++ b/cmake/mysql_version.cmake
@@ -31,7 +31,7 @@ SET(DOT_FRM_VERSION "6")

 # Generate "something" to trigger cmake rerun when VERSION changes
 CONFIGURE_FILE(
-  ${CMAKE_SOURCE_DIR}/VERSION
+  ${CMAKE_SOURCE_DIR}/MYSQL_VERSION
   ${CMAKE_BINARY_DIR}/VERSION.dep
 )

@@ -39,7 +39,7 @@ CONFIGURE_FILE(

 MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
  IF(NOT ${var})
-   FILE (STRINGS ${CMAKE_SOURCE_DIR}/VERSION str REGEX "^[ ]*${keyword}=")
+   FILE (STRINGS ${CMAKE_SOURCE_DIR}/MYSQL_VERSION str REGEX "^[ ]*${keyword}=")
    IF(str)
      STRING(REPLACE "${keyword}=" "" str ${str})
      STRING(REGEX REPLACE  "[ ].*" ""  str "${str}")

写好的脚本直接用:

mv VERSION MYSQL_VERSION
sed -i '' 's|${CMAKE_SOURCE_DIR}/VERSION|${CMAKE_SOURCE_DIR}/MYSQL_VERSION|g' cmake/mysql_version.cmake

参考资料


感谢您的阅读,觉得内容不错,点个赞吧 😆
原文地址: https://shockerli.net/post/mysql-source-version-conflict-in-cpp-11/

今天关于《MySQL 源码阅读 —— 问题 expanded from macro MYSQL_VERSION_MAJOR》的内容介绍就到此结束,如果有什么疑问或者建议,可以在golang学习网公众号下多多回复交流;文中若有不正之处,也希望回复留言以告知!

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>
评论列表