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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
b80bd854
Commit
b80bd854
authored
Feb 16, 2007
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Manual merge
parent
e4c2ffcb
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
428 additions
and
34 deletions
+428
-34
mysql-test/r/subselect.result
mysql-test/r/subselect.result
+125
-18
mysql-test/r/view.result
mysql-test/r/view.result
+121
-9
mysql-test/t/subselect.test
mysql-test/t/subselect.test
+93
-0
mysql-test/t/view.test
mysql-test/t/view.test
+89
-7
No files found.
mysql-test/r/subselect.result
View file @
b80bd854
This diff is collapsed.
Click to expand it.
mysql-test/r/view.result
View file @
b80bd854
...
...
@@ -834,14 +834,14 @@ show create view v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 99999999999999999999999999999999999999999999999999999 AS `col1`
drop view v1;
create table t (c char);
create view v as select c from t;
insert into v values ('');
select * from v;
c
drop view v;
drop table t;
create table t (c char);
create view v as select c from t;
insert into v values ('');
select * from v;
c
drop view v;
drop table t;
create table t1 (a int, b int);
insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
create view v1(c) as select a+1 from t1 where b >= 4;
...
...
@@ -2543,7 +2543,7 @@ create table t1(f1 int, f2 int);
create view v1 as select ta.f1 as a, tb.f1 as b from t1 ta, t1 tb where ta.f1=tb
.f1 and ta.f2=tb.f2;
insert into t1 values(1,1),(2,2);
create view v2 as select * from v1 where a > 1 with check option;
create view v2 as select * from v1 where a > 1 with
local
check option;
select * from v2;
a b
2 2
...
...
@@ -3014,6 +3014,17 @@ i j
6 3
DROP VIEW v1, v2;
DROP TABLE t1;
CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL;
SHOW CREATE VIEW v;
View Create View
v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select ((not(0)) * 5) AS `x`
SELECT !0 * 5 AS x FROM DUAL;
x
5
SELECT * FROM v;
x
5
DROP VIEW v;
DROP VIEW IF EXISTS v1;
CREATE VIEW v1 AS SELECT 'The\ZEnd';
SELECT * FROM v1;
...
...
@@ -3023,6 +3034,107 @@ SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select _latin1'The\ZEnd' AS `TheEnd`
DROP VIEW v1;
CREATE TABLE t1 (mydate DATETIME);
INSERT INTO t1 VALUES
('2007-01-01'), ('2007-01-02'), ('2007-01-30'), ('2007-01-31');
CREATE VIEW v1 AS SELECT mydate from t1;
SELECT * FROM t1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
mydate
2007-01-01 00:00:00
2007-01-02 00:00:00
2007-01-30 00:00:00
2007-01-31 00:00:00
SELECT * FROM v1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
mydate
2007-01-01 00:00:00
2007-01-02 00:00:00
2007-01-30 00:00:00
2007-01-31 00:00:00
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (b int);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (1), (2);
CREATE VIEW v1 AS
SELECT t2.b FROM t1,t2 WHERE t1.a = t2.b WITH CHECK OPTION;
SELECT * FROM v1;
b
1
2
UPDATE v1 SET b=3;
ERROR HY000: CHECK OPTION failed 'test.v1'
SELECT * FROM v1;
b
1
2
SELECT * FROM t1;
a
1
2
SELECT * FROM t2;
b
1
2
DROP VIEW v1;
DROP TABLE t1,t2;
create table t1(f1 int, f2 int);
insert into t1 values(1,2),(1,3),(1,1),(2,3),(2,1),(2,2);
select * from t1;
f1 f2
1 2
1 3
1 1
2 3
2 1
2 2
create view v1 as select * from t1 order by f2;
select * from v1;
f1 f2
1 1
2 1
1 2
2 2
1 3
2 3
explain extended select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
Warnings:
Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` order by `test`.`t1`.`f2`
select * from v1 order by f1;
f1 f2
1 1
1 2
1 3
2 1
2 2
2 3
explain extended select * from v1 order by f1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
Warnings:
Note 1003 select `test`.`t1`.`f1` AS `f1`,`test`.`t1`.`f2` AS `f2` from `test`.`t1` order by `test`.`t1`.`f1`,`test`.`t1`.`f2`
drop view v1;
drop table t1;
CREATE TABLE t1 (
id int(11) NOT NULL PRIMARY KEY,
country varchar(32),
code int(11) default NULL
);
INSERT INTO t1 VALUES
(1,'ITALY',100),(2,'ITALY',200),(3,'FRANCE',100), (4,'ITALY',100);
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT code, COUNT(DISTINCT country) FROM t1 GROUP BY code ORDER BY MAX(id);
code COUNT(DISTINCT country)
200 1
100 2
SELECT code, COUNT(DISTINCT country) FROM v1 GROUP BY code ORDER BY MAX(id);
code COUNT(DISTINCT country)
200 1
100 2
DROP VIEW v1;
DROP TABLE t1;
DROP VIEW IF EXISTS v1;
SELECT * FROM (SELECT 1) AS t;
1
...
...
mysql-test/t/subselect.test
View file @
b80bd854
...
...
@@ -2000,6 +2000,65 @@ SELECT a FROM t1 WHERE (SELECT 1 FROM DUAL WHERE 1=0) IS NULL;
EXPLAIN
SELECT
a
FROM
t1
WHERE
(
SELECT
1
FROM
DUAL
WHERE
1
=
0
)
IS
NULL
;
DROP
TABLE
t1
;
#
# Bug 24653: sorting by expressions containing subselects
# that return more than one row
#
CREATE
TABLE
t1
(
a
int
);
INSERT
INTO
t1
VALUES
(
2
),
(
4
),
(
1
),
(
3
);
CREATE
TABLE
t2
(
b
int
,
c
int
);
INSERT
INTO
t2
VALUES
(
2
,
1
),
(
1
,
3
),
(
2
,
1
),
(
4
,
4
),
(
2
,
2
),
(
1
,
4
);
SELECT
a
FROM
t1
ORDER
BY
(
SELECT
c
FROM
t2
WHERE
b
>
2
);
--
error
1242
SELECT
a
FROM
t1
ORDER
BY
(
SELECT
c
FROM
t2
WHERE
b
>
1
);
SELECT
a
FROM
t1
ORDER
BY
(
SELECT
c
FROM
t2
WHERE
b
>
2
),
a
;
--
error
1242
SELECT
a
FROM
t1
ORDER
BY
(
SELECT
c
FROM
t2
WHERE
b
>
1
),
a
;
SELECT
b
,
MAX
(
c
)
FROM
t2
GROUP
BY
b
,
(
SELECT
c
FROM
t2
WHERE
b
>
2
);
--
error
1242
SELECT
b
,
MAX
(
c
)
FROM
t2
GROUP
BY
b
,
(
SELECT
c
FROM
t2
WHERE
b
>
1
);
SELECT
a
FROM
t1
GROUP
BY
a
HAVING
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
2
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
))
>
3
;
--
error
1242
SELECT
a
FROM
t1
GROUP
BY
a
HAVING
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
1
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
))
>
3
;
SELECT
a
FROM
t1
GROUP
BY
a
HAVING
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
4
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
))
>
3
;
--
error
1242
SELECT
a
FROM
t1
GROUP
BY
a
HAVING
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
4
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
1
ORDER
BY
b
))
>
3
;
SELECT
a
FROM
t1
ORDER
BY
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
2
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
));
--
error
1242
SELECT
a
FROM
t1
ORDER
BY
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
1
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
1
ORDER
BY
b
));
SELECT
a
FROM
t1
ORDER
BY
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
4
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
2
ORDER
BY
b
));
--
error
1242
SELECT
a
FROM
t1
ORDER
BY
IFNULL
((
SELECT
b
FROM
t2
WHERE
b
>
4
),
(
SELECT
c
FROM
t2
WHERE
c
=
a
AND
b
>
1
ORDER
BY
b
));
DROP
TABLE
t1
,
t2
;
# End of 4.1 tests
#
...
...
@@ -2509,6 +2568,40 @@ SELECT SQL_NO_CACHE COUNT(*)
DROP
TABLE
t1
,
t2
;
#
# Bug #25219: EXIST subquery with UNION over a mix of
# correlated and uncorrelated selects
#
CREATE
TABLE
t1
(
id
char
(
4
)
PRIMARY
KEY
,
c
int
);
CREATE
TABLE
t2
(
c
int
);
INSERT
INTO
t1
VALUES
(
'aa'
,
1
);
INSERT
INTO
t2
VALUES
(
1
);
SELECT
*
FROM
t1
WHERE
EXISTS
(
SELECT
c
FROM
t2
WHERE
c
=
1
UNION
SELECT
c
from
t2
WHERE
c
=
t1
.
c
);
INSERT
INTO
t1
VALUES
(
'bb'
,
2
),
(
'cc'
,
3
),
(
'dd'
,
1
);
SELECT
*
FROM
t1
WHERE
EXISTS
(
SELECT
c
FROM
t2
WHERE
c
=
1
UNION
SELECT
c
from
t2
WHERE
c
=
t1
.
c
);
INSERT
INTO
t2
VALUES
(
2
);
CREATE
TABLE
t3
(
c
int
);
INSERT
INTO
t3
VALUES
(
1
);
SELECT
*
FROM
t1
WHERE
EXISTS
(
SELECT
t2
.
c
FROM
t2
JOIN
t3
ON
t2
.
c
=
t3
.
c
WHERE
t2
.
c
=
1
UNION
SELECT
c
from
t2
WHERE
c
=
t1
.
c
);
DROP
TABLE
t1
,
t2
,
t3
;
#
# Bug#21904 (parser problem when using IN with a double "(())")
#
...
...
mysql-test/t/view.test
View file @
b80bd854
...
...
@@ -748,12 +748,12 @@ drop view v1;
#
# VIEWs with national characters
#
create table t (c char);
create view v as select c from t;
insert into v values ('');
select * from v;
drop view v;
drop table t;
create table t (c char);
create view v as select c from t;
insert into v values ('');
select * from v;
drop view v;
drop table t;
#
# problem with used_tables() of outer reference resolved in VIEW
...
...
@@ -2385,7 +2385,7 @@ create table t1(f1 int, f2 int);
create
view
v1
as
select
ta
.
f1
as
a
,
tb
.
f1
as
b
from
t1
ta
,
t1
tb
where
ta
.
f1
=
tb
.
f1
and
ta
.
f2
=
tb
.
f2
;
insert
into
t1
values
(
1
,
1
),(
2
,
2
);
create
view
v2
as
select
*
from
v1
where
a
>
1
with
check
option
;
create
view
v2
as
select
*
from
v1
where
a
>
1
with
local
check
option
;
select
*
from
v2
;
update
v2
set
b
=
3
where
a
=
2
;
select
*
from
v2
;
...
...
@@ -2959,6 +2959,17 @@ SELECT * FROM t1;
DROP
VIEW
v1
,
v2
;
DROP
TABLE
t1
;
#
# Bug #25580: !0 as an operand in a select expression of a view
#
CREATE
VIEW
v
AS
SELECT
!
0
*
5
AS
x
FROM
DUAL
;
SHOW
CREATE
VIEW
v
;
SELECT
!
0
*
5
AS
x
FROM
DUAL
;
SELECT
*
FROM
v
;
DROP
VIEW
v
;
#
# BUG#24293: '\Z' token is not handled correctly in views
...
...
@@ -2975,6 +2986,77 @@ SHOW CREATE VIEW v1;
DROP
VIEW
v1
;
#
# Bug #26124: BETWEEN over a view column of the DATETIME type
#
CREATE
TABLE
t1
(
mydate
DATETIME
);
INSERT
INTO
t1
VALUES
(
'2007-01-01'
),
(
'2007-01-02'
),
(
'2007-01-30'
),
(
'2007-01-31'
);
CREATE
VIEW
v1
AS
SELECT
mydate
from
t1
;
SELECT
*
FROM
t1
WHERE
mydate
BETWEEN
'2007-01-01'
AND
'2007-01-31'
;
SELECT
*
FROM
v1
WHERE
mydate
BETWEEN
'2007-01-01'
AND
'2007-01-31'
;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
#
# Bug #25931: update of a multi-table view with check option
#
CREATE
TABLE
t1
(
a
int
);
CREATE
TABLE
t2
(
b
int
);
INSERT
INTO
t1
VALUES
(
1
),
(
2
);
INSERT
INTO
t2
VALUES
(
1
),
(
2
);
CREATE
VIEW
v1
AS
SELECT
t2
.
b
FROM
t1
,
t2
WHERE
t1
.
a
=
t2
.
b
WITH
CHECK
OPTION
;
SELECT
*
FROM
v1
;
--
error
1369
UPDATE
v1
SET
b
=
3
;
SELECT
*
FROM
v1
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
t2
;
DROP
VIEW
v1
;
DROP
TABLE
t1
,
t2
;
#
# Bug#12122: Views with ORDER BY can't be resolved using MERGE algorithm.
#
create
table
t1
(
f1
int
,
f2
int
);
insert
into
t1
values
(
1
,
2
),(
1
,
3
),(
1
,
1
),(
2
,
3
),(
2
,
1
),(
2
,
2
);
select
*
from
t1
;
create
view
v1
as
select
*
from
t1
order
by
f2
;
select
*
from
v1
;
explain
extended
select
*
from
v1
;
select
*
from
v1
order
by
f1
;
explain
extended
select
*
from
v1
order
by
f1
;
drop
view
v1
;
drop
table
t1
;
#
# Bug#26209: queries with GROUP BY and ORDER BY using views
#
CREATE
TABLE
t1
(
id
int
(
11
)
NOT
NULL
PRIMARY
KEY
,
country
varchar
(
32
),
code
int
(
11
)
default
NULL
);
INSERT
INTO
t1
VALUES
(
1
,
'ITALY'
,
100
),(
2
,
'ITALY'
,
200
),(
3
,
'FRANCE'
,
100
),
(
4
,
'ITALY'
,
100
);
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
SELECT
code
,
COUNT
(
DISTINCT
country
)
FROM
t1
GROUP
BY
code
ORDER
BY
MAX
(
id
);
SELECT
code
,
COUNT
(
DISTINCT
country
)
FROM
v1
GROUP
BY
code
ORDER
BY
MAX
(
id
);
DROP
VIEW
v1
;
DROP
TABLE
t1
;
#
# BUG#25897: Some queries are no longer possible after a CREATE VIEW
...
...
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