~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/logging_query/logging_query.cc

Merge in security refactor.

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, Inc.
 
4
 *  Copyright (C) 2008,2009 Sun Microsystems
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
27
27
#include <sys/types.h>
28
28
#include <sys/stat.h>
29
29
#include <fcntl.h>
30
 
#include <string>
31
 
#include <boost/format.hpp>
32
 
#include <boost/program_options.hpp>
33
 
#include <drizzled/module/option_map.h>
34
 
#include <cstdio>
35
 
#include <cerrno>
36
 
 
37
 
namespace po= boost::program_options;
 
30
 
 
31
 
38
32
using namespace drizzled;
39
 
using namespace std;
40
 
 
41
 
#define ESCAPE_CHAR      '\\'
42
 
#define SEPARATOR_CHAR   ','
43
 
 
44
 
namespace drizzle_plugin
45
 
{
 
33
 
 
34
/* TODO make this dynamic as needed */
 
35
static const int MAX_MSG_LEN= 32*1024;
46
36
 
47
37
static bool sysvar_logging_query_enable= false;
 
38
static char* sysvar_logging_query_filename= NULL;
 
39
static char* sysvar_logging_query_pcre= NULL;
48
40
/* TODO fix these to not be unsigned long once we have sensible sys_var system */
49
 
static uint32_constraint sysvar_logging_query_threshold_slow;
50
 
static uint32_constraint sysvar_logging_query_threshold_big_resultset;
51
 
static uint32_constraint sysvar_logging_query_threshold_big_examined;
 
41
static unsigned long sysvar_logging_query_threshold_slow= 0;
 
42
static unsigned long sysvar_logging_query_threshold_big_resultset= 0;
 
43
static unsigned long sysvar_logging_query_threshold_big_examined= 0;
 
44
 
 
45
/* stolen from mysys/my_getsystime
 
46
   until the Session has a good utime "now" we can use
 
47
   will have to use this instead */
 
48
 
 
49
static uint64_t get_microtime()
 
50
{
 
51
#if defined(HAVE_GETHRTIME)
 
52
  return gethrtime()/1000;
 
53
#else
 
54
  uint64_t newtime;
 
55
  struct timeval t;
 
56
  /*
 
57
    The following loop is here because gettimeofday may fail on some systems
 
58
  */
 
59
  while (gettimeofday(&t, NULL) != 0) {}
 
60
  newtime= (uint64_t)t.tv_sec * 1000000 + t.tv_usec;
 
61
  return newtime;
 
62
#endif  /* defined(HAVE_GETHRTIME) */
 
63
}
52
64
 
53
65
/* quote a string to be safe to include in a CSV line
54
66
   that means backslash quoting all commas, doublequotes, backslashes,
66
78
 
67
79
*/
68
80
 
69
 
static void quotify(const string &src, string &dst)
 
81
static unsigned char *quotify (const unsigned char *src, size_t srclen,
 
82
                               unsigned char *dst, size_t dstlen)
70
83
{
71
84
  static const char hexit[]= { '0', '1', '2', '3', '4', '5', '6', '7',
72
85
                          '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
73
 
  string::const_iterator src_iter;
74
 
  
75
 
  for (src_iter= src.begin(); src_iter < src.end(); ++src_iter)
 
86
  size_t dst_ndx;  /* ndx down the dst */
 
87
  size_t src_ndx;  /* ndx down the src */
 
88
 
 
89
  assert(dst);
 
90
  assert(dstlen > 0);
 
91
 
 
92
  for (dst_ndx= 0,src_ndx= 0; src_ndx < srclen; src_ndx++)
76
93
  {
77
 
    if (static_cast<unsigned char>(*src_iter) > 0x7f)
78
 
    {
79
 
      dst.push_back(*src_iter);
80
 
    }
81
 
    else if (*src_iter == 0x00)  // null
82
 
    {
83
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('0');
84
 
    }
85
 
    else if (*src_iter == 0x07)  // bell
86
 
    {
87
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('a');
88
 
    }
89
 
    else if (*src_iter == 0x08)  // backspace
90
 
    {
91
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('b');
92
 
    }
93
 
    else if (*src_iter == 0x09)  // horiz tab
94
 
    {
95
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('t');
96
 
    }
97
 
    else if (*src_iter == 0x0a)  // line feed
98
 
    {
99
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('n');
100
 
    }
101
 
    else if (*src_iter == 0x0b)  // vert tab
102
 
    {
103
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('v');
104
 
    }
105
 
    else if (*src_iter == 0x0c)  // formfeed
106
 
    {
107
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('f');
108
 
    }
109
 
    else if (*src_iter == 0x0d)  // carrage return
110
 
    {
111
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('r');
112
 
    }
113
 
    else if (*src_iter == 0x1b)  // escape
114
 
    {
115
 
      dst.push_back(ESCAPE_CHAR); dst.push_back('e');
116
 
    }
117
 
    else if (*src_iter == 0x22)  // quotation mark
118
 
    {
119
 
      dst.push_back(ESCAPE_CHAR); dst.push_back(0x22);
120
 
    }
121
 
    else if (*src_iter == SEPARATOR_CHAR)
122
 
    {
123
 
      dst.push_back(ESCAPE_CHAR); dst.push_back(SEPARATOR_CHAR);
124
 
    }
125
 
    else if (*src_iter == ESCAPE_CHAR)
126
 
    {
127
 
      dst.push_back(ESCAPE_CHAR); dst.push_back(ESCAPE_CHAR);
128
 
    }
129
 
    else if ((*src_iter < 0x20) || (*src_iter == 0x7F))  // other unprintable ASCII
130
 
    {
131
 
      dst.push_back(ESCAPE_CHAR);
132
 
      dst.push_back('x');
133
 
      dst.push_back(hexit[(*src_iter >> 4) & 0x0f]);
134
 
      dst.push_back(hexit[*src_iter & 0x0f]);
 
94
 
 
95
    /* Worst case, need 5 dst bytes for the next src byte.
 
96
       backslash x hexit hexit null
 
97
       so if not enough room, just terminate the string and return
 
98
    */
 
99
    if ((dstlen - dst_ndx) < 5)
 
100
    {
 
101
      dst[dst_ndx]= (unsigned char)0x00;
 
102
      return dst;
 
103
    }
 
104
 
 
105
    if (src[src_ndx] > 0x7f)
 
106
    {
 
107
      // pass thru high bit characters, they are non-ASCII UTF8 Unicode
 
108
      dst[dst_ndx++]= src[src_ndx];
 
109
    }
 
110
    else if (src[src_ndx] == 0x00)  // null
 
111
    {
 
112
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) '0';
 
113
    }
 
114
    else if (src[src_ndx] == 0x07)  // bell
 
115
    {
 
116
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) 'a';
 
117
    }
 
118
    else if (src[src_ndx] == 0x08)  // backspace
 
119
    {
 
120
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) 'b';
 
121
    }
 
122
    else if (src[src_ndx] == 0x09)  // horiz tab
 
123
    {
 
124
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) 't';
 
125
    }
 
126
    else if (src[src_ndx] == 0x0a)  // line feed
 
127
    {
 
128
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) 'n';
 
129
    }
 
