| 445 | #define INSERTS_FOR_T1_BUGGED 100000 |
| 446 | |
| 447 | int prepare_select_bug(void) |
| 448 | { |
| 449 | uint8_t *select_array; |
| 450 | cdb2_hndl_tp *db; |
| 451 | int rc; |
| 452 | |
| 453 | select_array = (uint8_t *)calloc(sizeof(uint8_t), select_records + 1); |
| 454 | rc = cdb2_open(&db, dbname, cltype, 0); |
| 455 | cdb2_hndl_set_max_retries(db, max_retries); |
| 456 | if (debug_trace) { |
| 457 | cdb2_set_debug_trace(db); |
| 458 | } |
| 459 | |
| 460 | rc = cdb2_run_statement(db, "set hasql on"); |
| 461 | |
| 462 | if (rc) { |
| 463 | tdprintf(stderr, db, __func__, __LINE__, "%s line %d: run rc %d %s\n", |
| 464 | __func__, __LINE__, rc, cdb2_errstr(db)); |
| 465 | if (exit_at_failure) myexit(__func__, __LINE__, 1); |
| 466 | return rc; |
| 467 | } |
| 468 | |
| 469 | rc = cdb2_run_statement(db, "set transaction serializable"); |
| 470 | if (rc) { |
| 471 | tdprintf(stderr, db, __func__, __LINE__, "%s line %d: run rc %d %s\n", |
| 472 | __func__, __LINE__, rc, cdb2_errstr(db)); |
| 473 | if (exit_at_failure) myexit(__func__, __LINE__, 1); |
| 474 | return rc; |
| 475 | } |
| 476 | |
| 477 | int iteration = 0; |
| 478 | cdb2_effects_tp effects; |
| 479 | char sql[64]; |
| 480 | |
| 481 | // First erase everything larger |
| 482 | do { |
| 483 | iteration++; |
| 484 | rc = cdb2_run_statement(db, "begin"); |
| 485 | if (rc) { |
| 486 | tdprintf(stderr, db, __func__, __LINE__, "XXX %s: begin rc %d %s\n", |
| 487 | __func__, rc, cdb2_errstr(db)); |
| 488 | exit(1); |
| 489 | } |
| 490 | |
| 491 | snprintf(sql, sizeof(sql), "delete from t1 where a >= %u limit 1000", |
| 492 | select_records); |
| 493 | |
| 494 | rc = cdb2_run_statement(db, sql); |
| 495 | if (rc) { |
| 496 | tdprintf(stderr, db, __func__, __LINE__, |
| 497 | "XXX %s line %d: run rc %d %s\n", __func__, __LINE__, rc, |
| 498 | cdb2_errstr(db)); |
| 499 | exit(1); |
| 500 | } |
| 501 | |
| 502 | rc = cdb2_run_statement(db, "commit"); |
| 503 | if (rc) { |
| 504 | tdprintf(stderr, db, __func__, __LINE__, |
no test coverage detected