183 lines
7.3 KiB
Plaintext
183 lines
7.3 KiB
Plaintext
## manipulate of fulltext indexes on document
|
|
|
|
--source include/xplugin_preamble.inc
|
|
--source include/xplugin_create_user.inc
|
|
|
|
## Test starts here
|
|
--let $xtest_file= $MYSQL_TMP_DIR/admin_create_index_fulltext.tmp
|
|
--write_file $xtest_file
|
|
-->quiet
|
|
|
|
## Test data
|
|
|
|
|
|
-->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 Show %COLL%
|
|
-->echo ### Columns of %COLL%
|
|
-->stmtsql show columns from xtest.%COLL%
|
|
-->recvresult
|
|
-->echo ### Indexes of %COLL%
|
|
-->stmtsql show index from xtest.%COLL%
|
|
-->recvresult
|
|
-->echo ############################
|
|
-->endmacro
|
|
|
|
-->title =Create collection fulltext1
|
|
-->stmtadmin create_collection {"schema":"xtest", "name":"fulltext1"}
|
|
-->recvresult
|
|
|
|
|
|
-->title =check required status var updated
|
|
-->sql
|
|
SHOW STATUS like 'Mysqlx_stmt_create_collection_index%';
|
|
SHOW STATUS like 'Mysqlx_stmt_drop_collection_index%';
|
|
SHOW STATUS LIKE 'Mysqlx_stmt_execute_mysqlx';
|
|
-->endsql
|
|
|
|
|
|
-->title =Create entire document fulltext index and drop it
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"one", "unique":false, "constraint":{"member":"$", "type":"fulltext", "required":true}}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
-->stmtadmin drop_collection_index {"schema":"xtest", "collection":"fulltext1", "name":"one"}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
|
|
-->sql
|
|
SHOW STATUS like 'Mysqlx_stmt_create_collection_index%';
|
|
SHOW STATUS like 'Mysqlx_stmt_drop_collection_index%';
|
|
SHOW STATUS LIKE 'Mysqlx_stmt_execute_mysqlx';
|
|
-->endsql
|
|
|
|
|
|
-->title =Create fulltext index (without constraint.type) and drop it
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"one", "unique":false, "constraint":{"member":"$.first", "required":true}}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
-->stmtadmin drop_collection_index {"schema":"xtest", "collection":"fulltext1", "name":"one"}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
|
|
-->title =Create two fulltext indexes on the same member and drop one
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"one", "unique":false, "constraint":{"member":"$.first", "type":"fulltext", "required":true}}
|
|
-->recvresult
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"two", "unique":false, "constraint":{"member":"$.first", "type":"fulltext", "required":true}}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
|
|
-->title =Drop fulltext index on $.first
|
|
-->stmtadmin drop_collection_index {"schema":"xtest", "collection":"fulltext1", "name":"one"}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
|
|
-->title =Create fulltext index on two memebers
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"three", "unique":false, "constraint":[{"member":"$.first", "type":"fulltext", "required":true},{"member":"$.second", "type":"fulltext", "required":true}]}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
|
|
-->title =Create fulltext index on not requiered member
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"four", "unique":false, "constraint":{"member":"$.second", "type":"fulltext", "required":false}}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
|
|
-->title =Create fulltext index with parser
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"five", "unique":false, "with_parser":"ngram", "constraint":{"member":"$.third", "type":"fulltext", "required":false}}
|
|
-->recvresult
|
|
-->callmacro Show fulltext1
|
|
|
|
|
|
-->title =Is collection with fulltext index still collection?
|
|
-->stmtadmin list_objects {"schema":"xtest"}
|
|
-->recvresult
|
|
|
|
-->title =Drop collection fulltext1
|
|
-->stmtadmin drop_collection {"schema":"xtest", "name":"fulltext1"}
|
|
-->recvresult
|
|
|
|
-->title =Create collection fulltext1
|
|
-->stmtadmin create_collection {"schema":"xtest", "name":"fulltext1"}
|
|
-->recvresult
|
|
-->title =Create fulltext index with FULLTEXT instead of fulltext
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"FULLTEXT", "name":"four", "unique":false, "constraint":{"member":"$.second", "type":"FULLTEXT", "required":true}}
|
|
-->recvresult
|
|
-->title =Verify "NOT NULL" for generated column
|
|
-->callmacro Show fulltext1
|
|
-->title =Check generated column can be dropped
|
|
-->stmtsql ALTER TABLE xtest.fulltext1 DROP COLUMN `$ix_ft_r_350BEBA0BA8F7BA4E147A3E652BE04A3B53B4479`;
|
|
-->recvresult
|
|
-->title =Create fulltext index with FULLTEXT nested doc
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"FULLTEXT", "name":"five", "unique":false, "constraint":{"member":"$.b[1].c", "type":"FULLTEXT", "required":true}}
|
|
-->recvresult
|
|
-->stmtadmin disable_notices {"notice":"warnings"}
|
|
-->recvresult
|
|
-->title =Drop collection fulltext1
|
|
-->stmtadmin drop_collection {"schema":"xtest", "name":"fulltext1"}
|
|
-->recvresult
|
|
|
|
|
|
-->title =Create collection fulltext2
|
|
-->stmtadmin create_collection {"schema":"xtest", "name":"fulltext2"}
|
|
-->recvresult
|
|
|
|
-->title =Try to create unique fulltext index
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"fulltext", "name":"five", "unique":true, "constraint":{"member":"$.first", "type":"fulltext", "required":true}}
|
|
-->expecterror ER_X_CMD_ARGUMENT_VALUE
|
|
-->recvresult
|
|
|
|
-->title =Insert not-text values to collection with fulltext index
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"fulltext", "name":"six", "unique":false, "constraint":{"member":"$.first", "type":"fulltext", "required":false}}
|
|
-->recvresult
|
|
-->callmacro Insert fulltext2 '{"_id": "one", "first":30}' ER_SUCCESS
|
|
-->callmacro Insert fulltext2 '{"_id": "three", "first":{"second":42}}' ER_SUCCESS
|
|
-->callmacro Insert fulltext2 '{"_id": "two", "first":null}' ER_SUCCESS
|
|
-->callmacro Insert fulltext2 '{"_id": "five", "second":30}' ER_SUCCESS
|
|
|
|
-->title =Try to create fulltext index on missing member
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"fulltext", "name":"seven", "unique":false, "constraint":{"member":"$.first", "type":"fulltext", "required":true}}
|
|
-->expecterror ER_X_DOC_REQUIRED_FIELD_MISSING
|
|
-->recvresult
|
|
|
|
|
|
-->title =Try to create fulltext index with unknown parser
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"fulltext", "name":"eight", "unique":false, "with_parser": "blablabla", "constraint":{"member":"$.first", "type":"fulltext", "required":false}}
|
|
-->expecterror ER_FUNCTION_NOT_DEFINED
|
|
-->recvresult
|
|
|
|
-->title =Try to create 'regular' index with parser
|
|
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"index", "name":"nine", "unique":false, "with_parser": "ngram", "constraint":{"member":"$.first", "type":"fulltext", "required":false}}
|
|
-->expecterror ER_X_CMD_ARGUMENT_VALUE
|
|
-->recvresult
|
|
EOF
|
|
|
|
CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4';
|
|
|
|
--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
|
|
|