130
    else if (src[src_ndx] == 0x0b)  // vert tab
 
131
    {
 
132
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) 'v';
 
133
    }
 
134
    else if (src[src_ndx] == 0x0c)  // formfeed
 
135
    {
 
136
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) 'f';
 
137
    }
 
138
    else if (src[src_ndx] == 0x0d)  // carrage return
 
139
    {
 
140
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) 'r';
 
141
    }
 
142
    else if (src[src_ndx] == 0x1b)  // escape
 
143
    {
 
144
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= (unsigned char) 'e';
 
145
    }
 
146
    else if (src[src_ndx] == 0x22)  // quotation mark
 
147
    {
 
148
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= 0x22;
 
149
    }
 
150
    else if (src[src_ndx] == 0x2C)  // comma
 
151
    {
 
152
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= 0x2C;
 
153
    }
 
154
    else if (src[src_ndx] == 0x5C)  // backslash
 
155
    {
 
156
      dst[dst_ndx++]= 0x5C; dst[dst_ndx++]= 0x5C;
 
157
    }
 
158
    else if ((src[src_ndx] < 0x20) || (src[src_ndx] == 0x7F))  // other unprintable ASCII
 
159
    {
 
160
      dst[dst_ndx++]= 0x5C;
 
161
      dst[dst_ndx++]= (unsigned char) 'x';
 
162
      dst[dst_ndx++]= hexit[(src[src_ndx] >> 4) & 0x0f];
 
163
      dst[dst_ndx++]= hexit[src[src_ndx] & 0x0f];
135
164
    }
