~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/table_writer.cc

Remove dead memset call.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <iostream>
23
23
#include <fstream>
24
24
#include <string>
25
 
#include <getopt.h>
26
25
#include <drizzled/message/table.pb.h>
27
26
 
 
27
#include <boost/program_options.hpp>
 
28
 
28
29
using namespace std;
29
30
using namespace drizzled;
30
31
 
 
32
namespace po=boost::program_options;
 
33
 
31
34
/*
32
35
  Written from Google proto example
33
36
*/
34
37
 
35
 
static void fill_engine(message::Table::StorageEngine *engine)
 
38
static void fill_engine(message::Engine *engine)
36
39
{
37
 
  int16_t x;
38
 
 
39
40
  engine->set_name("InnoDB");
40
 
  message::Table::StorageEngine::EngineOption *option;
 
41
  message::Engine::Option *option;
41
42
 
42
43
  string option_names[2]= {
43
44
    "INDEX_DIRECTORY"
50
51
  };
51
52
 
52
53
  /* Add some engine options */
53
 
  for (x= 0; x < 2; x++)
 
54
  for (int16_t x= 0; x < 2; x++)
54
55
  {
55
 
    option= engine->add_option();
56
 
    option->set_option_name(option_names[x]);
57
 
    option->set_option_value(option_values[x]);
58
 
    option->set_option_type(message::Table::StorageEngine::EngineOption::STRING);
 
56
    option= engine->add_options();
 
57
    option->set_name(option_names[x]);
 
58
    option->set_state(option_values[x]);
59
59
  }
60
60
}
61
61
 
192
192
  }
193
193
 
194
194
  /* Do engine-specific stuff */
195
 
  message::Table::StorageEngine *engine= table->mutable_engine();
 
195
  message::Engine *engine= table->mutable_engine();
196
196
  fill_engine(engine);
197
197
 
198
198
}
216
216
 
217
217
}
218
218
 
219
 
static void usage(char *argv0)
220
 
{
221
 
  cerr << "Usage:  " << argv0 << " [-t N] TABLE_NAME.dfe" << endl;
222
 
  cerr << endl;
223
 
  cerr << "-t N\tTable Number" << endl;
224
 
  cerr << "\t0 - default" << endl;
225
 
  cerr << endl;
226
 
}
227
219
 
228
220
int main(int argc, char* argv[])
229
221
{
230
 
  int opt;
231
222
  int table_number= 0;
232
223
 
233
224
  GOOGLE_PROTOBUF_VERIFY_VERSION;
234
225
 
235
 
  while ((opt= getopt(argc, argv, "t:")) != -1)
 
226
  po::options_description desc("Allowed options");
 
227
  desc.add_options()
 
228
    ("help", "produce help message")
 
229
    ("table-number,t", po::value<int>(&table_number)->default_value(0), "Table Number");
 
230
 
 
231
  po::variables_map vm;
 
232
  po::positional_options_description p;
 
233
  p.add("table-name", 1);
 
234
 
 
235
  po::store(po::command_line_parser(argc, argv).options(desc).
 
236
            positional(p).run(), vm);
 
237
 
 
238
  if (not vm.count("table-name"))
236
239
  {
237
 
    switch (opt)
238
 
    {
239
 
    case 't':
240
 
      table_number= atoi(optarg);
241
 
      break;
242
 
    default:
243
 
      usage(argv[0]);
244
 
      exit(EXIT_FAILURE);
245
 
    }
246
 
  }
247
 
 
248
 
  if (optind >= argc) {
249
240
    fprintf(stderr, "Expected Table name argument\n\n");
250
 
    usage(argv[0]);
 
241
    cerr << desc << endl;
251
242
    exit(EXIT_FAILURE);
252
243
  }
253
244
 
263
254
    break;
264
255
  default:
265
256
    fprintf(stderr, "Invalid table number.\n\n");
266
 
    usage(argv[0]);
 
257
    cerr << desc << endl;
267
258
    exit(EXIT_FAILURE);
268
259
  }
269
260
 
270
 
  fstream output(argv[optind], ios::out | ios::trunc | ios::binary);
 
261
  fstream output(vm["table-name"].as<string>().c_str(),
 
262
                 ios::out | ios::trunc | ios::binary);
271
263
  if (!table.SerializeToOstream(&output))
272
264
  {
273
265
    cerr << "Failed to write schema." << endl;