Skip to content

Commit

Permalink
Bug #24573230: REMOVE #DEFINES WITH GLOBAL INFLUENCE FROM MY_GLOBAL.H
Browse files Browse the repository at this point in the history
my_global.h should not have #defines that modify behavior of system
headers; this is brittle, and better suited to CMake options,
so move it there.

It should also not try to #undef symbols from other files, which is
again brittle (especially as these symbols tend to change without
people remembering to update my_global.h -- it seems to already have
happened during the introduction of yaSSL). Instead, make sure these
symbols are simply not added during compilation in the first place.
Every plugin now gets compiled with ${SSL_DEFINES} added automatically,
so they don't have to add that manually -- except if they are recompiled
for embedded, in which case ${SSL_DEFINES} is never added in the first
place (instead of having to #undef them).

I've double-checked that the logic for EMBEDDED_LIBRARY is the same
by manually adding #error directives in my_global.h and compiling
(then removed them again before submission).

Change-Id: I70c0e2db82a9b65a1b0a5e35b75ce861bc1cdc0a
  • Loading branch information
Steinar H. Gunderson committed Sep 2, 2016
1 parent ba8d0b2 commit abbd9d9
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 41 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -570,6 +570,10 @@ INCLUDE(configure.cmake)
# Common defines and includes
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
ADD_DEFINITIONS(-DRAPIDJSON_NO_SIZETYPEDEFINE)
ADD_DEFINITIONS(-D__STDC_LIMIT_MACROS) # Enable C99 limit macros
ADD_DEFINITIONS(-D__STDC_FORMAT_MACROS) # Enable C99 printf format macros
ADD_DEFINITIONS(-D_USE_MATH_DEFINES) # Get access to M_PI, M_E, etc. in math.h

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_SOURCE_DIR}/extra/rapidjson/include
Expand Down
4 changes: 3 additions & 1 deletion cmake/plugin.cmake
Expand Up @@ -124,6 +124,8 @@ MACRO(MYSQL_ADD_PLUGIN)
ADD_CONVENIENCE_LIBRARY(${target} STATIC ${SOURCES})
SET_TARGET_PROPERTIES(${target}
PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER")
SET_TARGET_PROPERTIES(${target}
PROPERTIES COMPILE_FLAGS ${SSL_DEFINES})

DTRACE_INSTRUMENT(${target})
ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
Expand All @@ -136,7 +138,7 @@ MACRO(MYSQL_ADD_PLUGIN)
DTRACE_INSTRUMENT(${target}_embedded)
IF(ARG_RECOMPILE_FOR_EMBEDDED)
SET_TARGET_PROPERTIES(${target}_embedded
PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER;EMBEDDED_LIBRARY")
PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER;EMBEDDED_LIBRARY;NO_EMBEDDED_ACCESS_CHECKS")
ENDIF()
ADD_DEPENDENCIES(${target}_embedded GenError)
ENDIF()
Expand Down
11 changes: 0 additions & 11 deletions include/my_global.h
Expand Up @@ -25,10 +25,6 @@

#include "my_config.h"

#define __STDC_LIMIT_MACROS /* Enable C99 limit macros */
#define __STDC_FORMAT_MACROS /* Enable C99 printf format macros */
#define _USE_MATH_DEFINES /* Get access to M_PI, M_E, etc. in math.h */

#ifdef _WIN32
/* Include common headers.*/
# include <winsock2.h>
Expand Down Expand Up @@ -521,13 +517,6 @@ typedef char my_bool; /* Small bool */
#define MYSQL_PLUGIN_IMPORT
#endif

#ifdef EMBEDDED_LIBRARY
#define NO_EMBEDDED_ACCESS_CHECKS
/* Things we don't need in the embedded version of MySQL */
#undef HAVE_OPENSSL
#endif /* EMBEDDED_LIBRARY */


enum loglevel {
ERROR_LEVEL= 0,
WARNING_LEVEL= 1,
Expand Down
3 changes: 1 addition & 2 deletions libmysqld/CMakeLists.txt
Expand Up @@ -13,8 +13,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY
${SSL_DEFINES})
ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY -DNO_EMBEDDED_ACCESS_CHECKS)

INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/include
Expand Down
6 changes: 4 additions & 2 deletions libmysqld/examples/CMakeLists.txt
@@ -1,4 +1,4 @@
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 2016, Oracle 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
Expand All @@ -21,7 +21,8 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
)


ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT)
ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -DNO_EMBEDDED_ACCESS_CHECKS)
REMOVE_DEFINITIONS(-DMYSQL_CLIENT)


MYSQL_ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
Expand All @@ -43,6 +44,7 @@ ENDIF()



REMOVE_DEFINITIONS(${SSL_DEFINES})
MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc)
TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver)

Expand Down
5 changes: 1 addition & 4 deletions storage/ndb/memcache/src/ClusterConnectionPool.cc
@@ -1,5 +1,5 @@
/*
Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights
reserved.
This program is free software; you can redistribute it and/or
Expand All @@ -21,9 +21,6 @@
#include <my_config.h>
#include <stdio.h>
#include <assert.h>

/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <pthread.h>

Expand Down
5 changes: 1 addition & 4 deletions storage/ndb/memcache/src/DataTypeHandler.cc
@@ -1,5 +1,5 @@
/*
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights
reserved.
This program is free software; you can redistribute it and/or
Expand All @@ -24,9 +24,6 @@
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>

/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

#include <NdbApi.hpp>
Expand Down
3 changes: 1 addition & 2 deletions storage/ndb/memcache/src/ndb_flush.cc
@@ -1,5 +1,5 @@
/*
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2011, 2016, Oracle 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
Expand All @@ -21,7 +21,6 @@
#include <my_config.h>

/* System headers */
#define __STDC_FORMAT_MACROS
#include <assert.h>
#include <ctype.h>

Expand Down
4 changes: 1 addition & 3 deletions storage/ndb/memcache/src/ndb_pipeline.cc
@@ -1,5 +1,5 @@
/*
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights
reserved.
This program is free software; you can redistribute it and/or
Expand All @@ -22,8 +22,6 @@
#include <pthread.h>
#include <stdio.h>

/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

#include "config.h"
Expand Down
3 changes: 1 addition & 2 deletions storage/ndb/memcache/src/ndb_worker.cc
@@ -1,5 +1,5 @@
/*
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights
reserved.
This program is free software; you can redistribute it and/or
Expand All @@ -22,7 +22,6 @@
#include <my_config.h>

/* System headers */
#define __STDC_FORMAT_MACROS
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down
1 change: 0 additions & 1 deletion storage/ndb/memcache/src/schedulers/S_sched.cc
Expand Up @@ -23,7 +23,6 @@
#include <ctype.h>
#include <stdio.h>
#include <sys/errno.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

/* Memcache headers */
Expand Down
3 changes: 1 addition & 2 deletions storage/ndb/memcache/src/schedulers/Scheduler73.cc
@@ -1,5 +1,5 @@
/*
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights
reserved.
This program is free software; you can redistribute it and/or
Expand All @@ -22,7 +22,6 @@
#include <ctype.h>
#include <stdio.h>
#include <sys/errno.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

/* Memcache headers */
Expand Down
2 changes: 0 additions & 2 deletions storage/ndb/memcache/src/schedulers/Stockholm.cc
Expand Up @@ -22,8 +22,6 @@
#include <my_config.h>

/* System headers */
/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <stdio.h>

Expand Down
3 changes: 1 addition & 2 deletions storage/ndb/memcache/src/schedulers/Trondheim.cc
@@ -1,5 +1,5 @@
/*
Copyright (c) 2015, Oracle and/or its affiliates. All rights
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights
reserved.
This program is free software; you can redistribute it and/or
Expand All @@ -23,7 +23,6 @@
#include <ctype.h>
#include <stdio.h>
#include <sys/errno.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>

/* Memcache headers */
Expand Down
3 changes: 0 additions & 3 deletions storage/perfschema/CMakeLists.txt
Expand Up @@ -23,9 +23,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}
${SSL_INCLUDE_DIRS})

ADD_DEFINITIONS(-DMYSQL_SERVER)
IF (SSL_DEFINES)
ADD_DEFINITIONS(${SSL_DEFINES})
ENDIF()

#
# Maintainer: keep this list sorted, to avoid merge collisions.
Expand Down

0 comments on commit abbd9d9

Please sign in to comment.