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_groupby_o.test |
########### ../t/find_crud_groupby_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 group by (grouping) # ### - find with group by (grouping) using Alias and Functions # ### - find with different operators in having (grouping_criteria) # ### # ######################################################################## # --echo ============================================== --echo CRUD FIND GROUP BY SCENARIOS --echo ============================================== --echo --echo ================================================================================ --echo PREAMBLE --echo ================================================================================ --source ../include/xplugin_preamble.inc create user crudfindgroupuser@localhost identified by 'crudfindgroupuser'; grant all on *.* to crudfindgroupuser@localhost; ## TEST STARTS HERE --echo ================================================================================ --echo TEST START --echo ================================================================================ --write_file $MYSQL_TMP_DIR/find_crud_table_groupby.tmp -->sql DROP SCHEMA if EXISTS minisakila; CREATE SCHEMA minisakila; USE minisakila; CREATE TABLE actor ( actor_id smallint(5) unsigned NOT NULL AUTO_INCREMENT, first_name varchar(45) NOT NULL, age int, last_update timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (actor_id) ); INSERT INTO actor VALUES (1,'actor1',20,'2006-02-15 04:34:33'), (2,'actor2',25,'2006-02-14 04:34:33'), (3,'actor3',28,'2006-02-14 04:34:33'), (4,'actor4',15,'2006-02-15 04:34:33'), (5,'actor5',32,'2006-02-16 04:34:33'), (6,'actor6',37,'2006-02-17 04:34:33'), (7,'actor7',null,'2006-02-18 04:34:33'); -->endsql -->echo Table based scenarios -->echo Find specific row criteria and group by (grouping) Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: IDENT identifier { name: "last_update" } } } criteria { type: OPERATOR operator { name: "!=" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_STRING v_string { value: "actor7" } } } } } grouping { type: IDENT identifier { name: "last_update" } } } -->recvresult -->echo Find specific row with criteria and group by (grouping) Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } } -->recvresult -->echo Find specific row criteria and group by (grouping) and having (grouping_criteria) Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "AVG" } param { type: IDENT identifier { name: "age" } } } } alias: "Average Age" } projection { source { type: IDENT identifier { name: "last_update" } } } criteria { type: OPERATOR operator { name: "!=" param { type: IDENT identifier { name: "first_name" } } param { type: LITERAL literal { type: V_STRING v_string { value: "actor7" } } } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: "<" param { type: IDENT identifier { name: "Average Age" } } param { type: LITERAL literal { type: V_DOUBLE v_double: 32 } } } } } -->recvresult -->echo Find specific row with COUNT, MAX and MIN functions with group by (grouping) Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "COUNT" } param { type: IDENT identifier { name: "age" } } } } alias: "Age count" } projection { source { type: FUNC_CALL function_call { name { name: "MAX" } param { type: IDENT identifier { name: "age" } } } } alias: "Maximum_Age" } projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } } -->recvresult -->echo Find specific row with COUNT, MAX and MIN functions with group by (grouping) and Having (grouping_criteria) Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "COUNT" } param { type: IDENT identifier { name: "age" } } } } alias: "Age count" } projection { source { type: FUNC_CALL function_call { name { name: "MAX" } param { type: IDENT identifier { name: "age" } } } } alias: "Maximum_Age" } projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "Maximum_Age" } } param { type: LITERAL literal { type: V_UINT v_unsigned_int: 32 } } } } } -->recvresult -->echo Find specific row with group by (grouping) and Having (grouping_criteria) with != Operator Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: "!=" param { type: IDENT identifier { name: "Minimum_Age" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 15 } } } } } -->recvresult -->echo Find specific row with group by (grouping) and Having (grouping_criteria) with >= Operator Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: ">=" param { type: IDENT identifier { name: "Minimum_Age" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 32 } } } } } -->recvresult -->echo Find specific row with group by (grouping) and Having (grouping_criteria) with > Operator Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: ">" param { type: IDENT identifier { name: "Minimum_Age" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 32 } } } } } -->recvresult -->echo Find specific row with group by (grouping) and Having (grouping_criteria) with <= Operator Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: "<=" param { type: IDENT identifier { name: "Minimum_Age" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 25 } } } } } -->recvresult -->echo Find specific row with group by (grouping) and Having (grouping_criteria) with < Operator Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: "<" param { type: IDENT identifier { name: "Minimum_Age" } } param { type: LITERAL literal { type: V_SINT v_signed_int: 25 } } } } } -->recvresult -->echo Find specific row with group by (grouping) and Having (grouping_criteria) with null DataType Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: "is" param { type: IDENT identifier { name: "Minimum_Age" } } param { type: LITERAL literal { type: V_NULL } } } } } -->recvresult -->echo Find specific row with group by (grouping) and Having (grouping_criteria) with not null DataType Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "MIN" } param { type: IDENT identifier { name: "age" } } } } alias: "Minimum_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: "is_not" param { type: IDENT identifier { name: "Minimum_Age" } } param { type: LITERAL literal { type: V_NULL } } } } } -->recvresult -->echo Find specific row with group by (grouping) and Having (grouping_criteria) with double DataType Mysqlx.Crud.Find { collection { name: "actor" schema: "minisakila" } data_model: TABLE projection { source { type: FUNC_CALL function_call { name { name: "AVG" } param { type: IDENT identifier { name: "age" } } } } alias: "Average_Age" } projection { source { type: IDENT identifier { name: "last_update" } } } grouping { type: IDENT identifier { name: "last_update" } } grouping_criteria { type: OPERATOR operator { name: "==" param { type: IDENT identifier { name: "Average_Age" } } param { type: LITERAL literal { type: V_DOUBLE v_double: 17.500000 } } } } } -->recvresult ## Negative test scenarios for Table -->echo Error because expression not in group list 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" } } } } } grouping { type: IDENT identifier { name: "last_update" } } } -->recverror ER_WRONG_FIELD_WITH_GROUP ## Cleanup -->echo ================================================================================ -->echo CLEAN UP -->echo ================================================================================ -->sql DROP SCHEMA IF EXISTS minisakila; DROP SCHEMA IF EXISTS mysqlxcoll; DROP USER crudfindgroupuser@localhost; -->endsql EOF --exec $MYSQLXTEST -u crudfindgroupuser --password='crudfindgroupuser' --file=$MYSQL_TMP_DIR/find_crud_table_groupby.tmp 2>&1 --remove_file $MYSQL_TMP_DIR/find_crud_table_groupby.tmp ## Postamble --echo ================================================================================ --echo POSTAMBLE --echo ================================================================================ uninstall plugin mysqlx;