mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
Merge rurik.mysql.com:/home/igor/mysql-5.0
into rurik.mysql.com:/home/igor/dev/mysql-5.0-2
This commit is contained in:
commit
ed5ac749b9
7 changed files with 122 additions and 5 deletions
|
@ -12,7 +12,7 @@ explain extended select count(a) as b from t1 where a=0 having b >=0;
|
|||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
Warnings:
|
||||
Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where 0 having (count(`test`.`t1`.`a`) >= 0)
|
||||
Note 1003 select count(`test`.`t1`.`a`) AS `b` from `test`.`t1` where 0 having (`b` >= 0)
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
raw_id int(10) NOT NULL default '0',
|
||||
|
|
|
@ -1151,8 +1151,8 @@ EXPLAIN
|
|||
SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
|
||||
WHERE t1.name LIKE 'A%' OR FALSE;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
|
||||
1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
|
||||
1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
|
||||
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
|
||||
DROP TABLE t1,t2;
|
||||
DROP VIEW IF EXISTS v1,v2;
|
||||
DROP TABLE IF EXISTS t1,t2;
|
||||
|
@ -1176,3 +1176,38 @@ a b
|
|||
3 3
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1,t2;
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t2 (b int);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4);
|
||||
INSERT INTO t2 VALUES (2), (3);
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1);
|
||||
a b
|
||||
1 NULL
|
||||
2 2
|
||||
3 3
|
||||
4 NULL
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1);
|
||||
a b
|
||||
1 NULL
|
||||
2 2
|
||||
3 3
|
||||
4 NULL
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1);
|
||||
a b
|
||||
1 NULL
|
||||
2 2
|
||||
3 3
|
||||
4 NULL
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2);
|
||||
a b
|
||||
1 NULL
|
||||
2 2
|
||||
3 3
|
||||
4 NULL
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0);
|
||||
a b
|
||||
1 NULL
|
||||
2 2
|
||||
3 3
|
||||
4 NULL
|
||||
DROP TABLE t1,t2;
|
||||
|
|
|
@ -2660,3 +2660,28 @@ SELECT * FROM v1;
|
|||
id t COUNT(*)
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(
|
||||
fName varchar(25) NOT NULL,
|
||||
lName varchar(25) NOT NULL,
|
||||
DOB date NOT NULL,
|
||||
uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY);
|
||||
INSERT INTO t1(fName, lName, DOB) VALUES
|
||||
('Hank', 'Hill', '1964-09-29'),
|
||||
('Tom', 'Adams', '1908-02-14'),
|
||||
('Homer', 'Simpson', '1968-03-05');
|
||||
CREATE VIEW v1 AS
|
||||
SELECT (year(now())-year(DOB)) AS Age
|
||||
FROM t1 HAVING Age < 75;
|
||||
SHOW CREATE VIEW v1;
|
||||
View Create View
|
||||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_no_cache (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75)
|
||||
SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75;
|
||||
Age
|
||||
42
|
||||
38
|
||||
SELECT * FROM v1;
|
||||
Age
|
||||
42
|
||||
38
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
|
|
@ -805,3 +805,21 @@ SELECT v1.a, v2. b
|
|||
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug 19816: LEFT OUTER JOIN with constant ORed predicates in WHERE clause
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (a int);
|
||||
CREATE TABLE t2 (b int);
|
||||
INSERT INTO t1 VALUES (1), (2), (3), (4);
|
||||
INSERT INTO t2 VALUES (2), (3);
|
||||
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1);
|
||||
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1 OR 1);
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (0 OR 1);
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 2=2);
|
||||
SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.b WHERE (1=1 OR 1=0);
|
||||
|
||||
DROP TABLE t1,t2;
|
||||
|
|
|
@ -2528,3 +2528,31 @@ SELECT * FROM v1;
|
|||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# Bug #19573: VIEW with HAVING that refers an alias name
|
||||
#
|
||||
|
||||
CREATE TABLE t1(
|
||||
fName varchar(25) NOT NULL,
|
||||
lName varchar(25) NOT NULL,
|
||||
DOB date NOT NULL,
|
||||
uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY);
|
||||
|
||||
INSERT INTO t1(fName, lName, DOB) VALUES
|
||||
('Hank', 'Hill', '1964-09-29'),
|
||||
('Tom', 'Adams', '1908-02-14'),
|
||||
('Homer', 'Simpson', '1968-03-05');
|
||||
|
||||
CREATE VIEW v1 AS
|
||||
SELECT (year(now())-year(DOB)) AS Age
|
||||
FROM t1 HAVING Age < 75;
|
||||
SHOW CREATE VIEW v1;
|
||||
|
||||
SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75;
|
||||
SELECT * FROM v1;
|
||||
|
||||
DROP VIEW v1;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
|
|
11
sql/item.cc
11
sql/item.cc
|
@ -4840,7 +4840,16 @@ void Item_ref::cleanup()
|
|||
void Item_ref::print(String *str)
|
||||
{
|
||||
if (ref)
|
||||
(*ref)->print(str);
|
||||
{
|
||||
if ((*ref)->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF &&
|
||||
name && alias_name_used)
|
||||
{
|
||||
THD *thd= current_thd;
|
||||
append_identifier(thd, str, name, (uint) strlen(name));
|
||||
}
|
||||
else
|
||||
(*ref)->print(str);
|
||||
}
|
||||
else
|
||||
Item_ident::print(str);
|
||||
}
|
||||
|
|
|
@ -2570,7 +2570,9 @@ Item_cond::fix_fields(THD *thd, Item **ref)
|
|||
(item= *li.ref())->check_cols(1))
|
||||
return TRUE; /* purecov: inspected */
|
||||
used_tables_cache|= item->used_tables();
|
||||
if (!item->const_item())
|
||||
if (item->const_item())
|
||||
and_tables_cache= (table_map) 0;
|
||||
else
|
||||
{
|
||||
tmp_table_map= item->not_null_tables();
|
||||
not_null_tables_cache|= tmp_table_map;
|
||||
|
|
Loading…
Reference in a new issue