Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
Description
This change was suggested by Serg during the review of MDEV-20016.
Let's implement sql_type() in abstract classes as much as possible. It will reduce the amout of the code:
- in the built-in Field_xxx classes
- in the future plugin Field_xxx classes
Note, this task is limited to Field_real and Field_int only. Other classes will be changed the same way later.
Let's remove sql_type() implementations from:
- Field_tiny
- Field_short
- Field_medium
- Field_long
- Field_longlong
- Field_float
- Field_double
The inherited implementations will work for these classes. The exact data type name will be taken from the Type_handler.
The implementation for the abstract classes will look like:
void Field_int::sql_type(String &res) const |
{
|
CHARSET_INFO *cs=res.charset();
|
Name name= type_handler()->type_handler_signed()->name();
|
res.length(cs->cset->snprintf(cs,(char*) res.ptr(),res.alloced_length(), |
"%.*s(%d)", (int) name.length(), name.ptr(), |
(int) field_length)); |
add_zerofill_and_unsigned(res);
|
}
|
void Field_real::sql_type(String &res) const |
{
|
const Name name= type_handler()->name(); |
if (dec >= FLOATING_POINT_DECIMALS) |
{
|
res.set_ascii(name.ptr(), name.length());
|
}
|
else |
{
|
CHARSET_INFO *cs= res.charset();
|
res.length(cs->cset->snprintf(cs,(char*) res.ptr(),res.alloced_length(), |
"%.*s(%d,%d)", (int) name.length(), name.ptr(), |
(int) field_length,dec)); |
}
|
add_zerofill_and_unsigned(res);
|
}
|
Attachments
Issue Links
- blocks
-
MDEV-4912 Data type plugin API version 1
- Closed
-
MDEV-20016 Add MariaDB_DATA_TYPE_PLUGIN
- Closed