~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/crash_function/crash.cc

  • Committer: Brian Aker
  • Date: 2010-08-18 19:37:19 UTC
  • mto: This revision was merged to the branch mainline in revision 1720.
  • Revision ID: brian@tangent.org-20100818193719-bxxzn1pi22styowd
created function that can be used to simply crash the server.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Brian Aker
 
5
 */
 
6
 
 
7
#include "config.h"
 
8
 
 
9
#include <signal.h>
 
10
#include <drizzled/session.h>
 
11
#include <drizzled/function/str/strfunc.h>
 
12
 
 
13
using namespace drizzled;
 
14
 
 
15
class Crash :public Item_str_func
 
16
{
 
17
public:
 
18
  Crash() :
 
19
    Item_str_func()
 
20
  { }
 
21
 
 
22
 
 
23
  void fix_length_and_dec()
 
24
  {
 
25
    max_length= MAX_FIELD_NAME * system_charset_info->mbmaxlen;
 
26
    maybe_null= true;
 
27
  }
 
28
  const char *func_name() const { return "crash"; }
 
29
  const char *fully_qualified_func_name() const { return "crash()"; }
 
30
 
 
31
  String *val_str(String *str)
 
32
  {
 
33
    raise(SIGSEGV);
 
34
 
 
35
    return str;
 
36
  }
 
37
};
 
38
 
 
39
static int initialize(drizzled::module::Context &context)
 
40
{
 
41
  context.add(new plugin::Create_function<Crash>("crash"));
 
42
  return 0;
 
43
}
 
44
 
 
45
DRIZZLE_DECLARE_PLUGIN
 
46
{
 
47
  DRIZZLE_VERSION_ID,
 
48
  "crash",
 
49
  "1.0",
 
50
  "Brian Aker",
 
51
  "Cause the database to crash.",
 
52
  PLUGIN_LICENSE_BSD,
 
53
  initialize, /* Plugin Init */
 
54
  NULL,   /* system variables */
 
55
  NULL    /* config options */
 
56
}
 
57
DRIZZLE_DECLARE_PLUGIN_END;