Commit 7779c79f authored by Tor Didriksen's avatar Tor Didriksen

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.
parent c5a294e8
...@@ -1076,4 +1076,19 @@ SPATIAL INDEX i1 (col1, col2) ...@@ -1076,4 +1076,19 @@ SPATIAL INDEX i1 (col1, col2)
); );
ERROR HY000: Incorrect arguments to SPATIAL INDEX ERROR HY000: Incorrect arguments to SPATIAL INDEX
DROP TABLE t0, t1, t2; 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 End of 5.5 tests
...@@ -820,5 +820,23 @@ CREATE TABLE t3 ( ...@@ -820,5 +820,23 @@ CREATE TABLE t3 (
# cleanup # cleanup
DROP TABLE t0, t1, t2; 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 --echo End of 5.5 tests
...@@ -1906,7 +1906,13 @@ class Field_geom :public Field_blob { ...@@ -1906,7 +1906,13 @@ class Field_geom :public Field_blob {
int store(longlong nr, bool unsigned_val); int store(longlong nr, bool unsigned_val);
int store_decimal(const my_decimal *); int store_decimal(const my_decimal *);
uint size_of() const { return sizeof(*this); } 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; }; geometry_type get_geometry_type() { return geom_type; };
}; };
#endif /*HAVE_SPATIAL*/ #endif /*HAVE_SPATIAL*/
......
...@@ -178,7 +178,10 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions) ...@@ -178,7 +178,10 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
((Field_timestamp*) field)->set_time(); ((Field_timestamp*) field)->set_time();
return 0; // Ok to set time to NULL return 0; // Ok to set time to NULL
} }
// Note: we ignore any potential failure of reset() here.
field->reset(); field->reset();
if (field == field->table->next_number_field) if (field == field->table->next_number_field)
{ {
field->table->auto_increment_field_not_null= FALSE; field->table->auto_increment_field_not_null= FALSE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment