From: Tor Didriksen Date: July 4 2011 12:23pm Subject: bzr push into mysql-5.5 branch (tor.didriksen:3449 to 3450) Bug#11908153 List-Archive: http://lists.mysql.com/commits/140175 X-Bug: 11908153 Message-Id: <201107041223.p64CNq2s003490@acsmt357.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3450 Tor Didriksen 2011-07-04 Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE Field_geom::reset() failed to reset its base Field_blob. The range optimizer used the un-initilized field during optimization and execution. @ mysql-test/r/gis.result New test case. @ mysql-test/t/gis.test New test case. @ sql/field.h Field_geom::reset() must call Field_blob::reset(), even if the field is not nullable. modified: mysql-test/r/gis.result mysql-test/t/gis.test sql/field.h sql/field_conv.cc 3449 Jon Olav Hauglid 2011-07-04 [merge] Merge from mysql-5.1 to mysql-5.5. modified: mysql-test/include/mtr_check.sql mysql-test/include/mtr_warnings.sql === modified file 'mysql-test/r/gis.result' --- a/mysql-test/r/gis.result 2011-04-07 10:57:32 +0000 +++ b/mysql-test/r/gis.result 2011-07-04 11:53:07 +0000 @@ -1076,4 +1076,19 @@ SPATIAL INDEX i1 (col1, col2) ); ERROR HY000: Incorrect arguments to SPATIAL INDEX DROP TABLE t0, t1, t2; +# +# Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE +# +CREATE TABLE g1 +(a geometry NOT NULL, UNIQUE KEY i (a(151))) engine=myisam; +INSERT INTO g1 VALUES (geomfromtext('point(1 1)')); +INSERT INTO g1 VALUES (geomfromtext('point(1 2)')); +FLUSH TABLES; +SELECT 1 FROM g1 +FORCE INDEX(i) WHERE a = date_sub(now(), interval 2808.4 year_month) +; +1 +Warnings: +Warning 1441 Datetime function: datetime field overflow +DROP TABLE g1; End of 5.5 tests === modified file 'mysql-test/t/gis.test' --- a/mysql-test/t/gis.test 2011-04-07 10:57:32 +0000 +++ b/mysql-test/t/gis.test 2011-07-04 11:53:07 +0000 @@ -820,5 +820,23 @@ CREATE TABLE t3 ( # cleanup DROP TABLE t0, t1, t2; +--echo # +--echo # Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE +--echo # + +CREATE TABLE g1 +(a geometry NOT NULL, UNIQUE KEY i (a(151))) engine=myisam; + +INSERT INTO g1 VALUES (geomfromtext('point(1 1)')); +INSERT INTO g1 VALUES (geomfromtext('point(1 2)')); + +FLUSH TABLES; + +SELECT 1 FROM g1 +FORCE INDEX(i) WHERE a = date_sub(now(), interval 2808.4 year_month) +; + +DROP TABLE g1; + --echo End of 5.5 tests === modified file 'sql/field.h' --- a/sql/field.h 2011-07-03 23:48:19 +0000 +++ b/sql/field.h 2011-07-04 11:53:07 +0000 @@ -1906,7 +1906,13 @@ public: int store(longlong nr, bool unsigned_val); int store_decimal(const my_decimal *); uint size_of() const { return sizeof(*this); } - int reset(void) { return !maybe_null() || Field_blob::reset(); } + + /** + Non-nullable GEOMETRY types cannot have defaults, + but the underlying blob must still be reset. + */ + int reset(void) { return Field_blob::reset() || !maybe_null(); } + geometry_type get_geometry_type() { return geom_type; }; }; #endif /*HAVE_SPATIAL*/ === modified file 'sql/field_conv.cc' --- a/sql/field_conv.cc 2011-07-03 23:48:19 +0000 +++ b/sql/field_conv.cc 2011-07-04 11:53:07 +0000 @@ -178,7 +178,10 @@ set_field_to_null_with_conversions(Field ((Field_timestamp*) field)->set_time(); return 0; // Ok to set time to NULL } + + // Note: we ignore any potential failure of reset() here. field->reset(); + if (field == field->table->next_number_field) { field->table->auto_increment_field_not_null= FALSE; No bundle (reason: useless for push emails).