171
171
fd= open(_filename.c_str(),
172
172
O_WRONLY | O_APPEND | O_CREAT,
173
173
S_IRUSR|S_IWUSR);
177
sql_perror( _("fail open()"), _filename);
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"),
231
234
if (session->examined_row_count < sysvar_logging_query_threshold_big_examined.get())
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);
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();
241
if (session->getElapsedTime() < (sysvar_logging_query_threshold_slow.get()))
245
if ((t_mark - session->start_utime) < (sysvar_logging_query_threshold_slow.get()))
244
248
Session::QueryString query_string(session->getQueryString());
268
272
% session->getQueryId()
271
% getCommandName(session->command)
275
% command_name[session->command].str
272
276
% (t_mark - session->getConnectMicroseconds())
273
% session->getElapsedTime()
277
% (t_mark - session->start_utime)
274
278
% (t_mark - session->utime_after_lock)
275
279
% session->sent_row_count
276
280
% session->examined_row_count
314
318
context("enable",
315
319
po::value<bool>(&sysvar_logging_query_enable)->default_value(false)->zero_tokens(),
316
_("Enable logging to CSV file"));
320
N_("Enable logging to CSV file"));
317
321
context("filename",
318
322
po::value<string>(),
319
_("File to log to"));
323
N_("File to log to"));
321
325
po::value<string>()->default_value(""),
322
_("PCRE to match the query against"));
326
N_("PCRE to match the query against"));
323
327
context("threshold-slow",
324
328
po::value<uint32_constraint>(&sysvar_logging_query_threshold_slow)->default_value(0),
325
_("Threshold for logging slow queries, in microseconds"));
329
N_("Threshold for logging slow queries, in microseconds"));
326
330
context("threshold-big-resultset",
327
331
po::value<uint32_constraint>(&sysvar_logging_query_threshold_big_resultset)->default_value(0),
328
_("Threshold for logging big queries, for rows returned"));
332
N_("Threshold for logging big queries, for rows returned"));
329
333
context("threshold-big-examined",
330
334
po::value<uint32_constraint>(&sysvar_logging_query_threshold_big_examined)->default_value(0),
331
_("Threshold for logging big queries, for rows examined"));
335
N_("Threshold for logging big queries, for rows examined"));
334
338
} /* namespace drizzle_plugin */