mariadb/mysql-test/main/create_drop_view.result
Monty dfb41fddf6 Make error messages from DROP TABLE and DROP TABLE IF EXISTS consistent
- IF EXISTS ends with a list of all not existing object, instead of a
  separate note for every not existing object
- Produce a "Note" for all wrongly dropped objects
  (like trying to do DROP SEQUENCE for a normal table)
- Do not write existing tables that could not be dropped to binlog

Other things:
MDEV-22820 Bogus "Unknown table" warnings produced upon attempt to drop
           parent table referenced by FK
This was caused by an older version of this commit patch and later fixed
2020-06-14 19:39:42 +03:00

66 lines
1.6 KiB
Text

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 '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 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 TABLE IF EXISTS v1;
Warnings:
Note 1965 'test.v1' is a view
DROP VIEW IF EXISTS v1;
DROP VIEW IF EXISTS v1;
Warnings:
Note 4092 Unknown VIEW: 'test.v1'
DROP VIEW IF EXISTS t1;
Warnings:
Warning 1347 'test.t1' is not of type 'VIEW'
Note 4092 Unknown VIEW: 'test.t1'
DROP TABLE t1;