[MDEV-9316] Add Field::store_hex_hybrid() Created: 2015-12-23  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   

This method in item.cc:

int Item_hex_hybrid::save_in_field(Field *field, bool no_conversions)
{
..
}

depends on the data type. It should be split apart into virtual methods in Field, so the user-defined data types and the standard data types look similar.

For example, the INET6 data type will need its own conversion, which is not compatible with the current behavior of Item_hex_hybrid::save_in_field().

The relevant pieces of the code in the original type handler patch:

-int Item_hex_hybrid::save_in_field(Field *field, bool no_conversions)
+int Item_hex_hybrid::save_in_field_as_string(Field *field)
 {
   field->set_notnull();
-  if (field->result_type() == STRING_RESULT)
-    return field->store(str_value.ptr(), str_value.length(), 
-                        collation.collation);
+  return field->store(str_value.ptr(), str_value.length(), 
+                      collation.collation);
+}
 
+
+int Item_hex_hybrid::save_in_field_as_number(Field *field)
+{
+  field->set_notnull();
 
@@ -6413,6 +6466,15 @@ int Item_hex_hybrid::save_in_field(Field
 }
+int Item_hex_hybrid::save_in_field(Field *field, bool no_conversions)
+{
+  if (const Type_handler *handler= Type_handlers.handler(field->type()))
+    return handler->save_in_field(this, field);
+  return field->result_type() == STRING_RESULT ?
+         save_in_field_as_string(field) : save_in_field_as_number(field);
+}
+


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