~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
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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.
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
2173.2.1 by Monty Taylor
Fixes incorrect usage of include
20
#include <config.h>
2148.7.12 by Brian Aker
Merge in header fixes.
21
22
#include <drizzled/function/str/strfunc.h>
23
#include <drizzled/item/func.h>
24
#include <drizzled/plugin.h>
1130.1.9 by Monty Taylor
Changed some plugins from including slots to include plugins. Oops.
25
#include <drizzled/plugin/function.h>
134.1.2 by Mark Atwood
Add hello_world() UDF
26
942.1.12 by Monty Taylor
Converted udf_func into a factory.
27
#include <string>
28
29
using namespace std;
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
30
using namespace drizzled;
942.1.12 by Monty Taylor
Converted udf_func into a factory.
31
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
32
class Item_func_hello_world : public Item_str_func
134.1.2 by Mark Atwood
Add hello_world() UDF
33
{
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
34
public:
896.1.4 by Monty Taylor
Fixed compiler warnings.
35
  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.
36
  const char *func_name() const { return "hello_world"; }
37
  String *val_str(String* s) {
38
    s->set(STRING_WITH_LEN("Hello World!"),system_charset_info);
39
    return s;
1891.2.1 by Monty Taylor
Fixed things to make things compile with clang
40
  }
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
41
  void fix_length_and_dec() {
42
    max_length=strlen("Hello World!");
134.1.2 by Mark Atwood
Add hello_world() UDF
43
  }
139.1.8 by Stewart Smith
UDFs are now normal Item_func objects. Simplifies handling them a lot.
44
};
45
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
46
plugin::Create_function<Item_func_hello_world> *hello_world_udf= NULL;
134.1.2 by Mark Atwood
Add hello_world() UDF
47
1530.2.6 by Monty Taylor
Moved plugin::Context to module::Context.
48
static int hello_world_plugin_init(drizzled::module::Context &context)
134.1.2 by Mark Atwood
Add hello_world() UDF
49
{
1093.1.62 by Monty Taylor
Moved UDFs to slot organization.
50
  hello_world_udf=
51
    new plugin::Create_function<Item_func_hello_world>("hello_world");
1324.2.2 by Monty Taylor
Use the plugin::Context everywhere.
52
  context.add(hello_world_udf);
134.1.2 by Mark Atwood
Add hello_world() UDF
53
54
  return 0;
55
}
56
1228.1.5 by Monty Taylor
Merged in some naming things.
57
DRIZZLE_DECLARE_PLUGIN
134.1.2 by Mark Atwood
Add hello_world() UDF
58
{
1241.10.2 by Monty Taylor
Added support for embedding the drizzle version number in the plugin file.
59
  DRIZZLE_VERSION_ID,
134.1.2 by Mark Atwood
Add hello_world() UDF
60
  "hello_world",
177.4.3 by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings
61
  "1.0",
134.1.2 by Mark Atwood
Add hello_world() UDF
62
  "Mark Atwood",
63
  "Hello, world!",
64
  PLUGIN_LICENSE_GPL,
65
  hello_world_plugin_init, /* Plugin Init */
2095.3.1 by Monty Taylor
Re-purpose the old plugin sysvar slot in the struct to be a depends list.
66
  NULL,   /* depends */
134.1.2 by Mark Atwood
Add hello_world() UDF
67
  NULL    /* config options */
68
}
1228.1.5 by Monty Taylor
Merged in some naming things.
69
DRIZZLE_DECLARE_PLUGIN_END;