Commit 88f1b90a authored by unknown's avatar unknown

Fix for bug #6755 (ALTER TABLE ENABLE KEYS corrupts spatial index)


myisam/mi_check.c:
  Spatial keys should not be filesort-ed.
  Specific function neede to insert key into spatial index
mysql-test/r/gis-rtree.result:
  Appropriate test result
mysql-test/t/gis-rtree.test:
  Test case
parent 5fc09be9
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#ifdef HAVE_SYS_MMAN_H #ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
#include "rt_index.h"
#ifndef USE_RAID #ifndef USE_RAID
#define my_raid_create(A,B,C,D,E,F,G) my_create(A,B,C,G) #define my_raid_create(A,B,C,D,E,F,G) my_create(A,B,C,G)
...@@ -1465,6 +1466,12 @@ static int writekeys(MI_CHECK *param, register MI_INFO *info, byte *buff, ...@@ -1465,6 +1466,12 @@ static int writekeys(MI_CHECK *param, register MI_INFO *info, byte *buff,
if (_mi_ft_add(info,i,(char*) key,buff,filepos)) if (_mi_ft_add(info,i,(char*) key,buff,filepos))
goto err; goto err;
} }
else if (info->s->keyinfo[i].flag & HA_SPATIAL)
{
uint key_length=_mi_make_key(info,i,key,buff,filepos);
if (rtree_insert(info, i, key, key_length))
goto err;
}
else else
{ {
uint key_length=_mi_make_key(info,i,key,buff,filepos); uint key_length=_mi_make_key(info,i,key,buff,filepos);
...@@ -3987,7 +3994,8 @@ static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows) ...@@ -3987,7 +3994,8 @@ static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows)
key->seg->charset->mbmaxlen; key->seg->charset->mbmaxlen;
key_maxlength+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN; key_maxlength+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
} }
return (key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) && return (key->flag & HA_SPATIAL) ||
(key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) &&
((ulonglong) rows * key_maxlength > ((ulonglong) rows * key_maxlength >
(ulonglong) myisam_max_temp_length)); (ulonglong) myisam_max_temp_length));
} }
......
...@@ -757,3 +757,44 @@ SPATIAL KEY(g) ...@@ -757,3 +757,44 @@ SPATIAL KEY(g)
) ENGINE=MyISAM; ) ENGINE=MyISAM;
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)')); INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)'));
drop table t1; drop table t1;
CREATE TABLE t1 (
geoobjid INT NOT NULL,
line LINESTRING NOT NULL,
kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
name VARCHAR(32),
SPATIAL KEY (line)
) engine=myisam;
ALTER TABLE t1 DISABLE KEYS;
INSERT INTO t1 (name, kind, line) VALUES
("Aadaouane", "pp", GeomFromText("POINT(32.816667 35.983333)")),
("Aadassiye", "pp", GeomFromText("POINT(35.816667 36.216667)")),
("Aadbel", "pp", GeomFromText("POINT(34.533333 36.100000)")),
("Aadchit", "pp", GeomFromText("POINT(33.347222 35.423611)")),
("Aadchite", "pp", GeomFromText("POINT(33.347222 35.423611)")),
("Aadchit el Qoussair", "pp", GeomFromText("POINT(33.283333 35.483333)")),
("Aaddaye", "pp", GeomFromText("POINT(36.716667 40.833333)")),
("'Aadeissa", "pp", GeomFromText("POINT(32.823889 35.698889)")),
("Aaderup", "pp", GeomFromText("POINT(55.216667 11.766667)")),
("Qalaat Aades", "pp", GeomFromText("POINT(33.503333 35.377500)")),
("A ad'ino", "pp", GeomFromText("POINT(54.812222 38.209167)")),
("Aadi Noia", "pp", GeomFromText("POINT(13.800000 39.833333)")),
("Aad La Macta", "pp", GeomFromText("POINT(35.779444 -0.129167)")),
("Aadland", "pp", GeomFromText("POINT(60.366667 5.483333)")),
("Aadliye", "pp", GeomFromText("POINT(33.366667 36.333333)")),
("Aadloun", "pp", GeomFromText("POINT(33.403889 35.273889)")),
("Aadma", "pp", GeomFromText("POINT(58.798333 22.663889)")),
("Aadma Asundus", "pp", GeomFromText("POINT(58.798333 22.663889)")),
("Aadmoun", "pp", GeomFromText("POINT(34.150000 35.650000)")),
("Aadneram", "pp", GeomFromText("POINT(59.016667 6.933333)")),
("Aadneskaar", "pp", GeomFromText("POINT(58.083333 6.983333)")),
("Aadorf", "pp", GeomFromText("POINT(47.483333 8.900000)")),
("Aadorp", "pp", GeomFromText("POINT(52.366667 6.633333)")),
("Aadouane", "pp", GeomFromText("POINT(32.816667 35.983333)")),
("Aadoui", "pp", GeomFromText("POINT(34.450000 35.983333)")),
("Aadouiye", "pp", GeomFromText("POINT(34.583333 36.183333)")),
("Aadouss", "pp", GeomFromText("POINT(33.512500 35.601389)")),
("Aadra", "pp", GeomFromText("POINT(33.616667 36.500000)")),
("Aadzi", "pp", GeomFromText("POINT(38.100000 64.850000)"));
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;
...@@ -118,3 +118,50 @@ CREATE TABLE t1 ( ...@@ -118,3 +118,50 @@ CREATE TABLE t1 (
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)')); INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)'));
#select * from t1 where g<GeomFromText('LineString(1 2, 2 3)'); #select * from t1 where g<GeomFromText('LineString(1 2, 2 3)');
drop table t1; drop table t1;
CREATE TABLE t1 (
geoobjid INT NOT NULL,
line LINESTRING NOT NULL,
kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
name VARCHAR(32),
SPATIAL KEY (line)
) engine=myisam;
ALTER TABLE t1 DISABLE KEYS;
INSERT INTO t1 (name, kind, line) VALUES
("Aadaouane", "pp", GeomFromText("POINT(32.816667 35.983333)")),
("Aadassiye", "pp", GeomFromText("POINT(35.816667 36.216667)")),
("Aadbel", "pp", GeomFromText("POINT(34.533333 36.100000)")),
("Aadchit", "pp", GeomFromText("POINT(33.347222 35.423611)")),
("Aadchite", "pp", GeomFromText("POINT(33.347222 35.423611)")),
("Aadchit el Qoussair", "pp", GeomFromText("POINT(33.283333 35.483333)")),
("Aaddaye", "pp", GeomFromText("POINT(36.716667 40.833333)")),
("'Aadeissa", "pp", GeomFromText("POINT(32.823889 35.698889)")),
("Aaderup", "pp", GeomFromText("POINT(55.216667 11.766667)")),
("Qalaat Aades", "pp", GeomFromText("POINT(33.503333 35.377500)")),
("A ad'ino", "pp", GeomFromText("POINT(54.812222 38.209167)")),
("Aadi Noia", "pp", GeomFromText("POINT(13.800000 39.833333)")),
("Aad La Macta", "pp", GeomFromText("POINT(35.779444 -0.129167)")),
("Aadland", "pp", GeomFromText("POINT(60.366667 5.483333)")),
("Aadliye", "pp", GeomFromText("POINT(33.366667 36.333333)")),
("Aadloun", "pp", GeomFromText("POINT(33.403889 35.273889)")),
("Aadma", "pp", GeomFromText("POINT(58.798333 22.663889)")),
("Aadma Asundus", "pp", GeomFromText("POINT(58.798333 22.663889)")),
("Aadmoun", "pp", GeomFromText("POINT(34.150000 35.650000)")),
("Aadneram", "pp", GeomFromText("POINT(59.016667 6.933333)")),
("Aadneskaar", "pp", GeomFromText("POINT(58.083333 6.983333)")),
("Aadorf", "pp", GeomFromText("POINT(47.483333 8.900000)")),
("Aadorp", "pp", GeomFromText("POINT(52.366667 6.633333)")),
("Aadouane", "pp", GeomFromText("POINT(32.816667 35.983333)")),
("Aadoui", "pp", GeomFromText("POINT(34.450000 35.983333)")),
("Aadouiye", "pp", GeomFromText("POINT(34.583333 36.183333)")),
("Aadouss", "pp", GeomFromText("POINT(33.512500 35.601389)")),
("Aadra", "pp", GeomFromText("POINT(33.616667 36.500000)")),
("Aadzi", "pp", GeomFromText("POINT(38.100000 64.850000)"));
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;
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