~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to plugin/schema_dictionary/tables.cc

  • Committer: Padraig O'Sullivan
  • Date: 2010-04-17 01:38:47 UTC
  • mfrom: (1237.9.238 bad-staging)
  • Revision ID: osullivan.padraig@gmail.com-20100417013847-ibjioqsfbmf5yg4g
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
  add_field("ENGINE");
59
59
  add_field("ROW_FORMAT", 10);
60
60
  add_field("TABLE_COLLATION");
 
61
  add_field("TABLE_CREATION_TIME");
 
62
  add_field("TABLE_UPDATE_TIME");
61
63
  add_field("TABLE_COMMENT", 2048);
62
64
}
63
65
 
79
81
     return false;
80
82
 
81
83
    table_names.clear();
82
 
    plugin::StorageEngine::getTableNames(schema_name(), table_names);
 
84
    SchemaIdentifier identifier(schema_name());
 
85
    plugin::StorageEngine::getTableNames(getSession(), identifier, table_names);
83
86
    table_iterator= table_names.begin();
84
87
    is_tables_primed= true;
85
88
  }
89
92
 
90
93
  table_proto.Clear();
91
94
  {
92
 
    Session *session= current_session;
93
 
    char path[FN_REFLEN];
94
 
    build_table_filename(path, sizeof(path), schema_name().c_str(), table_name().c_str(), false);
95
 
    plugin::StorageEngine::getTableDefinition(*session,
96
 
                                             path,
97
 
                                             schema_name().c_str(),
98
 
                                             table_name().c_str(),
99
 
                                             false,
100
 
                                             &table_proto);
 
95
    TableIdentifier identifier(schema_name().c_str(), table_name().c_str());
 
96
    plugin::StorageEngine::getTableDefinition(getSession(),
 
97
                                             identifier,
 
98
                                             table_proto);
101
99
  }
102
100
 
103
 
  if (checkTableName())
104
 
    return false;
105
 
 
106
101
  return true;
107
102
}
108
103
 
116
111
 
117
112
    if (not nextSchema())
118
113
      return false;
 
114
 
119
115
    is_tables_primed= false;
120
116
  }
121
117
 
122
118
  return true;
123
119
}
124
120
 
125
 
bool TablesTool::Generator::checkTableName()
126
 
{
127
 
  if (isWild(table_name()))
128
 
    return true;
129
 
 
130
 
  if (not table_predicate.empty() && table_predicate.compare(table_name()))
131
 
    return true;
132
 
 
133
 
  return false;
134
 
}
135
 
 
136
121
bool TablesTool::Generator::populate()
137
122
{
138
123
  if (not nextTable())
213
198
void TablesTool::Generator::fill()
214
199
{
215
200
 
 
201
  /**
 
202
    @note use --replace-column
 
203
  */
 
204
 
216
205
  /* TABLE_SCHEMA */
217
 
  push(schema_name());
 
206
  push(table_proto.schema());
218
207
 
219
208
  /* TABLE_NAME */
220
 
  push(table_name());
 
209
  push(table_proto.name());
221
210
 
222
211
  /* TABLE_TYPE */
223
212
  {
248
237
  /* TABLE_COLLATION */
249
238
  push(table_proto.options().collation());
250
239
 
 
240
  /* TABLE_CREATION_TIME */
 
241
  time_t time_arg= table_proto.creation_timestamp();
 
242
  char buffer[40];
 
243
  struct tm tm_buffer;
 
244
 
 
245
  localtime_r(&time_arg, &tm_buffer);
 
246
  strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer);
 
247
  push(buffer);
 
248
 
 
249
  /* TABLE_UPDATE_TIME */
 
250
  time_arg= table_proto.update_timestamp();
 
251
  localtime_r(&time_arg, &tm_buffer);
 
252
  strftime(buffer, sizeof(buffer), "%a %b %d %H:%M:%S %Y", &tm_buffer);
 
253
  push(buffer);
 
254
 
251
255
  /* TABLE_COMMENT */
252
256
  push(table_proto.options().comment());
253
257
}
254
 
 
255
 
bool ShowTables::Generator::checkSchema()
256
 
{
257
 
  Session *session= current_session;
258
 
 
259
 
  if (session->lex->select_lex.db)
260
 
  {
261
 
    return schema_name().compare(session->lex->select_lex.db);
262
 
  }
263
 
  return session->db.compare(schema_name());
264
 
}