Current Path : /home/usr.opt/mysql57/mysql-test/suite/x/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : /home/usr.opt/mysql57/mysql-test/suite/x/t/find_crud_conditionalclauses_o.test |
########### ../t/find_crud_conditionalclauses_o.test ####### ### # ### This test runs aims to run FIND operation statements # ### variant with mysqlxtest client for Table and Document data models. # ### Test covers # ### - find with different operators # ### - find with metadata result # ### - find with limit (row count and offset) # ### - find with Order Asc/Desc # ### # ######################################################################## # --echo ============================================== --echo CRUD FIND CONDITIONAL CLAUSES SCENARIOS --echo ============================================== --echo --echo ================================================================================ --echo PREAMBLE --echo ================================================================================ --source ../include/xplugin_preamble.inc create user crudfinduser@localhost identified by 'crudfinduser'; grant all on *.* to crudfinduser@localhost; ## TEST STARTS HERE --echo ================================================================================ --echo TEST START --echo ================================================================================ --write_file $MYSQL_TMP_DIR/find_crud_table.tmp -->sql DROP SCHEMA if EXISTS minisakila; CREATE SCHEMA minisakila; USE minisakila; CREATE TABLE actor ( actor_id int unsigned NOT NULL AUTO_INCREMENT, first_name varchar(45) NOT NULL, last_name varchar(45) NOT NULL, is_active bit(1) NOT NULL, PRIMARY KEY (actor_id) ); INSERT INTO actor VALUES (NULL,'Victor','Otero',true), (NULL,'Gonzalo','Crhystens',false), (NULL,'Abraham','Vega',true), (NULL,'Jennifer','Leon',false), (NULL,'Jhonny','Test',true); -->endsql -->echo Table based scenarios -->echo Find all the rows including all the metadata Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE } ## expect Mysqlx.Sql.ColumnMetaData -->recv ## expect Mysqlx.Sql.ColumnMetaData -->recv ## expect Mysqlx.Sql.ColumnMetaData -->recv ## expect Mysqlx.Sql.ColumnMetaData -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.CursorFetchDone -->recv ## expect Mysqlx.Sql.StmtExecuteOk -->recv -->echo Find all the rows without the metadata Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE } -->recvresult -->echo Find with limit row count and offset Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE limit { row_count:1 offset:3 } } # From third row only one row -->recvresult -->echo Find with limit row count Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE limit { row_count:4 } } -->recvresult -->echo Find specific row with == Operator Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 1 } } } } } -->recvresult -->echo Find specific row with != Operator Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "!=" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 1 } } } } } -->recvresult -->echo Find specific row with like Operator Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "like" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"%on%"} } } } } } -->recvresult -->echo Find specific row with && and like Operators Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "&&" param { type: OPERATOR operator { name: "like" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"%on%"} } } } } param { type: OPERATOR operator { name: "like" param { type: IDENT identifier { name: "last_name" } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"%ns%"} } } } } } } } -->recvresult -->echo Find specific row with || and in Operators Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "||" param { type: OPERATOR operator { name: "in" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 1 } } param { type: LITERAL literal { type: V_SINT v_signed_int: 2 } } } } param { type: OPERATOR operator { name: "like" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"%ham%"} } } } } } } } -->recvresult -->echo Find specific row with not_in Operators Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "||" param { type: OPERATOR operator { name: "not_in" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 1 } } param { type: LITERAL literal { type: V_SINT v_signed_int: 2 } } } } param { type: OPERATOR operator { name: "like" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"%ham%"} } } } } } } } -->recvresult -->echo Find specific row with &&, <= and >= Operators Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "&&" param { type: OPERATOR operator { name: "<=" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 4 } } } } param { type: OPERATOR operator { name: ">=" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 2 } } } } } } } -->recvresult -->echo Find specific row with &&, < and > Operators Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "&&" param { type: OPERATOR operator { name: "<" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 4 } } } } param { type: OPERATOR operator { name: ">" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 2 } } } } } } } -->recvresult -->echo Find specific row with like Operator using string Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "like" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_STRING v_string { value: "%on%" } } } } } } -->recvresult -->echo Find specific row with != Operator with order desc Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "!=" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_STRING v_string { value: "Omar" } } } } } order { expr { type: IDENT identifier { name: "last_name" } } direction: DESC } } -->recvresult -->echo Find specific row with != Operator with order asc Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "!=" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_STRING v_string { value: "Omar" } } } } } order { expr { type: IDENT identifier { name: "last_name" } } direction: ASC } } -->recvresult ## Negative test scenarios for Table -->echo Find using not available schema name Mysqlx.Crud.Find { collection { name: "actor" schema: "noavailableschema" } data_model: TABLE criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 1 } } } } } -->expecterror 1146 -->recvresult -->echo Find using not available table name Mysqlx.Crud.Find { collection { name: "notavailableatable" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "actor_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 1 } } } } } -->expecterror 1146 -->recvresult -->echo Find using not available column name Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "notavailablecolumn" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 1 } } } } } -->expecterror 1054 -->recvresult EOF --exec $MYSQLXTEST -u crudfinduser --password='crudfinduser' --file=$MYSQL_TMP_DIR/find_crud_table.tmp 2>&1 --remove_file $MYSQL_TMP_DIR/find_crud_table.tmp --write_file $MYSQL_TMP_DIR/find_crud_coll.tmp -->sql DROP SCHEMA if EXISTS mysqlxcoll; CREATE SCHEMA mysqlxcoll; USE mysqlxcoll; CREATE TABLE maincoll (doc JSON, _id VARCHAR(32) NOT NULL PRIMARY KEY); INSERT INTO maincoll (doc, _id) values ('{"_id": "1", "name": "Victor", "last_name": "Otero","amount": 4.99}',json_unquote(json_extract(doc, '$._id'))); INSERT INTO maincoll (doc, _id) values ('{"_id": "2", "name": "Gonzalo", "last_name": "Crhystens","amount": 120.57}',json_unquote(json_extract(doc, '$._id'))); INSERT INTO maincoll (doc, _id) values ('{"_id": "3", "name": "Abraham", "last_name": "Vega","amount": 74.56}',json_unquote(json_extract(doc, '$._id'))); INSERT INTO maincoll (doc, _id) values ('{"_id": "4", "name": "Jennifer", "last_name": "Leon","amount": 387.14}',json_unquote(json_extract(doc, '$._id'))); INSERT INTO maincoll (doc, _id) values ('{"_id": "5", "name": "Jhonny", "last_name": "Test","amount": 125.45}',json_unquote(json_extract(doc, '$._id'))); -->endsql -->echo Collection based scenarios -->echo Find all the rows including all metadata Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT } ## expect Mysqlx.Sql.ColumnMetaData -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.Row -->recv ## expect Mysqlx.Sql.ResultFetchDone -->recv ## expect Mysqlx.Sql.StmtExecuteOk -->recv -->echo Find all the rows without all metadata Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT } -->recvresult -->echo Find with limit row count and offset Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT limit{ row_count:2 offset:3 } } -->recvresult -->echo Find with limit row count Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT limit{ row_count:3 } } -->recvresult -->echo Find specific row with == Operator Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "_id" } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"1"} } } } } } -->recvresult -->echo Find specific row with != Operator Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "!=" param { type: IDENT identifier { document_path { type: MEMBER value: "name" } } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"Jhonny"} } } } } } -->recvresult -->echo Find specific row with like Operator Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "like" param { type: IDENT identifier { document_path { type: MEMBER value: "name" } } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"%er%"} } } } } } -->recvresult -->echo Find specific row with && and like Operators Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "&&" param { type: OPERATOR operator{ name: "like" param{ type: IDENT identifier { document_path { type: MEMBER value: "name" } } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"%er%"} } } } } param { type: OPERATOR operator{ name: "like" param{ type: IDENT identifier { document_path { type: MEMBER value: "last_name" } } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"%on%"} } } } } } } } -->recvresult -->echo Find specific row with || and in Operators Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "||" param { type: OPERATOR operator{ name: "in" param { type: IDENT identifier { name: "_id" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 3 } } param { type: LITERAL literal { type: V_SINT v_signed_int: 4 } } } } param { type: OPERATOR operator { name: "like" param { type: IDENT identifier { document_path { type: MEMBER value: "name" } } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"Gonzalo"} } } } } } } } -->recvresult -->echo Find specific row with not_in Operators Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "not_in" param { type: IDENT identifier { name: "_id" } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"1"} } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"2"} } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"3"} } } } } } -->recvresult -->echo Find specific row with &&, <= and >= Operators Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "&&" param { type: OPERATOR operator{ name: "<=" param{ type: IDENT identifier { document_path { type: MEMBER value: "amount" } } } param { type: LITERAL literal { type: V_DOUBLE v_double: 120.57 } } } } param { type: OPERATOR operator{ name: ">=" param{ type: IDENT identifier { document_path { type: MEMBER value: "amount" } } } param { type: LITERAL literal { type: V_DOUBLE v_double: 4.99 } } } } } } } -->recvresult -->echo Find specific row with &&, < and > Operators Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "&&" param { type: OPERATOR operator{ name: "<" param{ type: IDENT identifier { document_path { type: MEMBER value: "amount" } } } param { type: LITERAL literal { type: V_DOUBLE v_double: 120.57 } } } } param { type: OPERATOR operator{ name: ">" param{ type: IDENT identifier { document_path { type: MEMBER value: "amount" } } } param { type: LITERAL literal { type: V_DOUBLE v_double: 4.99 } } } } } } } -->recvresult -->echo Find with not available schema name Mysqlx.Crud.Find { collection { name: "maincoll" schema: "notavailableschema" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "not_in" param { type: IDENT identifier { document_path { type: MEMBER value: "==" } } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"1"} } } } } } -->expecterror 1146 -->recvresult -->echo Find with not available table name Mysqlx.Crud.Find { collection { name: "notavailabletable" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "_id" } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"1"} } } } } } -->expecterror 1146 -->recvresult -->echo Find with not available column name Mysqlx.Crud.Find { collection { name: "maincoll" schema: "mysqlxcoll" } data_model: DOCUMENT criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { document_path { type: MEMBER value: "notavailablecolumn" } } } param { type: LITERAL literal { type: V_OCTETS v_octets {value:"1"} } } } } } -->recvresult ## Cleanup -->echo ================================================================================ -->echo CLEAN UP -->echo ================================================================================ -->sql DROP SCHEMA IF EXISTS minisakila; DROP SCHEMA IF EXISTS mysqlxcoll; DROP USER crudfinduser@localhost; -->endsql EOF --exec $MYSQLXTEST -u crudfinduser --password='crudfinduser' --file=$MYSQL_TMP_DIR/find_crud_coll.tmp 2>&1 --remove_file $MYSQL_TMP_DIR/find_crud_coll.tmp ## Postamble --echo ================================================================================ --echo POSTAMBLE --echo ================================================================================ uninstall plugin mysqlx;