~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/shutdown_function/shutdown.cc

Renamed more stuff to drizzle.

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
 
#define SHUTDOWN_MESSAGE "Beginning shutdown"
16
 
 
17
 
class Shutdown :public Item_str_func
18
 
{
19
 
public:
20
 
  Shutdown() :
21
 
    Item_str_func()
22
 
  { }
23
 
 
24
 
 
25
 
  void fix_length_and_dec()
26
 
  {
27
 
    max_length= sizeof(SHUTDOWN_MESSAGE) * system_charset_info->mbmaxlen;
28
 
    maybe_null= true;
29
 
  }
30
 
  const char *func_name() const { return "shutdown"; }
31
 
  const char *fully_qualified_func_name() const { return "shutdown()"; }
32
 
 
33
 
  String *val_str(String *str)
34
 
  {
35
 
    kill_drizzle();
36
 
 
37
 
    str->copy(SHUTDOWN_MESSAGE, sizeof(SHUTDOWN_MESSAGE) -1, system_charset_info);
38
 
 
39
 
    return str;
40
 
  }
41
 
};
42
 
 
43
 
static int initialize(drizzled::module::Context &context)
44
 
{
45
 
  context.add(new plugin::Create_function<Shutdown>("shutdown"));
46
 
  return 0;
47
 
}
48
 
 
49
 
DRIZZLE_DECLARE_PLUGIN
50
 
{
51
 
  DRIZZLE_VERSION_ID,
52
 
  "shutdown",
53
 
  "1.0",
54
 
  "Brian Aker",
55
 
  "Cause the database to shutdown.",
56
 
  PLUGIN_LICENSE_BSD,
57
 
  initialize, /* Plugin Init */
58
 
  NULL,   /* system variables */
59
 
  NULL    /* config options */
60
 
}
61
 
DRIZZLE_DECLARE_PLUGIN_END;