diff options
author | hf@deer.(none) <> | 2004-12-10 16:06:49 +0400 |
---|---|---|
committer | hf@deer.(none) <> | 2004-12-10 16:06:49 +0400 |
commit | 192715dbbb009f8e636c74907f7a8a2678bab63b (patch) | |
tree | fac5d0ecf6bba7008a8028e86bee3f9cee4960a1 | |
parent | 4915d196eb9d20cb627603a7ca4a83bf8637d0ba (diff) | |
download | mariadb-git-192715dbbb009f8e636c74907f7a8a2678bab63b.tar.gz |
Fix for bug #6516 (Server crash loading spatial data)
(after discussion with SerG)
-rw-r--r-- | include/my_base.h | 1 | ||||
-rw-r--r-- | myisam/mi_write.c | 7 | ||||
-rw-r--r-- | myisam/rt_index.c | 3 | ||||
-rw-r--r-- | myisam/sp_key.c | 5 | ||||
-rw-r--r-- | mysql-test/r/gis-rtree.result | 6 | ||||
-rw-r--r-- | mysql-test/t/gis-rtree.test | 7 | ||||
-rw-r--r-- | sql/handler.cc | 6 |
7 files changed, 30 insertions, 5 deletions
diff --git a/include/my_base.h b/include/my_base.h index d884113dc4d..7290d0da09b 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -291,6 +291,7 @@ enum ha_base_keytype { #define HA_ERR_NO_SUCH_TABLE 155 /* The table does not exist in engine */ #define HA_ERR_TABLE_EXIST 156 /* The table existed in storage engine */ #define HA_ERR_NO_CONNECTION 157 /* Could not connect to storage engine */ +#define HA_ERR_NULL_IN_SPATIAL 158 /* NULLs are not supported in spatial index */ /* Other constants */ diff --git a/myisam/mi_write.c b/myisam/mi_write.c index 303e924118f..7d053ddfd22 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -124,8 +124,8 @@ int mi_write(MI_INFO *info, byte *record) { if (local_lock_tree) rw_unlock(&share->key_root_lock[i]); - DBUG_PRINT("error",("Got error: %d on write",my_errno)); - goto err; + DBUG_PRINT("error",("Got error: %d on write",my_errno)); + goto err; } } if (local_lock_tree) @@ -159,7 +159,8 @@ int mi_write(MI_INFO *info, byte *record) err: save_errno=my_errno; - if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL) + if (my_errno == HA_ERR_FOUND_DUPP_KEY || my_errno == HA_ERR_RECORD_FILE_FULL || + my_errno == HA_ERR_NULL_IN_SPATIAL) { if (info->bulk_insert) { diff --git a/myisam/rt_index.c b/myisam/rt_index.c index cfb2ca877f4..bdf5ee9c60f 100644 --- a/myisam/rt_index.c +++ b/myisam/rt_index.c @@ -710,7 +710,8 @@ err1: int rtree_insert(MI_INFO *info, uint keynr, uchar *key, uint key_length) { - return (rtree_insert_level(info, keynr, key, key_length, -1) == -1) ? -1 : 0; + return (!key_length || + (rtree_insert_level(info, keynr, key, key_length, -1) == -1)) ? -1 : 0; } diff --git a/myisam/sp_key.c b/myisam/sp_key.c index 0e424a9e193..b61e8094cde 100644 --- a/myisam/sp_key.c +++ b/myisam/sp_key.c @@ -50,6 +50,11 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, dlen = _mi_calc_blob_length(keyseg->bit_start, pos); memcpy_fixed(&dptr, pos + keyseg->bit_start, sizeof(char*)); + if (!dptr) + { + my_errno= HA_ERR_NULL_IN_SPATIAL; + return 0; + } sp_mbr_from_wkb(dptr + 4, dlen - 4, SPDIMS, mbr); /* SRID */ for (i = 0, keyseg = keyinfo->seg; keyseg->type; keyseg++, i++) diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index 4ca8c379307..7b63654ffaf 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -798,3 +798,9 @@ INSERT INTO t1 (name, kind, line) VALUES ALTER TABLE t1 ENABLE KEYS; INSERT INTO t1 (name, kind, line) VALUES ("austria", "pp", GeomFromText('LINESTRING(14.9906 48.9887,14.9946 48.9904,14.9947 48.9916)')); drop table t1; +CREATE TABLE t1 (st varchar(100)); +INSERT INTO t1 VALUES ("Fake string"); +CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom)); +INSERT INTO t2 SELECT GeomFromText(st) FROM t1; +ERROR HY000: Unknown error +drop table t1, t2; diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index cb1627e0500..716dd38a119 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -165,3 +165,10 @@ INSERT INTO t1 (name, kind, line) VALUES ALTER TABLE t1 ENABLE KEYS; INSERT INTO t1 (name, kind, line) VALUES ("austria", "pp", GeomFromText('LINESTRING(14.9906 48.9887,14.9946 48.9904,14.9947 48.9916)')); drop table t1; + +CREATE TABLE t1 (st varchar(100)); +INSERT INTO t1 VALUES ("Fake string"); +CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom)); +--error 1105 +INSERT INTO t2 SELECT GeomFromText(st) FROM t1; +drop table t1, t2; diff --git a/sql/handler.cc b/sql/handler.cc index 530c5f137ec..3200c6932e9 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1083,6 +1083,9 @@ void handler::print_error(int error, myf errflag) textno=ER_DUP_KEY; break; } + case HA_ERR_NULL_IN_SPATIAL: + textno= ER_UNKNOWN_ERROR; + DBUG_VOID_RETURN; case HA_ERR_FOUND_DUPP_UNIQUE: textno=ER_DUP_UNIQUE; break; @@ -1196,7 +1199,8 @@ uint handler::get_dup_key(int error) { DBUG_ENTER("handler::get_dup_key"); table->file->errkey = (uint) -1; - if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOUND_DUPP_UNIQUE) + if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOUND_DUPP_UNIQUE || + error == HA_ERR_NULL_IN_SPATIAL) info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK); DBUG_RETURN(table->file->errkey); } |