00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <iostream>
00021 #include <fstream>
00022 #include <string>
00023 #include <drizzled/message/schema.pb.h>
00024
00025 using namespace std;
00026 using namespace drizzled;
00027
00028
00029
00030
00031
00032
00033 static void printSchema(const message::Schema *schema)
00034 {
00035 cout << "CREATE SCHEMA `" << schema->name() << "` ";
00036 if (schema->has_collation())
00037 cout << "COLLATE `" << schema->collation() << "` ";
00038
00039 for (int option_nr=0; option_nr < schema->engine().options_size(); option_nr++)
00040 {
00041 cout << " " << schema->engine().options(option_nr).name() << " = "
00042 << "'" << schema->engine().options(option_nr).state() << "'";
00043 }
00044
00045 cout << ";" << endl;
00046 }
00047
00048 int main(int argc, char* argv[])
00049 {
00050 GOOGLE_PROTOBUF_VERIFY_VERSION;
00051
00052 if (argc != 2) {
00053 cerr << "Usage: " << argv[0] << " SCHEMA" << endl;
00054 return -1;
00055 }
00056
00057 message::Schema schema;
00058
00059 {
00060
00061 fstream input(argv[1], ios::in | ios::binary);
00062 if (!schema.ParseFromIstream(&input))
00063 {
00064 cerr << "Failed to parse schema." << endl;
00065 return -1;
00066 }
00067 }
00068
00069 printSchema(&schema);
00070
00071 return 0;
00072 }