~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/table_function.h

Merge Joe, plus I updated the tests.

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, Inc.
 
6
 *  Copyright (C) 2010 Sun Microsystems
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/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"
35
35
#include <set>
36
36
#include <algorithm>
37
37
 
38
 
#include "drizzled/visibility.h"
39
 
 
40
38
namespace drizzled
41
39
{
42
40
 
 
41
extern int wild_case_compare(const CHARSET_INFO * const cs, 
 
42
                             const char *str,const char *wildstr);
 
43
 
43
44
namespace plugin
44
45
{
45
46
 
46
 
#define TABLE_FUNCTION_BLOB_SIZE 2049
47
 
 
48
47
// Not thread safe, but plugins are just loaded in a single thread right
49
48
// now.
50
49
static const char *local_string_append(const char *arg1, const char *arg2)
60
59
  return buffer;
61
60
}
62
61
 
63
 
class DRIZZLED_API TableFunction : public Plugin
 
62
class TableFunction : public Plugin
64
63
{
65
64
  TableFunction();
66
65
  TableFunction(const TableFunction &);
67
66
  TableFunction& operator=(const TableFunction &);
68
67
 
69
68
  message::Table proto;
70
 
  identifier::Table identifier;
 
69
  TableIdentifier identifier;
71
70
  std::string local_path;
 
71
  std::string local_schema;
 
72
  std::string local_table_name;
72
73
  std::string original_table_label;
73
74
 
74
75
  void setName(); // init name
75
76
 
76
77
  void init();
77
78
 
78
 
 
79
79
public:
80
80
  TableFunction(const char *schema_arg, const char *table_arg) :
81
81
    Plugin(local_string_append(schema_arg, table_arg) , "TableFunction"),
98
98
    BOOLEAN,
99
99
    NUMBER,
100
100
    STRING,
101
 
    VARBINARY,
102
 
    SIZE
 
101
    VARBINARY
103
102
  };
104
103
 
105
104
  class Generator 
154
153
 
155
154
  const std::string &getIdentifierTableName()
156
155
  { 
157
 
    return identifier.getTableName();
 
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;
158
164
  }
159
165
 
160
166
  const std::string &getSchemaHome()
161
167
  { 
162
 
    return identifier.getSchemaName();
 
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;
163
176
  }
164
177
 
165
178
  const std::string &getPath()
166
179
  { 
167
 
    return identifier.getPath();
 
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;
168
188
  }
169
189
 
170
190
  virtual Generator *generator(Field **arg);
184
204
                 TableFunction::ColumnType type,
185
205
                 uint32_t field_length,
186
206
                 bool is_default_null= false);
187
 
 
188
 
  virtual bool visable() { return true; }
189
207
};
190
208
 
191
209
} /* namespace plugin */