1273.13.5
by Brian Aker
Additional definitions. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2010 Sun Microsystems
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
20 |
||
1273.14.5
by Monty Taylor
Merged trunk. |
21 |
#include "config.h" |
1273.13.49
by Brian Aker
Does not work (compile issue in plugin). |
22 |
#include "plugin/schema_dictionary/dictionary.h" |
1273.13.5
by Brian Aker
Additional definitions. |
23 |
|
24 |
using namespace std; |
|
25 |
using namespace drizzled; |
|
26 |
||
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
27 |
SchemasTool::SchemasTool() : |
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
28 |
plugin::TableFunction("DATA_DICTIONARY", "SCHEMAS") |
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
29 |
{
|
30 |
add_field("SCHEMA_NAME"); |
|
31 |
add_field("DEFAULT_COLLATION_NAME"); |
|
1340.1.4
by Brian Aker
A first pass through adding a timestamp to our proto. |
32 |
add_field("SCHEMA_CREATION_TIME"); |
33 |
add_field("SCHEMA_UPDATE_TIME"); |
|
1802.12.1
by Brian Aker
This solves bug lp:654905 |
34 |
add_field("SCHEMA_UUID", plugin::TableFunction::STRING, 36, true); |
35 |
add_field("SCHEMA_VERSION", plugin::TableFunction::NUMBER, 0, true); |
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
36 |
add_field("SCHEMA_USE_COUNT", plugin::TableFunction::NUMBER, 0, true); |
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
37 |
}
|
38 |
||
39 |
SchemasTool::Generator::Generator(Field **arg) : |
|
1273.13.32
by Brian Aker
Big ole patch. This covers moving information_schema to old_* table names |
40 |
plugin::TableFunction::Generator(arg), |
1643.3.1
by Brian Aker
Move schema listing logic out. |
41 |
schema_generator(getSession()) |
42 |
{
|
|
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
43 |
}
|
44 |
||
1273.13.36
by Brian Aker
Adding support for LOCAL_TABLE_NAMES and SCHEMA_NAMES |
45 |
bool SchemasTool::Generator::nextSchema() |
46 |
{
|
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
47 |
drizzled::message::SchemaPtr schema_ptr; |
1643.3.1
by Brian Aker
Move schema listing logic out. |
48 |
while ((schema_ptr= schema_generator)) |
1273.13.36
by Brian Aker
Adding support for LOCAL_TABLE_NAMES and SCHEMA_NAMES |
49 |
{
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
50 |
schema= schema_ptr; |
1643.3.1
by Brian Aker
Move schema listing logic out. |
51 |
return true; |
1273.13.36
by Brian Aker
Adding support for LOCAL_TABLE_NAMES and SCHEMA_NAMES |
52 |
}
|
53 |
||
1643.3.1
by Brian Aker
Move schema listing logic out. |
54 |
return false; |
1273.13.36
by Brian Aker
Adding support for LOCAL_TABLE_NAMES and SCHEMA_NAMES |
55 |
}
|
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
56 |
|
57 |
||
1273.13.21
by Brian Aker
Fix interface (we no longer need Fields passed around). |
58 |
bool SchemasTool::Generator::populate() |
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
59 |
{
|
60 |
if (nextSchema()) |
|
61 |
{
|
|
62 |
fill(); |
|
63 |
return true; |
|
64 |
}
|
|
65 |
||
66 |
return false; |
|
67 |
}
|
|
68 |
||
69 |
/**
|
|
70 |
A lack of a parsed schema file means we are using defaults.
|
|
71 |
*/
|
|
72 |
void SchemasTool::Generator::fill() |
|
73 |
{
|
|
74 |
/* SCHEMA_NAME */
|
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
75 |
push(schema->name()); |
1273.13.18
by Brian Aker
Update code, first pass through cleaner method for recursing through |
76 |
|
77 |
/* DEFAULT_COLLATION_NAME */
|
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
78 |
push(schema->collation()); |
1340.1.4
by Brian Aker
A first pass through adding a timestamp to our proto. |
79 |
|
80 |
/* SCHEMA_CREATION_TIME */
|
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
81 |
time_t time_arg= schema->creation_timestamp(); |
1340.1.4
by Brian Aker
A first pass through adding a timestamp to our proto. |
82 |
char buffer[40]; |
83 |
struct tm tm_buffer; |
|
84 |
||
85 |
localtime_r(&time_arg, &tm_buffer); |
|
86 |
strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer); |
|
87 |
push(buffer); |
|
88 |
||
89 |
/* SCHEMA_UPDATE_TIME */
|
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
90 |
time_arg= schema->update_timestamp(); |
1340.1.4
by Brian Aker
A first pass through adding a timestamp to our proto. |
91 |
localtime_r(&time_arg, &tm_buffer); |
92 |
strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer); |
|
93 |
push(buffer); |
|
1802.12.1
by Brian Aker
This solves bug lp:654905 |
94 |
|
95 |
/* SCHEMA_UUID */
|
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
96 |
push(schema->uuid()); |
1802.12.1
by Brian Aker
This solves bug lp:654905 |
97 |
|
98 |
/* SCHEMA_VERSION */
|
|
1812.3.8
by Brian Aker
This switches our schema system over to using a shared ptr. Lets see how |
99 |
push(schema->version()); |
100 |
||
101 |
/* SCHEMA_USE_COUNT */
|
|
102 |
push(schema->version()); |
|
1273.13.13
by Brian Aker
Clean up schemata |
103 |
}
|