|
Let's add a new class with approximately this definition:
|
class Type_collection
|
{
|
public:
|
virtual ~Type_collection() {}
|
virtual const Type_handler *aggregate_for_result(const Type_handler *h1,
|
const Type_handler *h2)
|
const= 0;
|
virtual const Type_handler *aggregate_for_comparison(const Type_handler *h1,
|
const Type_handler *h2)
|
const= 0;
|
virtual const Type_handler *aggregate_for_min_max(const Type_handler *h1,
|
const Type_handler *h2)
|
const= 0;
|
virtual const Type_handler *aggregate_for_num_op(const Type_handler *h1,
|
const Type_handler *h2)
|
const= 0;
|
};
|
It will work as follows:
- Data type plugins will provide instances of Type_collection.
- Each Type_collection will contain one or more data types (Type_handler instances).
- Data types from the same Type_collection will "know" each other.
- If two data types are from the same collection, data type aggregation for various operations (i.e. result, comparson, LEAST/GREATES, numeric dyadic operators) will be delegated to their Type_collection through virtual methods.
For now there will be two collections:
- Type_collection_geometry, containing Type_handler_geometry.
- Type_collection_std, containing all other built-in data types.
Later, we'll split out geometry subtypes (POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION) into separate type handlers, so Type_collection_geometry will contain 8 type handlers
(the generic one, and handlers for 7 subtypes):
- Type_handler_geometry
- Type_handler_point
- Type_handler_linestring
- Type_handler_polygon
- Type_handler_multipoint
- Type_handler_multilinestring
- Type_handler_multipolygon
- Type_handler_geometrycollection
Later, we'll add Type_collection_json and will turn JSON functionality into handlers:
- Type_handler_varchar_json
- Type_handler_tinytext_json
- Type_handler_text_json
- Type_handler_mediumtext_json
- Type_handler_longtext_json
and remove Item::is_json_type().
Later, we'll add Type_collection_inet with two data type handlers:
- Type_handler_inet4
- Type_handler_inet6
|