~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/function_engine/function.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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