Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-4422

Remove mariadb.h and my_sys.h dependency from collation.h

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 5.4.3
    • 5.5.1
    • PrimProc
    • None

    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.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.