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