00001 /* Copyright (C) 2003 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 #ifndef _NDB_OPTS_H 00018 #define _NDB_OPTS_H 00019 00020 #include <ndb_global.h> 00021 #include <my_sys.h> 00022 #include <my_getopt.h> 00023 #include <mysql_version.h> 00024 #include <ndb_version.h> 00025 #include <ndb_opt_defaults.h> 00026 00027 #define NDB_STD_OPTS_VARS \ 00028 my_bool opt_ndb_optimized_node_selection 00029 00030 int opt_ndb_nodeid; 00031 bool opt_endinfo= 0; 00032 my_bool opt_ndb_shm; 00033 my_bool opt_core; 00034 const char *opt_ndb_connectstring= 0; 00035 const char *opt_connect_str= 0; 00036 const char *opt_ndb_mgmd= 0; 00037 char opt_ndb_constrbuf[1024]; 00038 unsigned opt_ndb_constrbuf_len= 0; 00039 00040 #ifndef DBUG_OFF 00041 const char *opt_debug= 0; 00042 #endif 00043 00044 #define OPT_NDB_CONNECTSTRING 'c' 00045 #if defined VM_TRACE && ( ! ( defined NDB_OSE || defined NDB_SOFTOSE) ) 00046 #define OPT_WANT_CORE_DEFAULT 1 00047 #else 00048 #define OPT_WANT_CORE_DEFAULT 0 00049 #endif 00050 00051 #define NDB_STD_OPTS_COMMON \ 00052 { "usage", '?', "Display this help and exit.", \ 00053 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ 00054 { "help", '?', "Display this help and exit.", \ 00055 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ 00056 { "version", 'V', "Output version information and exit.", 0, 0, 0, \ 00057 GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, \ 00058 { "ndb-connectstring", OPT_NDB_CONNECTSTRING, \ 00059 "Set connect string for connecting to ndb_mgmd. " \ 00060 "Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". " \ 00061 "Overides specifying entries in NDB_CONNECTSTRING and Ndb.cfg", \ 00062 (gptr*) &opt_ndb_connectstring, (gptr*) &opt_ndb_connectstring, \ 00063 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ 00064 { "ndb-mgmd-host", OPT_NDB_MGMD, \ 00065 "Set host and port for connecting to ndb_mgmd. " \ 00066 "Syntax: <hostname>[:<port>].", \ 00067 (gptr*) &opt_ndb_mgmd, (gptr*) &opt_ndb_mgmd, 0, \ 00068 GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ 00069 { "ndb-nodeid", OPT_NDB_NODEID, \ 00070 "Set node id for this node.", \ 00071 (gptr*) &opt_ndb_nodeid, (gptr*) &opt_ndb_nodeid, 0, \ 00072 GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ 00073 { "ndb-shm", OPT_NDB_SHM,\ 00074 "Allow optimizing using shared memory connections when available",\ 00075 (gptr*) &opt_ndb_shm, (gptr*) &opt_ndb_shm, 0,\ 00076 GET_BOOL, NO_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0 },\ 00077 {"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION,\ 00078 "Select nodes for transactions in a more optimal way",\ 00079 (gptr*) &opt_ndb_optimized_node_selection,\ 00080 (gptr*) &opt_ndb_optimized_node_selection, 0,\ 00081 GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},\ 00082 { "connect-string", OPT_NDB_CONNECTSTRING, "same as --ndb-connectstring",\ 00083 (gptr*) &opt_ndb_connectstring, (gptr*) &opt_ndb_connectstring, \ 00084 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ 00085 { "core-file", OPT_WANT_CORE, "Write core on errors.",\ 00086 (gptr*) &opt_core, (gptr*) &opt_core, 0,\ 00087 GET_BOOL, NO_ARG, OPT_WANT_CORE_DEFAULT, 0, 0, 0, 0, 0},\ 00088 {"character-sets-dir", OPT_CHARSETS_DIR,\ 00089 "Directory where character sets are.", (gptr*) &charsets_dir,\ 00090 (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}\ 00091 00092 #ifndef DBUG_OFF 00093 #define NDB_STD_OPTS(prog_name) \ 00094 { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \ 00095 (gptr*) &opt_debug, (gptr*) &opt_debug, \ 00096 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \ 00097 NDB_STD_OPTS_COMMON 00098 #else 00099 #define NDB_STD_OPTS(prog_name) NDB_STD_OPTS_COMMON 00100 #endif 00101 00102 static void ndb_std_print_version() 00103 { 00104 printf("MySQL distrib %s, for %s (%s)\n", 00105 MYSQL_SERVER_VERSION,SYSTEM_TYPE,MACHINE_TYPE); 00106 } 00107 00108 static void usage(); 00109 00110 enum ndb_std_options { 00111 OPT_NDB_SHM= 256, 00112 OPT_NDB_SHM_SIGNUM, 00113 OPT_NDB_OPTIMIZED_NODE_SELECTION, 00114 OPT_WANT_CORE, 00115 OPT_NDB_MGMD, 00116 OPT_NDB_NODEID, 00117 OPT_CHARSETS_DIR, 00118 NDB_STD_OPTIONS_LAST /* should always be last in this enum */ 00119 }; 00120 00121 static my_bool 00122 ndb_std_get_one_option(int optid, 00123 const struct my_option *opt __attribute__((unused)), 00124 char *argument) 00125 { 00126 switch (optid) { 00127 #ifndef DBUG_OFF 00128 case '#': 00129 if (opt_debug) 00130 { 00131 DBUG_PUSH(opt_debug); 00132 } 00133 else 00134 { 00135 DBUG_PUSH("d:t"); 00136 } 00137 opt_endinfo= 1; 00138 break; 00139 #endif 00140 case 'V': 00141 ndb_std_print_version(); 00142 exit(0); 00143 case '?': 00144 usage(); 00145 exit(0); 00146 case OPT_NDB_SHM: 00147 if (opt_ndb_shm) 00148 { 00149 #ifndef NDB_SHM_TRANSPORTER 00150 printf("Warning: binary not compiled with shared memory support,\n" 00151 "Tcp connections will now be used instead\n"); 00152 opt_ndb_shm= 0; 00153 #endif 00154 } 00155 break; 00156 case OPT_NDB_MGMD: 00157 case OPT_NDB_NODEID: 00158 { 00159 int len= my_snprintf(opt_ndb_constrbuf+opt_ndb_constrbuf_len, 00160 sizeof(opt_ndb_constrbuf)-opt_ndb_constrbuf_len, 00161 "%s%s%s",opt_ndb_constrbuf_len > 0 ? ",":"", 00162 optid == OPT_NDB_NODEID ? "nodeid=" : "", 00163 argument); 00164 opt_ndb_constrbuf_len+= len; 00165 } 00166 /* fall through to add the connectstring to the end 00167 * and set opt_ndbcluster_connectstring 00168 */ 00169 case OPT_NDB_CONNECTSTRING: 00170 if (opt_ndb_connectstring && opt_ndb_connectstring[0]) 00171 my_snprintf(opt_ndb_constrbuf+opt_ndb_constrbuf_len, 00172 sizeof(opt_ndb_constrbuf)-opt_ndb_constrbuf_len, 00173 "%s%s", opt_ndb_constrbuf_len > 0 ? ",":"", 00174 opt_ndb_connectstring); 00175 else 00176 opt_ndb_constrbuf[opt_ndb_constrbuf_len]= 0; 00177 opt_connect_str= opt_ndb_constrbuf; 00178 break; 00179 } 00180 return 0; 00181 } 00182 00183 #endif /*_NDB_OPTS_H */
1.4.7