136
165
    else  // everything else
137
166
    {
138
 
      dst.push_back(*src_iter);
 
167
      dst[dst_ndx++]= src[src_ndx];
139
168
    }
 
169
    dst[dst_ndx]= '\0';
140
170
  }
 
171
  return dst;
141
172
}
142
173
 
143
174
 
144
175
class Logging_query: public drizzled::plugin::Logging
145
176
{
146
 
  const std::string _filename;
147
 
  const std::string _query_pcre;
148
177
  int fd;
149
178
  pcre *re;
150
179
  pcre_extra *pe;
151
180
 
152
 
  /** Format of the output string */
153
 
  boost::format formatter;
154
 
 
155
181
public:
156
182
 
157
 
  Logging_query(const std::string &filename,
158
 
                const std::string &query_pcre) :
159
 
    drizzled::plugin::Logging("Logging_query"),
160
 
    _filename(filename),
161
 
    _query_pcre(query_pcre),
162
 
    fd(-1), re(NULL), pe(NULL),
163
 
    formatter("%1%,%2%,%3%,\"%4%\",\"%5%\",\"%6%\",%7%,%8%,"
164
 
              "%9%,%10%,%11%,%12%,%13%,%14%,\"%15%\"\n")
 
183
  Logging_query()
 
184
    : drizzled::plugin::Logging("Logging_query"),
 
185
      fd(-1), re(NULL), pe(NULL)
165
186
  {
166
187
 
167
188
    /* if there is no destination filename, dont bother doing anything */
168
 
    if (_filename.empty())
 
189
    if (sysvar_logging_query_filename == NULL)
169
190
      return;
170
191
 
171
 
    fd= open(_filename.c_str(),
 
192
    fd= open(sysvar_logging_query_filename,
172
193
             O_WRONLY | O_APPEND | O_CREAT,
173
194
             S_IRUSR|S_IWUSR);
174
 
 
175
195
    if (fd < 0)
176
196
    {
177
 
      sql_perror( _("fail open()"), _filename);
 
197
      errmsg_printf(ERRMSG_LVL_ERROR, _("fail open() fn=%s er=%s\n"),
 
198
                    sysvar_logging_query_filename,
 
199
                    strerror(errno));
178
200
      return;
179
201
    }
180
202
 
181
 
    if (not _query_pcre.empty())
 
203
    if (sysvar_logging_query_pcre != NULL)
182
204
    {
183
205
      const char *this_pcre_error;
184
206
      int this_pcre_erroffset;
185
 
      re= pcre_compile(_query_pcre.c_str(), 0, &this_pcre_error,
 
207
      re= pcre_compile(sysvar_logging_query_pcre, 0, &this_pcre_error,
186
208
                       &this_pcre_erroffset, NULL);
187
209
      pe= pcre_study(re, 0, &this_pcre_error);
188
210
      /* TODO emit error messages if there is a problem */
207
229
    }
208
230
  }
209
231
 
 
232
 
 
233
  virtual bool pre (Session *)
 
234
  {
 
235
    /* we could just not have a pre entrypoint at all,
 
236
       and have logging_pre == NULL
 
237
       but we have this here for the sake of being an example */
 
238
    return false;
 
239
  }
 
240
 
210
241
  virtual bool post (Session *session)
211
242
  {
212
 
    size_t wrv;
 
243
    char msgbuf[MAX_MSG_LEN];
 
244
    int msgbuf_len= 0;
 
245
    int wrv;
213
246
 
214
247
    assert(session != NULL);
215
248
 
226
259
    // return if not enabled or query was too fast or resultset was too small
227
260
    if (sysvar_logging_query_enable == false)
228
261
      return false;
229
 
    if (session->sent_row_count < sysvar_logging_query_threshold_big_resultset.get())
230
 
      return false;
231
 
    if (session->examined_row_count < sysvar_logging_query_threshold_big_examined.get())
232
 
      return false;
233
 
 
234
 
    /*
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.
238
 
    */
239
 
    uint64_t t_mark= session->getCurrentTimestamp(false);
240
 
 
241
 
    if (session->getElapsedTime() < (sysvar_logging_query_threshold_slow.get()))
242
 
      return false;
243
 
 
244
 
    Session::QueryString query_string(session->getQueryString());
 
262
    if (session->sent_row_count < sysvar_logging_query_threshold_big_resultset)
 
263
      return false;
 
264
    if (session->examined_row_count < sysvar_logging_query_threshold_big_examined)
 
265
      return false;
 
266
 
 
267
    /* TODO, the session object should have a "utime command completed"
 
268
       inside itself, so be more accurate, and so this doesnt have to
 
269
       keep calling current_utime, which can be slow */
 
270
  
 
271
    uint64_t t_mark= get_microtime();
 
272
  
 
273
    if ((t_mark - session->start_utime) < (sysvar_logging_query_threshold_slow))
 
274
      return false;
 
275
 
245
276
    if (re)
246
277
    {
247
278
      int this_pcre_rc;
248
 
      this_pcre_rc= pcre_exec(re, pe, query_string->c_str(), query_string->length(), 0, 0, NULL, 0);
 
279
      this_pcre_rc = pcre_exec(re, pe, session->query, session->query_length, 0, 0, NULL, 0);
249
280
      if (this_pcre_rc < 0)
250
281
        return false;
251
282
    }
252
283
 
253
284
    // buffer to quotify the query
254
 
    string qs;
255
 
    
256
 
    // Since quotify() builds the quoted string incrementally, we can
257
 
    // avoid some reallocating if we reserve some space up front.
258
 
    qs.reserve(query_string->length());
259
 
    
260
 
    quotify(*query_string, qs);
261
 
    
 
285
    unsigned char qs[255];
 
286
  
262
287
    // to avoid trying to printf %s something that is potentially NULL
263
 
    util::string::const_shared_ptr schema(session->schema());
264
 
    const char *dbs= (schema and not schema->empty()) ? schema->c_str() : "";
265
 
 
266
 
    formatter % t_mark
267
 
              % session->thread_id
268
 
              % session->getQueryId()
269
 
              % dbs
270
 
              % qs
271
 
              % getCommandName(session->command)
272
 
              % (t_mark - session->getConnectMicroseconds())
273
 
              % session->getElapsedTime()
274
 
              % (t_mark - session->utime_after_lock)
275
 
              % session->sent_row_count
276
 
              % session->examined_row_count
277
 
              % session->tmp_table
278
 
              % session->total_warn_count
279
 
              % session->getServerId()
280
 
              % glob_hostname;
281
 
 
282
 
    string msgbuf= formatter.str();
283
 
 
 
288
    const char *dbs= session->db.empty() ? "" : session->db.c_str();
 
289
  
 
290
    msgbuf_len=
 
291
      snprintf(msgbuf, MAX_MSG_LEN,
 
292
               "%"PRIu64",%"PRIu64",%"PRIu64",\"%.*s\",\"%s\",\"%.*s\","
 
293
               "%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64",%"PRIu64","
 
294
               "%"PRIu32",%"PRIu32",%"PRIu32",\"%s\"\n",
 
295
               t_mark,
 
296
               session->thread_id,
 
297
               session->getQueryId(),
 
298
               // dont need to quote the db name, always CSV safe
 
299
               (int)session->db.length(), dbs,
 
300
               // do need to quote the query
 
301
               quotify((unsigned char *)session->getQueryString(),
 
302
                       session->getQueryLength(), qs, sizeof(qs)),
 
303
               // command_name is defined in drizzled/sql_parse.cc
 
304
               // dont need to quote the command name, always CSV safe
 
305
               (int)command_name[session->command].length,
 
306
               command_name[session->command].str,
 
307
               // counters are at end, to make it easier to add more
 
308
               (t_mark - session->getConnectMicroseconds()),
 
309
               (t_mark - session->start_utime),
 
310
               (t_mark - session->utime_after_lock),
 
311
               session->sent_row_count,
 
312
               session->examined_row_count,
 
313
               session->tmp_table,
 
314
               session->total_warn_count,
 
315
               session->getServerId(),
 
316
               glob_hostname
 
317
               );
 
318
  
284
319
    // a single write has a kernel thread lock, thus no need mutex guard this
285
 
    wrv= write(fd, msgbuf.c_str(), msgbuf.length());
286
 
    assert(wrv == msgbuf.length());
287
 
 
 
320
    wrv= write(fd, msgbuf, msgbuf_len);
 
321
    assert(wrv == msgbuf_len);
 
322
  
288
323
    return false;
289
324
  }
290
325
};
291
326
 
292
 
static int logging_query_plugin_init(drizzled::module::Context &context)
293
 
{
294
 
 
295
 
  const module::option_map &vm= context.getOptions();
296
 
 
297
 
  if (vm.count("filename") > 0)
298
 
  {
299
 
    context.add(new Logging_query(vm["filename"].as<string>(),
300
 
                                  vm["pcre"].as<string>()));
301
 
    context.registerVariable(new sys_var_bool_ptr("enable", &sysvar_logging_query_enable));
302
 
    context.registerVariable(new sys_var_const_string_val("filename", vm["filename"].as<string>()));
303
 
    context.registerVariable(new sys_var_const_string_val("pcre", vm["pcre"].as<string>()));
304
 
    context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_slow", sysvar_logging_query_threshold_slow));
305
 
    context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_big_resultset", sysvar_logging_query_threshold_big_resultset));
306
 
    context.registerVariable(new sys_var_constrained_value<uint32_t>("threshold_big_examined", sysvar_logging_query_threshold_big_examined));
307
 
  }
308
 
 
309
 
  return 0;
310
 
}
311
 
 
312
 
static void init_options(drizzled::module::option_context &context)
313
 
{
314
 
  context("enable",
315
 
          po::value<bool>(&sysvar_logging_query_enable)->default_value(false)->zero_tokens(),
316
 
          _("Enable logging to CSV file"));
317
 
  context("filename",
318
 
          po::value<string>(),
319
 
          _("File to log to"));
320
 
  context("pcre",
321
 
          po::value<string>()->default_value(""),
322
 
          _("PCRE to match the query against"));
323
 
  context("threshold-slow",
324
 
          po::value<uint32_constraint>(&sysvar_logging_query_threshold_slow)->default_value(0),
325
 
          _("Threshold for logging slow queries, in microseconds"));
326
 
  context("threshold-big-resultset",
327
 
          po::value<uint32_constraint>(&sysvar_logging_query_threshold_big_resultset)->default_value(0),
328
 
          _("Threshold for logging big queries, for rows returned"));
329
 
  context("threshold-big-examined",
330
 
          po::value<uint32_constraint>(&sysvar_logging_query_threshold_big_examined)->default_value(0),
331
 
          _("Threshold for logging big queries, for rows examined"));
332
 
}
333
 
 
334
 
} /* namespace drizzle_plugin */
 
327
static Logging_query *handler= NULL;
 
328
 
 
329
static int logging_query_plugin_init(drizzled::plugin::Registry &registry)
 
330
{
 
331
  handler= new Logging_query();
 
332
  registry.add(handler);
 
333
 
 
334
  return 0;
 
335
}
 
336
 
 
337
static int logging_query_plugin_deinit(drizzled::plugin::Registry &registry)
 
338
{
 
339
  registry.remove(handler);
 
340
  delete handler;
 
341
 
 
342
  return 0;
 
343
}
 
344
 
 
345
static DRIZZLE_SYSVAR_BOOL(
 
346
  enable,
 
347
  sysvar_logging_query_enable,
 
348
  PLUGIN_VAR_NOCMDARG,
 
349
  N_("Enable logging to CSV file"),
 
350
  NULL, /* check func */
 
351
  NULL, /* update func */
 
352
  false /* default */);
 
353
 
 
354
static DRIZZLE_SYSVAR_STR(
 
355
  filename,
 
356
  sysvar_logging_query_filename,
 
357
  PLUGIN_VAR_READONLY,
 
358
  N_("File to log to"),
 
359
  NULL, /* check func */
 
360
  NULL, /* update func*/
 
361
  NULL /* default */);
 
362
 
 
363
static DRIZZLE_SYSVAR_STR(
 
364
  pcre,
 
365
  sysvar_logging_query_pcre,
 
366
  PLUGIN_VAR_READONLY,
 
367
  N_("PCRE to match the query against"),
 
368
  NULL, /* check func */
 
369
  NULL, /* update func*/
 
370
  NULL /* default */);
 
371
 
 
372
static DRIZZLE_SYSVAR_ULONG(
 
373
  threshold_slow,
 
374
  sysvar_logging_query_threshold_slow,
 
375
  PLUGIN_VAR_OPCMDARG,
 
376
  N_("Threshold for logging slow queries, in microseconds"),
 
377
  NULL, /* check func */
 
378
  NULL, /* update func */
 
379
  0, /* default */
 
380
  0, /* min */
 
381
  UINT32_MAX, /* max */
 
382
  0 /* blksiz */);
 
383
 
 
384
static DRIZZLE_SYSVAR_ULONG(
 
385
  threshold_big_resultset,
 
386
  sysvar_logging_query_threshold_big_resultset,
 
387
  PLUGIN_VAR_OPCMDARG,
 
388
  N_("Threshold for logging big queries, for rows returned"),
 
389
  NULL, /* check func */
 
390
  NULL, /* update func */
 
391
  0, /* default */
 
392
  0, /* min */
 
393
  UINT32_MAX, /* max */
 
394
  0 /* blksiz */);
 
395
 
 
396
static DRIZZLE_SYSVAR_ULONG(
 
397
  threshold_big_examined,
 
398
  sysvar_logging_query_threshold_big_examined,
 
399
  PLUGIN_VAR_OPCMDARG,
 
400
  N_("Threshold for logging big queries, for rows examined"),
 
401
  NULL, /* check func */
 
402
  NULL, /* update func */
 
403
  0, /* default */
 
404
  0, /* min */
 
405
  UINT32_MAX, /* max */
 
406
  0 /* blksiz */);
 
407
 
 
408
static drizzle_sys_var* logging_query_system_variables[]= {
 
409
  DRIZZLE_SYSVAR(enable),
 
410
  DRIZZLE_SYSVAR(filename),
 
411
  DRIZZLE_SYSVAR(pcre),
 
412
  DRIZZLE_SYSVAR(threshold_slow),
 
413
  DRIZZLE_SYSVAR(threshold_big_resultset),
 
414
  DRIZZLE_SYSVAR(threshold_big_examined),
 
415
  NULL
 
416
};
335
417
 
336
418
DRIZZLE_DECLARE_PLUGIN
337
419
{
338
420
  DRIZZLE_VERSION_ID,
339
 
  "logging-query",
 
421
  "logging_query",
340
422
  "0.2",
341
423
  "Mark Atwood <mark@fallenpegasus.com>",
342
424
  N_("Log queries to a CSV file"),
343
425
  PLUGIN_LICENSE_GPL,
344
 
  drizzle_plugin::logging_query_plugin_init,
345
 
  NULL,
346
 
  drizzle_plugin::init_options
 
426
  logging_query_plugin_init,
 
427
  logging_query_plugin_deinit,
 
428
  NULL,   /* status variables */
 
429
  logging_query_system_variables,
 
430
  NULL
347
431
}
348
432
DRIZZLE_DECLARE_PLUGIN_END;