~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to drizzled/show.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:
191
191
  @returns true if errors are detected, false otherwise.
192
192
*/
193
193
 
194
 
static bool store_db_create_info(const char *dbname, string &buffer, bool if_not_exists)
 
194
static bool store_db_create_info(SchemaIdentifier &schema_identifier, string &buffer, bool if_not_exists)
195
195
{
196
196
  message::Schema schema;
197
197
 
198
 
  bool found= plugin::StorageEngine::getSchemaDefinition(dbname, schema);
 
198
  bool found= plugin::StorageEngine::getSchemaDefinition(schema_identifier, schema);
199
199
  if (not found)
200
200
    return false;
201
201
 
217
217
  return true;
218
218
}
219
219
 
220
 
bool mysqld_show_create_db(Session *session, const char *dbname, bool if_not_exists)
 
220
bool mysqld_show_create_db(Session &session, SchemaIdentifier &schema_identifier, bool if_not_exists)
221
221
{
 
222
  message::Schema schema_message;
222
223
  string buffer;
223
224
 
224
 
  if (not store_db_create_info(dbname, buffer, if_not_exists))
225
 
  {
226
 
    /*
227
 
      This assumes that the only reason for which store_db_create_info()
228
 
      can fail is incorrect database name (which is the case now).
229
 
    */
230
 
    my_error(ER_BAD_DB_ERROR, MYF(0), dbname);
 
225
  if (not plugin::StorageEngine::getSchemaDefinition(schema_identifier, schema_message))
 
226
  {
 
227
    /*
 
228
      This assumes that the only reason for which store_db_create_info()
 
229
      can fail is incorrect database name (which is the case now).
 
230
    */
 
231
    my_error(ER_BAD_DB_ERROR, MYF(0), schema_identifier.getSQLPath().c_str());
 
232
    return true;
 
233
  }
 
234
 
 
235
  if (not store_db_create_info(schema_identifier, buffer, if_not_exists))
 
236
  {
 
237
    /*
 
238
      This assumes that the only reason for which store_db_create_info()
 
239
      can fail is incorrect database name (which is the case now).
 
240
    */
 
241
    my_error(ER_BAD_DB_ERROR, MYF(0), schema_identifier.getSQLPath().c_str());
231
242
    return true;
232
243
  }
233
244
 
235
246
  field_list.push_back(new Item_empty_string("Database",NAME_CHAR_LEN));
236
247
  field_list.push_back(new Item_empty_string("Create Database",1024));
237
248
 
238
 
  if (session->client->sendFields(&field_list))
239
 
    return true;
240
 
 
241
 
  session->client->store(dbname, strlen(dbname));
242
 
  session->client->store(buffer);
243
 
 
244
 
  if (session->client->flush())
245
 
    return true;
246
 
 
247
 
  session->my_eof();
 
249
  if (session.client->sendFields(&field_list))
 
250
    return true;
 
251
 
 
252
  session.client->store(schema_message.name());
 
253
  session.client->store(buffer);
 
254
 
 
255
  if (session.client->flush())
 
256
    return true;
 
257
 
 
258
  session.my_eof();
248
259
 
249
260
  return false;
250
261
}
404
415
 
405
416
    if (field->has_charset())
406
417
    {
407
 
      if (field->charset() != share->table_charset)
408
 
      {
409
 
        packet->append(STRING_WITH_LEN(" CHARACTER SET "));
410
 
        packet->append(field->charset()->csname);
411
 
      }
412
 
 
413
418
      /*
414
419
        For string types dump collation name only if
415
420
        collation is not primary for the given charset