From: Date: October 7 2006 6:39pm Subject: bk commit into 4.1 tree (holyfoot:1.2574) BUG#22372 List-Archive: http://lists.mysql.com/commits/13293 X-Bug: 22372 Message-Id: <20061007163914.D8B77A08078@deer.myoffice.izhnet.ru> Below is the list of changes that have just been committed into a local 4.1 repository of hf. When hf 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, 2006-10-07 21:39:10+05:00, holyfoot@stripped +5 -0 bug #22372 (LOAD DATA crashes the table with the GEOMETRY field) The problem is that the GEOMETRY field doesn't have and default value that is usually set by Field::reset method, if the field can't be NULL. So if the loaded file doesn't have all the data it can't be loaded. I propose to check if the 'reset' operation is possible for the field and return an error if it's not. mysql-test/r/gis.result@stripped, 2006-10-07 21:39:07+05:00, holyfoot@stripped +6 -0 test result mysql-test/std_data/bad_gis_data.dat@stripped, 2006-10-07 21:39:07+05:00, holyfoot@stripped +1 -0 New BitKeeper file ``mysql-test/std_data/bad_gis_data.dat'' mysql-test/std_data/bad_gis_data.dat@stripped, 2006-10-07 21:39:07+05:00, holyfoot@stripped +0 -0 mysql-test/t/gis.test@stripped, 2006-10-07 21:39:07+05:00, holyfoot@stripped +7 -0 test case sql/field.h@stripped, 2006-10-07 21:39:07+05:00, holyfoot@stripped +2 -0 method added to check if the field can handle the 'reset' operation sql/sql_load.cc@stripped, 2006-10-07 21:39:07+05:00, holyfoot@stripped +5 -0 if the field can't do the 'reset' operation properly we can't execute further # 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: holyfoot # Host: deer.(none) # Root: /home/hf/work/22372/my41-22372 --- 1.133/sql/field.h 2006-10-07 21:39:14 +05:00 +++ 1.134/sql/field.h 2006-10-07 21:39:14 +05:00 @@ -126,6 +126,8 @@ public: bool eq(Field *field) { return ptr == field->ptr && null_ptr == field->null_ptr; } virtual bool eq_def(Field *field); virtual uint32 pack_length() const { return (uint32) field_length; } + bool cant_reset() const + { return (flags & NOT_NULL_FLAG) && (type()==FIELD_TYPE_GEOMETRY); } virtual void reset(void) { bzero(ptr,pack_length()); } virtual void reset_fields() {} virtual void set_default() --- 1.87/sql/sql_load.cc 2006-10-07 21:39:14 +05:00 +++ 1.88/sql/sql_load.cc 2006-10-07 21:39:14 +05:00 @@ -561,6 +561,11 @@ read_sep_field(THD *thd,COPY_INFO &info, break; for (; sql_field ; sql_field=(Item_field*) it++) { + if (sql_field->field->cant_reset()) + { + my_error(ER_SPATIAL_CANT_HAVE_NULL,MYF(0)); + DBUG_RETURN(1); + } sql_field->field->set_null(); sql_field->field->reset(); thd->cuted_fields++; --- New file --- +++ mysql-test/std_data/bad_gis_data.dat 06/10/07 21:39:07 foo --- 1.22/mysql-test/r/gis.result 2006-10-07 21:39:14 +05:00 +++ 1.23/mysql-test/r/gis.result 2006-10-07 21:39:14 +05:00 @@ -661,6 +661,12 @@ POINT(10 10) select (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440)))); (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440)))) POINT(10 10) +create table t1 (a TEXT, b GEOMETRY NOT NULL, SPATIAL KEY(b)); +alter table t1 disable keys; +load data infile '../../std_data/bad_gis_data.dat' into table t1; +ERROR 42000: All parts of a SPATIAL index must be NOT NULL +alter table t1 enable keys; +drop table t1; create table t1 (g GEOMETRY); select * from t1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr --- 1.20/mysql-test/t/gis.test 2006-10-07 21:39:14 +05:00 +++ 1.21/mysql-test/t/gis.test 2006-10-07 21:39:14 +05:00 @@ -363,6 +363,13 @@ drop table t1; select (asWKT(geomfromwkb((0x000000000140240000000000004024000000000000)))); select (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440)))); +create table t1 (a TEXT, b GEOMETRY NOT NULL, SPATIAL KEY(b)); +alter table t1 disable keys; +--error 1252 +load data infile '../../std_data/bad_gis_data.dat' into table t1; +alter table t1 enable keys; +drop table t1; + # End of 4.1 tests --enable_metadata