polardbxengine/mysql-test/suite/x/t/admin_ensure_collection_mys...

153 lines
3.7 KiB
Plaintext

## Admin command: ensure_collection
--source include/xplugin_preamble.inc
--source include/xplugin_create_user.inc
CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4';
## Test starts here
--let $xtest_file= $MYSQL_TMP_DIR/admin_ensure_collection_mysqlx.tmp
--write_file $xtest_file
-->quiet
-->macro Make_stmt %CMD% %SCHEMA%
-->stmtadmin %CMD% { %SCHEMA% "name":"books"}
-->endmacro
-->macro Make_collection_with_schema %CMD% %SCHEMA% %ERROR%
-->callmacro Make_stmt %CMD% "schema":"%SCHEMA%",
-->expecterror %ERROR%
-->recvresult
-->stmtsql SHOW TABLES FROM xtest;
-->recvresult
-->endmacro
-->macro Make_collection_without_schema %CMD% %ERROR%
-->callmacro Make_stmt %CMD%
-->expecterror %ERROR%
-->recvresult
-->stmtsql SHOW TABLES FROM xtest;
-->recvresult
-->endmacro
-->macro Make_collection %CMD% %ERROR%
-->callmacro Make_collection_with_schema %CMD% xtest %ERROR%
-->endmacro
-->macro Make_table %DEF% %TEMP%
-->stmtsql CREATE %TEMP% TABLE xtest.books %DEF%;
-->recvresult
-->endmacro
-->macro Drop_table
-->stmtsql DROP TABLE xtest.books;
-->recvresult
-->endmacro
-->macro Make_index %NAME% %TYPE%
-->stmtadmin create_collection_index {"schema": "xtest", "collection":"books", "name":"%NAME%", "unique":true, "constraint":{"member":"$.%NAME%", "type":"%TYPE%", "required":false}}
-->recvresult
-->endmacro
-->callmacro Make_collection create_collection 0
-->callmacro Make_collection create_collection 1050
-->callmacro Make_collection ensure_collection 0
-->callmacro Make_index isbn TEXT(13)
-->callmacro Make_collection ensure_collection 0
-->callmacro Make_index pages INT
-->callmacro Make_collection ensure_collection 0
-->stmtsql ALTER TABLE xtest.books ADD COLUMN (nothing INT)
-->recvresult
-->callmacro Make_collection ensure_collection 5156
-->callmacro Drop_table
-->callmacro Make_collection ensure_collection 0
-->callmacro Drop_table
-->callmacro Make_collection create_collection 0
-->stmtsql ALTER TABLE xtest.books DROP _id
-->recvresult
-->callmacro Make_collection ensure_collection 5156
-->callmacro Drop_table
-->callmacro Make_table (doc JSON, _id VARBINARY(32))
-->callmacro Make_collection ensure_collection 5156
-->callmacro Drop_table
-->callmacro Make_table (doc INT, _id VARBINARY(32))
-->callmacro Make_collection ensure_collection 5156
-->callmacro Drop_table
-->callmacro Make_table (doc JSON, _id INT)
-->callmacro Make_collection ensure_collection 5156
-->callmacro Make_collection_with_schema ensure_collection nowhere 1049
-->callmacro Drop_table
-->callmacro Make_collection_without_schema ensure_collection 1046
-->stmtsql USE xtest
-->recvresult
-->callmacro Make_collection_without_schema ensure_collection 0
-->callmacro Drop_table
-->newsession temp
-->callmacro Make_table (it_is_not_collection INT) TEMPORARY
-->callmacro Make_collection ensure_collection 0
-->stmtsql SHOW COLUMNS FROM xtest.books
-->recvresult
-->closesession
-->stmtsql SHOW COLUMNS FROM xtest.books
-->recvresult
-->callmacro Drop_table
-->sql
CREATE USER unpriv;
SET PASSWORD FOR unpriv = 'x';
GRANT SELECT ON xtest.* TO unpriv;
-->endsql
-->newsession unable_to_create unpriv x
-->callmacro Make_collection ensure_collection 1142
-->closesession
-->stmtsql DROP USER unpriv;
-->recvresult
-->callmacro Make_table (it_is_not_collection INT)
-->stmtsql LOCK TABLE xtest.books WRITE;
-->recvresult
-->newsession lock
-->callmacro Make_collection ensure_collection 5156
-->closesession
-->stmtsql UNLOCK TABLES
-->recvresult
EOF
--exec $MYSQLXTEST -ux_root --password='' --file=$xtest_file 2>&1
SHOW STATUS like 'Mysqlx_stmt_create_collection';
SHOW STATUS like 'Mysqlx_stmt_ensure_collection';
SHOW STATUS like 'Mysqlx_stmt_execute_mysqlx';
## Cleanup
DROP SCHEMA IF EXISTS xtest;
--remove_file $xtest_file
--source include/xplugin_drop_user.inc