~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/logging_query/logging_query.cc

  • Committer: Brian Aker
  • Date: 2011-01-25 07:22:15 UTC
  • mfrom: (2109.1.7 drizzle-build)
  • Revision ID: brian@tangent.org-20110125072215-567z6uzy5vdvn4va
Merge in build/timestamp patches/fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008,2009 Sun Microsystems
 
4
 *  Copyright (C) 2008, 2009 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
234
234
    if (session->examined_row_count < sysvar_logging_query_threshold_big_examined.get())
235
235
      return false;
236
236
 
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 */
240
 
  
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();
 
237
    /*
 
238
      TODO, the session object should have a "utime command completed"
 
239
      inside itself, so be more accurate, and so this doesnt have to
 
240
      keep calling current_utime, which can be slow.
 
241
    */
 
242
    uint64_t t_mark= session->getCurrentTimestamp(false);
244
243
 
245
 
    if ((t_mark - session->start_utime) < (sysvar_logging_query_threshold_slow.get()))
 
244
    if (session->getElapsedTime() < (sysvar_logging_query_threshold_slow.get()))
246
245
      return false;
247
246
 
248
247
    Session::QueryString query_string(session->getQueryString());
274
273
              % qs
275
274
              % command_name[session->command].str
276
275
              % (t_mark - session->getConnectMicroseconds())
277
 
              % (t_mark - session->start_utime)
 
276
              % session->getElapsedTime()
278
277
              % (t_mark - session->utime_after_lock)
279
278
              % session->sent_row_count
280
279
              % session->examined_row_count
317
316
{
318
317
  context("enable",
319
318
          po::value<bool>(&sysvar_logging_query_enable)->default_value(false)->zero_tokens(),
320
 
          N_("Enable logging to CSV file"));
 
319
          _("Enable logging to CSV file"));
321
320
  context("filename",
322
321
          po::value<string>(),
323
 
          N_("File to log to"));
 
322
          _("File to log to"));
324
323
  context("pcre",
325
324
          po::value<string>()->default_value(""),
326
 
          N_("PCRE to match the query against"));
 
325
          _("PCRE to match the query against"));
327
326
  context("threshold-slow",
328
327
          po::value<uint32_constraint>(&sysvar_logging_query_threshold_slow)->default_value(0),
329
 
          N_("Threshold for logging slow queries, in microseconds"));
 
328
          _("Threshold for logging slow queries, in microseconds"));
330
329
  context("threshold-big-resultset",
331
330
          po::value<uint32_constraint>(&sysvar_logging_query_threshold_big_resultset)->default_value(0),
332
 
          N_("Threshold for logging big queries, for rows returned"));
 
331
          _("Threshold for logging big queries, for rows returned"));
333
332
  context("threshold-big-examined",
334
333
          po::value<uint32_constraint>(&sysvar_logging_query_threshold_big_examined)->default_value(0),
335
 
          N_("Threshold for logging big queries, for rows examined"));
 
334
          _("Threshold for logging big queries, for rows examined"));
336
335
}
337
336
 
338
337
} /* namespace drizzle_plugin */