~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_dictionary/schemas.cc

  • Committer: Brian Aker
  • Date: 2010-10-27 21:00:49 UTC
  • mto: This revision was merged to the branch mainline in revision 1886.
  • Revision ID: brian@tangent.org-20101027210049-zfpgx2cfbrh8maq9
A couple of fixes to documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2010 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2010 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
25
25
using namespace drizzled;
26
26
 
27
27
SchemasTool::SchemasTool() :
28
 
  DataDictionary("SCHEMAS")
 
28
  plugin::TableFunction("DATA_DICTIONARY", "SCHEMAS")
29
29
{
30
30
  add_field("SCHEMA_NAME");
31
31
  add_field("DEFAULT_COLLATION_NAME");
36
36
  add_field("SCHEMA_USE_COUNT", plugin::TableFunction::NUMBER, 0, true);
37
37
}
38
38
 
39
 
SchemasTool::Generator::Generator(drizzled::Field **arg) :
40
 
  DataDictionary::Generator(arg),
 
39
SchemasTool::Generator::Generator(Field **arg) :
 
40
  plugin::TableFunction::Generator(arg),
41
41
  schema_generator(getSession())
42
42
{
43
43
}
 
44
  
 
45
bool SchemasTool::Generator::nextSchema()
 
46
{
 
47
  drizzled::message::SchemaPtr schema_ptr;
 
48
  while ((schema_ptr= schema_generator))
 
49
  {
 
50
    schema= schema_ptr;
 
51
    return true;
 
52
  }
 
53
 
 
54
  return false;
 
55
}
 
56
 
44
57
 
45
58
bool SchemasTool::Generator::populate()
46
59
{
47
 
  drizzled::message::schema::shared_ptr schema_ptr;
48
 
  while ((schema_ptr= schema_generator))
 
60
  if (nextSchema())
49
61
  {
50
 
    /* SCHEMA_NAME */
51
 
    push(schema_ptr->name());
52
 
 
53
 
    /* DEFAULT_COLLATION_NAME */
54
 
    push(schema_ptr->collation());
55
 
 
56
 
    /* SCHEMA_CREATION_TIME */
57
 
    time_t time_arg= schema_ptr->creation_timestamp();
58
 
    char buffer[40];
59
 
    struct tm tm_buffer;
60
 
 
61
 
    localtime_r(&time_arg, &tm_buffer);
62
 
    strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer);
63
 
    push(buffer);
64
 
 
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);
69
 
    push(buffer);
70
 
 
71
 
    /* SCHEMA_UUID */
72
 
    push(schema_ptr->uuid());
73
 
 
74
 
    /* SCHEMA_VERSION */
75
 
    push(schema_ptr->version());
76
 
 
77
 
    /* SCHEMA_USE_COUNT */
78
 
    push(schema_ptr->version());
 
62
    fill();
79
63
    return true;
80
64
  }
81
65
 
82
66
  return false;
83
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 */
 
75
  push(schema->name());
 
76
 
 
77
  /* DEFAULT_COLLATION_NAME */
 
78
  push(schema->collation());
 
79
 
 
80
  /* SCHEMA_CREATION_TIME */
 
81
  time_t time_arg= schema->creation_timestamp();
 
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 */
 
90
  time_arg= schema->update_timestamp();
 
91
  localtime_r(&time_arg, &tm_buffer);
 
92
  strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer);
 
93
  push(buffer);
 
94
 
 
95
  /* SCHEMA_UUID */
 
96
  push(schema->uuid());
 
97
 
 
98
  /* SCHEMA_VERSION */
 
99
  push(schema->version());
 
100
 
 
101
  /* SCHEMA_USE_COUNT */
 
102
  push(schema->version());
 
103
}