~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/schema_reader.cc

  • Committer: Stewart Smith
  • Date: 2008-07-13 06:56:15 UTC
  • mto: (210.1.1 drizzle)
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: stewart@flamingspork.com-20080713065615-vzok75kgnnviokl9
Move MD5() into a UDF

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#include <iostream>
21
 
#include <fstream>
22
 
#include <string>
23
 
#include <drizzled/message/schema.pb.h>
24
 
 
25
 
using namespace std;
26
 
using namespace drizzled;
27
 
 
28
 
 
29
 
/*
30
 
  Written from Google proto example
31
 
*/
32
 
 
33
 
static void printSchema(const message::Schema *schema)
34
 
{
35
 
  cout << "CREATE SCHEMA `" << schema->name() << "` ";
36
 
  if (schema->has_collation())
37
 
    cout << "COLLATE `" << schema->collation() << "` ";
38
 
  cout << ";" << endl;
39
 
}
40
 
 
41
 
int main(int argc, char* argv[])
42
 
{
43
 
  GOOGLE_PROTOBUF_VERIFY_VERSION;
44
 
 
45
 
  if (argc != 2) {
46
 
    cerr << "Usage:  " << argv[0] << " SCHEMA" << endl;
47
 
    return -1;
48
 
  }
49
 
 
50
 
  message::Schema schema;
51
 
 
52
 
  {
53
 
    // Read the existing address book.
54
 
    fstream input(argv[1], ios::in | ios::binary);
55
 
    if (!schema.ParseFromIstream(&input))
56
 
    {
57
 
      cerr << "Failed to parse schema." << endl;
58
 
      return -1;
59
 
    }
60
 
  }
61
 
 
62
 
  printSchema(&schema);
63
 
 
64
 
  return 0;
65
 
}