~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/query_log/event.h

  • Committer: Daniel Nichter
  • Date: 2011-05-15 17:58:28 UTC
  • mto: This revision was merged to the branch mainline in revision 2387.
  • Revision ID: daniel@percona.com-20110515175828-1n4orh47k6vw44o7
Add query_log plugin.  It's tested and documented.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  *  Copyright (C) 2011 Daniel Nichter
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; version 2 of the License.
 
7
 *
 
8
 *  This program is distributed in the hope that it will be useful,
 
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 *  GNU General Public License for more details.
 
12
 *
 
13
 *  You should have received a copy of the GNU General Public License
 
14
 *  along with this program; if not, write to the Free Software
 
15
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
16
 */
 
17
 
 
18
#pragma once
 
19
 
 
20
/**
 
21
 * @file
 
22
 *   event.h
 
23
 *
 
24
 * @brief
 
25
 *   Defines the event_t struct that encapsulates an event.
 
26
 *
 
27
 * @details
 
28
 *   An event (i.e. a query) has the attributes defined in the event_t struct.
 
29
 *   The values come from various members of the Session class.  This is
 
30
 *   a necessary redundancy for two reasons.  First, access to this data via
 
31
 *   the Session class is not uniform; it requires various calls and
 
32
 *   calculations.  Look at QueryLog::afterStatement() to see this.  Second,
 
33
 *   because the QueryLog object controls the logger classes, i.e.
 
34
 *   QueryLoggerFile and others in the futre, event creation and filtering
 
35
 *   is done in one place (QueryLog::afterStatement()) and then acceptable
 
36
 *   events are passed to the logger classes so that all they have to do is log.
 
37
 *
 
38
 *   Since this is just a collection of variables, making this a class
 
39
 *   with accessor functions is overkill.
 
40
 */
 
41
struct event_t {
 
42
  // GMT timestamps (2002-01-31T10:00:01.123456)
 
43
  std::string ts;
 
44
 
 
45
  // integers
 
46
  uint32_t session_id;
 
47
  uint32_t query_id;
 
48
  uint32_t rows_examined;
 
49
  uint32_t rows_sent;
 
50
  uint32_t tmp_tables;
 
51
  uint32_t warnings;
 
52
 
 
53
  // times (42.123456)
 
54
  double execution_time;
 
55
  double lock_time;
 
56
  double session_time;
 
57
 
 
58
  // bools ("true" or "false")
 
59
  const char *error;
 
60
 
 
61
  // strings, not quoted or escaped
 
62
  const char *schema;
 
63
 
 
64
  // query, not quoted or escaped
 
65
  const char *query;
 
66
};