MCPcopy Create free account
hub / github.com/DeNA/HandlerSocket-Plugin-for-MySQL / test_9

Method test_9

client/hstest.cpp:516–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514};
515
516void
517hstest_thread::test_9(int test_num)
518{
519 /* create table hstest
520 * ( k varchar(255) not null, v varchar(255) not null, primary key(k))
521 * engine = innodb; */
522 auto_mysql db;
523 // mysqltest_thread_initobj initobj;
524 std::string err;
525 const char op = arg.sh.op;
526 const std::string suffix = arg.sh.conf.get_str("value_suffix", "upd");
527 unsigned long long err_cnt = 0;
528 unsigned long long query_cnt = 0;
529 #if 0
530 my_bool reconnect = 0;
531 if (mysql_options(db, MYSQL_OPT_RECONNECT, &reconnect) != 0) {
532 err = "mysql_options() failed";
533 ++err_cnt;
534 return;
535 }
536 #endif
537 unsigned int seed = time(0) + arg.id + 1;
538 seed ^= arg.sh.conf.get_int("seed_xor", 0);
539 drand48_data randbuf;
540 srand48_r(seed, &randbuf);
541 const std::string mysql_host = arg.sh.conf.get_str("host", "localhost");
542 const int mysql_port = arg.sh.conf.get_int("mysqlport", 3306);
543 const int num = arg.sh.loop;
544 const std::string mysql_user = arg.sh.conf.get_str("mysqluser", "root");
545 const std::string mysql_passwd = arg.sh.conf.get_str("mysqlpass", "");
546 const std::string mysql_dbname = arg.sh.conf.get_str("dbname", "hstest");
547 const int keep_connection = arg.sh.conf.get_int("keep_connection", 1);
548 const int verbose = arg.sh.conf.get_int("verbose", 1);
549 const int tablesize = arg.sh.conf.get_int("tablesize", 10000);
550 const int moreflds = arg.sh.conf.get_int("moreflds", 0);
551 const std::string moreflds_prefix = arg.sh.conf.get_str(
552 "moreflds_prefix", "column0123456789_");
553 const int use_handler = arg.sh.conf.get_int("handler", 0);
554 const int sched_flag = arg.sh.conf.get_int("sched", 0);
555 const int use_in = arg.sh.conf.get_int("in", 0);
556 const int ssps = use_in ? 0 : arg.sh.conf.get_int("ssps", 0);
557 std::string flds = "v";
558 for (int i = 0; i < moreflds; ++i) {
559 char buf[1024];
560 snprintf(buf, sizeof(buf), ",%s%d", moreflds_prefix.c_str(), i);
561 flds += std::string(buf);
562 }
563 int connected = 0;
564 std::auto_ptr<auto_mysql_stmt> stmt;
565 string_buffer wbuf;
566 for (int i = 0; i < num; ++i) {
567 const double tm1 = gettimeofday_double();
568 const int flags = 0;
569 if (connected == 0) {
570 if (!mysql_real_connect(db, mysql_host.c_str(),
571 mysql_user.c_str(), mysql_user.empty() ? 0 : mysql_passwd.c_str(),
572 mysql_dbname.c_str(), mysql_port, 0, flags)) {
573 err = "failed to connect: " + std::string(mysql_error(db));

Callers

nothing calls this directly

Calls 14

get_strMethod · 0.80
get_intMethod · 0.80
emptyMethod · 0.80
increment_connMethod · 0.80
make_spaceMethod · 0.80
space_wroteMethod · 0.80
append_literalMethod · 0.80
increment_countMethod · 0.80
gettimeofday_doubleFunction · 0.70
resetMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected