~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_dictionary/schemas.cc

Removed reference to aio.h - we don't reference its use anywhere.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
21
 
#include "config.h"
22
 
#include "plugin/schema_dictionary/dictionary.h"
23
 
 
24
 
using namespace std;
25
 
using namespace drizzled;
26
 
 
27
 
SchemasTool::SchemasTool() :
28
 
  plugin::TableFunction("DATA_DICTIONARY", "SCHEMAS")
29
 
{
30
 
  add_field("SCHEMA_NAME");
31
 
  add_field("DEFAULT_COLLATION_NAME");
32
 
  add_field("SCHEMA_CREATION_TIME");
33
 
  add_field("SCHEMA_UPDATE_TIME");
34
 
}
35
 
 
36
 
SchemasTool::Generator::Generator(Field **arg) :
37
 
  plugin::TableFunction::Generator(arg),
38
 
  schema_generator(getSession())
39
 
{
40
 
}
41
 
  
42
 
bool SchemasTool::Generator::nextSchema()
43
 
{
44
 
  const drizzled::message::Schema *schema_ptr;
45
 
  while ((schema_ptr= schema_generator))
46
 
  {
47
 
    schema.CopyFrom(*schema_ptr);
48
 
    return true;
49
 
  }
50
 
 
51
 
  return false;
52
 
}
53
 
 
54
 
 
55
 
bool SchemasTool::Generator::populate()
56
 
{
57
 
  if (nextSchema())
58
 
  {
59
 
    fill();
60
 
    return true;
61
 
  }
62
 
 
63
 
  return false;
64
 
}
65
 
 
66
 
/**
67
 
  A lack of a parsed schema file means we are using defaults.
68
 
*/
69
 
void SchemasTool::Generator::fill()
70
 
{
71
 
  /* SCHEMA_NAME */
72
 
  push(schema.name());
73
 
 
74
 
  /* DEFAULT_COLLATION_NAME */
75
 
  push(schema.collation());
76
 
 
77
 
  /* SCHEMA_CREATION_TIME */
78
 
  time_t time_arg= schema.creation_timestamp();
79
 
  char buffer[40];
80
 
  struct tm tm_buffer;
81
 
 
82
 
  localtime_r(&time_arg, &tm_buffer);
83
 
  strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer);
84
 
  push(buffer);
85
 
 
86
 
  /* SCHEMA_UPDATE_TIME */
87
 
  time_arg= schema.update_timestamp();
88
 
  localtime_r(&time_arg, &tm_buffer);
89
 
  strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer);
90
 
  push(buffer);
91
 
}