~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/table_function.h

  • Committer: Brian Aker
  • Date: 2010-11-22 00:16:44 UTC
  • mto: (1945.2.1 quick)
  • mto: This revision was merged to the branch mainline in revision 1947.
  • Revision ID: brian@tangent.org-20101122001644-pi6jv0d65e82xn38
Merge in lock refactor, this just encapsulates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <drizzled/definitions.h>
27
27
#include "drizzled/plugin.h"
28
28
#include "drizzled/plugin/plugin.h"
29
 
#include "drizzled/table_identifier.h"
 
29
#include "drizzled/identifier.h"
30
30
#include "drizzled/message/table.pb.h"
31
31
#include "drizzled/charset.h"
32
32
#include "drizzled/field.h"
44
44
namespace plugin
45
45
{
46
46
 
 
47
#define TABLE_FUNCTION_BLOB_SIZE 2049
 
48
 
47
49
// Not thread safe, but plugins are just loaded in a single thread right
48
50
// now.
49
51
static const char *local_string_append(const char *arg1, const char *arg2)
68
70
  message::Table proto;
69
71
  TableIdentifier identifier;
70
72
  std::string local_path;
71
 
  std::string local_schema;
72
 
  std::string local_table_name;
73
73
  std::string original_table_label;
74
74
 
75
75
  void setName(); // init name
76
76
 
77
77
  void init();
78
78
 
 
79
 
79
80
public:
80
81
  TableFunction(const char *schema_arg, const char *table_arg) :
81
82
    Plugin(local_string_append(schema_arg, table_arg) , "TableFunction"),
153
154
 
154
155
  const std::string &getIdentifierTableName()
155
156
  { 
156
 
    if (local_table_name.empty())
157
 
    {
158
 
      local_table_name= identifier.getTableName();
159
 
      std::transform(local_table_name.begin(), local_table_name.end(),
160
 
                     local_table_name.begin(), ::tolower);
161
 
    }
162
 
 
163
 
    return local_table_name;
 
157
    return identifier.getTableName();
164
158
  }
165
159
 
166
160
  const std::string &getSchemaHome()
167
161
  { 
168
 
    if (local_schema.empty())
169
 
    {
170
 
      local_schema= identifier.getSchemaName();
171
 
      std::transform(local_schema.begin(), local_schema.end(),
172
 
                     local_schema.begin(), ::tolower);
173
 
    }
174
 
 
175
 
    return local_schema;
 
162
    return identifier.getSchemaName();
176
163
  }
177
164
 
178
165
  const std::string &getPath()
179
166
  { 
180
 
    if (local_path.empty())
181
 
    {
182
 
      local_path= identifier.getPath();
183
 
      std::transform(local_path.begin(), local_path.end(),
184
 
                     local_path.begin(), ::tolower);
185
 
    }
186
 
 
187
 
    return local_path;
 
167
    return identifier.getPath();
188
168
  }
189
169
 
190
170
  virtual Generator *generator(Field **arg);
194
174
                 uint32_t length= 0);
195
175
 
196
176
  void add_field(const char *label,
197
 
                 uint32_t field_length= 64);
 
177
                 uint32_t field_length= MAXIMUM_IDENTIFIER_LENGTH);
198
178
 
199
179
  void add_field(const char *label,
200
180
                 TableFunction::ColumnType type,
204
184
                 TableFunction::ColumnType type,
205
185
                 uint32_t field_length,
206
186
                 bool is_default_null= false);
 
187
 
 
188
  virtual bool visable() { return true; }
207
189
};
208
190
 
209
191
} /* namespace plugin */