21
21
#include "config.h"
22
#include "plugin/schema_dictionary/dictionary.h"
23
#include <plugin/data_engine/schemas.h>
24
25
using namespace std;
25
26
using namespace drizzled;
27
28
SchemasTool::SchemasTool() :
28
DataDictionary("SCHEMAS")
29
plugin::TableFunction("DATA_DICTIONARY", "SCHEMAS")
30
31
add_field("SCHEMA_NAME");
31
32
add_field("DEFAULT_COLLATION_NAME");
32
add_field("SCHEMA_CREATION_TIME");
33
add_field("SCHEMA_UPDATE_TIME");
34
add_field("SCHEMA_UUID", plugin::TableFunction::STRING, 36, true);
35
add_field("SCHEMA_VERSION", plugin::TableFunction::NUMBER, 0, true);
36
add_field("SCHEMA_USE_COUNT", plugin::TableFunction::NUMBER, 0, true);
39
SchemasTool::Generator::Generator(drizzled::Field **arg) :
40
DataDictionary::Generator(arg),
41
schema_generator(getSession())
35
SchemasTool::Generator::Generator(Field **arg) :
36
plugin::TableFunction::Generator(arg),
37
is_schema_primed(false),
38
is_schema_parsed(false)
43
@note return true if a match occurs.
45
bool SchemasTool::Generator::checkSchema()
47
return isWild(schema_name());
50
bool SchemasTool::Generator::nextSchemaCore()
58
plugin::StorageEngine::getSchemaNames(schema_names);
59
schema_iterator= schema_names.begin();
60
is_schema_primed= true;
63
if (schema_iterator == schema_names.end())
67
is_schema_parsed= plugin::StorageEngine::getSchemaDefinition(*schema_iterator, schema);
75
bool SchemasTool::Generator::nextSchema()
77
while (not nextSchemaCore())
79
if (schema_iterator == schema_names.end())
45
87
bool SchemasTool::Generator::populate()
47
drizzled::message::schema::shared_ptr schema_ptr;
48
while ((schema_ptr= schema_generator))
51
push(schema_ptr->name());
53
/* DEFAULT_COLLATION_NAME */
54
push(schema_ptr->collation());
56
/* SCHEMA_CREATION_TIME */
57
time_t time_arg= schema_ptr->creation_timestamp();
61
localtime_r(&time_arg, &tm_buffer);
62
strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer);
65
/* SCHEMA_UPDATE_TIME */
66
time_arg= schema_ptr->update_timestamp();
67
localtime_r(&time_arg, &tm_buffer);
68
strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer);
72
push(schema_ptr->uuid());
75
push(schema_ptr->version());
77
/* SCHEMA_USE_COUNT */
78
push(schema_ptr->version());
99
A lack of a parsed schema file means we are using defaults.
101
void SchemasTool::Generator::fill()
106
/* DEFAULT_COLLATION_NAME */
107
if (is_schema_parsed)
108
push(schema.collation());