~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to drizzled/plugin/table_function.h

  • Committer: Padraig O'Sullivan
  • Date: 2010-04-17 01:38:47 UTC
  • mfrom: (1237.9.238 bad-staging)
  • Revision ID: osullivan.padraig@gmail.com-20100417013847-ibjioqsfbmf5yg4g
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
namespace plugin
45
45
{
46
46
 
 
47
// Not thread safe, but plugins are just loaded in a single thread right
 
48
// now.
 
49
static const char *local_string_append(const char *arg1, const char *arg2)
 
50
{
 
51
  static char buffer[1024];
 
52
  char *buffer_ptr= buffer;
 
53
  strcpy(buffer_ptr, arg1);
 
54
  buffer_ptr+= strlen(arg1);
 
55
  buffer_ptr[0]= '-';
 
56
  buffer_ptr++;
 
57
  strcpy(buffer_ptr, arg2);
 
58
 
 
59
  return buffer;
 
60
}
47
61
 
48
62
class TableFunction : public Plugin
49
63
{
55
69
  TableIdentifier identifier;
56
70
  std::string local_path;
57
71
  std::string local_schema;
 
72
  std::string local_table_name;
 
73
  std::string original_table_label;
58
74
 
59
75
  void setName(); // init name
60
76
 
62
78
 
63
79
public:
64
80
  TableFunction(const char *schema_arg, const char *table_arg) :
65
 
    Plugin(table_arg, "TableFunction"),
66
 
    identifier(schema_arg, table_arg)
 
81
    Plugin(local_string_append(schema_arg, table_arg) , "TableFunction"),
 
82
    identifier(schema_arg, table_arg),
 
83
    original_table_label(table_arg)
67
84
  {
68
85
    init();
69
86
  }
80
97
  enum ColumnType {
81
98
    BOOLEAN,
82
99
    NUMBER,
83
 
    STRING
 
100
    STRING,
 
101
    VARBINARY
84
102
  };
85
103
 
86
104
  class Generator 
87
105
  {
88
106
    Field **columns;
89
107
    Field **columns_iterator;
 
108
    Session *session;
 
109
 
 
110
  protected:
 
111
 
 
112
    drizzled::Session &getSession()
 
113
    {
 
114
      return *session;
 
115
    }
90
116
 
91
117
  public:
92
118
    const CHARSET_INFO *scs;
120
146
    arg.CopyFrom(proto);
121
147
  }
122
148
 
 
149
  const std::string &getTableLabel()
 
150
  { 
 
151
    return original_table_label;
 
152
  }
 
153
 
 
154
  const std::string &getIdentifierTableName()
 
155
  { 
 
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;
 
164
  }
 
165
 
123
166
  const std::string &getSchemaHome()
124
167
  { 
125
 
    if (local_schema.length() == 0)
 
168
    if (local_schema.empty())
126
169
    {
127
170
      local_schema= identifier.getSchemaName();
128
171
      std::transform(local_schema.begin(), local_schema.end(),
134
177
 
135
178
  const std::string &getPath()
136
179
  { 
137
 
    if (local_path.length() == 0)
 
180
    if (local_path.empty())
138
181
    {
139
182
      local_path= identifier.getPath();
140
183
      std::transform(local_path.begin(), local_path.end(),