## generated --source include/xplugin_preamble.inc --source include/xplugin_create_user.inc ## Test starts here CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4'; --let $xtest_file= $MYSQL_TMP_DIR/admin_create_index_string_mysqlx.tmp --write_file $xtest_file -->import assert_select.macro -->quiet ## Test data -->stmtadmin create_collection {"schema":"xtest", "name":"books1"} -->recvresult -->macro Assert_use_of_index %COLL% %NAME% %COND% callmacro Assert_select possible_keys %NAME% EXPLAIN SELECT * FROM xtest.%COLL% USE INDEX(`%NAME%`) WHERE %COND%; -->endmacro -->macro Insert %COLL% %VALUE% %ERROR% Mysqlx.Crud.Insert { collection { name: "%COLL%" schema: "xtest" } data_model: DOCUMENT row { field { type: LITERAL literal { type: V_STRING v_string { value: %VALUE% } } } } } -->expecterror %ERROR% -->recvresult -->endmacro -->macro Create_index %COLLECTION% %INDEX% %UNIQUE% %DOCUMENT_PATH% %TYPE% %REQUIRED% %ERROR% -->stmtadmin create_collection_index {"schema":"xtest", "collection":%COLLECTION%, "name": %INDEX%, "unique": %UNIQUE%, "constraint":{"member": %DOCUMENT_PATH%, "type": %TYPE%,"required": %REQUIRED%}} -->expecterror %ERROR% -->recvresult -->endmacro -->echo 1 -->callmacro Create_index "books1" "isbn" true "$.isbn" "TEXT(13)" false ER_SUCCESS -->callmacro Insert books1 '{"_id": "one", "name": "The Bla", "isbn" : "9780262527804", "pages":30}' ER_SUCCESS -->callmacro Insert books1 '{"_id": "two", "name": "The Bla II", "isbn" : "9780262527805"}' ER_SUCCESS -->callmacro Insert books1 '{"_id": "three", "name": "The Bla III"}' ER_SUCCESS -->callmacro Assert_use_of_index books1 isbn doc->'$.isbn' = '9780262527804' -->callmacro Create_index "books1" "pages" true "$.pages" "INT" true ER_X_DOC_REQUIRED_FIELD_MISSING -->callmacro Create_index "books1" "pages" true "$.pages" "INT" false ER_SUCCESS -->callmacro Assert_use_of_index books1 pages doc->'$.pages' > 1 -->callmacro Create_index "books1" "name" true "$.name" "TEXT(80)" true ER_SUCCESS -->callmacro Assert_use_of_index books1 name doc->'$.name' = 'The Bla' -->callmacro Create_index "books1" "another name" true "$.name" "TEXT(80)" true ER_SUCCESS -->callmacro Assert_use_of_index books1 another name doc->'$.name' = 'The Bla' -->callmacro Create_index "books1" "name_char" true "$.name" "CHAR(64)" true ER_SUCCESS -->callmacro Assert_use_of_index books1 name_char doc->'$.name' = 'The Bla' -->callmacro Create_index "books1" "isbn_char" true "$.isbn" "CHAR" true ER_DATA_TOO_LONG -->callmacro Insert books1 '{"_id": "four", "isbn": "9780262527809"}' ER_X_DOC_ID_MISSING -->callmacro Create_index "books1" "datetime`;drop table" false "$.data.datetime" "DATETIME" false ER_SUCCESS -->callmacro Create_index "books1" "_id" false "$.data.datetime" "DATETIME" false ER_SUCCESS -->callmacro Create_index "books1" "aaa" true "$.da\ta.da\tetime" "DATETIME" false ER_X_CMD_ARGUMENT_VALUE -->callmacro Create_index "books1" "" false "$.data.datetime" "DATETIME" false ER_X_CMD_ARGUMENT_VALUE -->callmacro Create_index "books1" "aaa" false "$.data.datetime" "text(20);drop table" false ER_X_CMD_ARGUMENT_VALUE -->callmacro Create_index "books1" "aaa" false "$.data.datetime" "varchar(20)" false ER_X_CMD_ARGUMENT_VALUE -->callmacro Create_index "books1" "aaa" false "$.data!datetime" "INT" false ER_X_CMD_ARGUMENT_VALUE -->callmacro Create_index "books1" "aaa" false "$.data' foo" "INT" false ER_X_CMD_ARGUMENT_VALUE -->callmacro Create_index "books1" "aaa" false "data.datetime" "INT" false ER_X_CMD_ARGUMENT_VALUE -->stmtadmin create_collection {"schema":"xtest", "name":"books0"} -->recvresult -->callmacro Insert books0 '{"_id": "one", "name": "The Bla", "isbn" : "9780262527804", "pages":30}' ER_SUCCESS -->callmacro Insert books0 '{"_id": "two", "name": "The Bla Bla", "isbn" : "1280262527804", "pages":50}' ER_SUCCESS -->stmtadmin create_collection_index {"schema":"xtest", "collection":"books0", "name":"mix", "unique":true, "constraint":[{"member":"$.isbn", "type":"TEXT(80)", "required":false}, {"member":"$.pages", "type":"INT", "required":false}]} -->recvresult -->callmacro Assert_use_of_index books0 mix doc->'$.isbn' = '9780262527804' and doc->'$.pages' > 1 -->callmacro Create_index "books0" "name_charset" true "$.name" "CHAR(64) CHARSET latin1 COLLATE latin1_bin" true ER_SUCCESS -->callmacro Assert_use_of_index books0 name_charset doc->'$.name' = 'The Bla' -->callmacro Create_index "books0" "isbn_text_charset" true "$.isbn" "TEXT(64) COLLATE latin1_bin" true ER_SUCCESS -->callmacro Assert_use_of_index books0 isbn_text_charset doc->'$.isbn' = '9780262527804' -->stmtsql show create table xtest.books0 -->recvresult EOF --exec $MYSQLXTEST -ux_root --password='' --file=$xtest_file 2>&1 ## Cleanup DROP SCHEMA IF EXISTS xtest; --remove_file $xtest_file --source include/xplugin_drop_user.inc