MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mainPopulate.cpp
1 /*
2  Copyright (C) 2005, 2006, 2008 MySQL AB, 2008 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include <ndb_global.h>
20 #include <ndb_opts.h>
21 
22 #include "userInterface.h"
23 #include "dbPopulate.h"
24 #include <NdbMain.h>
25 #include <NdbOut.hpp>
26 #include <random.h>
27 #include <NDBT.hpp>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 int useTableLogging;
33 #ifdef __cplusplus
34 }
35 #endif
36 
37 
38 static
39 void usage(const char *prog)
40 {
41 
42  ndbout_c(
43  "Usage: %s [-l]\n"
44  " -l Use logging and checkpointing on tables\n",
45  prog);
46 
47  exit(1);
48 }
49 
50 NDB_COMMAND(DbCreate, "DbCreate", "DbCreate", "DbCreate", 16384)
51 {
52  ndb_init();
53  int i;
54  UserHandle *uh;
55 
56  useTableLogging = 0;
57 
58  for(i = 1; i<argc; i++){
59  if(strcmp(argv[i], "-l") == 0){
60  useTableLogging = 1;
61  } else {
62  usage(argv[0]);
63  return 0;
64  }
65  }
66 
67  ndbout_c("Using %s tables",
68  useTableLogging ? "logging" : "temporary");
69 
70  myRandom48Init(0x3e6f);
71 
72  uh = userDbConnect(1, "TEST_DB");
73  dbPopulate(uh);
74  userDbDisconnect(uh);
75 
76  return NDBT_ProgramExit(NDBT_OK);
77 }