~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/function_engine/function.cc

  • Committer: Monty Taylor
  • Date: 2010-11-08 18:26:08 UTC
  • mto: This revision was merged to the branch mainline in revision 1931.
  • Revision ID: mordred@inaugust.com-20101108182608-lci86acl7r53sbi3
Replaced auto_ptr with scoped_ptr.

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, Inc.
 
4
 *  Copyright (C) 2010 Sun Microsystems
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
 
31
34
Function::Function(const std::string &name_arg) :
32
35
  drizzled::plugin::StorageEngine(name_arg,
33
36
                                  HTON_ALTER_NOT_SUPPORTED |
38
41
  data_dictionary_message(new(message::Schema))
39
42
 
40
43
{
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);
 
44
  information_message->set_name("information_schema");
 
45
  data_dictionary_message->set_collation("utf8_general_ci");
44
46
 
45
 
  data_dictionary_message->set_name(DATA_DICTIONARY_IDENTIFIER.getSchemaName());
 
47
  data_dictionary_message->set_name("data_dictionary");
46
48
  data_dictionary_message->set_collation("utf8_general_ci");
47
 
  data_dictionary_message->mutable_replication_options()->set_dont_replicate(true);
48
49
}
49
50
 
50
51
 
54
55
}
55
56
 
56
57
int Function::doGetTableDefinition(Session &,
57
 
                                   const identifier::Table &identifier,
 
58
                                   const TableIdentifier &identifier,
58
59
                                   message::Table &table_proto)
59
60
{
60
61
  drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
69
70
  return EEXIST;
70
71
}
71
72
 
72
 
void Function::doGetSchemaIdentifiers(identifier::Schema::vector& schemas)
 
73
void Function::doGetSchemaIdentifiers(SchemaIdentifiers& schemas)
73
74
{
74
75
  schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
75
76
  schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
76
77
}
77
78
 
78
 
drizzled::message::schema::shared_ptr Function::doGetSchemaDefinition(const identifier::Schema &schema_identifier)
 
79
bool Function::doGetSchemaDefinition(const SchemaIdentifier &schema_identifier, message::SchemaPtr &schema_message)
79
80
{
80
 
  drizzled::message::schema::shared_ptr schema_message;
 
81
  schema_message.reset(new message::Schema); // This should be fixed, we could just be using ones we built on startup.
81
82
 
82
83
  if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
83
84
  {
89
90
  }
90
91
  else
91
92
  {
92
 
    return drizzled::message::schema::shared_ptr();
 
93
    return false;
93
94
  }
94
95
 
95
 
  return schema_message;
 
96
  return true;
96
97
}
97
98
 
98
 
bool Function::doCanCreateTable(const drizzled::identifier::Table &table_identifier)
 
99
bool Function::doCanCreateTable(const drizzled::TableIdentifier &table_identifier)
99
100
{
100
 
  if (static_cast<const identifier::Schema&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
 
101
  if (static_cast<const SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
101
102
  {
102
103
    return false;
103
104
  }
104
105
 
105
 
  else if (static_cast<const identifier::Schema&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
 
106
  else if (static_cast<const SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
106
107
  {
107
108
    return false;
108
109
  }
110
111
  return true;
111
112
}
112
113
 
113
 
bool Function::doDoesTableExist(Session&, const identifier::Table &identifier)
 
114
bool Function::doDoesTableExist(Session&, const TableIdentifier &identifier)
114
115
{
115
116
  drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
116
117
 
122
123
 
123
124
 
124
125
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
125
 
                                     const drizzled::identifier::Schema &schema_identifier,
126
 
                                     drizzled::identifier::Table::vector &set_of_identifiers)
 
126
                                     const drizzled::SchemaIdentifier &schema_identifier,
 
127
                                     drizzled::TableIdentifiers &set_of_identifiers)
127
128
{
128
 
  set<std::string> set_of_names;
 
129
  set<string> set_of_names;
129
130
  drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
130
131
 
131
 
  for (set<std::string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
 
132
  for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
132
133
  {
133
 
    set_of_identifiers.push_back(identifier::Table(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
 
134
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
134
135
  }
135
136
}
136
137
 
150
151
  "Function Engine provides the infrastructure for Table Functions,etc.",
151
152
  PLUGIN_LICENSE_GPL,
152
153
  init,     /* Plugin Init */
153
 
  NULL,               /* depends */
 
154
  NULL,               /* system variables */
154
155
  NULL                /* config options   */
155
156
}
156
157
DRIZZLE_DECLARE_PLUGIN_END;