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
acdc3834
Commit
acdc3834
authored
Dec 10, 2014
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-7287 VIEW: CREATE IF NOT EXISTS
parent
92a523e5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
240 additions
and
0 deletions
+240
-0
mysql-test/r/create_drop_view.result
mysql-test/r/create_drop_view.result
+59
-0
mysql-test/suite/rpl/r/rpl_create_drop_view.result
mysql-test/suite/rpl/r/rpl_create_drop_view.result
+99
-0
mysql-test/suite/rpl/t/rpl_create_drop_view.test
mysql-test/suite/rpl/t/rpl_create_drop_view.test
+55
-0
mysql-test/t/create_drop_view.test
mysql-test/t/create_drop_view.test
+27
-0
No files found.
mysql-test/r/create_drop_view.result
0 → 100644
View file @
acdc3834
CREATE TABLE t1(id INT);
CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 WHERE id>10;
INSERT INTO t1 VALUES (5), (8), (10), (20), (30);
SELECT * FROM t1;
id
5
8
10
20
30
SELECT * FROM v1;
id
20
30
CREATE VIEW v1 AS SELECT * FROM t1 WHERE id>11;
ERROR 42S01: Table 'v1' already exists
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME='v1';
VIEW_DEFINITION
select `test`.`t1`.`id` AS `id` from `test`.`t1` where (`test`.`t1`.`id` > 10)
CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 WHERE id>12;
Warnings:
Note 1050 Table 'test' already exists
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME='v1';
VIEW_DEFINITION
select `test`.`t1`.`id` AS `id` from `test`.`t1` where (`test`.`t1`.`id` > 10)
CREATE OR REPLACE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 WHERE id>13;
ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME='v1';
VIEW_DEFINITION
select `test`.`t1`.`id` AS `id` from `test`.`t1` where (`test`.`t1`.`id` > 10)
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1 WHERE id>14;
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME='v1';
VIEW_DEFINITION
select `test`.`t1`.`id` AS `id` from `test`.`t1` where (`test`.`t1`.`id` > 14)
INSERT INTO t1 VALUES (50), (80), (3), (2), (40);
SELECT * FROM t1;
id
5
8
10
20
30
50
80
3
2
40
SELECT * FROM v1;
id
20
30
50
80
40
DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v1;
Warnings:
Note 1051 Unknown table 'test.v1'
DROP TABLE t1;
mysql-test/suite/rpl/r/rpl_create_drop_view.result
0 → 100644
View file @
acdc3834
include/master-slave.inc
[connection master]
CREATE TABLE t1(id INT);
CREATE VIEW v1 AS SELECT * FROM t1 WHERE id>10;
INSERT INTO t1 VALUES (5), (8), (10), (20), (30);
SELECT * FROM t1;
id
5
8
10
20
30
SELECT * FROM v1;
id
20
30
# Syncing slave with master
SELECT * FROM t1;
id
5
8
10
20
30
SELECT * FROM v1;
id
20
30
CREATE VIEW v1 AS SELECT * FROM t1 WHERE id>10;
ERROR 42S01: Table 'v1' already exists
CREATE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 WHERE id>10;
Warnings:
Note 1050 Table 'test' already exists
CREATE OR REPLACE VIEW IF NOT EXISTS v1 AS SELECT * FROM t1 WHERE id>10;
ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS
# Syncing slave with master
SELECT * FROM t1;
id
5
8
10
20
30
SELECT * FROM v1;
id
20
30
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1 WHERE id>10;
INSERT INTO t1 VALUES (50), (80), (3), (2), (40);
SELECT * FROM t1;
id
5
8
10
20
30
50
80
3
2
40
SELECT * FROM v1;
id
20
30
50
80
40
# Syncing slave with master
SELECT * FROM t1;
id
5
8
10
20
30
50
80
3
2
40
SELECT * FROM v1;
id
20
30
50
80
40
DROP VIEW v1;
DROP TABLE t1;
DROP VIEW v1;
ERROR 42S02: Unknown table 'test.v1'
DROP VIEW IF EXISTS v2;
Warnings:
Note 1051 Unknown table 'test.v2'
# Syncing slave with master
SELECT * FROM v1;
ERROR 42S02: Table 'test.v1' doesn't exist
include/rpl_end.inc
mysql-test/suite/rpl/t/rpl_create_drop_view.test
0 → 100644
View file @
acdc3834
--
source
include
/
master
-
slave
.
inc
connection
master
;
CREATE
TABLE
t1
(
id
INT
);
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
10
;
INSERT
INTO
t1
VALUES
(
5
),
(
8
),
(
10
),
(
20
),
(
30
);
SELECT
*
FROM
t1
;
SELECT
*
FROM
v1
;
--
echo
# Syncing slave with master
sync_slave_with_master
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
v1
;
connection
master
;
--
error
ER_TABLE_EXISTS_ERROR
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
10
;
CREATE
VIEW
IF
NOT
EXISTS
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
10
;
--
error
ER_WRONG_USAGE
CREATE
OR
REPLACE
VIEW
IF
NOT
EXISTS
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
10
;
--
echo
# Syncing slave with master
sync_slave_with_master
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
v1
;
connection
master
;
CREATE
OR
REPLACE
VIEW
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
10
;
INSERT
INTO
t1
VALUES
(
50
),
(
80
),
(
3
),
(
2
),
(
40
);
SELECT
*
FROM
t1
;
SELECT
*
FROM
v1
;
--
echo
# Syncing slave with master
sync_slave_with_master
;
SELECT
*
FROM
t1
;
SELECT
*
FROM
v1
;
connection
master
;
DROP
VIEW
v1
;
DROP
TABLE
t1
;
--
error
ER_BAD_TABLE_ERROR
DROP
VIEW
v1
;
DROP
VIEW
IF
EXISTS
v2
;
--
echo
# Syncing slave with master
sync_slave_with_master
;
--
error
ER_NO_SUCH_TABLE
SELECT
*
FROM
v1
;
--
source
include
/
rpl_end
.
inc
mysql-test/t/create_drop_view.test
0 → 100644
View file @
acdc3834
CREATE
TABLE
t1
(
id
INT
);
CREATE
VIEW
IF
NOT
EXISTS
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
10
;
INSERT
INTO
t1
VALUES
(
5
),
(
8
),
(
10
),
(
20
),
(
30
);
SELECT
*
FROM
t1
;
SELECT
*
FROM
v1
;
--
error
ER_TABLE_EXISTS_ERROR
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
11
;
SELECT
VIEW_DEFINITION
FROM
INFORMATION_SCHEMA
.
VIEWS
WHERE
TABLE_NAME
=
'v1'
;
CREATE
VIEW
IF
NOT
EXISTS
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
12
;
SELECT
VIEW_DEFINITION
FROM
INFORMATION_SCHEMA
.
VIEWS
WHERE
TABLE_NAME
=
'v1'
;
--
error
ER_WRONG_USAGE
CREATE
OR
REPLACE
VIEW
IF
NOT
EXISTS
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
13
;
SELECT
VIEW_DEFINITION
FROM
INFORMATION_SCHEMA
.
VIEWS
WHERE
TABLE_NAME
=
'v1'
;
CREATE
OR
REPLACE
VIEW
v1
AS
SELECT
*
FROM
t1
WHERE
id
>
14
;
SELECT
VIEW_DEFINITION
FROM
INFORMATION_SCHEMA
.
VIEWS
WHERE
TABLE_NAME
=
'v1'
;
INSERT
INTO
t1
VALUES
(
50
),
(
80
),
(
3
),
(
2
),
(
40
);
SELECT
*
FROM
t1
;
SELECT
*
FROM
v1
;
DROP
VIEW
IF
EXISTS
v1
;
DROP
VIEW
IF
EXISTS
v1
;
DROP
TABLE
t1
;
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