[MDEV-9220]  Split filesort.cc:make_sortkey() and filesort.cc::sortlength() into virtual methods in Type_handler Created: 2015-12-01  Updated: 2016-01-12  Resolved: 2016-01-12

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: 10.2.0

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: refactoring

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed

 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();


Generated at Thu Feb 08 07:33:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.