~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump_drizzle.cc

  • Committer: Andrew Hutchings
  • Date: 2010-09-23 20:32:31 UTC
  • mto: (1792.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1793.
  • Revision ID: andrew@linuxjedi.co.uk-20100923203231-9bpfjwm0fih91ize
Fix various bugs

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <drizzled/gettext.h>
26
26
#include <boost/lexical_cast.hpp>
27
27
 
 
28
extern bool  verbose;
 
29
 
28
30
bool DrizzleDumpDatabaseDrizzle::populateTables()
29
31
{
30
32
  drizzle_result_st *result;
33
35
 
34
36
  dcon->setDB(databaseName);
35
37
 
 
38
  if (verbose)
 
39
    std::cerr << _("-- Retrieving table structures for ") << databaseName << "..." << std::endl;
 
40
 
36
41
  query="SELECT TABLE_NAME, TABLE_COLLATION, ENGINE FROM DATA_DICTIONARY.TABLES WHERE TABLE_SCHEMA='";
37
42
  query.append(databaseName);
38
43
  query.append("' ORDER BY TABLE_NAME");
57
62
  return true;
58
63
}
59
64
 
 
65
bool DrizzleDumpDatabaseDrizzle::populateTables(const std::vector<std::string> &table_names)
 
66
{
 
67
  drizzle_result_st *result;
 
68
  drizzle_row_t row;
 
69
  std::string query;
 
70
 
 
71
  dcon->setDB(databaseName);
 
72
 
 
73
  if (verbose)
 
74
    std::cerr << _("-- Retrieving table structures for ") << databaseName << "..." << std::endl;
 
75
  for (std::vector<std::string>::const_iterator it= table_names.begin(); it != table_names.end(); ++it)
 
76
  {
 
77
    std::string tableName= *it;
 
78
    query="SELECT TABLE_NAME, TABLE_COLLATION, ENGINE FROM DATA_DICTIONARY.TABLES WHERE TABLE_SCHEMA='";
 
79
    query.append(databaseName);
 
80
    query.append("' AND TABLE_NAME = '");
 
81
    query.append(tableName);
 
82
    query.append("'");
 
83
 
 
84
    result= dcon->query(query);
 
85
 
 
86
    if ((row= drizzle_row_next(result)))
 
87
    {
 
88
      DrizzleDumpTableMySQL *table = new DrizzleDumpTableMySQL(tableName, dcon);
 
89
      DrizzleDumpTable *table = new DrizzleDumpTableDrizzle(tableName, dcon);
 
90
      table->collate= row[1];
 
91
      table->engineName= row[2];
 
92
      table->autoIncrement= 0;
 
93
      table->database= this;
 
94
      table->populateFields();
 
95
      table->populateIndexes();
 
96
      tables.push_back(table);
 
97
      dcon->freeResult(result);
 
98
    }
 
99
    else
 
100
    {
 
101
      dcon->freeResult(result);
 
102
      return false;
 
103
    }
 
104
  }
 
105
 
 
106
  return true;
 
107
 
 
108
}
 
109
 
60
110
void DrizzleDumpDatabaseDrizzle::setCollate(const char* newCollate)
61
111
{
62
112
  if (newCollate)
71
121
  drizzle_row_t row;
72
122
  std::string query;
73
123
 
 
124
  if (verbose)
 
125
    std::cerr << _("-- Retrieving fields for ") << tableName << "..." << std::endl;
 
126
 
74
127
  query= "SELECT COLUMN_NAME, DATA_TYPE, COLUMN_DEFAULT, COLUMN_DEFAULT_IS_NULL, IS_NULLABLE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, COLLATION_NAME, IS_AUTO_INCREMENT, ENUM_VALUES FROM DATA_DICTIONARY.COLUMNS WHERE TABLE_SCHEMA='";
75
128
  query.append(database->databaseName);
76
129
  query.append("' AND TABLE_NAME='");
118
171
  bool firstIndex= true;
119
172
  DrizzleDumpIndex *index;
120
173
 
 
174
  if (verbose)
 
175
    std::cerr << _("-- Retrieving indexes for ") << tableName << "..." << std::endl;
 
176
 
121
177
  query= "SELECT INDEX_NAME, COLUMN_NAME, IS_USED_IN_PRIMARY, IS_UNIQUE FROM DATA_DICTIONARY.INDEX_PARTS WHERE TABLE_NAME='";
122
178
  query.append(tableName);
123
179
  query.append("'");