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

Method load_names

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

Source from the content-addressed store, hash-verified

266}
267
268int db_ctl::load_names(void)
269{
270 const char* sql = "select id, name, type from tbl_name";
271 if (ctl_conn_->sql_select(sql) == false)
272 {
273 logger_error("sql(%s) error", sql);
274 return -1;
275 }
276
277 const std::vector<acl::db_row*>* rows = ctl_conn_->get_rows();
278 if (rows == NULL)
279 {
280 logger_error("tbl_name empty");
281 return 0;
282 }
283
284 unsigned int id;
285 int type;
286 const char* name;
287 size_t i;
288 for (i = 0; i < rows->size(); i++)
289 {
290 const acl::db_row* row = (*rows)[i];
291 id = row->field_int("id", -1);
292 if (id == (unsigned int) -1)
293 {
294 logger_error("invalid id");
295 continue;
296 }
297 name = row->field_string("name");
298 if (name == NULL)
299 {
300 logger_error("invalid name");
301 continue;
302 }
303 type = row->field_int("type", -1);
304 if (type < NAME_TYPE_DB || type > NAME_TYPE_IDX)
305 {
306 logger_error("invalid type");
307 continue;
308 }
309 add_name(name, id, (name_type_t) type);
310 }
311
312 ctl_conn_->free_result();
313 return (int) i;
314}
315
316int db_ctl::load_idx_hosts(void)
317{

Callers

nothing calls this directly

Calls 6

get_rowsMethod · 0.80
field_intMethod · 0.80
field_stringMethod · 0.80
free_resultMethod · 0.80
sql_selectMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected