1# Routine to be called by t/view.inc
2#
3# The variable $after_select must be set before calling this routine.
4
5eval CREATE VIEW v1 AS SELECT $after_select;
6SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1';
7#
8# Extract the VIEW's SELECT from INFORMATION_SCHEMA.VIEWS
9let $query1 = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`;
10#
11# Extract the VIEW's SELECT from SHOW CREATE VIEW
12# SHOW CREATE VIEW v1
13# View    Create View     character_set_client    collation_connection
14# v1      CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select '<--- .....
15let $value= query_get_value(SHOW CREATE VIEW v1, Create View, 1);
16let $query2 = `SELECT SUBSTR("$value",INSTR("$value",' as select ') + CHAR_LENGTH(' as '))`;
17DROP VIEW v1;
18
19# Recreate the view based on SELECT from INFORMATION_SCHEMA.VIEWS
20eval CREATE VIEW v1 AS $query1;
21DROP VIEW v1;
22# Recreate the view based on SHOW CREATE VIEW
23eval CREATE VIEW v1 AS $query2;
24DROP VIEW v1;
25
26