diff options
author | Tor Didriksen <tor.didriksen@oracle.com> | 2011-07-04 13:53:07 +0200 |
---|---|---|
committer | Tor Didriksen <tor.didriksen@oracle.com> | 2011-07-04 13:53:07 +0200 |
commit | 7779c79f04cb0471ef307d03baa8eac1cc37d2ed (patch) | |
tree | 87a2c93295b84f83e7b2fd5aa0b018533889f70f | |
parent | c5a294e82854138a64e37dfadd4b1a27381b145c (diff) | |
download | mariadb-git-7779c79f04cb0471ef307d03baa8eac1cc37d2ed.tar.gz |
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.
-rw-r--r-- | mysql-test/r/gis.result | 15 | ||||
-rw-r--r-- | mysql-test/t/gis.test | 18 | ||||
-rw-r--r-- | sql/field.h | 8 | ||||
-rw-r--r-- | sql/field_conv.cc | 3 |
4 files changed, 43 insertions, 1 deletions
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index bfd0ddccb90..0dc10c56bd0 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -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 diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 2a800140d1f..104afddeee5 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -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 diff --git a/sql/field.h b/sql/field.h index 304e75494e2..9c2cd52cfa5 100644 --- a/sql/field.h +++ b/sql/field.h @@ -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*/ diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 3890fe395d7..1a3ac9de08b 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -178,7 +178,10 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions) ((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; |