~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/function_engine/function.cc

  • Committer: lbieber
  • Date: 2010-10-06 16:34:16 UTC
  • mfrom: (1816.1.3 build)
  • Revision ID: lbieber@orisndriz08-20101006163416-ea0sl59qgpglk21y
Merge Monty - Change the requirement from either libinnodb to libhaildb. Also, tied it to version 2.2
Merge Andrew - fix bug 650935: remove --compress from all clients
Merge Andrew - fix bug 653471: Add -A to drizzle client
Merge Travis - 621861 = To change C structs to C++ classes in Drizzle

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
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 |
34
37
                                  HTON_HAS_SCHEMA_DICTIONARY |
35
38
                                  HTON_SKIP_STORE_LOCK |
36
 
                                  HTON_TEMPORARY_NOT_SUPPORTED),
37
 
  information_message(new(message::Schema)),
38
 
  data_dictionary_message(new(message::Schema))
39
 
 
 
39
                                  HTON_TEMPORARY_NOT_SUPPORTED)
40
40
{
41
 
  information_message->set_name(INFORMATION_SCHEMA_IDENTIFIER.getSchemaName());
42
 
  data_dictionary_message->set_collation("utf8_general_ci");
43
 
 
44
 
  data_dictionary_message->set_name(DATA_DICTIONARY_IDENTIFIER.getSchemaName());
45
 
  data_dictionary_message->set_collation("utf8_general_ci");
46
41
}
47
42
 
48
43
 
49
 
Cursor *Function::create(Table &table)
 
44
Cursor *Function::create(TableShare &table)
50
45
{
51
46
  return new FunctionCursor(*this, table);
52
47
}
53
48
 
54
49
int Function::doGetTableDefinition(Session &,
55
 
                                   const identifier::Table &identifier,
 
50
                                   const TableIdentifier &identifier,
56
51
                                   message::Table &table_proto)
57
52
{
58
53
  drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
67
62
  return EEXIST;
68
63
}
69
64
 
70
 
void Function::doGetSchemaIdentifiers(identifier::Schema::vector& schemas)
 
65
void Function::doGetSchemaIdentifiers(SchemaIdentifiers& schemas)
71
66
{
72
67
  schemas.push_back(INFORMATION_SCHEMA_IDENTIFIER);
73
68
  schemas.push_back(DATA_DICTIONARY_IDENTIFIER);
74
69
}
75
70
 
76
 
bool Function::doGetSchemaDefinition(const identifier::Schema &schema_identifier, message::schema::shared_ptr &schema_message)
 
71
bool Function::doGetSchemaDefinition(const SchemaIdentifier &schema_identifier, message::Schema &schema_message)
77
72
{
78
 
  schema_message.reset(new message::Schema); // This should be fixed, we could just be using ones we built on startup.
79
 
 
80
73
  if (schema_identifier == INFORMATION_SCHEMA_IDENTIFIER)
81
74
  {
82
 
    schema_message= information_message;
 
75
    schema_message.set_name("information_schema");
 
76
    schema_message.set_collation("utf8_general_ci");
83
77
  }
84
78
  else if (schema_identifier == DATA_DICTIONARY_IDENTIFIER)
85
79
  {
86
 
    schema_message= data_dictionary_message;
 
80
    schema_message.set_name("data_dictionary");
 
81
    schema_message.set_collation("utf8_general_ci");
87
82
  }
88
83
  else
89
84
  {
93
88
  return true;
94
89
}
95
90
 
96
 
bool Function::doCanCreateTable(const drizzled::identifier::Table &table_identifier)
 
91
bool Function::doCanCreateTable(const drizzled::TableIdentifier &table_identifier)
97
92
{
98
 
  if (static_cast<const identifier::Schema&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
 
93
  if (static_cast<const SchemaIdentifier&>(table_identifier) == INFORMATION_SCHEMA_IDENTIFIER)
99
94
  {
100
95
    return false;
101
96
  }
102
97
 
103
 
  else if (static_cast<const identifier::Schema&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
 
98
  else if (static_cast<const SchemaIdentifier&>(table_identifier) == DATA_DICTIONARY_IDENTIFIER)
104
99
  {
105
100
    return false;
106
101
  }
108
103
  return true;
109
104
}
110
105
 
111
 
bool Function::doDoesTableExist(Session&, const identifier::Table &identifier)
 
106
bool Function::doDoesTableExist(Session&, const TableIdentifier &identifier)
112
107
{
113
108
  drizzled::plugin::TableFunction *function= getFunction(identifier.getPath());
114
109
 
120
115
 
121
116
 
122
117
void Function::doGetTableIdentifiers(drizzled::CachedDirectory&,
123
 
                                     const drizzled::identifier::Schema &schema_identifier,
124
 
                                     drizzled::identifier::Table::vector &set_of_identifiers)
 
118
                                     const drizzled::SchemaIdentifier &schema_identifier,
 
119
                                     drizzled::TableIdentifiers &set_of_identifiers)
125
120
{
126
 
  set<std::string> set_of_names;
 
121
  set<string> set_of_names;
127
122
  drizzled::plugin::TableFunction::getNames(schema_identifier.getSchemaName(), set_of_names);
128
123
 
129
 
  for (set<std::string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
 
124
  for (set<string>::iterator iter= set_of_names.begin(); iter != set_of_names.end(); iter++)
130
125
  {
131
 
    set_of_identifiers.push_back(identifier::Table(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
 
126
    set_of_identifiers.push_back(TableIdentifier(schema_identifier, *iter, drizzled::message::Table::FUNCTION));
132
127
  }
133
128
}
134
129
 
148
143
  "Function Engine provides the infrastructure for Table Functions,etc.",
149
144
  PLUGIN_LICENSE_GPL,
150
145
  init,     /* Plugin Init */
151
 
  NULL,               /* depends */
 
146
  NULL,               /* system variables */
152
147
  NULL                /* config options   */
153
148
}
154
149
DRIZZLE_DECLARE_PLUGIN_END;