171
171
fd= open(_filename.c_str(),
172
172
O_WRONLY | O_APPEND | O_CREAT,
173
173
S_IRUSR|S_IWUSR);
176
char errmsg[STRERROR_MAX];
177
strerror_r(errno, errmsg, sizeof(errmsg));
178
errmsg_printf(ERRMSG_LVL_ERROR, _("fail open() fn=%s er=%s\n"),
177
sql_perror( _("fail open()"), _filename);
234
231
if (session->examined_row_count < sysvar_logging_query_threshold_big_examined.get())
237
/* TODO, the session object should have a "utime command completed"
238
inside itself, so be more accurate, and so this doesnt have to
239
keep calling current_utime, which can be slow */
241
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
242
boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
243
uint64_t t_mark= (mytime-epoch).total_microseconds();
235
TODO, the session object should have a "utime command completed"
236
inside itself, so be more accurate, and so this doesnt have to
237
keep calling current_utime, which can be slow.
239
uint64_t t_mark= session->getCurrentTimestamp(false);
245
if ((t_mark - session->start_utime) < (sysvar_logging_query_threshold_slow.get()))
241
if (session->getElapsedTime() < (sysvar_logging_query_threshold_slow.get()))
248
244
Session::QueryString query_string(session->getQueryString());
272
268
% session->getQueryId()
275
% command_name[session->command].str
271
% getCommandName(session->command)
276
272
% (t_mark - session->getConnectMicroseconds())
277
% (t_mark - session->start_utime)
273
% session->getElapsedTime()
278
274
% (t_mark - session->utime_after_lock)
279
275
% session->sent_row_count
280
276
% session->examined_row_count
318
314
context("enable",
319
315
po::value<bool>(&sysvar_logging_query_enable)->default_value(false)->zero_tokens(),
320
N_("Enable logging to CSV file"));
316
_("Enable logging to CSV file"));
321
317
context("filename",
322
318
po::value<string>(),
323
N_("File to log to"));
319
_("File to log to"));
325
321
po::value<string>()->default_value(""),
326
N_("PCRE to match the query against"));
322
_("PCRE to match the query against"));
327
323
context("threshold-slow",
328
324
po::value<uint32_constraint>(&sysvar_logging_query_threshold_slow)->default_value(0),
329
N_("Threshold for logging slow queries, in microseconds"));
325
_("Threshold for logging slow queries, in microseconds"));
330
326
context("threshold-big-resultset",
331
327
po::value<uint32_constraint>(&sysvar_logging_query_threshold_big_resultset)->default_value(0),
332
N_("Threshold for logging big queries, for rows returned"));
328
_("Threshold for logging big queries, for rows returned"));
333
329
context("threshold-big-examined",
334
330
po::value<uint32_constraint>(&sysvar_logging_query_threshold_big_examined)->default_value(0),
335
N_("Threshold for logging big queries, for rows examined"));
331
_("Threshold for logging big queries, for rows examined"));
338
334
} /* namespace drizzle_plugin */