DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
g GEOMETRY NOT NULL,
SPATIAL KEY(g)
) ENGINE=MyISAM;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `fid` int(11) NOT NULL AUTO_INCREMENT,
  `g` geometry NOT NULL,
  PRIMARY KEY (`fid`),
  SPATIAL KEY `g` (`g`(32))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(150 150, 150 150)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(149 149, 151 151)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(148 148, 152 152)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(147 147, 153 153)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(146 146, 154 154)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(145 145, 155 155)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(144 144, 156 156)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(143 143, 157 157)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(142 142, 158 158)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(141 141, 159 159)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(140 140, 160 160)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(139 139, 161 161)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(138 138, 162 162)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(137 137, 163 163)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(136 136, 164 164)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(135 135, 165 165)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(134 134, 166 166)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(133 133, 167 167)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(132 132, 168 168)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(131 131, 169 169)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(130 130, 170 170)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(129 129, 171 171)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(128 128, 172 172)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(127 127, 173 173)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(126 126, 174 174)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(125 125, 175 175)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(124 124, 176 176)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(123 123, 177 177)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(122 122, 178 178)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(121 121, 179 179)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(120 120, 180 180)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(119 119, 181 181)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(118 118, 182 182)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(117 117, 183 183)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(116 116, 184 184)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(115 115, 185 185)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(114 114, 186 186)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(113 113, 187 187)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(112 112, 188 188)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(111 111, 189 189)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(110 110, 190 190)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(109 109, 191 191)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(108 108, 192 192)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(107 107, 193 193)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(106 106, 194 194)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(105 105, 195 195)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(104 104, 196 196)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(103 103, 197 197)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(102 102, 198 198)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(101 101, 199 199)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(100 100, 200 200)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(99 99, 201 201)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(98 98, 202 202)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(97 97, 203 203)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(96 96, 204 204)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(95 95, 205 205)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(94 94, 206 206)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(93 93, 207 207)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(92 92, 208 208)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(91 91, 209 209)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(90 90, 210 210)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(89 89, 211 211)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(88 88, 212 212)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(87 87, 213 213)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(86 86, 214 214)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(85 85, 215 215)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(84 84, 216 216)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(83 83, 217 217)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(82 82, 218 218)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(81 81, 219 219)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(80 80, 220 220)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(79 79, 221 221)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(78 78, 222 222)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(77 77, 223 223)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(76 76, 224 224)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(75 75, 225 225)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(74 74, 226 226)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(73 73, 227 227)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(72 72, 228 228)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(71 71, 229 229)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(70 70, 230 230)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(69 69, 231 231)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(68 68, 232 232)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(67 67, 233 233)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(66 66, 234 234)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(65 65, 235 235)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(64 64, 236 236)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(63 63, 237 237)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(62 62, 238 238)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(61 61, 239 239)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(60 60, 240 240)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(59 59, 241 241)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(58 58, 242 242)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(57 57, 243 243)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(56 56, 244 244)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(55 55, 245 245)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(54 54, 246 246)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(53 53, 247 247)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(52 52, 248 248)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(51 51, 249 249)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(50 50, 250 250)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(49 49, 251 251)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(48 48, 252 252)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(47 47, 253 253)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(46 46, 254 254)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(45 45, 255 255)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(44 44, 256 256)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(43 43, 257 257)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(42 42, 258 258)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(41 41, 259 259)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(40 40, 260 260)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(39 39, 261 261)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(38 38, 262 262)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(37 37, 263 263)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(36 36, 264 264)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(35 35, 265 265)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(34 34, 266 266)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(33 33, 267 267)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(32 32, 268 268)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(31 31, 269 269)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(30 30, 270 270)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(29 29, 271 271)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(28 28, 272 272)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(27 27, 273 273)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(26 26, 274 274)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(25 25, 275 275)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(24 24, 276 276)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(23 23, 277 277)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(22 22, 278 278)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(21 21, 279 279)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(20 20, 280 280)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(19 19, 281 281)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(18 18, 282 282)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(17 17, 283 283)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(16 16, 284 284)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(15 15, 285 285)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(14 14, 286 286)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(13 13, 287 287)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(12 12, 288 288)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(11 11, 289 289)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(10 10, 290 290)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(9 9, 291 291)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(8 8, 292 292)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(7 7, 293 293)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(6 6, 294 294)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(5 5, 295 295)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(4 4, 296 296)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(3 3, 297 297)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(2 2, 298 298)'));
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 1, 299 299)'));
SELECT count(*) FROM t1;
count(*)
150
EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	range	g	g	32	NULL	8	Using where
SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
fid	AsText(g)
1	LINESTRING(150 150,150 150)
3	LINESTRING(148 148,152 152)
4	LINESTRING(147 147,153 153)
5	LINESTRING(146 146,154 154)
6	LINESTRING(145 145,155 155)
7	LINESTRING(144 144,156 156)
8	LINESTRING(143 143,157 157)
9	LINESTRING(142 142,158 158)
10	LINESTRING(141 141,159 159)
11	LINESTRING(140 140,160 160)
2	LINESTRING(149 149,151 151)
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
g GEOMETRY NOT NULL
) ENGINE=MyISAM;
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10))));
INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10))));
ALTER TABLE t2 ADD SPATIAL KEY(g);
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `fid` int(11) NOT NULL AUTO_INCREMENT,
  `g` geometry NOT NULL,
  PRIMARY KEY (`fid`),
  SPATIAL KEY `g` (`g`(32))
) ENGINE=MyISAM AUTO_INCREMENT=101 DEFAULT CHARSET=latin1
SELECT count(*) FROM t2;
count(*)
100
EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g, 
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t2	range	g	g	32	NULL	4	Using where
SELECT fid, AsText(g) FROM t2 WHERE Within(g, 
GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
fid	AsText(g)
46	LINESTRING(51 41,60 50)
56	LINESTRING(41 41,50 50)
45	LINESTRING(51 51,60 60)
55	LINESTRING(41 51,50 60)
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
99
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
98
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
97
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
96
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
95
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
94
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
93
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
92
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
91
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
90
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
89
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
88
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
87
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
86
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
85
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
84
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
83
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
82
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
81
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
80
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
79
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
78
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
77
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
76
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
75
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
74
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
73
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
72
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
71
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
70
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
69
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
68
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
67
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
66
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
65
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
64
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
63
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
62
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
61
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
60
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
59
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
58
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
57
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
56
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
55
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
54
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
53
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
52
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
51
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
50
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
49
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
48
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
47
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
46
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
45
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
44
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
43
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
42
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
41
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
40
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
39
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
38
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
37
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
36
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
35
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
34
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
33
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
32
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
31
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
30
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
29
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
28
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
27
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
26
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
25
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
24
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
23
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
22
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
21
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
20
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
19
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
18
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
17
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
16
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
15
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
14
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
13
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
12
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
11
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
10
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
SELECT count(*) FROM t2;
count(*)
9
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
SELECT count(*) FROM t2;
count(*)
8
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
SELECT count(*) FROM t2;
count(*)
7
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
SELECT count(*) FROM t2;
count(*)
6
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
SELECT count(*) FROM t2;
count(*)
5
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
SELECT count(*) FROM t2;
count(*)
4
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
SELECT count(*) FROM t2;
count(*)
3
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
SELECT count(*) FROM t2;
count(*)
2
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
SELECT count(*) FROM t2;
count(*)
1
DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
SELECT count(*) FROM t2;
count(*)
0
DROP TABLE t2;
drop table if exists t1;
Warnings:
Note	1051	Unknown table 't1'
CREATE TABLE t1 (a geometry NOT NULL, SPATIAL (a));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
check table t1;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
analyze table t1;
Table	Op	Msg_type	Msg_text
test.t1	analyze	status	OK
drop table t1;
CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
g GEOMETRY NOT NULL,
SPATIAL KEY(g)
) ENGINE=MyISAM;
INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 2, 2 3)')),(GeomFromText('LineString(1 2, 2 4)'));
drop table t1;
CREATE TABLE t1 (
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;
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 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1, t2;
CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Warnings:
Warning	1101	BLOB/TEXT column 'geometry' can't have a default value
INSERT INTO t1 (geometry) VALUES
(PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000
-66.8158332999, -18.7186111000 -66.8102777000, -18.7211111000 -66.9269443999,
-18.6086111000 -66.9327777000))'));
INSERT INTO t1 (geometry) VALUES
(PolygonFromText('POLYGON((-65.7402776999 -96.6686111000, -65.7372222000
-96.5516666000, -65.8502777000 -96.5461111000, -65.8527777000 -96.6627777000,
-65.7402776999 -96.6686111000))'));
check table t1 extended;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
drop table t1;
CREATE TABLE t1 (
c1 geometry NOT NULL default '',
SPATIAL KEY i1 (c1(32))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Warnings:
Warning	1101	BLOB/TEXT column 'c1' can't have a default value
INSERT INTO t1 (c1) VALUES (
PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
                            -18.6055555000 -66.8158332999,
                            -18.7186111000 -66.8102777000,
                            -18.7211111000 -66.9269443999,
                            -18.6086111000 -66.9327777000))'));
