MCPcopy Create free account
hub / github.com/acl-dev/acl / load_db_hosts

Method load_db_hosts

lib_acl_cpp/app/ndb/ctl_server/db_ctl.cpp:410–458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410int db_ctl::load_db_hosts(void)
411{
412 const char* sql = "select id_db, id_idx_host, count from tbl_db_host";
413 if ((ctl_conn_->sql_select(sql)) == false)
414 {
415 logger_error("sql(%s) error", sql);
416 return -1;
417 }
418
419 const std::vector<acl::db_row*>* rows = ctl_conn_->get_rows();
420 if (rows == NULL)
421 {
422 logger_warn("tbl_db_host empty");
423 return 0;
424 }
425
426 unsigned int id_db, id_idx_host;
427 acl_int64 count;
428
429 size_t i;
430 for (i = 0; i < rows->size(); i++)
431 {
432 const acl::db_row* row = (*rows)[i];
433 if ((id_db = row->field_int("id_db", -1)) == (unsigned int) -1)
434 {
435 logger_warn("id_db(-1) invalid");
436 continue;
437 }
438 else if ((id_idx_host = row->field_int("id_idx_host", -1))
439 == (unsigned int) -1)
440 {
441 logger_warn("id_idx_host invalid");
442 continue;
443 }
444 else if ((count = row->field_int64("count", -1)) == -1)
445 {
446 logger_warn("count invalid");
447 continue;
448 }
449 DB_HOST* host = (DB_HOST*) acl_mymalloc(sizeof(DB_HOST));
450 host->id_db = id_db;
451 host->id_idx_host = id_idx_host;
452 host->count = count;
453 db_hosts_.push_back(host);
454 }
455
456 ctl_conn_->free_result();
457 return (int) i;
458}
459
460int db_ctl::load_db_tbls(void)
461{

Callers

nothing calls this directly

Calls 7

get_rowsMethod · 0.80
field_intMethod · 0.80
field_int64Method · 0.80
free_resultMethod · 0.80
sql_selectMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected