1## Modify view
2
3## Preamble
4--source ../include/xplugin_preamble.inc
5
6## Test data
7## Test starts here
8--let $xtest_file= $MYSQL_TMP_DIR/create_view.tmp
9--write_file $xtest_file
10-->quiet
11
12-->macro Modify_view	%FIELD% %FIELD_ALIAS% %OPTION% %ERROR%
13Mysqlx.Crud.ModifyView {
14  collection { name: "xview" schema: "xtest" }
15  %OPTION%
16  stmt: {
17    collection { name: "xtable" schema: "xtest"}
18    projection {
19      alias: "%FIELD_ALIAS%"
20      source { type: IDENT identifier { name: "%FIELD%" } }
21    }
22    data_model: TABLE
23  }
24}
25-->recvuntil %ERROR%
26-->sql
27SHOW CREATE VIEW xtest.xview
28-->endsql
29-->endmacro
30
31-->title -Modify view (missing stmt)
32Mysqlx.Crud.ModifyView {
33  collection { name: "xview" schema: "xtest" }
34  algorithm: TEMPTABLE
35}
36-->recverror ER_X_INVALID_ARGUMENT
37
38-->title -Modify view (stmt)
39-->callmacro Modify_view	second	doc	#	Mysqlx.Ok
40
41
42-->title -Modify view (algorithm=temptable)
43-->callmacro Modify_view	second	doc	algorithm: TEMPTABLE	Mysqlx.Ok
44
45
46-->title -Modify view (algorithm=merge)
47-->callmacro Modify_view	second	doc	algorithm: MERGE	Mysqlx.Ok
48
49
50-->title -Modify view (definer=xuser)
51-->callmacro Modify_view	second	doc	definer: "xuser@localhost"	Mysqlx.Ok
52
53
54-->title -Modify view (security=invoker)
55-->callmacro Modify_view	second	doc	security: INVOKER	Mysqlx.Ok
56
57
58-->title -Modify view (security=definer)
59-->callmacro Modify_view	second	doc	security: DEFINER	Mysqlx.Ok
60
61
62-->title -Modify view (check=local)
63-->callmacro Modify_view	second	doc	check: LOCAL	Mysqlx.Ok
64
65
66-->title -Modify view (check=cascaded)
67-->callmacro Modify_view	second	doc	check: CASCADED	Mysqlx.Ok
68
69
70-->title -Modify view (column)
71-->callmacro Modify_view	second	doc	column: "third"	Mysqlx.Ok
72
73
74-->title -Modify view (too many columns)
75-->callmacro Modify_view	second	doc	column: "third" column: "fourth"	Mysqlx.Error
76
77
78-->stmtsql SHOW STATUS LIKE 'Mysqlx_crud_modify_view'
79-->recvresult
80EOF
81
82
83CREATE SCHEMA xtest;
84CREATE TABLE xtest.xtable (first INT, second JSON);
85CREATE USER xuser@localhost;
86CREATE VIEW xtest.xview AS SELECT first FROM xtest.xtable;
87SHOW CREATE VIEW xtest.xview;
88
89--exec $MYSQLXTEST -uroot --password='' --file=$xtest_file 2>&1
90
91--let $assert_text= Global status of 'Mysqlx_crud_modify_view'
92--let $assert_cond= [SHOW GLOBAL STATUS LIKE \'Mysqlx_crud_modify_view\', Value, 1] = 11
93--source include/assert.inc
94
95
96--remove_file $xtest_file
97
98
99## Postamble
100DROP SCHEMA IF EXISTS xtest;
101DROP USER xuser@localhost;
102UNINSTALL PLUGIN mysqlx;
103