~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/table_function.h

  • Committer: Olaf van der Spek
  • Date: 2011-02-12 18:24:24 UTC
  • mto: (2167.1.2 build) (2172.1.4 build)
  • mto: This revision was merged to the branch mainline in revision 2168.
  • Revision ID: olafvdspek@gmail.com-20110212182424-kgnm9osi7qo97at2
casts

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 *  Definitions required for TableFunction plugin
5
5
 *
6
 
 *  Copyright (C) 2010 Sun Microsystems
 
6
 *  Copyright (C) 2010 Sun Microsystems, Inc.
7
7
 *  Copyright (C) 2010 Monty Taylor
8
8
 *
9
9
 *  This program is free software; you can redistribute it and/or modify
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"
35
35
#include <set>
36
36
#include <algorithm>
37
37
 
 
38
#include "drizzled/visibility.h"
 
39
 
38
40
namespace drizzled
39
41
{
40
42
 
44
46
namespace plugin
45
47
{
46
48
 
 
49
#define TABLE_FUNCTION_BLOB_SIZE 2049
 
50
 
47
51
// Not thread safe, but plugins are just loaded in a single thread right
48
52
// now.
49
53
static const char *local_string_append(const char *arg1, const char *arg2)
59
63
  return buffer;
60
64
}
61
65
 
62
 
class TableFunction : public Plugin
 
66
class DRIZZLED_API TableFunction : public Plugin
63
67
{
64
68
  TableFunction();
65
69
  TableFunction(const TableFunction &);
66
70
  TableFunction& operator=(const TableFunction &);
67
71
 
68
72
  message::Table proto;
69
 
  TableIdentifier identifier;
 
73
  identifier::Table identifier;
70
74
  std::string local_path;
71
 
  std::string local_schema;
72
 
  std::string local_table_name;
73
75
  std::string original_table_label;
74
76
 
75
77
  void setName(); // init name
76
78
 
77
79
  void init();
78
80
 
 
81
 
79
82
public:
80
83
  TableFunction(const char *schema_arg, const char *table_arg) :
81
84
    Plugin(local_string_append(schema_arg, table_arg) , "TableFunction"),
98
101
    BOOLEAN,
99
102
    NUMBER,
100
103
    STRING,
101
 
    VARBINARY
 
104
    VARBINARY,
 
105
    SIZE
102
106
  };
103
107
 
104
108
  class Generator 
153
157
 
154
158
  const std::string &getIdentifierTableName()
155
159
  { 
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;
 
160
    return identifier.getTableName();
164
161
  }
165
162
 
166
163
  const std::string &getSchemaHome()
167
164
  { 
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;
 
165
    return identifier.getSchemaName();
176
166
  }
177
167
 
178
168
  const std::string &getPath()
179
169
  { 
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;
 
170
    return identifier.getPath();
188
171
  }
189
172
 
190
173
  virtual Generator *generator(Field **arg);
194
177
                 uint32_t length= 0);
195
178
 
196
179
  void add_field(const char *label,
197
 
                 uint32_t field_length= 64);
 
180
                 uint32_t field_length= MAXIMUM_IDENTIFIER_LENGTH);
198
181
 
199
182
  void add_field(const char *label,
200
183
                 TableFunction::ColumnType type,
204
187
                 TableFunction::ColumnType type,
205
188
                 uint32_t field_length,
206
189
                 bool is_default_null= false);
 
190
 
 
191
  virtual bool visable() { return true; }
207
192
};
208
193
 
209
194
} /* namespace plugin */