~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/data_engine/tables.h

  • Committer: Monty Taylor
  • Date: 2010-02-05 08:11:15 UTC
  • mfrom: (1283 build)
  • mto: (1273.13.43 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: mordred@inaugust.com-20100205081115-dr82nvrwv4lvw7sd
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef PLUGIN_SCHEMA_DICTIONARY_TABLES_H
22
 
#define PLUGIN_SCHEMA_DICTIONARY_TABLES_H
 
21
#ifndef PLUGIN_DATA_ENGINE_TABLES_H
 
22
#define PLUGIN_DATA_ENGINE_TABLES_H
23
23
 
24
 
class TablesTool : public drizzled::plugin::TableFunction
 
24
class TablesTool : public SchemasTool
25
25
{
26
26
public:
27
27
 
28
28
  TablesTool();
29
29
 
30
30
  TablesTool(const char *schema_arg, const char *table_arg) :
31
 
    drizzled::plugin::TableFunction(schema_arg, table_arg)
 
31
    SchemasTool(schema_arg, table_arg)
32
32
  { }
33
33
 
34
34
  TablesTool(const char *table_arg) :
35
 
    drizzled::plugin::TableFunction("DATA_DICTIONARY", table_arg)
 
35
    SchemasTool(table_arg)
36
36
  { }
37
37
 
38
 
  class Generator : public drizzled::plugin::TableFunction::Generator 
 
38
  class Generator : public SchemasTool::Generator 
39
39
  {
40
 
    drizzled::generator::AllTables all_tables_generator;
41
 
    drizzled::message::Table table_message;
 
40
    drizzled::message::Table table_proto;
 
41
    std::set<std::string> table_names;
 
42
    std::set<std::string>::iterator table_iterator;
 
43
    bool is_tables_primed;
42
44
 
43
45
    virtual void fill();
 
46
    bool nextTableCore();
44
47
 
45
48
  public:
46
49
    Generator(drizzled::Field **arg);
47
50
 
48
 
    bool nextTable();
 
51
    void pushRow(drizzled::message::Table::TableOptions::RowType type);
49
52
 
50
53
    const std::string &table_name()
51
54
    {
52
 
      return table_message.name();
 
55
      return (*table_iterator);
53
56
    }
54
57
 
55
58
    const drizzled::message::Table& getTableProto()
56
59
    {
57
 
      return table_message;
58
 
    }
59
 
 
60
 
    const drizzled::message::Table& getTableMessage()
61
 
    {
62
 
      return table_message;
 
60
      return table_proto;
63
61
    }
64
62
 
65
63
    bool isTablesPrimed()
66
64
    {
67
 
      return true;
 
65
      return is_tables_primed;
68
66
    }
69
67
 
70
68
    bool populate();
71
 
  };
72
 
 
73
 
  Generator *generator(drizzled::Field **arg)
74
 
  {
75
 
    return new Generator(arg);
76
 
  }
77
 
 
78
 
};
79
 
 
80
 
#endif /* PLUGIN_SCHEMA_DICTIONARY_TABLES_H */
 
69
    bool nextTable();
 
70
    bool checkTableName();
 
71
  };
 
72
 
 
73
  Generator *generator(drizzled::Field **arg)
 
74
  {
 
75
    return new Generator(arg);
 
76
  }
 
77
 
 
78
};
 
79
 
 
80
class TableNames : public TablesTool
 
81
{
 
82
public:
 
83
  TableNames(const char *table_arg) :
 
84
    TablesTool(table_arg)
 
85
  { }
 
86
 
 
87
  TableNames() :
 
88
    TablesTool("LOCAL_TABLE_NAMES")
 
89
  {
 
90
    add_field("TABLE_NAME");
 
91
  }
 
92
 
 
93
  class Generator : public TablesTool::Generator 
 
94
  {
 
95
    void fill()
 
96
    {
 
97
      /* TABLE_NAME */
 
98
      push(table_name());
 
99
    }
 
100
 
 
101
    bool checkSchema();
 
102
 
 
103
  public:
 
104
    Generator(drizzled::Field **arg) :
 
105
      TablesTool::Generator(arg)
 
106
    { }
 
107
  };
 
108
 
 
109
  Generator *generator(drizzled::Field **arg)
 
110
  {
 
111
    return new Generator(arg);
 
112
  }
 
113
};
 
114
 
 
115
class TableStatus : public TableNames
 
116
{
 
117
public:
 
118
  TableStatus() :
 
119
    TableNames("LOCAL_TABLE_STATUS")
 
120
  {
 
121
    add_field("Name");
 
122
    add_field("Engine");
 
123
    add_field("Version");
 
124
    add_field("Row_format");
 
125
    add_field("Rows");
 
126
    add_field("Avg_row_length");
 
127
    add_field("Data_length");
 
128
    add_field("Max_data_length");
 
129
    add_field("Index_length");
 
130
    add_field("Data_free");
 
131
    add_field("Auto_increment");
 
132
    add_field("Create_time");
 
133
    add_field("Update_time");
 
134
    add_field("Check_time");
 
135
    add_field("Collation");
 
136
    add_field("Checksum");
 
137
    add_field("Create_options");
 
138
    add_field("Comment");
 
139
  }
 
140
 
 
141
  class Generator : public TableNames::Generator 
 
142
  {
 
143
    void fill()
 
144
    {
 
145
      /* Name */
 
146
      push(table_name());
 
147
 
 
148
      /* Engine */
 
149
      push(getTableProto().engine().name());
 
150
 
 
151
      /* Version */
 
152
      push(0);
 
153
 
 
154
      /* Row_format */
 
155
      pushRow(getTableProto().options().row_type());
 
156
 
 
157
      /* Rows */
 
158
      push(0);
 
159
 
 
160
      /* Avg_row_length */
 
161
      push(0);
 
162
 
 
163
      /* Data_length */
 
164
      push(0);
 
165
 
 
166
      /* Max_data_length */
 
167
      push(0);
 
168
 
 
169
      /* Index_length */
 
170
      push(0);
 
171
 
 
172
      /* Data_free */
 
173
      push(0);
 
174
 
 
175
      /* Auto_increment */
 
176
      push(0);
 
177
 
 
178
      /* Create_time */
 
179
      push(0);
 
180
 
 
181
      /* Collation */
 
182
      push(getTableProto().options().collation());
 
183
 
 
184
      /* Checksum */
 
185
      push(0);
 
186
 
 
187
      /* Create_options */
 
188
      push("");
 
189
 
 
190
      /* Comment */
 
191
      push(getTableProto().options().comment());
 
192
    }
 
193
 
 
194
  public:
 
195
    Generator(drizzled::Field **arg) :
 
196
      TableNames::Generator(arg)
 
197
    { }
 
198
  };
 
199
 
 
200
  Generator *generator(drizzled::Field **arg)
 
201
  {
 
202
    return new Generator(arg);
 
203
  }
 
204
};
 
205
 
 
206
#endif // PLUGIN_DATA_ENGINE_TABLES_H