Currently Item::tmp_table_field_from_field_type() has this code:
This is not friendly to pluggable data types.
We'll introduce a new method in Type_handler:
and move all switch pieces into implementations of make_table_field of the corresponding Type_handler_xxx.
Note, the new method for now will be used to create only fields for temporary tables, but later we'll reuse it for make_field() purposes in field.cc. Therefore, the API for the new method contains a new class Record_addr which describes pointer and null-pointer of this field in the record.
Additionally we'll remove the fixed_length and set_blob_packlength parameters from Item::tmp_table_field_from_field_type.
Reproducing these parameters in the new method make_table_field would look too dirty.
Removing fixed_length is easy: it's not really used, the code checking fixed_length in Item::tmp_table_field_from_field_type is dead code.
Removing set_blob_packlength is less trivial. This parameter was needed to choose a proper blob type handler (type_handler_blob, type_handler_tiny_blob, type_handler_medium_blob, type_handler_long_blob) depending on max_length. So instead of choosing the exact data type during tmp_table_field_from_type(), we'll fix all affected Item_xxx::type_handler() to return a correct type handler, which is in sync with max_length. Some Item_xxx will need to fix type_handler() or field_type(), other will need to fix fix_length_and_dec().