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
b7853de7
Commit
b7853de7
authored
Feb 15, 2007
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Manual merge
parent
5ebeadf4
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
320 additions
and
134 deletions
+320
-134
mysql-test/r/view.result
mysql-test/r/view.result
+121
-20
mysql-test/t/view.test
mysql-test/t/view.test
+90
-18
sql/sql_parse.cc
sql/sql_parse.cc
+109
-96
No files found.
mysql-test/r/view.result
View file @
b7853de7
...
...
@@ -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;
...
...
@@ -2060,17 +2060,6 @@ CALL p1();
DROP PROCEDURE p1;
DROP VIEW v1;
DROP TABLE t1;
create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime);
create view v1 as select * from t1;
desc v1;
Field Type Null Key Default Extra
f1 tinyint(1) YES NULL
f2 char(1) YES NULL
f3 varchar(1) YES NULL
f4 geometry YES NULL
f5 datetime YES NULL
drop view v1;
drop table t1;
create table t1(f1 datetime);
insert into t1 values('2005.01.01 12:0:0');
create view v1 as select f1, subtime(f1, '1:1:1') as sb from t1;
...
...
@@ -2543,7 +2532,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
...
...
@@ -3016,6 +3005,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;
...
...
@@ -3025,6 +3025,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 filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 100.00 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 filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 100.00 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/view.test
View file @
b7853de7
...
...
@@ -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
...
...
@@ -1878,15 +1878,6 @@ DROP PROCEDURE p1;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
#
# Bug #11335 View redefines column types
#
create
table
t1
(
f1
tinyint
(
1
),
f2
char
(
1
),
f3
varchar
(
1
),
f4
geometry
,
f5
datetime
);
create
view
v1
as
select
*
from
t1
;
desc
v1
;
drop
view
v1
;
drop
table
t1
;
#
# Bug #11760 Typo in Item_func_add_time::print() results in NULLs returned
# subtime() in view
...
...
@@ -2386,7 +2377,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
;
...
...
@@ -2908,7 +2899,6 @@ DROP FUNCTION f1;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
#
# Bug #16813 (WITH CHECK OPTION doesn't work with UPDATE)
#
...
...
@@ -2960,6 +2950,18 @@ 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 +2977,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
...
...
@@ -3082,7 +3155,6 @@ drop table table_24532;
--
echo
End
of
5.0
tests
.
#
# Bug#21370 View renaming lacks tablename_to_filename encoding
#
...
...
sql/sql_parse.cc
View file @
b7853de7
This diff is collapsed.
Click to expand it.
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