~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/table_function.cc

  • Committer: Monty Taylor
  • Date: 2010-05-15 18:23:34 UTC
  • mto: (1530.6.1)
  • mto: This revision was merged to the branch mainline in revision 1556.
  • Revision ID: mordred@inaugust.com-20100515182334-bgbmwij0mioklajx
Renamed classes that were in drizzled::plugin but which were not meant
for consumption by plugin authors to drizzled::module - since they
really have to do with plugin module loading. This way when we
look in drizzled/plugin, we see nothing but plugin interfaces. Win.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#include <vector>
30
30
 
 
31
using namespace std;
 
32
 
31
33
namespace drizzled
32
34
{
33
35
 
35
37
 
36
38
void plugin::TableFunction::init()
37
39
{
38
 
  drizzled::message::Engine *engine;
 
40
  drizzled::message::Table::StorageEngine *engine;
39
41
  drizzled::message::Table::TableOptions *table_options;
40
42
 
41
43
  proto.set_name(getTableLabel());
59
61
  return false;
60
62
}
61
63
 
62
 
plugin::TableFunction *plugin::TableFunction::getFunction(const std::string &arg)
 
64
plugin::TableFunction *plugin::TableFunction::getFunction(const string &arg)
63
65
{
64
66
  return table_functions.getFunction(arg);
65
67
}
66
68
 
67
 
void plugin::TableFunction::getNames(const std::string &arg,
68
 
                                     std::set<std::string> &set_of_names)
 
69
void plugin::TableFunction::getNames(const string &arg,
 
70
                                     set<std::string> &set_of_names)
69
71
{
70
72
  table_functions.getNames(arg, set_of_names);
71
73
}
89
91
}
90
92
 
91
93
void plugin::TableFunction::add_field(const char *label,
92
 
                                      TableFunction::ColumnType type,
93
 
                                      uint32_t field_length,
94
 
                                      bool is_default_null)
 
94
                              TableFunction::ColumnType type,
 
95
                              uint32_t field_length,
 
96
                              bool is_default_null)
95
97
{
96
98
  drizzled::message::Table::Field *field;
97
99
  drizzled::message::Table::Field::FieldOptions *field_options;
113
115
    field_options->set_default_null(false);
114
116
    field_constraints->set_is_nullable(false);
115
117
  case TableFunction::STRING:
116
 
    {
117
 
      drizzled::message::Table::Field::StringFieldOptions *string_field_options;
118
 
      if (field_length >= TABLE_FUNCTION_BLOB_SIZE)
119
 
      {
120
 
        field->set_type(drizzled::message::Table::Field::BLOB);
121
 
        string_field_options= field->mutable_string_options();
122
 
        string_field_options->set_collation_id(default_charset_info->number);
123
 
        string_field_options->set_collation(default_charset_info->name);
124
 
      }
125
 
      else
126
 
      {
127
 
        field->set_type(drizzled::message::Table::Field::VARCHAR);
128
 
        string_field_options= field->mutable_string_options();
129
 
        string_field_options->set_length(field_length);
130
 
      }
131
 
    }
 
118
  {
 
119
    drizzled::message::Table::Field::StringFieldOptions *string_field_options;
 
120
    field->set_type(drizzled::message::Table::Field::VARCHAR);
 
121
 
 
122
    string_field_options= field->mutable_string_options();
 
123
    string_field_options->set_length(field_length);
 
124
  }
132
125
    break;
133
126
  case TableFunction::VARBINARY:
134
 
    {
135
 
      drizzled::message::Table::Field::StringFieldOptions *string_field_options;
136
 
      field->set_type(drizzled::message::Table::Field::VARCHAR);
 
127
  {
 
128
    drizzled::message::Table::Field::StringFieldOptions *string_field_options;
 
129
    field->set_type(drizzled::message::Table::Field::VARCHAR);
137
130
 
138
 
      string_field_options= field->mutable_string_options();
139
 
      string_field_options->set_length(field_length);
140
 
      string_field_options->set_collation(my_charset_bin.csname);
141
 
      string_field_options->set_collation_id(my_charset_bin.number);
142
 
    }
 
131
    string_field_options= field->mutable_string_options();
 
132
    string_field_options->set_length(field_length);
 
133
    string_field_options->set_collation(my_charset_bin.csname);
 
134
    string_field_options->set_collation_id(my_charset_bin.number);
 
135
  }
143
136
    break;
144
137
  case TableFunction::NUMBER: // Currently NUMBER always has a value
145
138
    field->set_type(drizzled::message::Table::Field::BIGINT);
 
139
    field_options->set_default_null(false);
 
140
    field_constraints->set_is_nullable(false);
146
141
    break;
147
142
  }
148
143
}
192
187
  assert(arg);
193
188
  length= length ? length : strlen(arg);
194
189
 
195
 
  if ((*columns_iterator)->char_length() < length)
196
 
    length= (*columns_iterator)->char_length();
197
 
 
198
190
  (*columns_iterator)->store(arg, length, scs);
199
191
  (*columns_iterator)->set_notnull();
200
192
  columns_iterator++;
202
194
 
203
195
void plugin::TableFunction::Generator::push()
204
196
{
205
 
  /* Only accept NULLs */
206
 
  assert((*columns_iterator)->maybe_null());
 
197
  assert((*columns_iterator)->type()  == DRIZZLE_TYPE_VARCHAR);
207
198
  (*columns_iterator)->set_null();
208
199
  columns_iterator++;
209
200
}
217
208
{
218
209
  if (arg)
219
210
  {
220
 
    (*columns_iterator)->store("YES", 3, scs);
 
211
    (*columns_iterator)->store("TRUE", 4, scs);
221
212
  }
222
213
  else
223
214
  {
224
 
    (*columns_iterator)->store("NO", 2, scs);
 
215
    (*columns_iterator)->store("FALSE", 5, scs);
225
216
  }
226
217
 
227
218
  columns_iterator++;