summaryrefslogtreecommitdiffstats
path: root/mysql-test/include/view_alias.inc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
commit06eaf7232e9a920468c0f8d74dcf2fe8b555501c (patch)
treee2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/include/view_alias.inc
parentInitial commit. (diff)
downloadmariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.tar.xz
mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.zip
Adding upstream version 1:10.11.6.upstream/1%10.11.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/include/view_alias.inc')
-rw-r--r--mysql-test/include/view_alias.inc25
1 files changed, 25 insertions, 0 deletions
diff --git a/mysql-test/include/view_alias.inc b/mysql-test/include/view_alias.inc
new file mode 100644
index 00000000..17adcf5f
--- /dev/null
+++ b/mysql-test/include/view_alias.inc
@@ -0,0 +1,25 @@
+# Routine to be called by t/view.inc
+#
+# The variable $after_select must be set before calling this routine.
+
+eval CREATE VIEW v1 AS SELECT $after_select;
+SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1';
+#
+# Extract the VIEW's SELECT from INFORMATION_SCHEMA.VIEWS
+let $query1 = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
+#
+# Extract the VIEW's SELECT from SHOW CREATE VIEW
+# SHOW CREATE VIEW v1
+# View Create View character_set_client collation_connection
+# v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select '<--- .....
+let $value= query_get_value(SHOW CREATE VIEW v1, Create View, 1);
+let $query2 = `SELECT SUBSTR("$value",INSTR("$value",' as select ') + CHAR_LENGTH(' as '))`;
+DROP VIEW v1;
+
+# Recreate the view based on SELECT from INFORMATION_SCHEMA.VIEWS
+eval CREATE VIEW v1 AS $query1;
+DROP VIEW v1;
+# Recreate the view based on SHOW CREATE VIEW
+eval CREATE VIEW v1 AS $query2;
+DROP VIEW v1;
+