From 813e6bcbbda3d7e4b6ad803e2993f9718ebe7daa Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Oct 2007 12:01:28 +0500 Subject: Bug #31155 gis types in union'd select cause crash. We use get_geometry_type() call to decide the exact type of a geometry field to be created (POINT, POLYGON etc) Though this function was only implemented for few items. In the bug's case we need to call this function for the Item_sum instance, where it was not implemented, what is the reason of the crash. Fixed by implementing virtual Item::get_geometry_type(), so it can be called for any Item. sql/item.h: Bug #31155 gis types in union'd select cause crash. virtual Item::geometry_type() added instead of various geometry_type() fucntions. sql/item.cc: Bug #31155 gis types in union'd select cause crash. Unified virtual ::get_geometry_type() function used sql/item_geofunc.cc: Bug #31155 gis types in union'd select cause crash. virtual Item::geometry_type() implemented for geo-Items. Mostly previous ::get_geometry_type() implementation changed sql/item_geofunc.h: Bug #31155 gis types in union'd select cause crash. get_geometry_type() declarations unified --- sql/item.cc | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'sql/item.cc') diff --git a/sql/item.cc b/sql/item.cc index e9b2904e3da..997ad0972db 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4364,11 +4364,8 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table) collation.collation); break; // Blob handled outside of case case MYSQL_TYPE_GEOMETRY: - return new Field_geom(max_length, maybe_null, name, table, - (Field::geometry_type) - ((type() == Item::TYPE_HOLDER) ? - ((Item_type_holder *)this)->get_geometry_type() : - ((Item_geometry_func *)this)->get_geometry_type())); + return new Field_geom(max_length, maybe_null, + name, table, get_geometry_type()); } } @@ -6489,9 +6486,7 @@ Item_type_holder::Item_type_holder(THD *thd, Item *item) decimals= 0; prev_decimal_int_part= item->decimal_int_part(); if (item->field_type() == MYSQL_TYPE_GEOMETRY) - geometry_type= (item->type() == Item::FIELD_ITEM) ? - ((Item_field *)item)->get_geometry_type() : - (Field::geometry_type)((Item_geometry_func *)item)->get_geometry_type(); + geometry_type= item->get_geometry_type(); } -- cgit v1.2.1