~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/schema_dictionary/tables.cc

  • Committer: patrick crews
  • Date: 2010-09-29 15:15:19 UTC
  • mfrom: (1099.4.188 drizzle)
  • Revision ID: gleebix@gmail.com-20100929151519-6mrmzd1ciw2p9nws
Tags: 2010.09.1802
Update translations

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
48
48
  add_field("TABLE_SCHEMA");
49
49
  add_field("TABLE_NAME");
50
50
  add_field("TABLE_TYPE");
51
 
  add_field("TABLE_ARCHETYPE");
52
51
  add_field("ENGINE");
53
52
  add_field("ROW_FORMAT", 10);
54
53
  add_field("TABLE_COLLATION");
55
54
  add_field("TABLE_CREATION_TIME");
56
55
  add_field("TABLE_UPDATE_TIME");
57
56
  add_field("TABLE_COMMENT", plugin::TableFunction::STRING, 2048, true);
58
 
  add_field("AUTO_INCREMENT", plugin::TableFunction::NUMBER, 0, false);
59
 
  add_field("TABLE_UUID", plugin::TableFunction::STRING, 36, true);
60
 
  add_field("TABLE_VERSION", plugin::TableFunction::NUMBER, 0, true);
61
57
}
62
58
 
63
59
TablesTool::Generator::Generator(Field **arg) :
68
64
 
69
65
bool TablesTool::Generator::nextTable()
70
66
{
71
 
  drizzled::message::table::shared_ptr table_ptr;
 
67
  const drizzled::message::Table *table_ptr;
72
68
  while ((table_ptr= all_tables_generator))
73
69
  {
74
70
    table_message.CopyFrom(*table_ptr);
89
85
  return false;
90
86
}
91
87
 
 
88
void TablesTool::Generator::pushType(message::Table::Field::FieldType type)
 
89
{
 
90
  switch (type)
 
91
  {
 
92
  default:
 
93
  case message::Table::Field::VARCHAR:
 
94
    push(VARCHAR);
 
95
    break;
 
96
  case message::Table::Field::DOUBLE:
 
97
    push(DOUBLE);
 
98
    break;
 
99
  case message::Table::Field::BLOB:
 
100
    push(BLOB);
 
101
    break;
 
102
  case message::Table::Field::ENUM:
 
103
    push(ENUM);
 
104
    break;
 
105
  case message::Table::Field::INTEGER:
 
106
    push(INTEGER);
 
107
    break;
 
108
  case message::Table::Field::BIGINT:
 
109
    push(BIGINT);
 
110
    break;
 
111
  case message::Table::Field::DECIMAL:
 
112
    push(DECIMAL);
 
113
    break;
 
114
  case message::Table::Field::DATE:
 
115
    push(DATE);
 
116
    break;
 
117
  case message::Table::Field::TIMESTAMP:
 
118
    push(TIMESTAMP);
 
119
    break;
 
120
  case message::Table::Field::DATETIME:
 
121
    push(DATETIME);
 
122
    break;
 
123
  }
 
124
}
 
125
 
92
126
void TablesTool::Generator::fill()
93
127
{
94
128
 
103
137
  push(getTableMessage().name());
104
138
 
105
139
  /* TABLE_TYPE */
106
 
  if (drizzled::identifier::Table::isView(getTableMessage().type()))
107
 
  {
108
 
    push("VIEW");
109
 
  }
110
 
  else
111
 
  {
112
 
    push("BASE");
113
 
  }
114
 
 
115
 
  /* TABLE_ARCHETYPE */
116
140
  {
117
141
    switch (getTableMessage().type())
118
142
    {
133
157
  }
134
158
 
135
159
  /* ENGINE */
136
 
  const drizzled::message::Engine &engine= getTableMessage().engine();
137
 
  push(engine.name());
 
160
  push(getTableMessage().engine().name());
138
161
 
139
162
  /* ROW_FORMAT */
140
 
  bool row_format_sent= false;
141
 
  for (ssize_t it= 0; it < engine.options_size(); it++)
142
 
  {
143
 
    const drizzled::message::Engine::Option &opt= engine.options(it);
144
 
    if (opt.name().compare("ROW_FORMAT") == 0)
145
 
    {
146
 
      row_format_sent= true;
147
 
      push(opt.state());
148
 
      break;
149
 
    }
150
 
  }
151
 
 
152
 
  if (not row_format_sent)
153
 
    push("DEFAULT");
 
163
  push("DEFAULT");
154
164
 
155
165
  /* TABLE_COLLATION */
156
166
  push(getTableMessage().options().collation());
179
189
  {
180
190
    push();
181
191
  }
182
 
 
183
 
  /* AUTO_INCREMENT */
184
 
  push(getTableMessage().options().auto_increment_value());
185
 
 
186
 
  /* TABLE_UUID */
187
 
  push(getTableMessage().uuid());
188
 
 
189
 
  /* TABLE_VERSION */
190
 
  push(getTableMessage().version());
191
192
}