Details

    Description

      To reduce the number of parameters in Type_handler methods (such as make_table_field_from_def(), see MDEV-9216), we'll introduce a new class representing the position and the offset of a bit.
      It will be reused for:

      • NULL bits (for NULL-able columns)
      • Data bits (for the BIT(N) data type, and similar)

      The tentative prototype:

      class Bit_addr
      {
        /**
          Byte where the bit is stored inside a record.
          If the corresponding Field is a NOT NULL field, this member is NULL.
        */
        uchar *m_ptr;
        /**
          Offset of the bit inside m_ptr[0], in the range 0..7.
        */
        uchar m_offs;
      public:
        Bit_addr(uchar *ptr, uchar offs)
         :m_ptr(ptr), m_offs(offs)
        {
          DBUG_ASSERT(ptr || offs == 0);
          DBUG_ASSERT(offs < 8);
        }
        uchar *ptr() const { return m_ptr; }
        uchar offs() const { return m_offs; }
        uchar bit() const { return m_ptr ? ((uchar) 1) << m_offs : 0; }
      };
      

      Encapsulation is needed for better consistency control, to make sure that m_ptr and m_offs always represent valid combinations.

      To further reuse the code, we'll replace Record_addr members null_ptr and null_bit to an instance of Bit_addr.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Description To reduce the number of parameters in Type_handler methods (such as {{make_table_field_from_def()}}, see MDEV-9216), we'll introduce a new class representing the position and the offset of a bit.
            It will be reused for:
            - NULL bits (for NULL-able columns)
            - Data bits (for the BIT(N) data type, and similar)

            The tentative prototype:

            {code:sql}
            class Bit_addr
            {
              /**
                Byte where the bit is stored inside a record.
                If the corresponding Field is a NOT NULL field, this member is NULL.
              */
              uchar *m_ptr;
              /**
                Offset of the bit inside m_ptr[0], in the range 0..7.
              */
              uchar m_offs;
            public:
              Bit_addr(uchar *ptr, uchar offs)
               :m_ptr(ptr), m_offs(offs)
              {
                DBUG_ASSERT(ptr || offs == 0);
                DBUG_ASSERT(offs < 8);
              }
              uchar *ptr() const { return m_ptr; }
              uchar offs() const { return m_offs; }
              uchar bit() const { return m_ptr ? ((uchar) 1) << m_offs : 0; }
            };
            {code}

            Encapsulation is needed for better consistency control, to make sure that m_ptr and m_offs always represent valid combinations.

            To further reuse the code, we'll derive {{Record_addr}} from {{Bit_addr}}.
            To reduce the number of parameters in Type_handler methods (such as {{make_table_field_from_def()}}, see MDEV-9216), we'll introduce a new class representing the position and the offset of a bit.
            It will be reused for:
            - NULL bits (for NULL-able columns)
            - Data bits (for the BIT(N) data type, and similar)

            The tentative prototype:

            {code:sql}
            class Bit_addr
            {
              /**
                Byte where the bit is stored inside a record.
                If the corresponding Field is a NOT NULL field, this member is NULL.
              */
              uchar *m_ptr;
              /**
                Offset of the bit inside m_ptr[0], in the range 0..7.
              */
              uchar m_offs;
            public:
              Bit_addr(uchar *ptr, uchar offs)
               :m_ptr(ptr), m_offs(offs)
              {
                DBUG_ASSERT(ptr || offs == 0);
                DBUG_ASSERT(offs < 8);
              }
              uchar *ptr() const { return m_ptr; }
              uchar offs() const { return m_offs; }
              uchar bit() const { return m_ptr ? ((uchar) 1) << m_offs : 0; }
            };
            {code}

            Encapsulation is needed for better consistency control, to make sure that m_ptr and m_offs always represent valid combinations.

            To further reuse the code, we'll replace {{Record_addr}} members {{null_ptr}} and {{null_bit}} to an instance of {{Bit_addr}}.
            bar Alexander Barkov made changes -
            issue.field.resolutiondate 2018-05-24 05:32:02.0 2018-05-24 05:32:02.164
            bar Alexander Barkov made changes -
            Fix Version/s 10.4.0 [ 23115 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 87436 ] MariaDB v4 [ 133554 ]

            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.