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-26 18:12:53+05:00, holyfoot@stripped +4 -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-26 18:12:51+05:00, holyfoot@stripped +6 -0
test result
mysql-test/std_data/bad_gis_data.dat@stripped, 2006-10-26 18:12:52+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-26 18:12:52+05:00, holyfoot@stripped
+0 -0
mysql-test/t/gis.test@stripped, 2006-10-26 18:12:51+05:00, holyfoot@stripped +7 -0
test case
sql/sql_load.cc@stripped, 2006-10-26 18:12:51+05:00, holyfoot@stripped +23 -2
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.87/sql/sql_load.cc 2006-10-26 18:12:58 +05:00
+++ 1.88/sql/sql_load.cc 2006-10-26 18:12:58 +05:00
@@ -535,6 +535,12 @@ read_sep_field(THD *thd,COPY_INFO &info,
{
if (field->type() == FIELD_TYPE_TIMESTAMP)
((Field_timestamp*) field)->set_time();
+ if (field->type() == FIELD_TYPE_GEOMETRY)
+ {
+ my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name,
+ thd->row_count);
+ DBUG_RETURN(1);
+ }
else if (field != table->next_number_field)
field->set_warning((uint) MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_NULL_TO_NOTNULL, 1);
@@ -561,8 +567,23 @@ read_sep_field(THD *thd,COPY_INFO &info,
break;
for (; sql_field ; sql_field=(Item_field*) it++)
{
- sql_field->field->set_null();
- sql_field->field->reset();
+ Field *field=sql_field->field;
+ field->set_null();
+ field->reset();
+ if (!field->maybe_null())
+ {
+ if (field->type() == FIELD_TYPE_TIMESTAMP)
+ ((Field_timestamp*) field)->set_time();
+ if (field->type() == FIELD_TYPE_GEOMETRY)
+ {
+ my_error(ER_WARN_NULL_TO_NOTNULL, MYF(0), field->field_name,
+ thd->row_count);
+ DBUG_RETURN(1);
+ }
+ else if (field != table->next_number_field)
+ field->set_warning((uint) MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WARN_NULL_TO_NOTNULL, 1);
+ }
thd->cuted_fields++;
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_WARN_TOO_FEW_RECORDS,
--- New file ---
+++ mysql-test/std_data/bad_gis_data.dat 06/10/26 18:12:52
foo
--- 1.22/mysql-test/r/gis.result 2006-10-26 18:12:58 +05:00
+++ 1.23/mysql-test/r/gis.result 2006-10-26 18:12:58 +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 01000: Data truncated; NULL supplied to NOT NULL column 'b' at row 1
+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-26 18:12:58 +05:00
+++ 1.21/mysql-test/t/gis.test 2006-10-26 18:12:58 +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 1263
+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
| Thread |
|---|
| • bk commit into 4.1 tree (holyfoot:1.2574) BUG#22372 | holyfoot | 26 Oct |