Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
1c2c6bba
Commit
1c2c6bba
authored
Apr 13, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge rurik.mysql.com:/home/igor/mysql-5.0
into rurik.mysql.com:/home/igor/dev/mysql-5.0-0
parents
8487a67b
cfefd88d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
169 additions
and
1 deletion
+169
-1
mysql-test/r/information_schema.result
mysql-test/r/information_schema.result
+17
-0
mysql-test/r/view.result
mysql-test/r/view.result
+82
-0
mysql-test/t/information_schema.test
mysql-test/t/information_schema.test
+5
-0
mysql-test/t/view.test
mysql-test/t/view.test
+62
-0
sql/sql_base.cc
sql/sql_base.cc
+1
-1
sql/sql_show.cc
sql/sql_show.cc
+2
-0
No files found.
mysql-test/r/information_schema.result
View file @
1c2c6bba
...
@@ -68,6 +68,23 @@ t2
...
@@ -68,6 +68,23 @@ t2
t3
t3
v1
v1
select c,table_name from 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)
left join information_schema.TABLES v2 on (v1.c=v2.table_name)
where v1.c like "t%";
where v1.c like "t%";
c table_name
c table_name
...
...
mysql-test/r/view.result
View file @
1c2c6bba
...
@@ -1612,3 +1612,85 @@ insert into t3 select x from v1;
...
@@ -1612,3 +1612,85 @@ insert into t3 select x from v1;
insert into t2 select x from v1;
insert into t2 select x from v1;
drop view v1;
drop view v1;
drop table t1,t2,t3;
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;
mysql-test/t/information_schema.test
View file @
1c2c6bba
...
@@ -24,6 +24,11 @@ create table t3(a int, KEY a_data (a));
...
@@ -24,6 +24,11 @@ create table t3(a int, KEY a_data (a));
create
table
mysqltest
.
t4
(
a
int
);
create
table
mysqltest
.
t4
(
a
int
);
create
view
v1
(
c
)
as
select
table_name
from
information_schema
.
TABLES
;
create
view
v1
(
c
)
as
select
table_name
from
information_schema
.
TABLES
;
select
*
from
v1
;
select
*
from
v1
;
select
c
,
table_name
from
v1
inner
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
where
v1
.
c
like
"t%"
;
select
c
,
table_name
from
v1
select
c
,
table_name
from
v1
left
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
left
join
information_schema
.
TABLES
v2
on
(
v1
.
c
=
v2
.
table_name
)
where
v1
.
c
like
"t%"
;
where
v1
.
c
like
"t%"
;
...
...
mysql-test/t/view.test
View file @
1c2c6bba
...
@@ -1457,3 +1457,65 @@ insert into t3 select x from v1;
...
@@ -1457,3 +1457,65 @@ insert into t3 select x from v1;
insert
into
t2
select
x
from
v1
;
insert
into
t2
select
x
from
v1
;
drop
view
v1
;
drop
view
v1
;
drop
table
t1
,
t2
,
t3
;
drop
table
t1
,
t2
,
t3
;
#
# Test for BUG #6106: query over a view using subquery for the underlying table
#
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
);
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
);
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
);
# Tests from the report for bug #6107
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
));
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
);
DROP
VIEW
v1
,
v2
,
v3
;
DROP
TABLE
t1
,
t2
;
sql/sql_base.cc
View file @
1c2c6bba
...
@@ -3588,7 +3588,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds)
...
@@ -3588,7 +3588,7 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds)
thd
->
set_query_id
=
1
;
thd
->
set_query_id
=
1
;
thd
->
lex
->
current_select
->
no_wrap_view_item
=
1
;
thd
->
lex
->
current_select
->
no_wrap_view_item
=
0
;
select_lex
->
cond_count
=
0
;
select_lex
->
cond_count
=
0
;
if
(
*
conds
)
if
(
*
conds
)
{
{
...
...
sql/sql_show.cc
View file @
1c2c6bba
...
@@ -1704,6 +1704,8 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
...
@@ -1704,6 +1704,8 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
strlen
(
item_field
->
field_name
),
0
)))
strlen
(
item_field
->
field_name
),
0
)))
return
0
;
return
0
;
}
}
else
if
(
item
->
type
()
==
Item
::
REF_ITEM
)
return
uses_only_table_name_fields
(
item
->
real_item
(),
table
);
if
(
item
->
type
()
==
Item
::
SUBSELECT_ITEM
&&
if
(
item
->
type
()
==
Item
::
SUBSELECT_ITEM
&&
!
item
->
const_item
())
!
item
->
const_item
())
return
0
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment