| 1 |
## Usage |
| 2 |
# |
| 3 |
# --let $crud_limit_macros=PATH |
| 4 |
# --source ../include/crud_limit.inc |
| 5 |
# |
| 6 |
|
| 7 |
--write_file $MYSQL_TMP_DIR/mysqlx-in.tmp |
| 8 |
|
| 9 |
-->import crud.macro |
| 10 |
-->import crud_insert.macro |
| 11 |
-->import %TEST_MACROS% |
| 12 |
|
| 13 |
-->echo |
| 14 |
-->echo ## I. Validation of Crud.Find limits |
| 15 |
-->echo # |
| 16 |
-->echo # 1. Different setting in old limit field |
| 17 |
-->echo # a. limit only to first row |
| 18 |
-->echo # b. limit only to first two rows |
| 19 |
-->echo # c. limit only to first hundred rows, still return all rows from collection |
| 20 |
-->echo # d. limit only to last two rows |
| 21 |
-->echo # e. limit only to last two rows, still the last one is out of resultset |
| 22 |
-->echo # 2. Setting literals in limit_expr field |
| 23 |
-->echo # a. limit only to first row |
| 24 |
-->echo # b. limit only to first two rows |
| 25 |
-->echo # c. limit only to first hundred rows, still return all rows from collection |
| 26 |
-->echo # d. limit only to last two rows |
| 27 |
-->echo # e. limit only to last two rows, still the last one is out of resultset |
| 28 |
-->echo # 3. Setting placeholders in limit_expr field |
| 29 |
-->echo # a. limit only to first row |
| 30 |
-->echo # b. limit only to first two rows |
| 31 |
-->echo # c. limit only to first hundred rows, still return all rows from collection |
| 32 |
-->echo # d. limit only to last two rows |
| 33 |
-->echo # e. limit only to last two rows, still the last one is out of resultset |
| 34 |
-->echo |
| 35 |
-->echo ## II. Validation of Crud.Delete limits |
| 36 |
-->echo # |
| 37 |
-->echo # 1. Different setting in old limit field |
| 38 |
-->echo # a. delete only first row |
| 39 |
-->echo # b. delete only first two rows |
| 40 |
-->echo # c. try to delete hundred rows, still only 6 delete (in collection) |
| 41 |
-->echo # 2. Setting literals in limit_expr field |
| 42 |
-->echo # a. delete only first row |
| 43 |
-->echo # b. delete only first two rows |
| 44 |
-->echo # c. try to delete hundred rows, still only 6 delete (in collection) |
| 45 |
-->echo # 3. Setting placeholders in limit_expr field |
| 46 |
-->echo # a. delete only first row |
| 47 |
-->echo # b. delete only first two rows |
| 48 |
-->echo # c. try to delete hundred rows, still only 6 delete (in collection) |
| 49 |
-->echo |
| 50 |
-->echo ## III. Validation of Crud.Update limits |
| 51 |
-->echo # |
| 52 |
-->echo # 1. Different setting in old limit field |
| 53 |
-->echo # a. delete only first row |
| 54 |
-->echo # b. delete only first two rows |
| 55 |
-->echo # c. try to delete hundred rows, still only 6 delete (in collection) |
| 56 |
-->echo # 2. Setting literals in limit_expr field |
| 57 |
-->echo # a. delete only first row |
| 58 |
-->echo # b. delete only first two rows |
| 59 |
-->echo # c. try to delete hundred rows, still only 6 delete (in collection) |
| 60 |
-->echo # 3. Setting placeholders in limit_expr field |
| 61 |
-->echo # a. delete only first row |
| 62 |
-->echo # b. delete only first two rows |
| 63 |
-->echo # c. try to delete hundred rows, still only 6 delete (in collection) |
| 64 |
-->echo |
| 65 |
-->echo ## IV. Validation invalid configuration of Crud limits |
| 66 |
-->echo # |
| 67 |
-->echo # 1. 'limit' and 'limit_expr' were set |
| 68 |
-->echo # a. in Crud.Find |
| 69 |
-->echo # b. in Crud.Update |
| 70 |
-->echo # d. in Crud.Delete |
| 71 |
-->echo # 2. 'limit' uses 'offset' field when Crud doesn't support it |
| 72 |
-->echo # a. in Crud.Update |
| 73 |
-->echo # b. in Crud.Delete |
| 74 |
-->echo # 2. 'limit_expr' uses 'offset' field when Crud doesn't support it |
| 75 |
-->echo # a. in Crud.Update |
| 76 |
-->echo # b. in Crud.Delete |
| 77 |
|
| 78 |
-->callmacro Setup_testcase |
| 79 |
|
| 80 |
-->echo |
| 81 |
-->echo # |
| 82 |
-->echo ## I.1 |
| 83 |
-->callmacro Setup_collection_with_data |
| 84 |
-->callmacro Find_execute_and_expect 1 limit {row_count:1} |
| 85 |
-->callmacro Find_execute_and_expect 2 limit {row_count:2} |
| 86 |
-->callmacro Find_execute_and_expect 9 limit {row_count:100} |
| 87 |
-->callmacro Find_execute_and_expect 2 limit {row_count:2 offset: 7} |
| 88 |
-->callmacro Find_execute_and_expect 1 limit {row_count:2 offset: 8} |
| 89 |
|
| 90 |
-->echo |
| 91 |
-->echo # |
| 92 |
-->echo ## I.2 |
| 93 |
callmacro Find_execute_and_expect 1 |
| 94 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:1}}}; |
| 95 |
callmacro Find_execute_and_expect 2 |
| 96 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:2}}}; |
| 97 |
callmacro Find_execute_and_expect 9 |
| 98 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:100}}}; |
| 99 |
callmacro Find_execute_and_expect 2 |
| 100 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:2}} offset{type:LITERAL literal {type:V_SINT v_signed_int:7}}}; |
| 101 |
callmacro Find_execute_and_expect 1 |
| 102 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:2}} offset{type:LITERAL literal {type:V_SINT v_signed_int:8}}}; |
| 103 |
|
| 104 |
-->echo |
| 105 |
-->echo # |
| 106 |
-->echo ## I.3 |
| 107 |
callmacro Find_execute_and_expect 1 |
| 108 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 109 |
args{ %ANY_START% type:V_SINT v_signed_int: 1 %ANY_END% }; |
| 110 |
callmacro Find_execute_and_expect 2 |
| 111 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 112 |
args{ %ANY_START% type:V_SINT v_signed_int: 2 %ANY_END% }; |
| 113 |
callmacro Find_execute_and_expect 9 |
| 114 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 115 |
args{ %ANY_START% type:V_SINT v_signed_int: 100 %ANY_END% }; |
| 116 |
callmacro Find_execute_and_expect 2 |
| 117 |
limit_expr { row_count{ type:PLACEHOLDER position:0} offset{type:PLACEHOLDER position:1}} |
| 118 |
args{ %ANY_START% type:V_SINT v_signed_int: 2 %ANY_END% } args{ %ANY_START% type:V_SINT v_signed_int: 7 %ANY_END% }; |
| 119 |
callmacro Find_execute_and_expect 1 |
| 120 |
limit_expr { row_count{ type:PLACEHOLDER position:0} offset { type:PLACEHOLDER position:1}} |
| 121 |
args{ %ANY_START% type:V_SINT v_signed_int: 2 %ANY_END% } args{ %ANY_START% type:V_SINT v_signed_int: 8 %ANY_END% }; |
| 122 |
|
| 123 |
-->echo |
| 124 |
-->echo # |
| 125 |
-->echo ## II.1 |
| 126 |
-->callmacro Setup_collection_with_data |
| 127 |
-->callmacro Delete_execute_and_expect 1 limit {row_count:1} |
| 128 |
-->callmacro Delete_execute_and_expect 2 limit {row_count:2} |
| 129 |
-->callmacro Delete_execute_and_expect 6 limit {row_count:100} |
| 130 |
|
| 131 |
-->echo |
| 132 |
-->echo # |
| 133 |
-->echo ## II.2 |
| 134 |
-->callmacro Setup_collection_with_data |
| 135 |
callmacro Delete_execute_and_expect 1 |
| 136 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:1}}}; |
| 137 |
callmacro Delete_execute_and_expect 2 |
| 138 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:2}}}; |
| 139 |
callmacro Delete_execute_and_expect 6 |
| 140 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:100}}}; |
| 141 |
|
| 142 |
-->echo |
| 143 |
-->echo # |
| 144 |
-->echo ## II.3 |
| 145 |
-->callmacro Setup_collection_with_data |
| 146 |
callmacro Delete_execute_and_expect 1 |
| 147 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 148 |
args{ %ANY_START% type:V_SINT v_signed_int: 1 %ANY_END% }; |
| 149 |
callmacro Delete_execute_and_expect 2 |
| 150 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 151 |
args{ %ANY_START% type:V_SINT v_signed_int: 2 %ANY_END% }; |
| 152 |
callmacro Delete_execute_and_expect 6 |
| 153 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 154 |
args{ %ANY_START% type:V_SINT v_signed_int: 100 %ANY_END% }; |
| 155 |
|
| 156 |
-->echo |
| 157 |
-->echo # |
| 158 |
-->echo ## III.1 |
| 159 |
-->callmacro Setup_collection_with_data |
| 160 |
-->callmacro Update_execute_and_expect 1 limit {row_count:1} |
| 161 |
-->callmacro Update_execute_and_expect 2 limit {row_count:2} |
| 162 |
-->callmacro Update_execute_and_expect 9 limit {row_count:100} |
| 163 |
|
| 164 |
-->echo |
| 165 |
-->echo # |
| 166 |
-->echo ## III.2 |
| 167 |
callmacro Update_execute_and_expect 1 |
| 168 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:1}}}; |
| 169 |
callmacro Update_execute_and_expect 2 |
| 170 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:2}}}; |
| 171 |
callmacro Update_execute_and_expect 9 |
| 172 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:100}}}; |
| 173 |
|
| 174 |
-->echo |
| 175 |
-->echo # |
| 176 |
-->echo ## III.3 |
| 177 |
callmacro Update_execute_and_expect 1 |
| 178 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 179 |
args{ %ANY_START% type:V_SINT v_signed_int: 1 %ANY_END% }; |
| 180 |
callmacro Update_execute_and_expect 2 |
| 181 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 182 |
args{ %ANY_START% type:V_SINT v_signed_int: 2 %ANY_END% }; |
| 183 |
callmacro Update_execute_and_expect 9 |
| 184 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} |
| 185 |
args{ %ANY_START% type:V_SINT v_signed_int: 100 %ANY_END% }; |
| 186 |
|
| 187 |
-->echo |
| 188 |
-->echo # |
| 189 |
-->echo ## IV.1 |
| 190 |
callmacro Find_execute_and_expect_error ER_X_BAD_MESSAGE |
| 191 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} limit { row_count:1 } |
| 192 |
args{ %ANY_START% type:V_SINT v_signed_int: 1 %ANY_END% }; |
| 193 |
|
| 194 |
callmacro Update_execute_and_expect_error ER_X_BAD_MESSAGE |
| 195 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} limit { row_count:1 } |
| 196 |
args{ %ANY_START% type:V_SINT v_signed_int: 1 %ANY_END% }; |
| 197 |
|
| 198 |
callmacro Delete_execute_and_expect_error ER_X_BAD_MESSAGE |
| 199 |
limit_expr { row_count{ type:PLACEHOLDER position:0}} limit { row_count:1 } |
| 200 |
args{ %ANY_START% type:V_SINT v_signed_int: 1 %ANY_END%}; |
| 201 |
|
| 202 |
-->echo |
| 203 |
-->echo # |
| 204 |
-->echo ## IV.2 |
| 205 |
callmacro Update_execute_and_expect_error ER_X_INVALID_ARGUMENT |
| 206 |
limit { row_count:1 offset: 1 }; |
| 207 |
|
| 208 |
callmacro Delete_execute_and_expect_error ER_X_INVALID_ARGUMENT |
| 209 |
limit { row_count:1 offset: 1 }; |
| 210 |
|
| 211 |
-->echo |
| 212 |
-->echo # |
| 213 |
-->echo ## IV.3 |
| 214 |
callmacro Update_execute_and_expect_error ER_X_INVALID_ARGUMENT |
| 215 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:1}} offset{type:LITERAL literal {type:V_SINT v_signed_int:1}}}; |
| 216 |
|
| 217 |
callmacro Delete_execute_and_expect_error ER_X_INVALID_ARGUMENT |
| 218 |
limit_expr {row_count{type:LITERAL literal {type:V_SINT v_signed_int:1}} offset{type:LITERAL literal {type:V_SINT v_signed_int:1}}}; |
| 219 |
|
| 220 |
EOF |
| 221 |
|
| 222 |
CREATE DATABASE xtest; |
| 223 |
|
| 224 |
exec $MYSQLXTEST |
| 225 |
-u x_root |
| 226 |
--password='' |
| 227 |
--schema=xtest |
| 228 |
-v%TEST_MACROS%=$crud_limit_macros |
| 229 |
--file=$MYSQL_TMP_DIR/mysqlx-in.tmp 2>&1; |
| 230 |
|
| 231 |
## Cleanup |
| 232 |
DROP DATABASE IF EXISTS xtest; |
| 233 |
|
| 234 |
--remove_file $MYSQL_TMP_DIR/mysqlx-in.tmp |