mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
information_schema.result, information_schema.test:
Added a test in connection with the fix for bug #6106. view.result, view.test: Added test cases for bugs #6106/6107. sql_show.cc: The addition of the case for items of the type REF_ITEM in the function uses_only_table_name_fields became necessary after the fix for bug #6106. sql_base.cc: The problem was due to the fact that two different column references were glued together though one of them belonged to a subquery while another to an outer query. This caused eventually a wrong calculation of values for the used_tables attribute. sql/sql_base.cc: The problem was due to the fact that two different column references were glued together though one of them belonged to a subquery while another to an outer query. This caused eventually a wrong calculation of values for the used_tables attribute. sql/sql_show.cc: The addition of the case for items of the type REF_ITEM in the function uses_only_table_name_fields became necessary after the fix for bug #6106. mysql-test/t/view.test: Added test cases for bugs #6106/6107. mysql-test/r/view.result: Added test cases for bugs #6106/6107. mysql-test/t/information_schema.test: Added a test in connection with the fix for bug #6106. mysql-test/r/information_schema.result: Added a test in connection with the fix for bug #6106.
This commit is contained in:
@ -68,6 +68,23 @@ t2
|
||||
t3
|
||||
v1
|
||||
select c,table_name from v1
|
||||
inner join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
||||
where v1.c like "t%";
|
||||
c table_name
|
||||
TABLES TABLES
|
||||
TABLE_PRIVILEGES TABLE_PRIVILEGES
|
||||
TABLE_CONSTRAINTS TABLE_CONSTRAINTS
|
||||
tables_priv tables_priv
|
||||
time_zone time_zone
|
||||
time_zone_leap_second time_zone_leap_second
|
||||
time_zone_name time_zone_name
|
||||
time_zone_transition time_zone_transition
|
||||
time_zone_transition_type time_zone_transition_type
|
||||
t1 t1
|
||||
t4 t4
|
||||
t2 t2
|
||||
t3 t3
|
||||
select c,table_name from v1
|
||||
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
|
||||
where v1.c like "t%";
|
||||
c table_name
|
||||
|
@ -1612,3 +1612,85 @@ insert into t3 select x from v1;
|
||||
insert into t2 select x from v1;
|
||||
drop view v1;
|
||||
drop table t1,t2,t3;
|
||||
CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10));
|
||||
INSERT INTO t1 VALUES(1,'trudy');
|
||||
INSERT INTO t1 VALUES(2,'peter');
|
||||
INSERT INTO t1 VALUES(3,'sanja');
|
||||
INSERT INTO t1 VALUES(4,'monty');
|
||||
INSERT INTO t1 VALUES(5,'david');
|
||||
INSERT INTO t1 VALUES(6,'kent');
|
||||
INSERT INTO t1 VALUES(7,'carsten');
|
||||
INSERT INTO t1 VALUES(8,'ranger');
|
||||
INSERT INTO t1 VALUES(10,'matt');
|
||||
CREATE TABLE t2 (col1 int, col2 int, col3 char(1));
|
||||
INSERT INTO t2 VALUES (1,1,'y');
|
||||
INSERT INTO t2 VALUES (1,2,'y');
|
||||
INSERT INTO t2 VALUES (2,1,'n');
|
||||
INSERT INTO t2 VALUES (3,1,'n');
|
||||
INSERT INTO t2 VALUES (4,1,'y');
|
||||
INSERT INTO t2 VALUES (4,2,'n');
|
||||
INSERT INTO t2 VALUES (4,3,'n');
|
||||
INSERT INTO t2 VALUES (6,1,'n');
|
||||
INSERT INTO t2 VALUES (8,1,'y');
|
||||
CREATE VIEW v1 AS SELECT * FROM t1;
|
||||
SELECT a.col1,a.col2,b.col2,b.col3
|
||||
FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1
|
||||
WHERE b.col2 IS NULL OR
|
||||
b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);
|
||||
col1 col2 col2 col3
|
||||
1 trudy 2 y
|
||||
2 peter 1 n
|
||||
3 sanja 1 n
|
||||
4 monty 3 n
|
||||
5 david NULL NULL
|
||||
6 kent 1 n
|
||||
7 carsten NULL NULL
|
||||
8 ranger 1 y
|
||||
10 matt NULL NULL
|
||||
SELECT a.col1,a.col2,b.col2,b.col3
|
||||
FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1
|
||||
WHERE b.col2 IS NULL OR
|
||||
b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);
|
||||
col1 col2 col2 col3
|
||||
1 trudy 2 y
|
||||
2 peter 1 n
|
||||
3 sanja 1 n
|
||||
4 monty 3 n
|
||||
5 david NULL NULL
|
||||
6 kent 1 n
|
||||
7 carsten NULL NULL
|
||||
8 ranger 1 y
|
||||
10 matt NULL NULL
|
||||
CREATE VIEW v2 AS SELECT * FROM t2;
|
||||
SELECT a.col1,a.col2,b.col2,b.col3
|
||||
FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1
|
||||
WHERE b.col2 IS NULL OR
|
||||
b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);
|
||||
col1 col2 col2 col3
|
||||
1 trudy 2 y
|
||||
2 peter 1 n
|
||||
3 sanja 1 n
|
||||
4 monty 3 n
|
||||
5 david NULL NULL
|
||||
6 kent 1 n
|
||||
7 carsten NULL NULL
|
||||
8 ranger 1 y
|
||||
10 matt NULL NULL
|
||||
SELECT a.col1,a.col2,b.col2,b.col3
|
||||
FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1
|
||||
WHERE a.col1 IN (1,5,9) AND
|
||||
(b.col2 IS NULL OR
|
||||
b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1));
|
||||
col1 col2 col2 col3
|
||||
1 trudy 2 y
|
||||
5 david NULL NULL
|
||||
CREATE VIEW v3 AS SELECT * FROM t1 WHERE col1 IN (1,5,9);
|
||||
SELECT a.col1,a.col2,b.col2,b.col3
|
||||
FROM v2 b RIGHT JOIN v3 a ON a.col1=b.col1
|
||||
WHERE b.col2 IS NULL OR
|
||||
b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);
|
||||
col1 col2 col2 col3
|
||||
1 trudy 2 y
|
||||
5 david NULL NULL
|
||||
DROP VIEW v1,v2,v3;
|
||||
DROP TABLE t1,t2;
|
||||
|
Reference in New Issue
Block a user