Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-19972

Move GIS code from Item_bool_func::get_full_func_mm_tree() to Item_func_spatial_rel::get_mm_leaf()

    Details

      Description

      Item_bool_func::get_full_func_mm_tree() has the following code blocks:

      #ifdef HAVE_SPATIAL
        const Type_handler_geometry *sav_geom_type= NULL;
        Field_geom *field_geom= dynamic_cast<Field_geom*>(field_item->field);
        if (field_geom)
        {
          sav_geom_type= field_geom->type_handler_geom();
          /* We have to be able to store all sorts of spatial features here */
          field_geom->set_type_handler(&type_handler_geometry);
        }
      #endif /*HAVE_SPATIAL*/
      

      and

      #ifdef HAVE_SPATIAL
        if (field_geom)
        {
          DBUG_ASSERT(sav_geom_type);
          field_geom->set_type_handler(sav_geom_type);
        }
      #endif /*HAVE_SPATIAL*/
      

      This code here prevents moving GIS implementation into a data type plugin. The server code should at the end know nothing about Field_geom and type_handler_geometry.

      Let's move this code inside Item_func_spatial_rel::get_mm_leaf(), so the Field_geom's type handler is changed just before the call for save_in_field_no_warnings() and restore it immediately after this.

      The new code in Item_func_spatial_rel::get_mm_leaf() will look like this:

        Field_geom *field_geom= dynamic_cast<Field_geom*>(field);
        DBUG_ASSERT(field_geom);
        const Type_handler_geometry *sav_geom_type= field_geom->type_handler_geom();
        // We have to be able to store all sorts of spatial features here
        field_geom->set_type_handler(&type_handler_geometry);
        bool rc= value->save_in_field_no_warnings(field, 1);
        field_geom->set_type_handler(sav_geom_type);
        if (rc)
          DBUG_RETURN(&sel_arg_impossible);
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                bar Alexander Barkov
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: