Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
Description
Data type plugins should be able to provide their own sets of built-in functions.
Let's add a new class Function_collection, as follows:
class Function_collection
|
{
|
public:
|
virtual ~Function_collection() {}
|
virtual bool init()= 0;
|
virtual void cleanup()= 0;
|
virtual Create_func *find_native_function_builder(THD *thd,
|
const LEX_CSTRING &name)
|
const= 0;
|
};
|
and, as a prove of the conceipt, move all GIS functions into a new class Function_collection_geometry.
- The method init() will do the collection initialization, e.g. create a hash to lookup Create_func builders by function names.
- The method cleanup will free all memory allocated by init(), e.g. free the lookup hash.
- The method find_native_function_builder will lookup a function by name and return its Create_func builder (or NULL if the function is not found).
This task will also do the following:
- Move all GIS function Create_func_xxx classes from item_create_cc to item_geofunc.cc
- Move definitions of Create_func_arg0, Create_func_arg1, Create_func_arg2, Create_func_arg3 from item_create.cc to item_create.h, so function collection plugins can reuse these classes.
- Remove this code from the bison grammar:
- | geometry_function
- {
-#ifdef HAVE_SPATIAL
- $$= $1;
- /* $1 may be NULL, GEOM_NEW not tested for out of memory */
- if (unlikely($$ == NULL))
- MYSQL_YYABORT;
-#else
- my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name,
- sym_group_geom.needed_define));
-#endif
- }
- ;
-
-geometry_function:
- CONTAINS_SYM '(' expr ',' expr ')'
- {
- $$= GEOM_NEW(thd,
- Item_func_spatial_precise_rel(thd, $3, $5,
- Item_func::SP_CONTAINS_FUNC));
- }
- | WITHIN '(' expr ',' expr ')'
- {
- $$= GEOM_NEW(thd, Item_func_spatial_precise_rel(thd, $3, $5,
- Item_func::SP_WITHIN_FUNC));
- }
and add something like this into the function_call_generic rule:
| CONTAINS_SYM '(' opt_expr_list ')'
{
if (!($$= Lex->make_item_func_call_native_or_parse_error(thd,
$1, $3)))
MYSQL_YYABORT;
}
| WITHIN '(' opt_expr_list ')'
{
if (!($$= Lex->make_item_func_call_native_or_parse_error(thd,
$1, $3)))
MYSQL_YYABORT;
}
- Add a global instance of Function_collection_geometry
Later, in a separate MDEV, we'll add a new plugin type, MYSQL_FUNCTION_COLLECTION_PLUGIN.