~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/function_engine/function.cc

  • Committer: Brian Aker
  • Date: 2010-02-14 02:02:48 UTC
  • mfrom: (1273.13.64 fix_is)
  • Revision ID: brian@gaz-20100214020248-bhovaejhz9fmer3q
MergeĀ inĀ data_dictionary.

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 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; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
#include "config.h"
 
22
 
 
23
#include <plugin/function_engine/function.h>
 
24
#include <plugin/function_engine/cursor.h>
 
25
 
 
26
#include <string>
 
27
 
 
28
using namespace std;
 
29
using namespace drizzled;
 
30
 
 
31
Function::Function(const std::string &name_arg) :
 
32
  drizzled::plugin::StorageEngine(name_arg,
 
33
                                  HTON_ALTER_NOT_SUPPORTED |
 
34
                                  HTON_HAS_DATA_DICTIONARY |
 
35
                                  HTON_SKIP_STORE_LOCK |
 
36
                                  HTON_TEMPORARY_NOT_SUPPORTED)
 
37
{
 
38
}
 
39
 
 
40
 
 
41
Cursor *Function::create(TableShare &table, memory::Root *mem_root)
 
42
{
 
43
  return new (mem_root) FunctionCursor(*this, table);
 
44
}
 
45
 
 
46
int Function::doGetTableDefinition(Session &,
 
47
                                     const char *path,
 
48
                                     const char *,
 
49
                                     const char *,
 
50
                                     const bool,
 
51
                                     message::Table *table_proto)
 
52
{
 
53
  string tab_name(path);
 
54
  transform(tab_name.begin(), tab_name.end(),
 
55
            tab_name.begin(), ::tolower);
 
56
 
 
57
  drizzled::plugin::TableFunction *function= getFunction(tab_name);
 
58
 
 
59
  if (not function)
 
60
  {
 
61
    return ENOENT;
 
62
  }
 
63
 
 
64
  if (table_proto)
 
65
  {
 
66
    function->define(*table_proto);
 
67
  }
 
68
 
 
69
  return EEXIST;
 
70
}
 
71
 
 
72
 
 
73
void Function::doGetTableNames(drizzled::CachedDirectory&, 
 
74
                               string &db, 
 
75
                               set<string> &set_of_names)
 
76
{
 
77
  drizzled::plugin::TableFunction::getNames(db, set_of_names);
 
78
}
 
79
 
 
80
 
 
81
static drizzled::plugin::StorageEngine *function_plugin= NULL;
 
82
 
 
83
static int init(drizzled::plugin::Registry &registry)
 
84
{
 
85
  function_plugin= new(std::nothrow) Function("FunctionEngine");
 
86
 
 
87
  if (not function_plugin)
 
88
  {
 
89
    return 1;
 
90
  }
 
91
 
 
92
  registry.add(function_plugin);
 
93
 
 
94
  return 0;
 
95
}
 
96
 
 
97
static int finalize(drizzled::plugin::Registry &registry)
 
98
{
 
99
  registry.remove(function_plugin);
 
100
  delete function_plugin;
 
101
 
 
102
  return 0;
 
103
}
 
104
 
 
105
DRIZZLE_DECLARE_PLUGIN
 
106
{
 
107
  DRIZZLE_VERSION_ID,
 
108
  "FunctionEngine",
 
109
  "1.0",
 
110
  "Brian Aker",
 
111
  "Function Engine provides the infrastructure for Table Functions,etc.",
 
112
  PLUGIN_LICENSE_GPL,
 
113
  init,     /* Plugin Init */
 
114
  finalize,     /* Plugin Deinit */
 
115
  NULL,               /* status variables */
 
116
  NULL,               /* system variables */
 
117
  NULL                /* config options   */
 
118
}
 
119
DRIZZLE_DECLARE_PLUGIN_END;