~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleimport.cc

  • Committer: Monty Taylor
  • Date: 2008-12-30 17:53:54 UTC
  • mfrom: (673.5.15 usability-cli-port)
  • mto: This revision was merged to the branch mainline in revision 755.
  • Revision ID: mordred@inaugust.com-20081230175354-4z4p06vztdxdjjri
Merged from LinuxJedi.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
#include <pthread.h>
33
33
 
 
34
/* Added this for string translation. */
 
35
#include <drizzled/gettext.h>
 
36
 
34
37
using namespace std;
35
38
 
36
39
/* Global Thread counter */
44
47
static char *add_load_option(char *ptr,const char *object,
45
48
           const char *statement);
46
49
 
47
 
static bool  verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0,
48
 
  opt_replace=0,silent=0,ignore=0,opt_compress=0,
49
 
  opt_low_priority= 0, tty_password= 0;
50
 
static bool debug_info_flag= 0, debug_check_flag= 0;
51
 
static uint opt_use_threads=0, opt_local_file=0, my_end_arg= 0;
52
 
static char  *opt_password=0, *current_user=0,
53
 
    *current_host=0, *current_db=0, *fields_terminated=0,
54
 
    *lines_terminated=0, *enclosed=0, *opt_enclosed=0,
55
 
    *escaped=0, *opt_columns=0,
 
50
static bool verbose= false, lock_tables= false, ignore_errors= false,
 
51
            opt_delete= false, opt_replace= false, silent= false,
 
52
            ignore= false, opt_compress= false, opt_low_priority= false,
 
53
            tty_password= false;
 
54
static bool debug_info_flag= false, debug_check_flag= false;
 
55
static uint opt_use_threads= 0, opt_local_file= 0, my_end_arg= 0;
 
56
static char  *opt_password= NULL, *current_user= NULL,
 
57
    *current_host= NULL, *current_db= NULL, *fields_terminated= NULL,
 
58
    *lines_terminated= NULL, *enclosed= NULL, *opt_enclosed= NULL,
 
59
    *escaped= NULL, *opt_columns= NULL,
56
60
    *default_charset= (char*) DRIZZLE_DEFAULT_CHARSET_NAME;
57
 
static uint     opt_drizzle_port= 0, opt_protocol= 0;
58
 
static char * opt_drizzle_unix_port=0;
 
61
static uint opt_protocol= 0;
 
62
static uint32_t opt_drizzle_port= 0;
 
63
static char * opt_drizzle_unix_port= 0;
59
64
static int64_t opt_ignore_lines= -1;
60
65
static const CHARSET_INFO *charset_info= &my_charset_utf8_general_ci;
61
66
 
119
124
  {"low-priority", OPT_LOW_PRIORITY,
120
125
   "Use LOW_PRIORITY when updating the table.", (char**) &opt_low_priority,
121
126
   (char**) &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
122
 
  {"password", 'p',
 
127
  {"password", 'P',
123
128
   "Password to use when connecting to server. If password is not given it's asked from the tty.",
124
129
   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
125
 
  {"port", 'P', "Port number to use for connection or 0 for default to, in "
 
130
  {"port", 'p', "Port number to use for connection or 0 for default to, in "
126
131
   "order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, "
127
132
   "built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
128
 
   (char**) &opt_drizzle_port,
129
 
   (char**) &opt_drizzle_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
130
 
   0},
 
133
   0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
131
134
  {"protocol", OPT_DRIZZLE_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
132
135
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
133
136
  {"replace", 'r', "If duplicate unique key was found, replace old row.",
184
187
extern "C"
185
188
bool get_one_option(int optid, const struct my_option *, char *argument)
186
189
{
 
190
  char *endchar= NULL;
 
191
  uint64_t temp_drizzle_port= 0;
 
192
 
187
193
  switch(optid) {
188
194
  case 'p':
 
195
    temp_drizzle_port= (uint64_t) strtoul(argument, &endchar, 10);
 
196
    /* if there is an alpha character this is not a valid port */
 
197
    if (strlen(endchar) != 0)
 
198
    {
 
199
      fprintf(stderr, _("Non-integer value supplied for port.  If you are trying to enter a password please use --password instead.\n"));
 
200
      exit(1);
 
201
    }
 
202
    /* If the port number is > 65535 it is not a valid port
 
203
       This also helps with potential data loss casting unsigned long to a
 
204
       uint32_t. */
 
205
    if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
 
206
    {
 
207
      fprintf(stderr, _("Value supplied for port is not valid.\n"));
 
208
      exit(1);
 
209
    }
 
210
    else
 
211
    {
 
212
      opt_drizzle_port= (uint32_t) temp_drizzle_port;
 
213
    }
 
214
    break;
 
215
  case 'P':
189
216
    if (argument)
190
217
    {
191
218
      char *start=argument;
198
225
                        "Aborting.\n");
199
226
        exit(ENOMEM);
200
227
      }
201
 
      while (*argument) *argument++= 'x';    /* Destroy argument */
 
228
      while (*argument)
 
229
      {
 
230
        /* Overwriting password with 'x' */
 
231
        *argument++= 'x';
 
232
      }
202
233
      if (*start)
203
 
        start[1]=0;        /* Cut length of argument */
 
234
      {
 
235
        /* Cut length of argument */
 
236
        start[1]= 0;
 
237
      }
204
238
      tty_password= 0;
205
239
    }
206
240
    else