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
-
Activity
Description |
{{protocol.cc}} has various tests for {{MYSQL_TYPE_XXX}}, for example:
{code:cpp} 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); } {cpp} 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: {code:cpp} 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 }; {code} - add a new virtual method in {{Type_handler}}: {code:cpp} virtual protocol_send_type_t protocol_send_type() const= 0; {code} So the {{::store()}} method implementations will simplify to something like: {code:cpp} 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); } {code} New data types will just need to implement a proper virtual implementation of {{Type_handler_xxx::protocol_send_type()}}. |
{{protocol.cc}} has various tests for {{MYSQL_TYPE_XXX}}, for example:
{code:cpp} 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); } {code} 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: {code:cpp} 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 }; {code} - add a new virtual method in {{Type_handler}}: {code:cpp} virtual protocol_send_type_t protocol_send_type() const= 0; {code} So the {{::store()}} method implementations will simplify to something like: {code:cpp} 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); } {code} New data types will just need to implement a proper virtual implementation of {{Type_handler_xxx::protocol_send_type()}}. |
issue.field.resolutiondate | 2019-04-02 13:53:00.0 | 2019-04-02 13:53:00.341 |
Fix Version/s | 10.4.4 [ 23310 ] | |
Fix Version/s | 10.4 [ 22408 ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 94148 ] | MariaDB v4 [ 133912 ] |