~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/function_engine/function.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 06:12:02 UTC
  • mfrom: (2190.1.6 drizzle-build)
  • Revision ID: brian@tangent.org-20110222061202-k03czxykqy4x9hjs
List update, header fixes, multiple symbols, and David deletes some code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2010 Sun Microsystems
 
4
 *  Copyright (C) 2010 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
 
21
#include <config.h>
22
22
 
23
23
#include <plugin/function_engine/function.h>
24
24
#include <plugin/function_engine/cursor.h>
28
28
using namespace std;
29
29
using namespace drizzled;
30
30
 
31
 
static SchemaIdentifier INFORMATION_SCHEMA_IDENTIFIER("INFORMATION_SCHEMA");
32
 
static SchemaIdentifier DATA_DICTIONARY_IDENTIFIER("DATA_DICTIONARY");
33
 
 
34
31
Function::Function(const std::string &name_arg) :
35
32
  drizzled::plugin::StorageEngine(name_arg,
36
33
                                  HTON_ALTER_NOT_SUPPORTED |
41
38
  data_dictionary_message(new(message::Schema))
42
39
 
43
40
{
44
 
  information_message->set_name("information_schema");
45
 
  data_dictionary_message->set_collation("utf8_general_ci");
 
41
  information_message->set_name(INFORMATION_SCHEMA_IDENTIFIER.getSchemaName());
 
42
  information_message->set_collation("utf8_general_ci");
 
43
  information_message->mutable_replication_options()->set_dont_replicate(true);
46
44
 
47
 
  data_dictionary_message->set_name("data_dictionary");
 
45
  data_dictionary_message->set_name(DATA_DICTIONARY_IDENTIFIER.getSchemaName());
48
46
  data_dictionary_message->set_collation("utf8_general_ci");
 
47
  data_dictionary_message->mutable_replication_options()->set_dont_replicate(true);
49
48
}
50
49
 
51
50
 
55
54
}
56
55
 
57
56
int Function::doGetTableDefinition(Session &,
58
 
                                   const TableIdentifier &identifier,
 
57
                                   const identifier::Table &identifier,
59
58
                                   message::Table &table_proto)
60
59
{
61
60
  drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
70
69
  return EEXIST;
71
70
}
72
71
 
73
 
void Function::doGetSchemaIdentifiers(SchemaIdentifiers& schemas)
 
72
void Function::doGetSchemaIdentifiers(identifier::Schema::vector& schemas)
74
73
{
75
74
  schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
76
75
  schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
77
76
}
78
77
 
79
 
bool Function::doGetSchemaDefinition(const SchemaIdentifier &schema_identifier, message::SchemaPtr &schema_message)
 
78
drizzled::message::schema::shared_ptr Function::doGetSchemaDefinition(const identifier::Schema &schema_identifier)
80
79
{
81
 
  schema_message.reset(new message::Schema); // This should be fixed, we could just be using ones we built on startup.
 
80
  drizzled::message::schema::shared_ptr schema_message;
82
81
 
83
82
  if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
84
83
  {
90
89
  }
91
90
  else
92
91
  {
93
 
    return false;
 
92
    return drizzled::message::schema::shared_ptr();
94
93
  }
95
94
 
96
 
  return true;
 
95
  return schema_message;
97
96
}
98
97
 
99
 
bool Function::doCanCreateTable(const drizzled::TableIdentifier &table_identifier)
 
98
bool Function::doCanCreateTable(const drizzled::identifier::Table &table_identifier)
100
99
{
101
 
  if (static_cast<const SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
 
100
  if (static_cast<const identifier::Schema&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
102
101
  {
103
102
    return false;
104
103
  }
105
104
 
106
 
  else if (static_cast<const SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
 
105
  else if (static_cast<const identifier::Schema&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
107
106
  {
108
107
    return false;
109
108
  }
111
110
  return true;
112
111
}
113
112
 
114
 
bool Function::doDoesTableExist(Session&, const TableIdentifier &identifier)
 
113
bool Function::doDoesTableExist(Session&, const identifier::Table &identifier)
115
114
{
116
115
  drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
117
116
 
123
122
 
124
123
 
125
124
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
126
 
                                     const drizzled::SchemaIdentifier &schema_identifier,
127
 
                                     drizzled::TableIdentifiers &set_of_identifiers)
 
125
                                     const drizzled::identifier::Schema &schema_identifier,
 
126
                                     drizzled::identifier::Table::vector &set_of_identifiers)
128
127
{
129
 
  set<string> set_of_names;
 
128
  set<std::string> set_of_names;
130
129
  drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
131
130
 
132
 
  for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
 
131
  for (set<std::string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
133
132
  {
134
 
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
 
133
    set_of_identifiers.push_back(identifier::Table(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
135
134
  }
136
135
}
137
136
 
151
150
  "Function Engine provides the infrastructure for Table Functions,etc.",
152
151
  PLUGIN_LICENSE_GPL,
153
152
  init,     /* Plugin Init */
154
 
  NULL,               /* system variables */
 
153
  NULL,               /* depends */
155
154
  NULL                /* config options   */
156
155
}
157
156
DRIZZLE_DECLARE_PLUGIN_END;