Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-31992

Automatic conversion from LEX_STRING to LEX_CSTRING

    XMLWordPrintable

Details

    Description

      Let's add automatic conversion operator from LEX_STRING to LEX_CSTRING.

      struct st_mysql_lex_string
      {
        char *str;
        size_t length;
      #ifdef __cplusplus
        // Allow automatic cast from LEX_STRING to LEX_CSTRING in c++.
        operator struct st_mysql_const_lex_string() const
        {
          return {str, length};
        }
      #endif
      

      This will help to remove some duplicate functions/methods accepting LEX_CSTRING and LEX_STRING and to avoid adding duplicate functions/methods in the future.

      Duplicate methods:

        Lex_cstring_with_compare(const LEX_STRING src) :
          Lex_cstring(src.str, src.length)
        { }
        Lex_cstring_with_compare(const LEX_CSTRING src) : Lex_cstring(src.str, src.length)
        { }
      

        Storage_engine_name(const LEX_CSTRING &name)
         :m_storage_engine_name(name)
        { }
        Storage_engine_name(const LEX_STRING &name)
        {
          m_storage_engine_name.str= name.str;
          m_storage_engine_name.length= name.length;
        }
      

        // Append with optional character set conversion from ASCII (e.g. to UCS2)
        bool append(const LEX_STRING *ls)
        {
          DBUG_ASSERT(ls->length < UINT_MAX32 &&
                      ((ls->length == 0 && !ls->str) ||
                       ls->length == strlen(ls->str)));
          return append(ls->str, (uint32) ls->length);
        }
        bool append(const LEX_CSTRING *ls)
        {
          DBUG_ASSERT(ls->length < UINT_MAX32 &&
                      ((ls->length == 0 && !ls->str) ||
                       ls->length == strlen(ls->str)));
          return append(ls->str, (uint32) ls->length);
        }
      

      The version with LEX_STRING should be removed.

      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.