Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
Description
protocol.cc has various tests for MYSQL_TYPE_XXX, for example:
bool Protocol_text::store(const char *from, size_t length, |
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
|
{
|
#ifndef DBUG_OFF
|
DBUG_ASSERT(field_types == 0 ||
|
field_types[field_pos] == MYSQL_TYPE_DECIMAL ||
|
field_types[field_pos] == MYSQL_TYPE_BIT ||
|
field_types[field_pos] == MYSQL_TYPE_NEWDECIMAL ||
|
(field_types[field_pos] >= MYSQL_TYPE_ENUM &&
|
field_types[field_pos] <= MYSQL_TYPE_GEOMETRY));
|
field_pos++;
|
#endif
|
return store_string_aux(from, length, fromcs, tocs); |
}
|
This is not friendly to new/pluggable data types.
To fix this problem, we'll do the following changes:
- change Send_field::type from enum_field_type to const Type_handler *
- add a new enum:
enum protocol_send_type_t
{
PROTOCOL_SEND_STRING,
PROTOCOL_SEND_FLOAT,
PROTOCOL_SEND_DOUBLE,
PROTOCOL_SEND_TINY,
PROTOCOL_SEND_SHORT,
PROTOCOL_SEND_LONG,
PROTOCOL_SEND_LONGLONG,
PROTOCOL_SEND_DATETIME,
PROTOCOL_SEND_DATE,
PROTOCOL_SEND_TIME
};
- add a new virtual method in Type_handler:
virtual protocol_send_type_t protocol_send_type() const= 0;
So the ::store() method implementations will simplify to something like:
bool Protocol_text::store(const char *from, size_t length, |
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
|
{
|
#ifndef DBUG_OFF
|
DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_STRING));
|
field_pos++;
|
#endif
|
return store_string_aux(from, length, fromcs, tocs); |
}
|
New data types will just need to implement a proper virtual implementation of Type_handler_xxx::protocol_send_type().
Attachments
Issue Links
- blocks
-
MDEV-4912 Data type plugin API version 1
- Closed