summaryrefslogtreecommitdiffstats
path: root/mysql-test/main/create_drop_view.test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:00:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 18:00:34 +0000
commit3f619478f796eddbba6e39502fe941b285dd97b1 (patch)
treee2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/main/create_drop_view.test
parentInitial commit. (diff)
downloadmariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz
mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/main/create_drop_view.test')
-rw-r--r--mysql-test/main/create_drop_view.test29
1 files changed, 29 insertions, 0 deletions
diff --git a/mysql-test/main/create_drop_view.test b/mysql-test/main/create_drop_view.test
new file mode 100644
index 00000000..0ebf643e
--- /dev/null
+++ b/mysql-test/main/create_drop_view.test
@@ -0,0 +1,29 @@
+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 TABLE IF EXISTS v1;
+DROP VIEW IF EXISTS v1;
+DROP VIEW IF EXISTS v1;
+DROP VIEW IF EXISTS t1;
+DROP TABLE t1;