From: Date: June 7 2007 8:42pm Subject: bk commit into 5.0 tree (evgen:1.2519) BUG#28763 List-Archive: http://lists.mysql.com/commits/28356 X-Bug: 28763 Message-Id: <20070607184202.E8B4122D461@moonbone.moonbone.local> Below is the list of changes that have just been committed into a local 5.0 repository of evgen. When evgen does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-06-07 22:41:58+04:00, evgen@stripped +5 -0 Bug#28763: Selecting geometry fields in UNION caused server crash. This bug was introduced by the fix for the bug#27300. In this fix a section of code was added to the Item::tmp_table_field_from_field_type method. This section supposed to create Field_geom fields for the Item_geometry_func class and its descendants. In order to get the geometry type of the current item it casted "this" to the Item_geometry_func* type. But the Item::tmp_table_field_from_field_type method is also used for creation of fields for UNION and in this case this method is called for an object of the Item_type_holder class and the cast to the Item_geometry_func* type causes a server crash. Now the Item::tmp_table_field_from_field_type method correctly works when it's called for both the Item_type_holder and the Item_geometry_func classes. The new geometry_type variable is added to the Item_type_holder class. The new method called get_geometry_type is added to the Item_field and the Field classes. It returns geometry type from the field for the Item_field and the Field_geom classes and fails an assert for other Field descendants. mysql-test/r/gis.result@stripped, 2007-06-07 22:18:33+04:00, evgen@stripped +21 -0 Added a test case for the bug#28763: Selecting geometry fields in UNION caused server crash. mysql-test/t/gis.test@stripped, 2007-06-07 22:18:12+04:00, evgen@stripped +13 -0 Added a test case for the bug#28763: Selecting geometry fields in UNION caused server crash. sql/field.h@stripped, 2007-06-07 22:38:46+04:00, evgen@stripped +6 -1 Bug#28763: Selecting geometry fields in UNION caused server crash. The new method called get_geometry_type is added to the Field class. It returns geometry type of the field for the Field_geom class and fails an assert for other Field descendants. sql/item.cc@stripped, 2007-06-07 22:38:26+04:00, evgen@stripped +7 -1 Bug#28763: Selecting geometry fields in UNION caused server crash. Now the Item::tmp_table_field_from_field_type method correctly works when it's called for both the Item_type_holder and the Item_geometry_func classes. sql/item.h@stripped, 2007-06-07 22:40:28+04:00, evgen@stripped +5 -0 Bug#28763: Selecting geometry fields in UNION caused server crash. The new method called get_geometry_type is added to the Item_field class. It returns geometry type from the field. The new geometry_type variable is added to the Item_type_holder class. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: evgen # Host: moonbone.local # Root: /mnt/gentoo64/work/28763-bug-5.0-opt-mysql --- 1.204/sql/field.h 2007-05-30 10:55:36 +04:00 +++ 1.205/sql/field.h 2007-06-07 22:38:46 +04:00 @@ -360,7 +360,11 @@ public: { return field_length / charset()->mbmaxlen; } - + virtual geometry_type get_geometry_type() + { + /* shouldn't get here. */ + DBUG_ASSERT(0); + } friend bool reopen_table(THD *,struct st_table *,bool); friend int cre_myisam(my_string name, register TABLE *form, uint options, ulonglong auto_increment_value); @@ -1325,6 +1329,7 @@ public: uint get_key_image(char *buff,uint length,imagetype type); uint size_of() const { return sizeof(*this); } int reset(void) { return !maybe_null() || Field_blob::reset(); } + geometry_type get_geometry_type() { return geom_type; }; }; #endif /*HAVE_SPATIAL*/ --- 1.269/sql/item.cc 2007-05-21 22:50:02 +04:00 +++ 1.270/sql/item.cc 2007-06-07 22:38:26 +04:00 @@ -4317,7 +4317,9 @@ Field *Item::tmp_table_field_from_field_ case MYSQL_TYPE_GEOMETRY: return new Field_geom(max_length, maybe_null, name, table, (Field::geometry_type) - ((Item_geometry_func *)this)->get_geometry_type()); + ((type() == Item::TYPE_HOLDER) ? + ((Item_type_holder *)this)->geometry_type : + ((Item_geometry_func *)this)->get_geometry_type())); } } @@ -6422,6 +6424,10 @@ Item_type_holder::Item_type_holder(THD * if (Field::result_merge_type(fld_type) == INT_RESULT) 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(); } --- 1.230/sql/item.h 2007-05-18 00:17:44 +04:00 +++ 1.231/sql/item.h 2007-06-07 22:40:28 +04:00 @@ -1304,6 +1304,10 @@ public: int fix_outer_field(THD *thd, Field **field, Item **reference); virtual Item *update_value_transformer(byte *select_arg); void print(String *str); + Field::geometry_type get_geometry_type() + { + return field->get_geometry_type(); + } friend class Item_default_value; friend class Item_insert_value; friend class st_select_lex_unit; @@ -2569,6 +2573,7 @@ protected: /* It is used to count decimal precision in join_types */ int prev_decimal_int_part; public: + Field::geometry_type geometry_type; Item_type_holder(THD*, Item*); Item_result result_type() const; --- 1.43/mysql-test/r/gis.result 2007-04-02 12:50:35 +04:00 +++ 1.44/mysql-test/r/gis.result 2007-06-07 22:18:33 +04:00 @@ -864,4 +864,25 @@ SELECT Overlaps(@horiz1, @point2) FROM D Overlaps(@horiz1, @point2) 0 DROP TABLE t1; +create table t1(f1 geometry, f2 point, f3 linestring); +select f1 from t1 union select f1 from t1; +f1 +insert into t1 (f2,f3) values (GeomFromText('POINT(1 1)'), +GeomFromText('LINESTRING(0 0,1 1,2 2)')); +select AsText(f2),AsText(f3) from t1; +AsText(f2) AsText(f3) +POINT(1 1) LINESTRING(0 0,1 1,2 2) +select AsText(a) from (select f2 as a from t1 union select f3 from t1) t; +AsText(a) +POINT(1 1) +LINESTRING(0 0,1 1,2 2) +create table t2 as select f2 as a from t1 union select f3 from t1; +desc t2; +Field Type Null Key Default Extra +a point YES NULL +select AsText(a) from t2; +AsText(a) +POINT(1 1) +LINESTRING(0 0,1 1,2 2) +drop table t1, t2; End of 5.0 tests --- 1.36/mysql-test/t/gis.test 2007-04-02 12:50:35 +04:00 +++ 1.37/mysql-test/t/gis.test 2007-06-07 22:18:12 +04:00 @@ -557,4 +557,17 @@ SELECT Overlaps(@horiz1, @point2) FROM D DROP TABLE t1; +# +# Bug#28763: Selecting geometry fields in UNION caused server crash. +# +create table t1(f1 geometry, f2 point, f3 linestring); +select f1 from t1 union select f1 from t1; +insert into t1 (f2,f3) values (GeomFromText('POINT(1 1)'), + GeomFromText('LINESTRING(0 0,1 1,2 2)')); +select AsText(f2),AsText(f3) from t1; +select AsText(a) from (select f2 as a from t1 union select f3 from t1) t; +create table t2 as select f2 as a from t1 union select f3 from t1; +desc t2; +select AsText(a) from t2; +drop table t1, t2; --echo End of 5.0 tests