| 1 |
## generated |
| 2 |
## Rel: Insert 0 rows |
| 3 |
|
| 4 |
--source include/xplugin_preamble.inc |
| 5 |
--source include/xplugin_create_user.inc |
| 6 |
|
| 7 |
create schema xtest default charset='utf8mb4'; |
| 8 |
|
| 9 |
## Test starts here |
| 10 |
--write_file $MYSQL_TMP_DIR/insert_table_empty.xpl |
| 11 |
## Test data |
| 12 |
-->sql |
| 13 |
use xtest; |
| 14 |
create table simpletable (id int auto_increment primary key, value int); |
| 15 |
create table mytable (i int NOT NULL, ui int unsigned, vc varchar(100), f float, d double, dt datetime, ts timestamp(5), j json); |
| 16 |
-->endsql |
| 17 |
|
| 18 |
## Insert nothing (to get an error) |
| 19 |
Mysqlx.Crud.Insert { |
| 20 |
collection { |
| 21 |
name: "mytable" |
| 22 |
schema: "xtest" |
| 23 |
} |
| 24 |
data_model: TABLE |
| 25 |
projection { |
| 26 |
name: "i" |
| 27 |
} |
| 28 |
projection { |
| 29 |
name: "ui" |
| 30 |
} |
| 31 |
projection { |
| 32 |
name: "vc" |
| 33 |
} |
| 34 |
projection { |
| 35 |
name: "f" |
| 36 |
} |
| 37 |
projection { |
| 38 |
name: "d" |
| 39 |
} |
| 40 |
projection { |
| 41 |
name: "dt" |
| 42 |
} |
| 43 |
projection { |
| 44 |
name: "ts" |
| 45 |
} |
| 46 |
projection { |
| 47 |
name: "j" |
| 48 |
} |
| 49 |
} |
| 50 |
## expect Mysqlx.Error |
| 51 |
-->recv |
| 52 |
|
| 53 |
-->sql |
| 54 |
select count(*) from xtest.mytable; |
| 55 |
truncate table xtest.mytable; |
| 56 |
-->endsql |
| 57 |
|
| 58 |
## Insert wrong type values |
| 59 |
Mysqlx.Crud.Insert { |
| 60 |
collection { |
| 61 |
name: "mytable" |
| 62 |
schema: "xtest" |
| 63 |
} |
| 64 |
data_model: TABLE |
| 65 |
projection { |
| 66 |
name: "i" |
| 67 |
} |
| 68 |
projection { |
| 69 |
name: "ui" |
| 70 |
} |
| 71 |
projection { |
| 72 |
name: "vc" |
| 73 |
} |
| 74 |
projection { |
| 75 |
name: "f" |
| 76 |
} |
| 77 |
projection { |
| 78 |
name: "d" |
| 79 |
} |
| 80 |
projection { |
| 81 |
name: "dt" |
| 82 |
} |
| 83 |
projection { |
| 84 |
name: "ts" |
| 85 |
} |
| 86 |
projection { |
| 87 |
name: "j" |
| 88 |
} |
| 89 |
row { |
| 90 |
field { |
| 91 |
type: LITERAL |
| 92 |
literal { |
| 93 |
type: V_SINT |
| 94 |
v_signed_int: -100 |
| 95 |
} |
| 96 |
} |
| 97 |
field { |
| 98 |
type: LITERAL |
| 99 |
literal { |
| 100 |
type: V_UINT |
| 101 |
v_unsigned_int: 100 |
| 102 |
} |
| 103 |
} |
| 104 |
field { |
| 105 |
type: LITERAL |
| 106 |
literal { |
| 107 |
type: V_STRING |
| 108 |
v_string { |
| 109 |
value: "" |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
field { |
| 114 |
type: LITERAL |
| 115 |
literal { |
| 116 |
type: V_FLOAT |
| 117 |
v_float: 0.333333 |
| 118 |
} |
| 119 |
} |
| 120 |
field { |
| 121 |
type: LITERAL |
| 122 |
literal { |
| 123 |
type: V_DOUBLE |
| 124 |
v_double: 0.333333333333 |
| 125 |
} |
| 126 |
} |
| 127 |
field { |
| 128 |
type: LITERAL |
| 129 |
literal { |
| 130 |
type: V_STRING |
| 131 |
v_string { |
| 132 |
value: "2015-05-05 1:20:30" |
| 133 |
} |
| 134 |
} |
| 135 |
} |
| 136 |
field { |
| 137 |
type: LITERAL |
| 138 |
literal { |
| 139 |
type: V_STRING |
| 140 |
v_string { |
| 141 |
value: "2015-06-06 03:10:20.12345" |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
field { |
| 146 |
type: LITERAL |
| 147 |
literal { |
| 148 |
type: V_STRING |
| 149 |
v_string { |
| 150 |
value: "{\"name\":\"Me\"}" |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
} |
| 155 |
row { |
| 156 |
field { |
| 157 |
type: LITERAL |
| 158 |
literal { |
| 159 |
type: V_NULL |
| 160 |
} |
| 161 |
} |
| 162 |
field { |
| 163 |
type: LITERAL |
| 164 |
literal { |
| 165 |
type: V_UINT |
| 166 |
v_unsigned_int: 50 |
| 167 |
} |
| 168 |
} |
| 169 |
field { |
| 170 |
type: LITERAL |
| 171 |
literal { |
| 172 |
type: V_STRING |
| 173 |
v_string { |
| 174 |
value: "new\'string" |
| 175 |
} |
| 176 |
} |
| 177 |
} |
| 178 |
field { |
| 179 |
type: LITERAL |
| 180 |
literal { |
| 181 |
type: V_FLOAT |
| 182 |
v_float: 0 |
| 183 |
} |
| 184 |
} |
| 185 |
field { |
| 186 |
type: LITERAL |
| 187 |
literal { |
| 188 |
type: V_DOUBLE |
| 189 |
v_double: 1 |
| 190 |
} |
| 191 |
} |
| 192 |
field { |
| 193 |
type: LITERAL |
| 194 |
literal { |
| 195 |
type: V_STRING |
| 196 |
v_string { |
| 197 |
value: "2000-1-1 1:1:1" |
| 198 |
} |
| 199 |
} |
| 200 |
} |
| 201 |
field { |
| 202 |
type: LITERAL |
| 203 |
literal { |
| 204 |
type: V_STRING |
| 205 |
v_string { |
| 206 |
value: "1999-2-2 2:2:2.22222" |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
field { |
| 211 |
type: LITERAL |
| 212 |
literal { |
| 213 |
type: V_NULL |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
} |
| 218 |
|
| 219 |
## expect Mysqlx.Error |
| 220 |
-->recv |
| 221 |
|
| 222 |
-->sql |
| 223 |
select count(*) from xtest.mytable; |
| 224 |
truncate table xtest.mytable; |
| 225 |
-->endsql |
| 226 |
|
| 227 |
|
| 228 |
## valid cases |
| 229 |
-->echo Valid cases |
| 230 |
|
| 231 |
Mysqlx.Crud.Insert { |
| 232 |
collection { |
| 233 |
name: "mytable" |
| 234 |
schema: "xtest" |
| 235 |
} |
| 236 |
data_model: TABLE |
| 237 |
projection { |
| 238 |
name: "i" |
| 239 |
} |
| 240 |
projection { |
| 241 |
name: "ui" |
| 242 |
} |
| 243 |
projection { |
| 244 |
name: "vc" |
| 245 |
} |
| 246 |
projection { |
| 247 |
name: "f" |
| 248 |
} |
| 249 |
projection { |
| 250 |
name: "d" |
| 251 |
} |
| 252 |
projection { |
| 253 |
name: "dt" |
| 254 |
} |
| 255 |
projection { |
| 256 |
name: "ts" |
| 257 |
} |
| 258 |
projection { |
| 259 |
name: "j" |
| 260 |
} |
| 261 |
row { |
| 262 |
field { |
| 263 |
type: LITERAL |
| 264 |
literal { |
| 265 |
type: V_SINT |
| 266 |
v_signed_int: -100 |
| 267 |
} |
| 268 |
} |
| 269 |
field { |
| 270 |
type: LITERAL |
| 271 |
literal { |
| 272 |
type: V_UINT |
| 273 |
v_unsigned_int: 100 |
| 274 |
} |
| 275 |
} |
| 276 |
field { |
| 277 |
type: LITERAL |
| 278 |
literal { |
| 279 |
type: V_STRING |
| 280 |
v_string { |
| 281 |
value: "string" |
| 282 |
} |
| 283 |
} |
| 284 |
} |
| 285 |
field { |
| 286 |
type: LITERAL |
| 287 |
literal { |
| 288 |
type: V_FLOAT |
| 289 |
v_float: 0.333333 |
| 290 |
} |
| 291 |
} |
| 292 |
field { |
| 293 |
type: LITERAL |
| 294 |
literal { |
| 295 |
type: V_DOUBLE |
| 296 |
v_double: 0.333333333333 |
| 297 |
} |
| 298 |
} |
| 299 |
field { |
| 300 |
type: LITERAL |
| 301 |
literal { |
| 302 |
type: V_STRING |
| 303 |
v_string { |
| 304 |
value: "2015-05-05 1:20:30" |
| 305 |
} |
| 306 |
} |
| 307 |
} |
| 308 |
field { |
| 309 |
type: LITERAL |
| 310 |
literal { |
| 311 |
type: V_STRING |
| 312 |
v_string { |
| 313 |
value: "2015-06-06 03:10:20.12345" |
| 314 |
} |
| 315 |
} |
| 316 |
} |
| 317 |
field { |
| 318 |
type: LITERAL |
| 319 |
literal { |
| 320 |
type: V_STRING |
| 321 |
v_string { |
| 322 |
value: "{\"name\":\"Me\"}" |
| 323 |
} |
| 324 |
} |
| 325 |
} |
| 326 |
} |
| 327 |
} |
| 328 |
## expect Mysqlx.Sql.StmtExecuteOk |
| 329 |
-->recvresult |
| 330 |
|
| 331 |
-->sql |
| 332 |
select count(*) from xtest.mytable; |
| 333 |
truncate table xtest.mytable; |
| 334 |
-->endsql |
| 335 |
|
| 336 |
Mysqlx.Crud.Insert { |
| 337 |
collection { |
| 338 |
name: "mytable" |
| 339 |
schema: "xtest" |
| 340 |
} |
| 341 |
data_model: TABLE |
| 342 |
projection { |
| 343 |
name: "i" |
| 344 |
} |
| 345 |
projection { |
| 346 |
name: "ui" |
| 347 |
} |
| 348 |
projection { |
| 349 |
name: "vc" |
| 350 |
} |
| 351 |
projection { |
| 352 |
name: "f" |
| 353 |
} |
| 354 |
projection { |
| 355 |
name: "d" |
| 356 |
} |
| 357 |
projection { |
| 358 |
name: "dt" |
| 359 |
} |
| 360 |
projection { |
| 361 |
name: "ts" |
| 362 |
} |
| 363 |
projection { |
| 364 |
name: "j" |
| 365 |
} |
| 366 |
row { |
| 367 |
field { |
| 368 |
type: LITERAL |
| 369 |
literal { |
| 370 |
type: V_SINT |
| 371 |
v_signed_int: -100 |
| 372 |
} |
| 373 |
} |
| 374 |
field { |
| 375 |
type: LITERAL |
| 376 |
literal { |
| 377 |
type: V_UINT |
| 378 |
v_unsigned_int: 100 |
| 379 |
} |
| 380 |
} |
| 381 |
field { |
| 382 |
type: LITERAL |
| 383 |
literal { |
| 384 |
type: V_STRING |
| 385 |
v_string { |
| 386 |
value: "" |
| 387 |
} |
| 388 |
} |
| 389 |
} |
| 390 |
field { |
| 391 |
type: LITERAL |
| 392 |
literal { |
| 393 |
type: V_FLOAT |
| 394 |
v_float: 0.333333 |
| 395 |
} |
| 396 |
} |
| 397 |
field { |
| 398 |
type: LITERAL |
| 399 |
literal { |
| 400 |
type: V_DOUBLE |
| 401 |
v_double: 0.333333333333 |
| 402 |
} |
| 403 |
} |
| 404 |
field { |
| 405 |
type: LITERAL |
| 406 |
literal { |
| 407 |
type: V_STRING |
| 408 |
v_string { |
| 409 |
value: "2015-05-05 1:20:30" |
| 410 |
} |
| 411 |
} |
| 412 |
} |
| 413 |
field { |
| 414 |
type: LITERAL |
| 415 |
literal { |
| 416 |
type: V_STRING |
| 417 |
v_string { |
| 418 |
value: "2015-06-06 03:10:20.12345" |
| 419 |
} |
| 420 |
} |
| 421 |
} |
| 422 |
field { |
| 423 |
type: LITERAL |
| 424 |
literal { |
| 425 |
type: V_STRING |
| 426 |
v_string { |
| 427 |
value: "{\"name\":\"Me\"}" |
| 428 |
} |
| 429 |
} |
| 430 |
} |
| 431 |
} |
| 432 |
row { |
| 433 |
field { |
| 434 |
type: LITERAL |
| 435 |
literal { |
| 436 |
type: V_SINT |
| 437 |
v_signed_int: -50 |
| 438 |
} |
| 439 |
} |
| 440 |
field { |
| 441 |
type: LITERAL |
| 442 |
literal { |
| 443 |
type: V_UINT |
| 444 |
v_unsigned_int: 50 |
| 445 |
} |
| 446 |
} |
| 447 |
field { |
| 448 |
type: LITERAL |
| 449 |
literal { |
| 450 |
type: V_STRING |
| 451 |
v_string { |
| 452 |
value: "new\'string" |
| 453 |
} |
| 454 |
} |
| 455 |
} |
| 456 |
field { |
| 457 |
type: LITERAL |
| 458 |
literal { |
| 459 |
type: V_FLOAT |
| 460 |
v_float: 0 |
| 461 |
} |
| 462 |
} |
| 463 |
field { |
| 464 |
type: LITERAL |
| 465 |
literal { |
| 466 |
type: V_DOUBLE |
| 467 |
v_double: 1 |
| 468 |
} |
| 469 |
} |
| 470 |
field { |
| 471 |
type: LITERAL |
| 472 |
literal { |
| 473 |
type: V_STRING |
| 474 |
v_string { |
| 475 |
value: "2000-1-1 1:1:1" |
| 476 |
} |
| 477 |
} |
| 478 |
} |
| 479 |
field { |
| 480 |
type: LITERAL |
| 481 |
literal { |
| 482 |
type: V_STRING |
| 483 |
v_string { |
| 484 |
value: "1999-2-2 2:2:2.22222" |
| 485 |
} |
| 486 |
} |
| 487 |
} |
| 488 |
field { |
| 489 |
type: LITERAL |
| 490 |
literal { |
| 491 |
type: V_NULL |
| 492 |
} |
| 493 |
} |
| 494 |
} |
| 495 |
} |
| 496 |
## expect Mysqlx.Sql.StmtExecuteOk |
| 497 |
-->recvresult |
| 498 |
|
| 499 |
## multiple rows with auto_increment |
| 500 |
Mysqlx.Crud.Insert { |
| 501 |
collection { |
| 502 |
name: "simpletable" |
| 503 |
schema: "xtest" |
| 504 |
} |
| 505 |
data_model: TABLE |
| 506 |
projection { |
| 507 |
name: "value" |
| 508 |
} |
| 509 |
row { |
| 510 |
field { |
| 511 |
type: LITERAL |
| 512 |
literal { |
| 513 |
type: V_SINT |
| 514 |
v_double: 5 |
| 515 |
} |
| 516 |
} |
| 517 |
} |
| 518 |
row { |
| 519 |
field { |
| 520 |
type: LITERAL |
| 521 |
literal { |
| 522 |
type: V_SINT |
| 523 |
v_double: 6 |
| 524 |
} |
| 525 |
} |
| 526 |
} |
| 527 |
} |
| 528 |
-->recvresult |
| 529 |
|
| 530 |
-->sql |
| 531 |
select count(*) from xtest.mytable; |
| 532 |
-->endsql |
| 533 |
EOF |
| 534 |
|
| 535 |
--exec $MYSQLXTEST -ux_root --password='' --file=$MYSQL_TMP_DIR/insert_table_empty.xpl 2>&1 |
| 536 |
|
| 537 |
## Cleanup |
| 538 |
--source ../include/xplugin_cleanup.inc |