~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/table_function.h

  • Committer: Siddharth Prakash Singh
  • Date: 2010-03-26 17:24:57 UTC
  • mto: This revision was merged to the branch mainline in revision 1425.
  • Revision ID: spsneo@spsneo-laptop-20100326172457-vni09y22ktvvefmn
some more sprintf --> snprintf

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/identifier.h"
 
29
#include "drizzled/table_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
 
 
49
47
// Not thread safe, but plugins are just loaded in a single thread right
50
48
// now.
51
49
static const char *local_string_append(const char *arg1, const char *arg2)
70
68
  message::Table proto;
71
69
  TableIdentifier identifier;
72
70
  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
 
 
80
79
public:
81
80
  TableFunction(const char *schema_arg, const char *table_arg) :
82
81
    Plugin(local_string_append(schema_arg, table_arg) , "TableFunction"),
106
105
  {
107
106
    Field **columns;
108
107
    Field **columns_iterator;
109
 
    Session *session;
110
 
 
111
 
  protected:
112
 
 
113
 
    drizzled::Session &getSession()
114
 
    {
115
 
      return *session;
116
 
    }
117
108
 
118
109
  public:
119
110
    const CHARSET_INFO *scs;
154
145
 
155
146
  const std::string &getIdentifierTableName()
156
147
  { 
157
 
    return identifier.getTableName();
 
148
    if (local_table_name.empty())
 
149
    {
 
150
      local_table_name= identifier.getTableName();
 
151
      std::transform(local_table_name.begin(), local_table_name.end(),
 
152
                     local_table_name.begin(), ::tolower);
 
153
    }
 
154
 
 
155
    return local_table_name;
158
156
  }
159
157
 
160
158
  const std::string &getSchemaHome()
161
159
  { 
162
 
    return identifier.getSchemaName();
 
160
    if (local_schema.empty())
 
161
    {
 
162
      local_schema= identifier.getSchemaName();
 
163
      std::transform(local_schema.begin(), local_schema.end(),
 
164
                     local_schema.begin(), ::tolower);
 
165
    }
 
166
 
 
167
    return local_schema;
163
168
  }
164
169
 
165
170
  const std::string &getPath()
166
171
  { 
167
 
    return identifier.getPath();
 
172
    if (local_path.empty())
 
173
    {
 
174
      local_path= identifier.getPath();
 
175
      std::transform(local_path.begin(), local_path.end(),
 
176
                     local_path.begin(), ::tolower);
 
177
    }
 
178
 
 
179
    return local_path;
168
180
  }
169
181
 
170
182
  virtual Generator *generator(Field **arg);
174
186
                 uint32_t length= 0);
175
187
 
176
188
  void add_field(const char *label,
177
 
                 uint32_t field_length= MAXIMUM_IDENTIFIER_LENGTH);
 
189
                 uint32_t field_length= 64);
178
190
 
179
191
  void add_field(const char *label,
180
192
                 TableFunction::ColumnType type,
184
196
                 TableFunction::ColumnType type,
185
197
                 uint32_t field_length,
186
198
                 bool is_default_null= false);
187
 
 
188
 
  virtual bool visable() { return true; }
189
199
};
190
200
 
191
201
} /* namespace plugin */