| 1 |
## generated |
| 2 |
## Simple collection |
| 3 |
|
| 4 |
--source include/xplugin_preamble.inc |
| 5 |
--source include/xplugin_create_user.inc |
| 6 |
|
| 7 |
create schema xtest default charset 'utf8mb4'; |
| 8 |
create database xtest_1 default charset 'utf8mb4'; |
| 9 |
|
| 10 |
|
| 11 |
## Test starts here |
| 12 |
--let $xtest_file= $MYSQL_TMP_DIR/admin_create_collection_mysqlx.xpl |
| 13 |
--write_file $xtest_file |
| 14 |
-->import admin_stmt.macro |
| 15 |
-->quiet |
| 16 |
|
| 17 |
callmacro Admin_stmt create_collection {"schema":"xtest","name":"books0"} |
| 18 |
ER_SUCCESS; |
| 19 |
|
| 20 |
callmacro Admin_stmt create_collection {"name":"books1", "schema":"xtest"} |
| 21 |
ER_SUCCESS; |
| 22 |
|
| 23 |
callmacro Admin_stmt create_collection {"name":"books1", "schema":"xtest"} |
| 24 |
ER_TABLE_EXISTS_ERROR; |
| 25 |
|
| 26 |
callmacro Admin_stmt create_collection {"name":"books1", "schema":"xtest_1"} |
| 27 |
ER_SUCCESS; |
| 28 |
|
| 29 |
callmacro Admin_stmt create_collection |
| 30 |
{"name":"books1", "schema":"xtest_1", "options": { |
| 31 |
"validation": { |
| 32 |
"schema":"{\"type\":\"object\"}" |
| 33 |
} |
| 34 |
}} |
| 35 |
ER_TABLE_EXISTS_ERROR; |
| 36 |
|
| 37 |
callmacro Admin_stmt create_collection |
| 38 |
{"name":"stuff", "schema":"xtest_1", "options": { |
| 39 |
"validation": { |
| 40 |
"schema":"{\"type\":\"object\"}" |
| 41 |
} |
| 42 |
}} |
| 43 |
ER_SUCCESS; |
| 44 |
|
| 45 |
callmacro Admin_stmt create_collection {"name":"stuff", "schema":"xtest_1"} |
| 46 |
ER_TABLE_EXISTS_ERROR; |
| 47 |
|
| 48 |
callmacro Admin_stmt create_collection {"schema":"xtest"} |
| 49 |
ER_X_CMD_NUM_ARGUMENTS; |
| 50 |
|
| 51 |
callmacro Admin_stmt create_collection {"schema":"xtest", "foo": "bar"} |
| 52 |
ER_X_CMD_NUM_ARGUMENTS; |
| 53 |
|
| 54 |
callmacro Admin_stmt create_collection {"name":"books2"} |
| 55 |
ER_X_CMD_NUM_ARGUMENTS; |
| 56 |
|
| 57 |
callmacro Admin_stmt create_collection {} |
| 58 |
ER_X_CMD_NUM_ARGUMENTS; |
| 59 |
|
| 60 |
callmacro Admin_stmt create_collection |
| 61 |
{"invalid_field_name": "nothing", |
| 62 |
"options": { |
| 63 |
"validation": {"schema": "{'{\"type\":\"object\"}'}"} |
| 64 |
}, |
| 65 |
"name":"books2", |
| 66 |
"schema":"xtest" |
| 67 |
} |
| 68 |
ER_X_CMD_INVALID_ARGUMENT; |
| 69 |
|
| 70 |
callmacro Admin_stmt create_collection {"schema":"xtest", "name":""} |
| 71 |
ER_X_BAD_TABLE; |
| 72 |
|
| 73 |
callmacro Admin_stmt create_collection {"schema":"", "name":"books2"} |
| 74 |
ER_X_BAD_SCHEMA; |
| 75 |
|
| 76 |
callmacro Admin_stmt create_collection {"schema":"xtest", "name":" "} |
| 77 |
ER_WRONG_TABLE_NAME; |
| 78 |
|
| 79 |
callmacro Admin_stmt create_collection {"schema":" ", "name":"books2"} |
| 80 |
ER_WRONG_DB_NAME; |
| 81 |
|
| 82 |
callmacro Admin_stmt create_collection {"schema":"xtest", "name":"col lection"} |
| 83 |
ER_SUCCESS; |
| 84 |
|
| 85 |
callmacro Admin_stmt create_collection |
| 86 |
{"schema":"xtest", "name":"a table name'with\"bad`characters"} |
| 87 |
ER_SUCCESS; |
| 88 |
|
| 89 |
|
| 90 |
Mysqlx.Sql.StmtExecute { |
| 91 |
stmt: "create_collection" |
| 92 |
args { |
| 93 |
type: OBJECT obj { |
| 94 |
fld { |
| 95 |
key:'schema' |
| 96 |
value{type:SCALAR scalar{type:V_STRING v_string{value:'xtest'}}} |
| 97 |
} |
| 98 |
fld { |
| 99 |
key:'name' |
| 100 |
value{type:SCALAR scalar{type:V_STRING v_string{value:'\000'}}} |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
namespace: "mysqlx" |
| 105 |
} |
| 106 |
-->expecterror ER_X_CMD_ARGUMENT_VALUE |
| 107 |
-->recvresult |
| 108 |
|
| 109 |
|
| 110 |
-->sql |
| 111 |
SHOW TABLES FROM xtest |
| 112 |
-->endsql |
| 113 |
|
| 114 |
|
| 115 |
callmacro Admin_stmt drop_collection {"schema":"xtest","name":"books0"} |
| 116 |
ER_SUCCESS; |
| 117 |
|
| 118 |
callmacro Admin_stmt drop_collection {"name":"books1","schema":"xtest"} |
| 119 |
ER_SUCCESS; |
| 120 |
|
| 121 |
callmacro Admin_stmt drop_collection {"name":"books1","schema":"xtest_1"} |
| 122 |
ER_SUCCESS; |
| 123 |
|
| 124 |
callmacro Admin_stmt drop_collection {"schema":"xtest_1","name":"stuff"} |
| 125 |
ER_SUCCESS; |
| 126 |
|
| 127 |
callmacro Admin_stmt drop_collection {"schema":"xtest"} |
| 128 |
ER_X_CMD_NUM_ARGUMENTS; |
| 129 |
|
| 130 |
callmacro Admin_stmt drop_collection {"name":"books2"} |
| 131 |
ER_X_CMD_NUM_ARGUMENTS; |
| 132 |
|
| 133 |
callmacro Admin_stmt drop_collection |
| 134 |
{"extra":"nothing", "name":"books2","schema":"xtest"} |
| 135 |
ER_X_CMD_INVALID_ARGUMENT; |
| 136 |
|
| 137 |
callmacro Admin_stmt drop_collection {} |
| 138 |
ER_X_CMD_NUM_ARGUMENTS; |
| 139 |
|
| 140 |
-->sql |
| 141 |
SHOW STATUS LIKE 'Mysqlx_stmt_execute_mysqlx'; |
| 142 |
-->endsql |
| 143 |
EOF |
| 144 |
|
| 145 |
--exec $MYSQLXTEST -ux_root --password='' --file=$xtest_file 2>&1 |
| 146 |
|
| 147 |
## Cleanup |
| 148 |
--source ../include/xplugin_cleanup.inc |
| 149 |
drop database if exists xtest_1; |
| 150 |
|