379 std::vector<std::string> args;
383 args.push_back(
"mysql");
386 args.push_back(
"-h" + host);
387 args.push_back(
"-u" + user);
389 if (!password.empty())
390 args.push_back(
"-p" + password);
395 args.push_back(
"-P" + port_or_socket);
399 if (!std::isdigit(port_or_socket[0]))
402 args.push_back(
"-P0");
403 args.push_back(
"--protocol=SOCKET");
404 args.push_back(
"-S" + port_or_socket);
408 args.push_back(
"-P" + port_or_socket);
413 args.push_back(
"--default-character-set=utf8");
416 args.push_back(
"--max-allowed-packet=1GB");
419 if (!database.empty())
420 args.push_back(database);
423 file_descriptor_source source(path);
428 boost::process::pipe outPipe = create_pipe();
429 boost::process::pipe errPipe = create_pipe();
431 child c = execute(run_exe(
433 set_args(args), bind_stdin(source), throw_on_error(),
434 bind_stdout(file_descriptor_sink(outPipe.sink, close_handle)),
435 bind_stderr(file_descriptor_sink(errPipe.sink, close_handle)));
437 file_descriptor_source mysqlOutfd(outPipe.source, close_handle);
438 file_descriptor_source mysqlErrfd(errPipe.source, close_handle);
440 stream<file_descriptor_source> mysqlOutStream(mysqlOutfd);
441 stream<file_descriptor_source> mysqlErrStream(mysqlErrfd);
443 std::stringstream out;
444 std::stringstream err;
446 copy(mysqlOutStream, out);
447 copy(mysqlErrStream, err);
449 TC_LOG_INFO(
"sql.updates",
"%s", out.str().c_str());
452 ret = wait_for_exit(c);
454 catch (boost::system::system_error&)
461 if (ret != EXIT_SUCCESS)
463 TC_LOG_FATAL(
"sql.updates",
"Applying of file \'%s\' to database \'%s\' failed!" \
464 " If you are an user pull the latest revision from the repository. If you are a developer fix your sql query.",
Definition: DBUpdater.h:26
MySQLConnectionInfo const * GetConnectionInfo() const
Definition: DatabaseWorkerPool.h:76
uint32_t uint32
Definition: Define.h:150
static std::string GetCorrectedMySQLExecutable()
Definition: DBUpdater.cpp:39
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:210
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207