[MCOL-4422] Remove mariadb.h and my_sys.h dependency from collation.h Created: 2020-11-30  Updated: 2020-12-02  Resolved: 2020-12-02

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 5.4.3
Fix Version/s: 5.5.1

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MCOL-495 Make string comparison not case sensi... Closed
blocks MCOL-4065 DISTINCT is case sensitive Closed
blocks MCOL-4388 Equality does not respect the NOPAD c... Closed
blocks MCOL-4417 Non-equality comparison operators do ... Closed

 Description   

collation.h currently looks as follows:

// These are the common headers needed to use the MariaDB collation library
 
// This must be included after any boost headers, or anything that includes
// boost headers. <mariadb.h> and boost are not friends.
#include <mariadb.h>
#undef set_bits  // mariadb.h defines set_bits, which is incompatible with boost
#include <my_sys.h>
#include <m_ctype.h>
#include <myisampack.h>

The above headers cause conflicts with MCS and boost headers.

Note, the header m_ctype.h itself does not need most of <mariadb.h> and <my_sys.h>.

It only needs the following declarations:

typedef long long int longlong;
typedef unsigned long long int ulonglong;
typedef uint32_t uint32;
typedef uint16_t uint16;
typedef char my_bool;
typedef unsigned char uchar;
 
typedef char    pchar;          /* Mixed prototypes can take char */
typedef char    puchar;         /* Mixed prototypes can take char */
typedef char    pbool;          /* Mixed prototypes can take char */
typedef short   pshort;         /* Mixed prototypes can take short int */
typedef float   pfloat;         /* Mixed prototypes can take float */
 
#define FALSE (0)
#define TRUE  (1)
#define DBUG_ASSERT(x)  idbassert(x)

Let's do the following:

  • Remove the dependency on <myisampack.h> from collation.h. It's needed only in func_char.cpp.
  • Remove the redundant dependencies on <mariadb.h> and <my_sys.h> from collation.h.
  • Add the above mentioned typedefs into collation.h before including <m_ctype.h>
  • Introduce a new class in collation.h

    class Charset
    {
    protected:
        const struct charset_info_st & mCharset;
    public:
        Charset(CHARSET_INFO & cs) :mCharset(cs) { }
        Charset(uint32_t charsetNumber);
        CHARSET_INFO & getCharset() const { return mCharset; }
    };
    

  • Implement this constructor:

     Charset(uint32_t charsetNumber);

    inside a *.cpp file, so only this cpp file needs to include <my_sys.h> for the prototype of get_charset().

As a result, collation.h will be an non-conflicting file, so we can freely include it from various other headers, e.g. from calpontsystemcatalog.h, without any conflicts.

Later we'll add more methods into the new class Charset, e.g. convenience wrappers to handle std::string etc.


Generated at Thu Feb 08 02:50:14 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.