[MDEV-20009] Add CAST(expr AS pluggable_type) Created: 2019-07-10  Updated: 2019-07-10  Resolved: 2019-07-10

Status: Closed
Project: MariaDB Server
Component/s: Data types
Fix Version/s: 10.5.0

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-4912 Data type plugin API version 1 Closed

 Description   

User defined type plugins and new built-in types (implemented as always-built-in plugins) will want to do CAST.
This task will add infrastructure for such casts.

Let's add this branch into the cast_type grammar rules:

       | IDENT_sys
         {
           const Type_handler *h;
           if (!(h= Type_handler::handler_by_name_or_error($1)))
             MYSQL_YYABORT;
           $$.set(h);
           Lex->charset= NULL;
         }

Note, the GEOMETRY data types (which is as of time of writing 95% plugin compatible) does not support CAST for now. So for test purposes let's override the relevant method as follows:

Item *
Type_handler_geometry::create_typecast_item(THD *thd, Item *item,
                                           const Type_cast_attributes &attr)
                                           const
{
  DBUG_EXECUTE_IF("emulate_geometry_create_typecast_item",
    return new (thd->mem_root) Item_func_geometry_from_text(thd, item);
  );
 
  return NULL;
}


Generated at Thu Feb 08 08:56:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.