~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
1241.9.36 by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h.
20
#include "config.h"
1130.1.9 by Monty Taylor
Changed some plugins from including slots to include plugins. Oops.
21
#include <drizzled/plugin/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
1530.2.6 by Monty Taylor
Moved plugin::Context to module::Context.
46
static int hello_world_plugin_init(drizzled::module::Context &context)
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");
1324.2.2 by Monty Taylor
Use the plugin::Context everywhere.
50
  context.add(hello_world_udf);
134.1.2 by Mark Atwood
Add hello_world() UDF
51
52
  return 0;
53
}
54
1228.1.5 by Monty Taylor
Merged in some naming things.
55
DRIZZLE_DECLARE_PLUGIN
134.1.2 by Mark Atwood
Add hello_world() UDF
56
{
1241.10.2 by Monty Taylor
Added support for embedding the drizzle version number in the plugin file.
57
  DRIZZLE_VERSION_ID,
134.1.2 by Mark Atwood
Add hello_world() UDF
58
  "hello_world",
177.4.3 by mark
ripped out more plugin ABI and API version checking, and plugin versions are now strings
59
  "1.0",
134.1.2 by Mark Atwood
Add hello_world() UDF
60
  "Mark Atwood",
61
  "Hello, world!",
62
  PLUGIN_LICENSE_GPL,
63
  hello_world_plugin_init, /* Plugin Init */
64
  NULL,   /* system variables */
65
  NULL    /* config options */
66
}
1228.1.5 by Monty Taylor
Merged in some naming things.
67
DRIZZLE_DECLARE_PLUGIN_END;