CHECK TABLE t1 EXTENDED;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
DROP TABLE t1;
CREATE TABLE t1 (
c1 geometry NOT NULL default '',
SPATIAL KEY i1 (c1(32))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Warnings:
Warning	1101	BLOB/TEXT column 'c1' can't have a default value
INSERT INTO t1 (c1) VALUES (
PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
                            -18.6055555000 -66.8158332999,
                            -18.7186111000 -66.8102777000,
                            -18.7211111000 -66.9269443999,
                            -18.6086111000 -66.9327777000))'));
INSERT INTO t1 (c1) VALUES (
PolygonFromText('POLYGON((-65.7402776999 -96.6686111000,
                            -65.7372222000 -96.5516666000,
                            -65.8502777000 -96.5461111000,
                            -65.8527777000 -96.6627777000,
                            -65.7402776999 -96.6686111000))'));
INSERT INTO t1 (c1) VALUES (
PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
                            -18.6055555000 -66.8158332999,
                            -18.7186111000 -66.8102777000,
                            -18.7211111000 -66.9269443999,
                            -18.6086111000 -66.9327777000))'));
CHECK TABLE t1 EXTENDED;
Table	Op	Msg_type	Msg_text
test.t1	check	status	OK
DROP TABLE t1;
CREATE TABLE t1 (foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,1)));
INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(1,0)));
INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,1)));
INSERT INTO t1 (foo) VALUES (PointFromWKB(POINT(0,0)));
SELECT 1 FROM t1 WHERE foo != PointFromWKB(POINT(0,0));
1
1
1
1
DROP TABLE t1;
CREATE TABLE t1(foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
INSERT INTO t1(foo) VALUES (NULL);
ERROR 23000: Column 'foo' cannot be null
INSERT INTO t1() VALUES ();
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
INSERT INTO t1(foo) VALUES ('');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT, b POINT NOT NULL, KEY (a), SPATIAL KEY (b));
INSERT INTO t1 (b) VALUES (GeomFromText('POINT(1 2)'));
INSERT INTO t1 (b) SELECT b FROM t1;
INSERT INTO t1 (b) SELECT b FROM t1;
INSERT INTO t1 (b) SELECT b FROM t1;
INSERT INTO t1 (b) SELECT b FROM t1;
INSERT INTO t1 (b) SELECT b FROM t1;
OPTIMIZE TABLE t1;
Table	Op	Msg_type	Msg_text
test.t1	optimize	status	OK
DROP TABLE t1;
