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

Split filesort.cc:make_sortkey() and filesort.cc::sortlength() into virtual methods in Type_handler

Details

    Description

      In order to make the built-in and pluggable data types look similar inside the server code, we'll split these functions into virtual methods in Type_handler:

      static void make_sortkey(register Sort_param *param,
                               register uchar *to, uchar *ref_pos)
      {
      ...
      }
      static uint
      sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
                 bool *multi_byte_charset)
      {
      ...
      }

      The relevant pieces of the code in the original data type plugin patch:

      --- sql/filesort.cc	2014-06-12 08:57:03 +0000
      +++ sql/filesort.cc	2014-06-25 13:34:23 +0000
      @@ -976,6 +976,13 @@ static void make_sortkey(register Sort_p
             if ((maybe_null = field->maybe_null()))
               to++;
           }
      +    else if (const Type_handler *handler= Type_handlers.handler(sort_field->item->field_type()))
      +    {
      +      if ((maybe_null= sort_field->item->maybe_null))
      +        *to++= 1;
      +      if (handler->make_sort_key(sort_field, to) && maybe_null)
      +        to[-1]= '\0';
      +    }
           else
           {						// Item
             Item *item=sort_field->item;
      @@ -1881,6 +1887,12 @@ sortlength(THD *thd, SORT_FIELD *sortord
             if (sortorder->field->maybe_null())
       	length++;				// Place for NULL marker
           }
      +    else if (const Type_handler *handler= Type_handlers.handler(sortorder->item->field_type()))
      +    {
      +      handler->sortlength(sortorder, sortorder->item);
      +      if (sortorder->item->maybe_null)
      +        length++;
      +    }
           else
           {
             sortorder->result_type= sortorder->item->cmp_type();

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            bar Alexander Barkov made changes -
            Labels refactoring
            bar Alexander Barkov made changes -
            Description In order to make the built-in and pluggable data types look similar inside the server code, we'll split these functions into virtual methods in Type_handler:
            {code}
            static void make_sortkey(register Sort_param *param,
                                     register uchar *to, uchar *ref_pos)
            {
            ...
            }
            static uint
            sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
                       bool *multi_byte_charset)
            {
            ...
            }
            {code}
            In order to make the built-in and pluggable data types look similar inside the server code, we'll split these functions into virtual methods in Type_handler:
            {code}
            static void make_sortkey(register Sort_param *param,
                                     register uchar *to, uchar *ref_pos)
            {
            ...
            }
            static uint
            sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
                       bool *multi_byte_charset)
            {
            ...
            }
            {code}

            The relevant pieces of the code in the original data type plugin patch:
            {code}
            --- sql/filesort.cc 2014-06-12 08:57:03 +0000
            +++ sql/filesort.cc 2014-06-25 13:34:23 +0000
            @@ -976,6 +976,13 @@ static void make_sortkey(register Sort_p
                   if ((maybe_null = field->maybe_null()))
                     to++;
                 }
            + else if (const Type_handler *handler= Type_handlers.handler(sort_field->item->field_type()))
            + {
            + if ((maybe_null= sort_field->item->maybe_null))
            + *to++= 1;
            + if (handler->make_sort_key(sort_field, to) && maybe_null)
            + to[-1]= '\0';
            + }
                 else
                 { // Item
                   Item *item=sort_field->item;
            @@ -985,7 +992,6 @@ static void make_sortkey(register Sort_p
                   {
                     const CHARSET_INFO *cs=item->collation.collation;
                     char fill_char= ((cs->state & MY_CS_BINSORT) ? (char) 0 : ' ');
            -
                     if (maybe_null)
                       *to++=1;
                     char *tmp_buffer= param->tmp_buffer ? param->tmp_buffer : (char*)to;
            @@ -1881,6 +1887,12 @@ sortlength(THD *thd, SORT_FIELD *sortord
                   if (sortorder->field->maybe_null())
              length++; // Place for NULL marker
                 }
            + else if (const Type_handler *handler= Type_handlers.handler(sortorder->item->field_type()))
            + {
            + handler->sortlength(sortorder, sortorder->item);
            + if (sortorder->item->maybe_null)
            + length++;
            + }
                 else
                 {
                   sortorder->result_type= sortorder->item->cmp_type();
            {code}
            bar Alexander Barkov made changes -
            Description In order to make the built-in and pluggable data types look similar inside the server code, we'll split these functions into virtual methods in Type_handler:
            {code}
            static void make_sortkey(register Sort_param *param,
                                     register uchar *to, uchar *ref_pos)
            {
            ...
            }
            static uint
            sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
                       bool *multi_byte_charset)
            {
            ...
            }
            {code}

            The relevant pieces of the code in the original data type plugin patch:
            {code}
            --- sql/filesort.cc 2014-06-12 08:57:03 +0000
            +++ sql/filesort.cc 2014-06-25 13:34:23 +0000
            @@ -976,6 +976,13 @@ static void make_sortkey(register Sort_p
                   if ((maybe_null = field->maybe_null()))
                     to++;
                 }
            + else if (const Type_handler *handler= Type_handlers.handler(sort_field->item->field_type()))
            + {
            + if ((maybe_null= sort_field->item->maybe_null))
            + *to++= 1;
            + if (handler->make_sort_key(sort_field, to) && maybe_null)
            + to[-1]= '\0';
            + }
                 else
                 { // Item
                   Item *item=sort_field->item;
            @@ -985,7 +992,6 @@ static void make_sortkey(register Sort_p
                   {
                     const CHARSET_INFO *cs=item->collation.collation;
                     char fill_char= ((cs->state & MY_CS_BINSORT) ? (char) 0 : ' ');
            -
                     if (maybe_null)
                       *to++=1;
                     char *tmp_buffer= param->tmp_buffer ? param->tmp_buffer : (char*)to;
            @@ -1881,6 +1887,12 @@ sortlength(THD *thd, SORT_FIELD *sortord
                   if (sortorder->field->maybe_null())
              length++; // Place for NULL marker
                 }
            + else if (const Type_handler *handler= Type_handlers.handler(sortorder->item->field_type()))
            + {
            + handler->sortlength(sortorder, sortorder->item);
            + if (sortorder->item->maybe_null)
            + length++;
            + }
                 else
                 {
                   sortorder->result_type= sortorder->item->cmp_type();
            {code}
            In order to make the built-in and pluggable data types look similar inside the server code, we'll split these functions into virtual methods in Type_handler:
            {code}
            static void make_sortkey(register Sort_param *param,
                                     register uchar *to, uchar *ref_pos)
            {
            ...
            }
            static uint
            sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
                       bool *multi_byte_charset)
            {
            ...
            }
            {code}

            The relevant pieces of the code in the original data type plugin patch:
            {code}
            --- sql/filesort.cc 2014-06-12 08:57:03 +0000
            +++ sql/filesort.cc 2014-06-25 13:34:23 +0000
            @@ -976,6 +976,13 @@ static void make_sortkey(register Sort_p
                   if ((maybe_null = field->maybe_null()))
                     to++;
                 }
            + else if (const Type_handler *handler= Type_handlers.handler(sort_field->item->field_type()))
            + {
            + if ((maybe_null= sort_field->item->maybe_null))
            + *to++= 1;
            + if (handler->make_sort_key(sort_field, to) && maybe_null)
            + to[-1]= '\0';
            + }
                 else
                 { // Item
                   Item *item=sort_field->item;
            @@ -1881,6 +1887,12 @@ sortlength(THD *thd, SORT_FIELD *sortord
                   if (sortorder->field->maybe_null())
              length++; // Place for NULL marker
                 }
            + else if (const Type_handler *handler= Type_handlers.handler(sortorder->item->field_type()))
            + {
            + handler->sortlength(sortorder, sortorder->item);
            + if (sortorder->item->maybe_null)
            + length++;
            + }
                 else
                 {
                   sortorder->result_type= sortorder->item->cmp_type();
            {code}
            bar Alexander Barkov made changes -
            Component/s OTHER [ 10125 ]
            Fix Version/s 10.2.0 [ 20700 ]
            Fix Version/s 10.2 [ 14601 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 72819 ] MariaDB v4 [ 132745 ]

            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.