Commit 3867aed6 authored by unknown's avatar unknown

Merge mhansson@bk-internal:/home/bk/mysql-5.1-opt

into  dl145s.mysql.com:/data0/mhansson/bug30942/my51-bug30942

parents adab28eb db39be95
......@@ -611,11 +611,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ref period period 4 test.t1.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort
1 SIMPLE t3 index period period 4 NULL 1
1 SIMPLE t1 ref period period 4 test.t3.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
1 SIMPLE t1 index period period 4 NULL 1
1 SIMPLE t3 ref period period 4 test.t1.period 4181
select period from t1;
period
......
......@@ -1425,6 +1425,37 @@ CHECK TABLE t1 EXTENDED;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
create table t1 (a geometry not null, spatial index(a));
insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072)));
insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284)));
insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0)));
insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53)));
insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111)));
insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241)));
insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111)));
insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251)));
insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231)));
insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260)));
insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236)));
insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125)));
insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275)));
insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29)));
insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86)));
insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270)));
insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19)));
insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255)));
insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130)));
insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39)));
insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159)));
insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270)));
insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82)));
insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34)));
insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53)));
insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183)));
insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192)));
insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159)));
insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178)));
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
......
......@@ -736,6 +736,12 @@ SELECT * FROM t1;
a
NULL
DROP TABLE t1;
CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
INSERT INTO `t1` VALUES ('','0000-00-00');
select geomfromtext(col9,col89) as a from t1;
a
NULL
DROP TABLE t1;
End of 4.1 tests
create table t1 (s1 geometry not null,s2 char(100));
create trigger t1_bu before update on t1 for each row set new.s1 = null;
......
......@@ -897,4 +897,168 @@ select '^^: The above should be ~= 20 + cost(select * from t1). Value less than
Z
^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error
drop table t1, t2;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT);
CREATE TABLE t2 (c INT PRIMARY KEY, d INT);
INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL);
INSERT INTO t1 SELECT a + 4, b FROM t1;
INSERT INTO t1 SELECT a + 8, b FROM t1;
INSERT INTO t1 SELECT a + 16, b FROM t1;
INSERT INTO t1 SELECT a + 32, b FROM t1;
INSERT INTO t1 SELECT a + 64, b FROM t1;
INSERT INTO t2 SELECT a, b FROM t1;
EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 2
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1
EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1
SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2;
a b c d
SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2;
a b c d
1 NULL 1 NULL
2 NULL 2 NULL
EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1
EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 128 Using filesort
1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1
SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a;
a b c d
SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a;
a b c d
1 NULL 1 NULL
2 NULL 2 NULL
3 NULL 3 NULL
4 NULL 4 NULL
5 NULL 5 NULL
6 NULL 6 NULL
7 NULL 7 NULL
8 NULL 8 NULL
9 NULL 9 NULL
10 NULL 10 NULL
11 NULL 11 NULL
12 NULL 12 NULL
13 NULL 13 NULL
14 NULL 14 NULL
15 NULL 15 NULL
16 NULL 16 NULL
17 NULL 17 NULL
18 NULL 18 NULL
19 NULL 19 NULL
20 NULL 20 NULL
21 NULL 21 NULL
22 NULL 22 NULL
23 NULL 23 NULL
24 NULL 24 NULL
25 NULL 25 NULL
26 NULL 26 NULL
27 NULL 27 NULL
28 NULL 28 NULL
29 NULL 29 NULL
30 NULL 30 NULL
31 NULL 31 NULL
32 NULL 32 NULL
33 NULL 33 NULL
34 NULL 34 NULL
35 NULL 35 NULL
36 NULL 36 NULL
37 NULL 37 NULL
38 NULL 38 NULL
39 NULL 39 NULL
40 NULL 40 NULL
41 NULL 41 NULL
42 NULL 42 NULL
43 NULL 43 NULL
44 NULL 44 NULL
45 NULL 45 NULL
46 NULL 46 NULL
47 NULL 47 NULL
48 NULL 48 NULL
49 NULL 49 NULL
50 NULL 50 NULL
51 NULL 51 NULL
52 NULL 52 NULL
53 NULL 53 NULL
54 NULL 54 NULL
55 NULL 55 NULL
56 NULL 56 NULL
57 NULL 57 NULL
58 NULL 58 NULL
59 NULL 59 NULL
60 NULL 60 NULL
61 NULL 61 NULL
62 NULL 62 NULL
63 NULL 63 NULL
64 NULL 64 NULL
65 NULL 65 NULL
66 NULL 66 NULL
67 NULL 67 NULL
68 NULL 68 NULL
69 NULL 69 NULL
70 NULL 70 NULL
71 NULL 71 NULL
72 NULL 72 NULL
73 NULL 73 NULL
74 NULL 74 NULL
75 NULL 75 NULL
76 NULL 76 NULL
77 NULL 77 NULL
78 NULL 78 NULL
79 NULL 79 NULL
80 NULL 80 NULL
81 NULL 81 NULL
82 NULL 82 NULL
83 NULL 83 NULL
84 NULL 84 NULL
85 NULL 85 NULL
86 NULL 86 NULL
87 NULL 87 NULL
88 NULL 88 NULL
89 NULL 89 NULL
90 NULL 90 NULL
91 NULL 91 NULL
92 NULL 92 NULL
93 NULL 93 NULL
94 NULL 94 NULL
95 NULL 95 NULL
96 NULL 96 NULL
97 NULL 97 NULL
98 NULL 98 NULL
99 NULL 99 NULL
100 NULL 100 NULL
101 NULL 101 NULL
102 NULL 102 NULL
103 NULL 103 NULL
104 NULL 104 NULL
105 NULL 105 NULL
106 NULL 106 NULL
107 NULL 107 NULL
108 NULL 108 NULL
109 NULL 109 NULL
110 NULL 110 NULL
111 NULL 111 NULL
112 NULL 112 NULL
113 NULL 113 NULL
114 NULL 114 NULL
115 NULL 115 NULL
116 NULL 116 NULL
117 NULL 117 NULL
118 NULL 118 NULL
119 NULL 119 NULL
120 NULL 120 NULL
121 NULL 121 NULL
122 NULL 122 NULL
123 NULL 123 NULL
124 NULL 124 NULL
125 NULL 125 NULL
126 NULL 126 NULL
127 NULL 127 NULL
128 NULL 128 NULL
DROP TABLE IF EXISTS t1,t2;
End of 5.0 tests.
......@@ -607,11 +607,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ref period period 4 test.t1.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort
1 SIMPLE t3 index period period 4 NULL 1
1 SIMPLE t1 ref period period 4 test.t3.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
1 SIMPLE t1 index period period 4 NULL 1
1 SIMPLE t3 ref period period 4 test.t1.period 4181
select period from t1;
period
......
......@@ -608,11 +608,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ref period period 4 test.t1.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort
1 SIMPLE t3 index period period 4 NULL 1
1 SIMPLE t1 ref period period 4 test.t3.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
1 SIMPLE t1 index period period 4 NULL 1
1 SIMPLE t3 ref period period 4 test.t1.period 4181
select period from t1;
period
......
......@@ -611,11 +611,11 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ref period period 4 test.t1.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort
1 SIMPLE t3 index period period 4 NULL 1
1 SIMPLE t1 ref period period 4 test.t3.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
1 SIMPLE t1 index period period 4 NULL 1
1 SIMPLE t3 ref period period 4 test.t1.period 4181
select period from t1;
period
......
......@@ -797,6 +797,42 @@ UPDATE t1 set spatial_point=GeomFromText('POINT(41 46)') where c1 like 'f%';
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
#
# Bug #30286 spatial index cause corruption and server crash!
#
create table t1 (a geometry not null, spatial index(a));
insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072)));
insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284)));
insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0)));
insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53)));
insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111)));
insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241)));
insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111)));
insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251)));
insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231)));
insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260)));
insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236)));
insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125)));
insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275)));
insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29)));
insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86)));
insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270)));
insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19)));
insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255)));
insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130)));
insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39)));
insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159)));
insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270)));
insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82)));
insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34)));
insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53)));
insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183)));
insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192)));
insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159)));
insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178)));
drop table t1;
# End of 4.1 tests
#
......
......@@ -432,6 +432,14 @@ INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug #30955 geomfromtext() crasher
#
CREATE TABLE `t1` ( `col9` set('a'), `col89` date);
INSERT INTO `t1` VALUES ('','0000-00-00');
select geomfromtext(col9,col89) as a from t1;
DROP TABLE t1;
--echo End of 4.1 tests
#
......
......@@ -698,4 +698,33 @@ select '^^: The above should be ~= 20 + cost(select * from t1). Value less than
drop table t1, t2;
#
# Bug #31094: Forcing index-based sort doesn't work anymore if joins are
# done
#
CREATE TABLE t1 (a INT PRIMARY KEY, b INT);
CREATE TABLE t2 (c INT PRIMARY KEY, d INT);
INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL);
INSERT INTO t1 SELECT a + 4, b FROM t1;
INSERT INTO t1 SELECT a + 8, b FROM t1;
INSERT INTO t1 SELECT a + 16, b FROM t1;
INSERT INTO t1 SELECT a + 32, b FROM t1;
INSERT INTO t1 SELECT a + 64, b FROM t1;
INSERT INTO t2 SELECT a, b FROM t1;
#expect indexed ORDER BY
EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2;
EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2;
SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2;
SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2;
#expect filesort
EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a;
EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a;
SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a;
SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a;
DROP TABLE IF EXISTS t1,t2;
--echo End of 5.0 tests.
......@@ -44,7 +44,7 @@ bool Gis_read_stream::get_next_word(LEX_STRING *res)
skip_space();
res->str= (char*) m_cur;
/* The following will also test for \0 */
if (!my_isvar_start(&my_charset_bin, *m_cur))
if ((m_cur >= m_limit) || !my_isvar_start(&my_charset_bin, *m_cur))
return 1;
/*
......
......@@ -12775,12 +12775,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
LINT_INIT(best_key_direction);
LINT_INIT(best_records);
/*
filesort() and join cache are usually faster than reading in
index order and not using join cache
*/
if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1)
DBUG_RETURN(0);
/*
If not used with LIMIT, only use keys if the whole query can be
resolved with a key; This is because filesort() is usually faster than
......@@ -12788,6 +12782,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
*/
if (select_limit >= table_records)
{
/*
filesort() and join cache are usually faster than reading in
index order and not using join cache
*/
if (tab->type == JT_ALL && tab->join->tables > tab->join->const_tables + 1)
DBUG_RETURN(0);
keys= *table->file->keys_to_use_for_scanning();
keys.merge(table->covering_keys);
......
......@@ -483,15 +483,16 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
uint key_length, uchar *page_buf, uint nod_flag)
{
double increase;
double best_incr = DBL_MAX;
double best_incr;
double area;
double best_area;
uchar *best_key;
uchar *best_key= NULL;
uchar *k = rt_PAGE_FIRST_KEY(page_buf, nod_flag);
uchar *last = rt_PAGE_END(page_buf);
LINT_INIT(best_area);
LINT_INIT(best_key);
LINT_INIT(best_incr);
for (; k < last; k = rt_PAGE_NEXT_KEY(k, key_length, nod_flag))
{
......@@ -500,22 +501,13 @@ static uchar *rtree_pick_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
&area)) == -1.0)
return NULL;
/* The following should be safe, even if we compare doubles */
if (increase < best_incr)
if (!best_key || increase < best_incr ||
((increase == best_incr) && (area < best_area)))
{
best_key = k;
best_area = area;
best_incr = increase;
}
else
{
/* The following should be safe, even if we compare doubles */
if ((increase == best_incr) && (area < best_area))
{
best_key = k;
best_area = area;
best_incr = increase;
}
}
}
return best_key;
}
......
......@@ -523,7 +523,10 @@ double rtree_overlapping_area(HA_KEYSEG *keyseg, uchar* a, uchar* b,
}
/*
Calculates MBR_AREA(a+b) - MBR_AREA(a)
Calculates MBR_AREA(a+b) - MBR_AREA(a)
Note: when 'a' and 'b' objects are far from each other,
the area increase can be really big, so this function
can return 'inf' as a result.
*/
double rtree_area_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
uint key_length, double *ab_area)
......
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