static int doquery() { int ret = 0; char buf[100]; Uint8 b_lo_buffer[NdbIndexStat::BoundBufferBytes]; Uint8 b_hi_buffer[NdbIndexStat::BoundBufferBytes]; NdbIndexStat::Bound b_lo(g_is, b_lo_buffer); NdbIndexStat::Bound b_hi(g_is, b_hi_buffer); do { NdbIndexStat::Range r(b_lo, b_hi); Uint8 s_buffer[NdbIndexStat::StatBufferBytes]; NdbIndexStat::Stat s(s_buffer); for (int n = 0; n < _query; n++) { g_is->reset_range(r); for (int i = 0; i <= 1; i++) { NdbIndexStat::Bound& b = (i == 0 ? b_lo : b_hi); if (ndb_rand() % 3 != 0) { if (ndb_rand() % 3 != 0) { Uint32 x = ndb_rand(); CHK2(g_is->add_bound(b, &x) == 0, g_is->getNdbError()); } else { CHK2(g_is->add_bound_null(b) == 0, g_is->getNdbError()); } bool strict = (ndb_rand() % 2 == 0); g_is->set_bound_strict(b, strict); } } CHK2(ret == 0, "failed"); CHK2(g_is->finalize_range(r) == 0, g_is->getNdbError()); CHK2(g_is->query_stat(r, s) == 0, g_is->getNdbError()); double rir = -1.0; NdbIndexStat::get_rir(s, &rir); g_info << "rir: " << format(rir, buf) << endl; } CHK2(ret == 0, "failed"); } while (0); return ret; }
int Ndb_move_data::move_batch() { int ret = 0; Op& op = m_op; op.rows_in_batch = 0; op.truncated_in_batch = 0; do { int res; CHK2((res = op.scanop->nextResult(true)) != -1, (op.scanop->getNdbError())); require(res == 0 || res == 1); if (res == 1) { op.end_of_scan = true; op.ndb->closeTransaction(op.scantrans); op.scantrans = 0; break; } require(op.updatetrans == 0); op.updatetrans = op.ndb->startTransaction(); CHK2(op.updatetrans != 0, (op.ndb->getNdbError())); do { CHK1(move_row() == 0); op.rows_in_batch++; CHK2((res = op.scanop->nextResult(false)) != -1, (op.scanop->getNdbError())); require(res == 0 || res == 2); } while (res == 0); CHK1(ret == 0); if (m_error_insert && ndb_rand() % 5 == 0) { invoke_error_insert(); CHK1(false); } CHK2(op.updatetrans->execute(NdbTransaction::Commit) == 0, (op.updatetrans->getNdbError())); op.ndb->closeTransaction(op.updatetrans); op.updatetrans = 0; } while (0); release_data(); return ret; }
static int dostats(int i) { int ret = 0; do { g_indname = g_indnames[i]; g_ind = g_indlist[i]; g_is->reset_index(); CHK2(g_is->set_index(*g_ind, *g_tab) == 0, g_is->getNdbError()); if (_delete) { g_info << g_indname << ": delete stats" << endl; if (ndb_rand() % 2 == 0) { CHK2(g_dic->deleteIndexStat(*g_ind, *g_tab) == 0, g_dic->getNdbError()); } else { CHK2(g_is->delete_stat(g_ndb_sys) == 0, g_is->getNdbError()); } } if (_update) { g_info << g_indname << ": update stats" << endl; if (ndb_rand() % 2 == 0) { CHK2(g_dic->updateIndexStat(*g_ind, *g_tab) == 0, g_dic->getNdbError()); } else { CHK2(g_is->update_stat(g_ndb_sys) == 0, g_is->getNdbError()); } } NdbIndexStat::Head head; g_is->read_head(g_ndb_sys); g_is->get_head(head); CHK2(head.m_found != -1, g_is->getNdbError()); if (head.m_found == false) { g_info << "no stats" << endl; break; } show_head(head); g_info << "read stats" << endl; CHK2(g_is->read_stat(g_ndb_sys) == 0, g_is->getNdbError()); g_is->move_cache(); g_is->clean_cache(); g_info << "query cache created" << endl; NdbIndexStat::CacheInfo infoQuery; g_is->get_cache_info(infoQuery, NdbIndexStat::CacheQuery); show_cache_info("query cache", infoQuery); if (_dump) { NdbIndexStatImpl& impl = g_is->getImpl(); NdbIndexStatImpl::CacheIter iter(impl); CHK2(impl.dump_cache_start(iter) == 0, g_is->getNdbError()); while (impl.dump_cache_next(iter) == true) { show_cache_entry(iter); } } if (_query > 0) { CHK2(doquery() == 0, "failed"); } } while (0); return ret; }