~drizzle-trunk/drizzle/development

584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
134.1.2 by Mark Atwood
Add hello_world() UDF
19
670.2.2 by Monty Taylor
Got rid of the rest of common_includes. Now on to server_includes.
20
#include <drizzled/server_includes.h>
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
21
#include <drizzled/slot/function.h>
584.4.6 by Monty Taylor
Moved stuff into item/
22
#include <drizzled/item/func.h>
670.1.20 by Monty Taylor
Renamed functions to function... everything else is singular.
23
#include <drizzled/function/str/strfunc.h>
134.1.2 by Mark Atwood
Add hello_world() UDF
24
942.1.12 by Monty Taylor
Converted udf_func into a factory.
25
#include <string>
26
27
using namespace std;
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
28
using namespace drizzled;
942.1.12 by Monty Taylor
Converted udf_func into a factory.
29
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
30
class Item_func_hello_world : public Item_str_func
134.1.2 by Mark Atwood
Add hello_world() UDF
31
{
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
32
public:
896.1.4 by Monty Taylor
Fixed compiler warnings.
33
  Item_func_hello_world() : Item_str_func() {}
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
34
  const char *func_name() const { return "hello_world"; }
35
  String *val_str(String* s) {
36
    s->set(STRING_WITH_LEN("Hello World!"),system_charset_info);
37
    return s;
38
  };
39
  void fix_length_and_dec() {
40
    max_length=strlen("Hello World!");
134.1.2 by Mark Atwood
Add hello_world() UDF
41
  }
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
42
};
43
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
44
plugin::Create_function<Item_func_hello_world> *hello_world_udf= NULL;
134.1.2 by Mark Atwood
Add hello_world() UDF
45
1110.1.5 by Monty Taylor
Renamed PluginRegistry to plugin::Registry.
46
static int hello_world_plugin_init(drizzled::plugin::Registry &registry)
134.1.2 by Mark Atwood
Add hello_world() UDF
47
{
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
48
  hello_world_udf=
49
    new plugin::Create_function<Item_func_hello_world>("hello_world");
50
  registry.function.add(hello_world_udf);
134.1.2 by Mark Atwood
Add hello_world() UDF
51
52
  return 0;
53
}
54
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
55
static int hello_world_plugin_deinit(drizzled::plugin::Registry &registry)
134.1.2 by Mark Atwood
Add hello_world() UDF
56
{
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
57
  registry.function.remove(hello_world_udf);
58
  delete hello_world_udf;
134.1.2 by Mark Atwood
Add hello_world() UDF
59
  return 0;
60
}
61
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
62
813.2.1 by Toru Maesaka
Renamed mysql_declare_plugin to drizzle_declare_plugin
63
drizzle_declare_plugin(hello_world)
134.1.2 by Mark Atwood
Add hello_world() UDF
64
{
65
  "hello_world",
177.4.3 by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings
66
  "1.0",
134.1.2 by Mark Atwood
Add hello_world() UDF
67
  "Mark Atwood",
68
  "Hello, world!",
69
  PLUGIN_LICENSE_GPL,
70
  hello_world_plugin_init, /* Plugin Init */
71
  hello_world_plugin_deinit, /* Plugin Deinit */
72
  NULL,   /* status variables */
73
  NULL,   /* system variables */
74
  NULL    /* config options */
75
}
813.2.2 by Toru Maesaka
Renamed mysql_declare_plugin_end to drizzle_declare_plugin_end
76
drizzle_declare_plugin_end;