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

Reduce the size of Lex_length_and_dec_st from 16 to 8

    XMLWordPrintable

Details

    Description

      We want to use Bison stack more efficiently and pass more structures through the stack instead of using Lex members.

      In particular, we want to get rid of Lex->charset. This change is really overdue.

      To be able to do this, we want to pass through the Bison stack a structure with data type handler and its basic attributes, consisting of the following four members:

      struct {
        const Type_handler *handler;
        CHARSET_INFO *charset;
        Lex_length_and_dec_st length_and_dec;
      };
      

      This structure should fit into the Bison variable limitation (see sql_yacc.yy):

      /* avoid unintentional %union size increases, it's what a parser stack made of */
      static_assert(sizeof(YYSTYPE) == sizeof(void*)*2+8, "%union size check");
      

      Currently this structure would not fit because Lex_length_and_dec_st consists of two pointers and therefore occupies 16 bytes (on 64bit platforms):

      struct Lex_length_and_dec_st
      {
      private:
        const char *m_length;
        const char *m_dec;
      public:
      

      Let's reduce the size of Lex_length_and_dec_st from current 16 bytes as follows:

      struct Lex_length_and_dec_st
      {
      private:
        uint32 m_length;
        uint8  m_dec;
        bool   m_has_explicit_length:1;
        bool   m_has_explicit_dec:1;
      public:
      

      After this change, the future structure consisting of the four fields (mentioned above) will occupy 24 bytes:

      struct {
        const Type_handler *handler;          // 8 bytes
        CHARSET_INFO *charset;                // 8 bytes
        Lex_length_and_dec_st length_and_dec; // 8 bytes
      };
      

      Note, this task is only about changing Lex_length_and_dec_st. The new structure (with handler, charset, length and dec) will be added later, under terms of a separate task.

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.