Commit 2fd1bd92 authored by gkodinov/kgeorge@magare.gmz's avatar gkodinov/kgeorge@magare.gmz

Merge magare.gmz:/home/kgeorge/mysql/autopush/B26794-5.0-opt

into  magare.gmz:/home/kgeorge/mysql/autopush/B26794-merge-5.1-opt
parents 31b636c0 2525db66
...@@ -886,7 +886,7 @@ ALTER TABLE t1 ADD b GEOMETRY NOT NULL, ADD SPATIAL INDEX(b); ...@@ -886,7 +886,7 @@ ALTER TABLE t1 ADD b GEOMETRY NOT NULL, ADD SPATIAL INDEX(b);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` varchar(500) DEFAULT NULL, `a` varchar(500) default NULL,
`b` geometry NOT NULL, `b` geometry NOT NULL,
SPATIAL KEY `b` (`b`) SPATIAL KEY `b` (`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
...@@ -894,7 +894,7 @@ ALTER TABLE t1 ADD KEY(b(50)); ...@@ -894,7 +894,7 @@ ALTER TABLE t1 ADD KEY(b(50));
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` varchar(500) DEFAULT NULL, `a` varchar(500) default NULL,
`b` geometry NOT NULL, `b` geometry NOT NULL,
SPATIAL KEY `b` (`b`), SPATIAL KEY `b` (`b`),
KEY `b_2` (`b`(50)) KEY `b_2` (`b`(50))
...@@ -903,9 +903,9 @@ ALTER TABLE t1 ADD c POINT; ...@@ -903,9 +903,9 @@ ALTER TABLE t1 ADD c POINT;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` varchar(500) DEFAULT NULL, `a` varchar(500) default NULL,
`b` geometry NOT NULL, `b` geometry NOT NULL,
`c` point DEFAULT NULL, `c` point default NULL,
SPATIAL KEY `b` (`b`), SPATIAL KEY `b` (`b`),
KEY `b_2` (`b`(50)) KEY `b_2` (`b`(50))
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
......
...@@ -958,6 +958,28 @@ a ratio ...@@ -958,6 +958,28 @@ a ratio
19 1.3333 19 1.3333
9 2.6667 9 2.6667
drop table t1; drop table t1;
CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME);
INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10);
UPDATE t1 SET b = SEC_TO_TIME(a);
SELECT a, b FROM t1 ORDER BY b DESC;
a b
1000000 277:46:40
100000 27:46:40
10000 02:46:40
1000 00:16:40
100 00:01:40
10 00:00:10
0 00:00:00
SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC;
a b
1000000 277:46:40
100000 27:46:40
10000 02:46:40
1000 00:16:40
100 00:01:40
10 00:00:10
0 00:00:00
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b)); CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b));
INSERT INTO t1 VALUES (1,1),(2,2); INSERT INTO t1 VALUES (1,1),(2,2);
CREATE TABLE t2 (a INT, b INT, KEY a (a,b)); CREATE TABLE t2 (a INT, b INT, KEY a (a,b));
......
...@@ -3933,4 +3933,42 @@ cc cc 7 ...@@ -3933,4 +3933,42 @@ cc cc 7
aa aa 2 aa aa 2
aa aa 2 aa aa 2
DROP TABLE t1,t2; DROP TABLE t1,t2;
CREATE TABLE t1 (
access_id int NOT NULL default '0',
name varchar(20) default NULL,
rank int NOT NULL default '0',
KEY idx (access_id)
);
CREATE TABLE t2 (
faq_group_id int NOT NULL default '0',
faq_id int NOT NULL default '0',
access_id int default NULL,
UNIQUE KEY idx1 (faq_id),
KEY idx2 (faq_group_id,faq_id)
);
INSERT INTO t1 VALUES
(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4);
INSERT INTO t2 VALUES
(261,265,1),(490,494,1);
SELECT t2.faq_id
FROM t1 INNER JOIN t2 IGNORE INDEX (idx1)
ON (t1.access_id = t2.access_id)
LEFT JOIN t2 t
ON (t.faq_group_id = t2.faq_group_id AND
find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4'))
WHERE
t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);
faq_id
265
SELECT t2.faq_id
FROM t1 INNER JOIN t2
ON (t1.access_id = t2.access_id)
LEFT JOIN t2 t
ON (t.faq_group_id = t2.faq_group_id AND
find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4'))
WHERE
t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);
faq_id
265
DROP TABLE t1,t2;
End of 5.0 tests End of 5.0 tests
...@@ -3873,3 +3873,16 @@ id_1 ...@@ -3873,3 +3873,16 @@ id_1
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1xt2; DROP TABLE t1xt2;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (3), (1), (2);
SELECT 'this is ' 'a test.' AS col1, a AS col2 FROM t1;
col1 col2
this is a test. 3
this is a test. 1
this is a test. 2
SELECT * FROM (SELECT 'this is ' 'a test.' AS col1, a AS t2 FROM t1) t;
col1 t2
this is a test. 3
this is a test. 1
this is a test. 2
DROP table t1;
...@@ -678,6 +678,21 @@ insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9); ...@@ -678,6 +678,21 @@ insert into t1 values (1,2,3), (9,8,3), (19,4,3), (1,4,9);
select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc; select a,(sum(b)/sum(c)) as ratio from t1 group by a order by sum(b)/sum(c) asc;
drop table t1; drop table t1;
#
# Bug#26672: Incorrect SEC_TO_TIME() casting in ORDER BY
#
CREATE TABLE t1 (a INT UNSIGNED NOT NULL, b TIME);
INSERT INTO t1 (a) VALUES (100000), (0), (100), (1000000),(10000), (1000), (10);
UPDATE t1 SET b = SEC_TO_TIME(a);
-- Correct ORDER
SELECT a, b FROM t1 ORDER BY b DESC;
-- must be ordered as the above
SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC;
DROP TABLE t1;
# #
# BUG#16590: Optimized does not do right "const" table pre-read # BUG#16590: Optimized does not do right "const" table pre-read
# #
......
...@@ -3299,4 +3299,51 @@ SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name; ...@@ -3299,4 +3299,51 @@ SELECT * FROM t1 LEFT JOIN t2 ON t1.name=t2.name;
DROP TABLE t1,t2; DROP TABLE t1,t2;
#
# Bug #26963: join with predicates that contain fields from equalities evaluated
# to constants after constant table substitution
#
CREATE TABLE t1 (
access_id int NOT NULL default '0',
name varchar(20) default NULL,
rank int NOT NULL default '0',
KEY idx (access_id)
);
CREATE TABLE t2 (
faq_group_id int NOT NULL default '0',
faq_id int NOT NULL default '0',
access_id int default NULL,
UNIQUE KEY idx1 (faq_id),
KEY idx2 (faq_group_id,faq_id)
);
INSERT INTO t1 VALUES
(1,'Everyone',2),(2,'Help',3),(3,'Technical Support',1),(4,'Chat User',4);
INSERT INTO t2 VALUES
(261,265,1),(490,494,1);
SELECT t2.faq_id
FROM t1 INNER JOIN t2 IGNORE INDEX (idx1)
ON (t1.access_id = t2.access_id)
LEFT JOIN t2 t
ON (t.faq_group_id = t2.faq_group_id AND
find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4'))
WHERE
t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);
SELECT t2.faq_id
FROM t1 INNER JOIN t2
ON (t1.access_id = t2.access_id)
LEFT JOIN t2 t
ON (t.faq_group_id = t2.faq_group_id AND
find_in_set(t.access_id, '1,4') < find_in_set(t2.access_id, '1,4'))
WHERE
t2.access_id IN (1,4) AND t.access_id IS NULL AND t2.faq_id in (265);
DROP TABLE t1,t2;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -2736,3 +2736,15 @@ DROP TABLE t1; ...@@ -2736,3 +2736,15 @@ DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
DROP TABLE t1xt2; DROP TABLE t1xt2;
#
# Bug #26728: derived table with concatanation of literals in select list
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (3), (1), (2);
SELECT 'this is ' 'a test.' AS col1, a AS col2 FROM t1;
SELECT * FROM (SELECT 'this is ' 'a test.' AS col1, a AS t2 FROM t1) t;
DROP table t1;
...@@ -1374,7 +1374,10 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length, ...@@ -1374,7 +1374,10 @@ sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length,
} }
else else
{ {
switch ((sortorder->result_type=sortorder->item->result_type())) { sortorder->result_type= sortorder->item->result_type();
if (sortorder->item->result_as_longlong())
sortorder->result_type= INT_RESULT;
switch (sortorder->result_type) {
case STRING_RESULT: case STRING_RESULT:
sortorder->length=sortorder->item->max_length; sortorder->length=sortorder->item->max_length;
set_if_smaller(sortorder->length, thd->variables.max_sort_length); set_if_smaller(sortorder->length, thd->variables.max_sort_length);
......
...@@ -4127,7 +4127,9 @@ bool Item_field::set_no_const_sub(byte *arg) ...@@ -4127,7 +4127,9 @@ bool Item_field::set_no_const_sub(byte *arg)
DESCRIPTION DESCRIPTION
The function returns a pointer to an item that is taken from The function returns a pointer to an item that is taken from
the very beginning of the item_equal list which the Item_field the very beginning of the item_equal list which the Item_field
object refers to (belongs to). object refers to (belongs to) unless item_equal contains a constant
item. In this case the function returns this constant item,
(if the substitution does not require conversion).
If the Item_field object does not refer any Item_equal object If the Item_field object does not refer any Item_equal object
'this' is returned 'this' is returned
...@@ -4136,7 +4138,8 @@ bool Item_field::set_no_const_sub(byte *arg) ...@@ -4136,7 +4138,8 @@ bool Item_field::set_no_const_sub(byte *arg)
of the thransformer method. of the thransformer method.
RETURN VALUES RETURN VALUES
pointer to a replacement Item_field if there is a better equal item; pointer to a replacement Item_field if there is a better equal item or
a pointer to a constant equal item;
this - otherwise. this - otherwise.
*/ */
...@@ -4144,6 +4147,14 @@ Item *Item_field::replace_equal_field(byte *arg) ...@@ -4144,6 +4147,14 @@ Item *Item_field::replace_equal_field(byte *arg)
{ {
if (item_equal) if (item_equal)
{ {
Item *const_item= item_equal->get_const();
if (const_item)
{
if (cmp_context != (Item_result)-1 &&
const_item->cmp_context != cmp_context)
return this;
return const_item;
}
Item_field *subst= item_equal->get_first(); Item_field *subst= item_equal->get_first();
if (subst && !field->eq(subst->field)) if (subst && !field->eq(subst->field))
return subst; return subst;
......
...@@ -1811,7 +1811,11 @@ class Item_string :public Item ...@@ -1811,7 +1811,11 @@ class Item_string :public Item
str_value.length(), collation.collation); str_value.length(), collation.collation);
} }
Item *safe_charset_converter(CHARSET_INFO *tocs); Item *safe_charset_converter(CHARSET_INFO *tocs);
inline void append(char *str, uint length) { str_value.append(str, length); } inline void append(char *str, uint length)
{
str_value.append(str, length);
max_length= str_value.numchars() * collation.collation->mbmaxlen;
}
void print(String *str); void print(String *str);
// to prevent drop fixed flag (no need parent cleanup call) // to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {} void cleanup() {}
......
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