MCPcopy Create free account
hub / github.com/MariaDB/server / test_12

Method test_12

plugin/handler_socket/client/hstest.cpp:1181–1311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1179}
1180
1181void
1182hstest_thread::test_12(int test_num)
1183{
1184 /* NOTE: num_threads should be 1 */
1185 /* create table hstest
1186 * ( k varchar(255) not null, v varchar(255) not null, primary key(k))
1187 * engine = innodb; */
1188 mysqltest_thread_initobj initobj;
1189 auto_mysql db;
1190 std::string err;
1191 unsigned long long err_cnt = 0;
1192 unsigned long long query_cnt = 0;
1193 #if 0
1194 my_bool reconnect = 0;
1195 if (mysql_options(db, MYSQL_OPT_RECONNECT, &reconnect) != 0) {
1196 err = "mysql_options() failed";
1197 ++err_cnt;
1198 return;
1199 }
1200 #endif
1201 const std::string mysql_host = arg.sh.conf.get_str("host", "localhost");
1202 const int mysql_port = arg.sh.conf.get_int("mysqlport", 3306);
1203 const unsigned int num = arg.sh.loop;
1204 const size_t pipe = arg.sh.pipe;
1205 const std::string mysql_user = arg.sh.conf.get_str("mysqluser", "root");
1206 const std::string mysql_passwd = arg.sh.conf.get_str("mysqlpass", "");
1207 const std::string mysql_dbname = arg.sh.conf.get_str("db", "hstest");
1208 const int keep_connection = arg.sh.conf.get_int("keep_connection", 1);
1209 const int verbose = arg.sh.conf.get_int("verbose", 1);
1210 const int use_handler = arg.sh.conf.get_int("handler", 0);
1211 int connected = 0;
1212 unsigned int k = 0;
1213 string_buffer buf;
1214 for (unsigned int i = 0; i < num; ++i) {
1215 const int flags = 0;
1216 if (connected == 0 && !mysql_real_connect(db, mysql_host.c_str(),
1217 mysql_user.c_str(), mysql_user.empty() ? 0 : mysql_passwd.c_str(),
1218 mysql_dbname.c_str(), mysql_port, 0, flags)) {
1219 err = "failed to connect: " + std::string(mysql_error(db));
1220 if (verbose >= 1) {
1221 fprintf(stderr, "e=[%s]\n", err.c_str());
1222 }
1223 ++err_cnt;
1224 return;
1225 }
1226 int r = 0;
1227 if (connected == 0 && use_handler) {
1228 const char *const q = "handler hstest open";
1229 r = mysql_real_query(db, q, strlen(q));
1230 if (r != 0) {
1231 err = 1;
1232 }
1233 }
1234 connected = 1;
1235 std::string result_str;
1236 unsigned int err = 0;
1237 unsigned int num_flds = 0, num_affected_rows = 0;
1238 int got_data = 0;

Callers

nothing calls this directly

Calls 15

mysql_optionsFunction · 0.85
stringClass · 0.85
mysql_errorFunction · 0.85
mysql_real_queryFunction · 0.85
mysql_num_fieldsFunction · 0.85
mysql_fetch_rowFunction · 0.85
mysql_field_countFunction · 0.85
mysql_affected_rowsFunction · 0.85
append_literalMethod · 0.80
make_spaceMethod · 0.80
space_wroteMethod · 0.80
increment_countMethod · 0.80

Tested by

no test coverage detected