1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-4734 Compilation failure: MariaDB-10.6 + ColumnStore-develop

mcsconfig.h and my_config.h have the following
pre-processor definitions:

1. Conflicting definitions coming from the standard cmake definitions:
- PACKAGE
- PACKAGE_BUGREPORT
- PACKAGE_NAME
- PACKAGE_STRING
- PACKAGE_TARNAME
- PACKAGE_VERSION
- VERSION

2. Conflicting definitions of other kinds:
- HAVE_STRTOLL - this is a dirt in MariaDB headers.
  Should be fixed in the server code. my_config.h erroneously
  performs "#define HAVE_STRTOLL" instead of "#define HAVE_STRTOLL 1".
  in some cases. The former is not CMake compatible style. The latter is.

3. Non-conflicting definitions:
  Otherwise, mcsconfig.h and my_config.h should be mutually compatible,
  because both are generated by cmake on the same host machine. So
  they should have exactly equal definitions like "HAVE_XXX", "SIZEOF_XXX", etc.

Observations:
- It's OK to include both mcsconfig.h and my_config.h providing that we
  suppress duplicate definition of the above conflicting types #1 and #2.
- There is no a need to suppress duplicate definitions mentioned in #3,
  as they are compatible!
- my_sys.h and m_ctype.h must always follow a CMake configuation header,
  either my_config.h or mcsconfig.h (or both).
  They must never be included without any preceeding configuration header.

This change make sure that we resolve conflicts by:
- either disallowing inclusion of mcsconfig.h and my_config.h
  at the same time
- or by hiding conflicting definitions #1 and #2
  (with their later restoring).
- also, by making sure that my_sys.h and m_ctype.h always follow
  a CMake configuration file.

Details:
- idb_mysql.h can now only be included only after my_config.h
  An attempt to use idb_mysql.h with mcsconfig.h instead of
  my_config.h is caught by the "#error" preprocessor directive.

- mariadb_my_sys.h can now be only included after mcsconfig.h.
  An attempt to use mariadb_my_sys.h without mcscofig.h
  (e.g. with my_config.h) is also caught by "#error".

- collation.h now can now be included in two ways.
  It now has the following effective structure:

    #if defined(PREFER_MY_CONFIG_H) && defined(MY_CONFIG_H)
    //  Remember current conflicting definitions on the preprocessor stack
    //  Undefine current conflicting definitions
    #endif
    #include "mcsconfig.h"
    #include "m_ctype.h"
    #if defined(PREFER_MY_CONFIG_H) && defined(MY_CONFIG_H)
    #    Restore conflicting definitions from the preprocessor stack
    #endif

  and can be included as follows:

  a. using only mcsconfig.h as a configuration header:

    // my_config.h must not be included so far
    #include "collation.h"

  b. using my_config.h as the first included configuration file:

    #define PREFER_MY_CONFIG_H // Force conflict resolution
    #include "my_config.h"     // can be included directly or indirectly
    ...
    #include "collation.h"

Other changes:

- Adding helper header files
     utils/common/mcsconfig_conflicting_defs_remember.h
     utils/common/mcsconfig_conflicting_defs_restore.h
     utils/common/mcsconfig_conflicting_defs_undef.h
  to perform conflict resolution easier.

- Removing `#include "collation.h"` from a number of files,
  as it's automatically included from rowgroup.h.

- Removing redundant `#include "utils_utf8.h"`.
  This change is not directly related to the problem being fixed,
  but it's nice to remove redundant directives for both collation.h
  and utils_utf8.h from all the files that do not really need them.
  (this change could probably have gone as a separate commit)

- Changing my_init() to MY_INIT(argv[0]) in the MCS services sources.
  After the fix of the complitation failure it appeared that ColumnStore
  services compiled with the debug build crash due to recent changes in
  safemalloc. The crash happened in strcmp() with `my_progname` as an argument
  (where my_progname is a mysys global variable). This problem should
  probably be fixed on the server side as well to avoid passing NULL.
  But, the majority of MariaDB executable programs also use MY_INIT(argv[0])
  rather than my_init(). So let's make MCS do like the other programs do.
This commit is contained in:
Alexander Barkov
2021-05-24 14:21:38 +04:00
parent 6448742225
commit 9608533d92
92 changed files with 203 additions and 127 deletions

View File

@ -18,6 +18,23 @@
#ifndef COLLATION_H_INCLUDED
#define COLLATION_H_INCLUDED
#if defined(PREFER_MY_CONFIG_H)
#if !defined(MY_CONFIG_H)
#error my_config.h was not included (but PREFER_MY_CONFIG_H was set)
#endif
#include "mcsconfig_conflicting_defs_remember.h"
#include "mcsconfig_conflicting_defs_undef.h"
#else
#if defined(MY_CONFIG_H)
#error my_config.h was included before mcsconfig.h (and PREFER_MY_CONFIG_H was not set)
#endif
#endif //PREFER_MY_CONFIG_H
#include "mcsconfig.h"
#include "exceptclasses.h"
#include "conststring.h"
@ -82,6 +99,11 @@ extern "C" MYSQL_PLUGIN_IMPORT CHARSET_INFO *default_charset_info;
#endif
#if defined(PREFER_MY_CONFIG_H)
#include "mcsconfig_conflicting_defs_restore.h"
#endif
namespace datatypes
{

View File

@ -22,8 +22,18 @@
// This must be included after any boost headers, or anything that includes
// boost headers. <mariadb.h> and boost are not friends.
#ifndef TEST_MCSCONFIG_H
#error mcscofig.h was not included
#endif
#include "mcsconfig_conflicting_defs_remember.h"
#include "mcsconfig_conflicting_defs_undef.h"
#include <mariadb.h>
#undef set_bits // mariadb.h defines set_bits, which is incompatible with boost
#include <my_sys.h>
#include "mcsconfig_conflicting_defs_restore.h"
#endif

View File

@ -0,0 +1,32 @@
/*
Copyright (C) 2021 MariaDB Corporation
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 Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/*
Remember all conflicting definitions
(between my_config.h and mcsconfig.h)
so that we can restore them later.
*/
#pragma push_macro("PACKAGE")
#pragma push_macro("PACKAGE_BUGREPORT")
#pragma push_macro("PACKAGE_NAME")
#pragma push_macro("PACKAGE_STRING")
#pragma push_macro("PACKAGE_TARNAME")
#pragma push_macro("PACKAGE_VERSION")
#pragma push_macro("VERSION")
#pragma push_macro("HAVE_STRTOLL")

View File

@ -0,0 +1,32 @@
/*
Copyright (C) 2021 MariaDB Corporation
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 Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/*
Restore all conflicting definitions
(between my_config.h and mcsconfig.h)
previously remembered by mcsconfig_conflicting_defs_remember.h
*/
#pragma pop_macro("PACKAGE")
#pragma pop_macro("PACKAGE_BUGREPORT")
#pragma pop_macro("PACKAGE_NAME")
#pragma pop_macro("PACKAGE_STRING")
#pragma pop_macro("PACKAGE_TARNAME")
#pragma pop_macro("PACKAGE_VERSION")
#pragma pop_macro("VERSION")
#pragma pop_macro("HAVE_STRTOLL")

View File

@ -0,0 +1,34 @@
/*
Copyright (C) 2021 MariaDB Corporation
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 Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/*
Undefine all conflicting definitions
(between my_config.h and mcsconfig.h)
so that we include:
- mcsconfig.h after my_config.h, or
- my_config.h after mcsconfig.h
*/
#undef PACKAGE
#undef PACKAGE_BUGREPORT
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
#undef VERSION
#undef HAVE_STRTOLL

View File

@ -14,10 +14,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#include "utils_utf8.h"
#include "collation.h"
#include "mariadb_my_sys.h"
#include <m_ctype.h>
namespace datatypes

View File

@ -38,7 +38,6 @@ using namespace execplan;
#include "idberrorinfo.h"
#include "errorids.h"
#include "collation.h"
using namespace logging;

View File

@ -40,10 +40,8 @@ using namespace rowgroup;
#include "errorids.h"
using namespace logging;
#include "utils_utf8.h"
using namespace funcexp;
#include "collation.h"
namespace
{

View File

@ -42,7 +42,6 @@ using namespace logging;
#include "dataconvert.h"
#include "numericliteral.h"
using namespace dataconvert;
#include "collation.h"
#include "checks.h"

View File

@ -38,8 +38,6 @@ using namespace rowgroup;
#include "errorids.h"
using namespace logging;
#include "collation.h"
#include "mariadb_my_sys.h"
#include <myisampack.h> // min_intXstore()
#include "vlarray.h"
@ -169,7 +167,7 @@ string Func_char::getStrVal(Row& row,
{
numBytes = actualBytes;
ostringstream os;
os << "Invalid character string for " << cs->csname << ": value = " << hex << buf + actualBytes;
os << "Invalid character string for " << cs->cs_name.str << ": value = " << hex << buf + actualBytes;
logging::Message::Args args;
logging::Message message(9);
args.add(os.str());

View File

@ -30,7 +30,6 @@ using namespace std;
#include "functioncolumn.h"
#include "rowgroup.h"
#include "calpontsystemcatalog.h"
#include "utils_utf8.h"
using namespace execplan;
#include "dataconvert.h"
@ -39,7 +38,6 @@ using namespace execplan;
#include "idberrorinfo.h"
#include "errorids.h"
#include "collation.h"
using namespace logging;

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"

View File

@ -20,7 +20,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"

View File

@ -26,13 +26,12 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
#include "utils_utf8.h" // idb_mbstowcs()
using namespace execplan;
#include "rowgroup.h"
using namespace rowgroup;
#include "collation.h"
namespace funcexp
{

View File

@ -33,10 +33,8 @@ using namespace rowgroup;
#include "errorids.h"
using namespace logging;
#include "utils_utf8.h"
using namespace funcexp;
#include "collation.h"
namespace
{

View File

@ -42,7 +42,6 @@ using namespace execplan;
#include "errorids.h"
using namespace logging;
#include "collation.h"
namespace funcexp
{

View File

@ -37,10 +37,8 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "utils_utf8.h"
using namespace funcexp;
#include "collation.h"
namespace funcexp
{

View File

@ -41,10 +41,8 @@ using namespace execplan;
#include "errorids.h"
using namespace logging;
#include "utils_utf8.h"
using namespace funcexp;
#include "collation.h"
namespace
{

View File

@ -37,7 +37,6 @@ using namespace joblist;
#include "utf8.h"
using namespace utf8;
#include "collation.h"
namespace funcexp
{

View File

@ -29,11 +29,8 @@ using namespace std;
#include "functor_int.h"
#include "functioncolumn.h"
#include "rowgroup.h"
#include "utils_utf8.h"
using namespace execplan;
#include "collation.h"
namespace funcexp
{
CalpontSystemCatalog::ColType Func_instr::operationType( FunctionParm& fp, CalpontSystemCatalog::ColType& resultType )

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -37,10 +37,8 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "utils_utf8.h"
using namespace funcexp;
#include "collation.h"
namespace funcexp
{

View File

@ -25,7 +25,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -34,7 +33,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -33,7 +33,6 @@ using namespace execplan;
#include "rowgroup.h"
#include "collation.h"
namespace funcexp
{

View File

@ -27,7 +27,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -36,9 +35,7 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
#include <mariadb.h> // INT_MAX32
#define INT_MAX32 0x7FFFFFFF
namespace funcexp
{

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -42,10 +42,8 @@ using namespace logging;
using namespace dataconvert;
#include "funchelpers.h"
#include "utils_utf8.h"
using namespace funcexp;
#include "collation.h"
namespace funcexp
{

View File

@ -34,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -28,7 +28,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -34,8 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
#include <mariadb.h> // DBUG_ASSERT
namespace funcexp
{
@ -76,7 +74,7 @@ std::string Func_reverse::getStrVal(rowgroup::Row& row,
if ((l = my_ismbchar(cs, pos, end)))
{
tmp -= l;
DBUG_ASSERT(tmp >= pbuf);
idbassert(tmp >= pbuf);
memcpy(tmp, pos, l);
pos += l;
}

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,8 +34,7 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
#include <mariadb.h> // INT_MAX32
#define INT_MAX32 0x7FFFFFFF
namespace funcexp
{

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -36,10 +36,8 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "utils_utf8.h"
using namespace funcexp;
#include "collation.h"
namespace funcexp

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -34,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -21,7 +21,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -30,7 +29,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
namespace funcexp
{

View File

@ -26,7 +26,6 @@ using namespace std;
#include "functor_str.h"
#include "functioncolumn.h"
#include "utils_utf8.h"
using namespace execplan;
#include "rowgroup.h"
@ -35,7 +34,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "collation.h"
class to_upper
{

View File

@ -32,7 +32,7 @@
#include "IDBLogger.h"
#include "IDBFactory.h"
#ifdef _MSC_VER
#include "utils_utf8.h"
#include "utils_utf8.h" // idb_wcstombs()
#endif
#include "installdir.h"

View File

@ -21,8 +21,10 @@
*
***********************************************************************/
#define PREFER_MY_CONFIG_H
#include <my_config.h>
#include <mysql.h>
#include <string>
using namespace std;

View File

@ -49,10 +49,8 @@
#include "funcexp.h"
#include "rowaggregation.h"
#include "calpontsystemcatalog.h"
#include "utils_utf8.h"
#include "vlarray.h"
#include "collation.h"
//..comment out NDEBUG to enable assertions, uncomment NDEBUG to disable
//#define NDEBUG

View File

@ -53,7 +53,6 @@
#include "mcsv1_udaf.h"
#include "constantcolumn.h"
#include "collation.h"
// To do: move code that depends on joblist to a proper subsystem.
namespace joblist

View File

@ -45,7 +45,6 @@ using namespace execplan;
#include "dataconvert.h"
#include "columnwidth.h"
#include "collation.h"
namespace rowgroup
{

View File

@ -48,7 +48,6 @@ using namespace rowgroup;
#include "joblisttypes.h"
#include "mcs_decimal.h"
#include "collation.h"
// See agg_arg_charsets in sql_type.h to see conversion rules for
// items that have different char sets