22 #include <plugin/schema_dictionary/dictionary.h>
23 #include <drizzled/identifier.h>
24 #include <drizzled/table_proto.h>
27 using namespace drizzled;
29 static const string STANDARD(
"STANDARD");
30 static const string TEMPORARY(
"TEMPORARY");
31 static const string INTERNAL(
"INTERNAL");
32 static const string FUNCTION(
"FUNCTION");
35 static const string VARCHAR(
"VARCHAR");
36 static const string DOUBLE(
"DOUBLE");
37 static const string BLOB(
"BLOB");
38 static const string ENUM(
"ENUM");
39 static const string INTEGER(
"INTEGER");
40 static const string BIGINT(
"BIGINT");
41 static const string DECIMAL(
"DECIMAL");
42 static const string DATE(
"DATE");
43 static const string TIMESTAMP(
"TIMESTAMP");
44 static const string DATETIME(
"DATETIME");
46 TablesTool::TablesTool() :
47 plugin::TableFunction(
"DATA_DICTIONARY",
"TABLES")
49 add_field(
"TABLE_SCHEMA", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
50 add_field(
"TABLE_NAME", plugin::TableFunction::STRING, MAXIMUM_IDENTIFIER_LENGTH,
false);
51 add_field(
"TABLE_TYPE");
52 add_field(
"TABLE_ARCHETYPE");
54 add_field(
"ROW_FORMAT", 10);
55 add_field(
"TABLE_COLLATION");
56 add_field(
"TABLE_CREATION_TIME");
57 add_field(
"TABLE_UPDATE_TIME");
58 add_field(
"TABLE_COMMENT", plugin::TableFunction::STRING,
59 TABLE_COMMENT_MAXLEN,
true);
60 add_field(
"AUTO_INCREMENT", plugin::TableFunction::NUMBER, 0,
false);
61 add_field(
"TABLE_UUID", plugin::TableFunction::STRING, 36,
true);
62 add_field(
"TABLE_VERSION", plugin::TableFunction::NUMBER, 0,
true);
63 add_field(
"IS_REPLICATED", plugin::TableFunction::BOOLEAN, 0,
false);
64 add_field(
"TABLE_DEFINER", plugin::TableFunction::STRING, 64,
true);
67 TablesTool::Generator::Generator(
Field **arg) :
68 plugin::TableFunction::Generator(arg),
69 all_tables_generator(getSession())
73 bool TablesTool::Generator::nextTable()
75 drizzled::message::table::shared_ptr table_ptr;
76 while ((table_ptr= all_tables_generator))
78 table_message.CopyFrom(*table_ptr);
85 bool TablesTool::Generator::populate()
104 push(getTableMessage().schema());
107 push(getTableMessage().name());
110 if (drizzled::identifier::Table::isView(getTableMessage().type()))
121 switch (getTableMessage().type())
124 case message::Table::STANDARD:
127 case message::Table::TEMPORARY:
130 case message::Table::INTERNAL:
133 case message::Table::FUNCTION:
144 bool row_format_sent=
false;
145 for (ssize_t it= 0; it < engine.options_size(); it++)
148 if (opt.name().compare(
"ROW_FORMAT") == 0)
150 row_format_sent=
true;
156 if (not row_format_sent)
160 push(getTableMessage().options().collation());
163 time_t time_arg= getTableMessage().creation_timestamp();
167 localtime_r(&time_arg, &tm_buffer);
168 strftime(buffer,
sizeof(buffer),
"%a %b %d %H:%M:%S %Y", &tm_buffer);
172 time_arg= getTableMessage().update_timestamp();
173 localtime_r(&time_arg, &tm_buffer);
174 strftime(buffer,
sizeof(buffer),
"%a %b %d %H:%M:%S %Y", &tm_buffer);
178 if (getTableMessage().options().has_comment())
180 push(getTableMessage().options().comment());
188 push(getTableMessage().options().auto_increment_value());
191 push(getTableMessage().uuid());
194 push(getTableMessage().version());
197 push(message::is_replicated(getTableMessage()));
200 if (message::has_definer(getTableMessage()))
202 push(message::definer(getTableMessage()));