~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Brian Aker
  • Date: 2010-12-18 02:06:13 UTC
  • Revision ID: brian@tangent.org-20101218020613-8lxhcvsy812bu960
Formatting + remove default from switch/case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
 
4
 *  Copyright (C) 2010 Vijay Samuel
4
5
 *  Copyright (C) 2008 MySQL
5
6
 *
6
7
 *  This program is free software; you can redistribute it and/or modify
33
34
 *
34
35
 **/
35
36
 
36
 
#include "client_priv.h"
 
37
#include "config.h"
 
38
#include <libdrizzle/drizzle_client.h>
 
39
 
 
40
#include "client/get_password.h"
 
41
 
 
42
#if TIME_WITH_SYS_TIME
 
43
# include <sys/time.h>
 
44
# include <time.h>
 
45
#else
 
46
# if HAVE_SYS_TIME_H
 
47
#  include <sys/time.h>
 
48
# else
 
49
#  include <time.h>
 
50
# endif
 
51
#endif
 
52
 
 
53
#include <cerrno>
37
54
#include <string>
38
55
#include <drizzled/gettext.h>
39
56
#include <iostream>
 
57
#include <fstream>
40
58
#include <map>
41
59
#include <algorithm>
42
60
#include <limits.h>
43
61
#include <cassert>
44
 
#include "drizzled/charset_info.h"
45
62
#include <stdarg.h>
46
63
#include <math.h>
 
64
#include <memory>
47
65
#include "client/linebuffer.h"
48
66
#include <signal.h>
49
67
#include <sys/ioctl.h>
50
68
#include <drizzled/configmake.h>
51
 
#include "drizzled/charset.h"
 
69
#include "drizzled/utf8/utf8.h"
 
70
#include <cstdlib>
52
71
 
53
72
#if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H)
54
73
#include <curses.h>
89
108
#  endif /* !defined(HAVE_READLINE_H) */
90
109
char *cmdline = NULL;
91
110
#else /* !defined(HAVE_READLINE_READLINE_H) */
92
 
/* no readline */
 
111
  /* no readline */
93
112
#  error Readline Required
94
113
#endif /* HAVE_LIBREADLINE */
95
114
 
103
122
extern int write_history ();
104
123
extern int read_history ();
105
124
#  endif /* defined(HAVE_READLINE_HISTORY_H) */
106
 
/* no history */
 
125
    /* no history */
107
126
#endif /* HAVE_READLINE_HISTORY */
108
127
 
109
128
/**
110
 
  Make the old readline interface look like the new one.
 
129
 Make the old readline interface look like the new one.
111
130
*/
112
131
#ifndef HAVE_RL_COMPLETION
113
132
typedef char **rl_completion_func_t(const char *, int, int);
139
158
#undef vidattr
140
159
#define vidattr(A) {}      // Can't get this to work
141
160
#endif
 
161
#include <boost/program_options.hpp>
 
162
#include <boost/scoped_ptr.hpp>
 
163
#include "drizzled/program_options/config_file.h"
142
164
 
143
 
using namespace drizzled;
144
165
using namespace std;
 
166
namespace po=boost::program_options;
 
167
namespace dpo=drizzled::program_options;
145
168
 
146
 
const string VER("14.14");
147
169
/* Don't try to make a nice table if the data is too big */
148
170
const uint32_t MAX_COLUMN_LENGTH= 1024;
149
171
 
151
173
const int MAX_SERVER_VERSION_LENGTH= 128;
152
174
 
153
175
#define PROMPT_CHAR '\\'
154
 
#define DEFAULT_DELIMITER ";"
155
176
 
156
 
typedef struct st_status
 
177
class Status
157
178
{
 
179
public:
 
180
 
 
181
  Status(int in_exit_status, 
 
182
         uint32_t in_query_start_line,
 
183
         char *in_file_name,
 
184
         LineBuffer *in_line_buff,
 
185
         bool in_batch,
 
186
         bool in_add_to_history)
 
187
    :
 
188
    exit_status(in_exit_status),
 
189
    query_start_line(in_query_start_line),
 
190
    file_name(in_file_name),
 
191
    line_buff(in_line_buff),
 
192
    batch(in_batch),
 
193
    add_to_history(in_add_to_history)
 
194
    {}
 
195
 
 
196
  Status() :
 
197
    exit_status(0),
 
198
    query_start_line(0),
 
199
    file_name(NULL),
 
200
    line_buff(NULL),
 
201
    batch(false),        
 
202
    add_to_history(false)
 
203
  {}
 
204
  
 
205
  int getExitStatus() const
 
206
  {
 
207
    return exit_status;
 
208
  }
 
209
 
 
210
  uint32_t getQueryStartLine() const
 
211
  {
 
212
    return query_start_line;
 
213
  }
 
214
 
 
215
  const char *getFileName() const
 
216
  {
 
217
    return file_name;
 
218
  }
 
219
 
 
220
  LineBuffer *getLineBuff() const
 
221
  {
 
222
    return line_buff;
 
223
  }
 
224
 
 
225
  bool getBatch() const
 
226
  {
 
227
    return batch;
 
228
  }
 
229
 
 
230
  bool getAddToHistory() const
 
231
  {
 
232
    return add_to_history;
 
233
  }
 
234
 
 
235
  void setExitStatus(int in_exit_status)
 
236
  {
 
237
    exit_status= in_exit_status;
 
238
  }
 
239
 
 
240
  void setQueryStartLine(uint32_t in_query_start_line)
 
241
  {
 
242
    query_start_line= in_query_start_line;
 
243
  }
 
244
 
 
245
  void setFileName(char *in_file_name)
 
246
  {
 
247
    file_name= in_file_name;
 
248
  }
 
249
 
 
250
  void setLineBuff(int max_size, FILE *file=NULL)
 
251
  {
 
252
    line_buff= new(std::nothrow) LineBuffer(max_size, file);
 
253
  }
 
254
 
 
255
  void setLineBuff(LineBuffer *in_line_buff)
 
256
  {
 
257
    line_buff= in_line_buff;
 
258
  }
 
259
 
 
260
  void setBatch(bool in_batch)
 
261
  {
 
262
    batch= in_batch;
 
263
  }
 
264
 
 
265
  void setAddToHistory(bool in_add_to_history)
 
266
  {
 
267
    add_to_history= in_add_to_history;
 
268
  }
 
269
 
 
270
private:
158
271
  int exit_status;
159
272
  uint32_t query_start_line;
160
273
  char *file_name;
161
274
  LineBuffer *line_buff;
162
275
  bool batch,add_to_history;
163
 
} STATUS;
164
 
 
 
276
}; 
165
277
 
166
278
static map<string, string>::iterator completion_iter;
167
279
static map<string, string>::iterator completion_end;
168
280
static map<string, string> completion_map;
169
281
static string completion_string;
170
282
 
171
 
static char **defaults_argv;
172
283
 
173
284
enum enum_info_type { INFO_INFO,INFO_ERROR,INFO_RESULT};
174
285
typedef enum enum_info_type INFO_TYPE;
176
287
static drizzle_st drizzle;      /* The library handle */
177
288
static drizzle_con_st con;      /* The connection */
178
289
static bool ignore_errors= false, quick= false,
179
 
            connected= false, opt_raw_data= false, unbuffered= false,
180
 
            output_tables= false, opt_rehash= true, skip_updates= false,
181
 
            safe_updates= false, one_database= false,
182
 
            opt_compress= false, opt_shutdown= false, opt_ping= false,
183
 
            vertical= false, line_numbers= true, column_names= true,
184
 
            opt_nopager= true, opt_outfile= false, named_cmds= false,
185
 
            tty_password= false, opt_nobeep= false, opt_reconnect= true,
186
 
            default_charset_used= false, opt_secure_auth= false,
187
 
            default_pager_set= false, opt_sigint_ignore= false,
188
 
            auto_vertical_output= false,
189
 
            show_warnings= false, executing_query= false, interrupted_query= false,
190
 
            opt_mysql= false;
191
 
static uint32_t  show_progress_size= 0;
 
290
  connected= false, opt_raw_data= false, unbuffered= false,
 
291
  output_tables= false, opt_rehash= true, skip_updates= false,
 
292
  safe_updates= false, one_database= false,
 
293
  opt_shutdown= false, opt_ping= false,
 
294
  vertical= false, line_numbers= true, column_names= true,
 
295
  opt_nopager= true, opt_outfile= false, named_cmds= false,
 
296
  opt_nobeep= false, opt_reconnect= true,
 
297
  opt_secure_auth= false,
 
298
  default_pager_set= false, opt_sigint_ignore= false,
 
299
  auto_vertical_output= false,
 
300
  show_warnings= false, executing_query= false, interrupted_query= false,
 
301
  use_drizzle_protocol= false, opt_local_infile;
 
302
static uint32_t show_progress_size= 0;
192
303
static bool column_types_flag;
193
304
static bool preserve_comments= false;
194
 
static uint32_t opt_max_input_line, opt_drizzle_port= 0;
195
 
static int verbose= 0, opt_silent= 0, opt_local_infile= 0;
 
305
static uint32_t opt_max_input_line;
 
306
static uint32_t opt_drizzle_port= 0;
 
307
static int  opt_silent, verbose= 0;
196
308
static drizzle_capabilities_t connect_flag= DRIZZLE_CAPABILITIES_NONE;
197
 
static char *current_host, *current_db, *current_user= NULL,
198
 
            *opt_password= NULL, *delimiter_str= NULL, *current_prompt= NULL;
199
309
static char *histfile;
200
310
static char *histfile_tmp;
201
311
static string *glob_buffer;
202
312
static string *processed_prompt= NULL;
203
313
static char *default_prompt= NULL;
204
314
static char *full_username= NULL,*part_username= NULL;
205
 
static STATUS status;
 
315
static Status status;
206
316
static uint32_t select_limit;
207
317
static uint32_t max_join_size;
208
318
static uint32_t opt_connect_timeout= 0;
 
319
std::string current_db,
 
320
  delimiter_str,  
 
321
  current_host,
 
322
  current_prompt,
 
323
  current_user,
 
324
  opt_verbose,
 
325
  current_password,
 
326
  opt_password,
 
327
  opt_protocol;
209
328
// TODO: Need to i18n these
210
329
static const char *day_names[]= {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
211
330
static const char *month_names[]= {"Jan","Feb","Mar","Apr","May","Jun","Jul",
212
 
  "Aug","Sep","Oct","Nov","Dec"};
213
 
static char default_pager[FN_REFLEN];
214
 
static char pager[FN_REFLEN], outfile[FN_REFLEN];
 
331
                                  "Aug","Sep","Oct","Nov","Dec"};
 
332
/* @TODO: Remove this */
 
333
#define FN_REFLEN 512
 
334
 
 
335
static string default_pager("");
 
336
static string pager("");
 
337
static string outfile("");
215
338
static FILE *PAGER, *OUTFILE;
216
339
static uint32_t prompt_counter;
217
 
static char delimiter[16]= DEFAULT_DELIMITER;
 
340
static char *delimiter= NULL;
218
341
static uint32_t delimiter_length= 1;
219
342
unsigned short terminal_width= 80;
220
343
 
221
 
static const CHARSET_INFO *charset_info= &my_charset_utf8_general_ci;
222
 
 
223
 
int drizzleclient_real_query_for_lazy(const char *buf, int length,
 
344
int drizzleclient_real_query_for_lazy(const char *buf, size_t length,
224
345
                                      drizzle_result_st *result,
225
346
                                      uint32_t *error_code);
226
347
int drizzleclient_store_result_for_lazy(drizzle_result_st *result);
232
353
void tee_putc(int c, FILE *file);
233
354
static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool);
234
355
/* The names of functions that actually do the manipulation. */
235
 
static int get_options(int argc,char **argv);
 
356
static int process_options(void);
236
357
static int com_quit(string *str,const char*),
237
 
           com_go(string *str,const char*), com_ego(string *str,const char*),
238
 
           com_print(string *str,const char*),
239
 
           com_help(string *str,const char*), com_clear(string *str,const char*),
240
 
           com_connect(string *str,const char*), com_status(string *str,const char*),
241
 
           com_use(string *str,const char*), com_source(string *str, const char*),
242
 
           com_rehash(string *str, const char*), com_tee(string *str, const char*),
243
 
           com_notee(string *str, const char*),
244
 
           com_prompt(string *str, const char*), com_delimiter(string *str, const char*),
245
 
           com_warnings(string *str, const char*), com_nowarnings(string *str, const char*),
246
 
           com_nopager(string *str, const char*), com_pager(string *str, const char*);
 
358
  com_go(string *str,const char*), com_ego(string *str,const char*),
 
359
  com_print(string *str,const char*),
 
360
  com_help(string *str,const char*), com_clear(string *str,const char*),
 
361
  com_connect(string *str,const char*), com_status(string *str,const char*),
 
362
  com_use(string *str,const char*), com_source(string *str, const char*),
 
363
  com_shutdown(string *str,const char*),
 
364
  com_rehash(string *str, const char*), com_tee(string *str, const char*),
 
365
  com_notee(string *str, const char*),
 
366
  com_prompt(string *str, const char*), com_delimiter(string *str, const char*),
 
367
  com_warnings(string *str, const char*), com_nowarnings(string *str, const char*),
 
368
  com_nopager(string *str, const char*), com_pager(string *str, const char*);
247
369
 
248
370
static int read_and_execute(bool interactive);
249
 
static int sql_connect(char *host,char *database,char *user,char *password,
 
371
static int sql_connect(const string &host, const string &database, const string &user, const string &password,
250
372
                       uint32_t silent);
251
373
static const char *server_version_string(drizzle_con_st *con);
252
374
static int put_info(const char *str,INFO_TYPE info,uint32_t error,
265
387
static int get_field_disp_length(drizzle_column_st * field);
266
388
static const char * strcont(register const char *str, register const char *set);
267
389
 
268
 
/* A structure which contains information on the commands this program
269
 
  can understand. */
270
 
typedef struct {
 
390
/* A class which contains information on the commands this program
 
391
   can understand. */
 
392
class Commands
 
393
{
 
394
private:
271
395
  const char *name;        /* User printable name of the function. */
272
396
  char cmd_char;        /* msql command character */
273
 
  int (*func)(string *str,const char *); /* Function to call to do the job. */
 
397
public:
 
398
Commands(const char *in_name,
 
399
         char in_cmd_char,
 
400
         int (*in_func)(string *str,const char *name),
 
401
         bool in_takes_params,
 
402
         const char *in_doc)
 
403
  :
 
404
  name(in_name),
 
405
  cmd_char(in_cmd_char),
 
406
  func(in_func),
 
407
  takes_params(in_takes_params),
 
408
  doc(in_doc)
 
409
  {}
 
410
 
 
411
  Commands()
 
412
  :
 
413
  name(),
 
414
  cmd_char(),
 
415
  func(NULL),
 
416
  takes_params(false),
 
417
  doc()
 
418
  {}
 
419
 
 
420
  int (*func)(string *str,const char *);/* Function to call to do the job. */
 
421
 
 
422
  const char *getName() const
 
423
  {
 
424
    return name;
 
425
  }
 
426
 
 
427
  char getCmdChar() const
 
428
  {
 
429
    return cmd_char;
 
430
  }
 
431
 
 
432
  bool getTakesParams() const
 
433
  {
 
434
    return takes_params;
 
435
  }
 
436
 
 
437
  const char *getDoc() const
 
438
  {
 
439
    return doc;
 
440
  }
 
441
 
 
442
  void setName(const char *in_name)
 
443
  {
 
444
     name= in_name;
 
445
  }
 
446
 
 
447
  void setCmdChar(char in_cmd_char)
 
448
  {
 
449
    cmd_char= in_cmd_char;
 
450
  }
 
451
 
 
452
  void setTakesParams(bool in_takes_params)
 
453
  {
 
454
    takes_params= in_takes_params;
 
455
  }
 
456
 
 
457
  void setDoc(const char *in_doc)
 
458
  {
 
459
    doc= in_doc;
 
460
  }
 
461
 
 
462
private:
274
463
  bool takes_params;        /* Max parameters for command */
275
464
  const char *doc;        /* Documentation for this function.  */
276
 
} COMMANDS;
277
 
 
278
 
 
279
 
static COMMANDS commands[] = {
280
 
  { "?",      '?', com_help,   0, N_("Synonym for `help'.") },
281
 
  { "clear",  'c', com_clear,  0, N_("Clear command.")},
282
 
  { "connect",'r', com_connect,1,
283
 
    N_("Reconnect to the server. Optional arguments are db and host.")},
284
 
  { "delimiter", 'd', com_delimiter,    1,
285
 
    N_("Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.") },
286
 
  { "ego",    'G', com_ego,    0,
287
 
    N_("Send command to drizzle server, display result vertically.")},
288
 
  { "exit",   'q', com_quit,   0, N_("Exit drizzle. Same as quit.")},
289
 
  { "go",     'g', com_go,     0, N_("Send command to drizzle server.") },
290
 
  { "help",   'h', com_help,   0, N_("Display this help.") },
291
 
  { "nopager",'n', com_nopager,0, N_("Disable pager, print to stdout.") },
292
 
  { "notee",  't', com_notee,  0, N_("Don't write into outfile.") },
293
 
  { "pager",  'P', com_pager,  1,
294
 
    N_("Set PAGER [to_pager]. Print the query results via PAGER.") },
295
 
  { "print",  'p', com_print,  0, N_("Print current command.") },
296
 
  { "prompt", 'R', com_prompt, 1, N_("Change your drizzle prompt.")},
297
 
  { "quit",   'q', com_quit,   0, N_("Quit drizzle.") },
298
 
  { "rehash", '#', com_rehash, 0, N_("Rebuild completion hash.") },
299
 
  { "source", '.', com_source, 1,
300
 
    N_("Execute an SQL script file. Takes a file name as an argument.")},
301
 
  { "status", 's', com_status, 0, N_("Get status information from the server.")},
302
 
  { "tee",    'T', com_tee,    1,
303
 
    N_("Set outfile [to_outfile]. Append everything into given outfile.") },
304
 
  { "use",    'u', com_use,    1,
305
 
    N_("Use another database. Takes database name as argument.") },
306
 
  { "warnings", 'W', com_warnings,  0,
307
 
    N_("Show warnings after every statement.") },
308
 
  { "nowarning", 'w', com_nowarnings, 0,
309
 
    N_("Don't show warnings after every statement.") },
 
465
}; 
 
466
 
 
467
 
 
468
static Commands commands[] = {
 
469
  Commands( "?",      '?', com_help,   0, N_("Synonym for `help'.") ),
 
470
  Commands( "clear",  'c', com_clear,  0, N_("Clear command.")),
 
471
  Commands( "connect",'r', com_connect,1,
 
472
    N_("Reconnect to the server. Optional arguments are db and host.")),
 
473
  Commands( "delimiter", 'd', com_delimiter,    1,
 
474
    N_("Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.") ),
 
475
  Commands( "ego",    'G', com_ego,    0,
 
476
    N_("Send command to drizzle server, display result vertically.")),
 
477
  Commands( "exit",   'q', com_quit,   0, N_("Exit drizzle. Same as quit.")),
 
478
  Commands( "go",     'g', com_go,     0, N_("Send command to drizzle server.") ),
 
479
  Commands( "help",   'h', com_help,   0, N_("Display this help.") ),
 
480
  Commands( "nopager",'n', com_nopager,0, N_("Disable pager, print to stdout.") ),
 
481
  Commands( "notee",  't', com_notee,  0, N_("Don't write into outfile.") ),
 
482
  Commands( "pager",  'P', com_pager,  1,
 
483
    N_("Set PAGER [to_pager]. Print the query results via PAGER.") ),
 
484
  Commands( "print",  'p', com_print,  0, N_("Print current command.") ),
 
485
  Commands( "prompt", 'R', com_prompt, 1, N_("Change your drizzle prompt.")),
 
486
  Commands( "quit",   'q', com_quit,   0, N_("Quit drizzle.") ),
 
487
  Commands( "rehash", '#', com_rehash, 0, N_("Rebuild completion hash.") ),
 
488
  Commands( "source", '.', com_source, 1,
 
489
    N_("Execute an SQL script file. Takes a file name as an argument.")),
 
490
  Commands( "status", 's', com_status, 0, N_("Get status information from the server.")),
 
491
  Commands( "tee",    'T', com_tee,    1,
 
492
    N_("Set outfile [to_outfile]. Append everything into given outfile.") ),
 
493
  Commands( "use",    'u', com_use,    1,
 
494
    N_("Use another database. Takes database name as argument.") ),
 
495
  Commands( "shutdown",    'u', com_shutdown,    1,
 
496
    N_("Shutdown the instance you are connected too.") ),
 
497
  Commands( "warnings", 'W', com_warnings,  0,
 
498
    N_("Show warnings after every statement.") ),
 
499
  Commands( "nowarning", 'w', com_nowarnings, 0,
 
500
    N_("Don't show warnings after every statement.") ),
310
501
  /* Get bash-like expansion for some commands */
311
 
  { "create table",     0, 0, 0, ""},
312
 
  { "create database",  0, 0, 0, ""},
313
 
  { "show databases",   0, 0, 0, ""},
314
 
  { "show fields from", 0, 0, 0, ""},
315
 
  { "show keys from",   0, 0, 0, ""},
316
 
  { "show tables",      0, 0, 0, ""},
317
 
  { "load data from",   0, 0, 0, ""},
318
 
  { "alter table",      0, 0, 0, ""},
319
 
  { "set option",       0, 0, 0, ""},
320
 
  { "lock tables",      0, 0, 0, ""},
321
 
  { "unlock tables",    0, 0, 0, ""},
 
502
  Commands( "create table",     0, 0, 0, ""),
 
503
  Commands( "create database",  0, 0, 0, ""),
 
504
  Commands( "show databases",   0, 0, 0, ""),
 
505
  Commands( "show fields from", 0, 0, 0, ""),
 
506
  Commands( "show keys from",   0, 0, 0, ""),
 
507
  Commands( "show tables",      0, 0, 0, ""),
 
508
  Commands( "load data from",   0, 0, 0, ""),
 
509
  Commands( "alter table",      0, 0, 0, ""),
 
510
  Commands( "set option",       0, 0, 0, ""),
 
511
  Commands( "lock tables",      0, 0, 0, ""),
 
512
  Commands( "unlock tables",    0, 0, 0, ""),
322
513
  /* generated 2006-12-28.  Refresh occasionally from lexer. */
323
 
  { "ACTION", 0, 0, 0, ""},
324
 
  { "ADD", 0, 0, 0, ""},
325
 
  { "AFTER", 0, 0, 0, ""},
326
 
  { "AGAINST", 0, 0, 0, ""},
327
 
  { "AGGREGATE", 0, 0, 0, ""},
328
 
  { "ALL", 0, 0, 0, ""},
329
 
  { "ALGORITHM", 0, 0, 0, ""},
330
 
  { "ALTER", 0, 0, 0, ""},
331
 
  { "ANALYZE", 0, 0, 0, ""},
332
 
  { "AND", 0, 0, 0, ""},
333
 
  { "ANY", 0, 0, 0, ""},
334
 
  { "AS", 0, 0, 0, ""},
335
 
  { "ASC", 0, 0, 0, ""},
336
 
  { "ASCII", 0, 0, 0, ""},
337
 
  { "ASENSITIVE", 0, 0, 0, ""},
338
 
  { "AUTO_INCREMENT", 0, 0, 0, ""},
339
 
  { "AVG", 0, 0, 0, ""},
340
 
  { "AVG_ROW_LENGTH", 0, 0, 0, ""},
341
 
  { "BACKUP", 0, 0, 0, ""},
342
 
  { "BDB", 0, 0, 0, ""},
343
 
  { "BEFORE", 0, 0, 0, ""},
344
 
  { "BEGIN", 0, 0, 0, ""},
345
 
  { "BERKELEYDB", 0, 0, 0, ""},
346
 
  { "BETWEEN", 0, 0, 0, ""},
347
 
  { "BIGINT", 0, 0, 0, ""},
348
 
  { "BINARY", 0, 0, 0, ""},
349
 
  { "BINLOG", 0, 0, 0, ""},
350
 
  { "BIT", 0, 0, 0, ""},
351
 
  { "BLOB", 0, 0, 0, ""},
352
 
  { "BOOL", 0, 0, 0, ""},
353
 
  { "BOOLEAN", 0, 0, 0, ""},
354
 
  { "BOTH", 0, 0, 0, ""},
355
 
  { "BTREE", 0, 0, 0, ""},
356
 
  { "BY", 0, 0, 0, ""},
357
 
  { "BYTE", 0, 0, 0, ""},
358
 
  { "CACHE", 0, 0, 0, ""},
359
 
  { "CALL", 0, 0, 0, ""},
360
 
  { "CASCADE", 0, 0, 0, ""},
361
 
  { "CASCADED", 0, 0, 0, ""},
362
 
  { "CASE", 0, 0, 0, ""},
363
 
  { "CHAIN", 0, 0, 0, ""},
364
 
  { "CHANGE", 0, 0, 0, ""},
365
 
  { "CHANGED", 0, 0, 0, ""},
366
 
  { "CHAR", 0, 0, 0, ""},
367
 
  { "CHARACTER", 0, 0, 0, ""},
368
 
  { "CHARSET", 0, 0, 0, ""},
369
 
  { "CHECK", 0, 0, 0, ""},
370
 
  { "CHECKSUM", 0, 0, 0, ""},
371
 
  { "CIPHER", 0, 0, 0, ""},
372
 
  { "CLIENT", 0, 0, 0, ""},
373
 
  { "CLOSE", 0, 0, 0, ""},
374
 
  { "CODE", 0, 0, 0, ""},
375
 
  { "COLLATE", 0, 0, 0, ""},
376
 
  { "COLLATION", 0, 0, 0, ""},
377
 
  { "COLUMN", 0, 0, 0, ""},
378
 
  { "COLUMNS", 0, 0, 0, ""},
379
 
  { "COMMENT", 0, 0, 0, ""},
380
 
  { "COMMIT", 0, 0, 0, ""},
381
 
  { "COMMITTED", 0, 0, 0, ""},
382
 
  { "COMPACT", 0, 0, 0, ""},
383
 
  { "COMPRESSED", 0, 0, 0, ""},
384
 
  { "CONCURRENT", 0, 0, 0, ""},
385
 
  { "CONDITION", 0, 0, 0, ""},
386
 
  { "CONNECTION", 0, 0, 0, ""},
387
 
  { "CONSISTENT", 0, 0, 0, ""},
388
 
  { "CONSTRAINT", 0, 0, 0, ""},
389
 
  { "CONTAINS", 0, 0, 0, ""},
390
 
  { "CONTINUE", 0, 0, 0, ""},
391
 
  { "CONVERT", 0, 0, 0, ""},
392
 
  { "CREATE", 0, 0, 0, ""},
393
 
  { "CROSS", 0, 0, 0, ""},
394
 
  { "CUBE", 0, 0, 0, ""},
395
 
  { "CURRENT_DATE", 0, 0, 0, ""},
396
 
  { "CURRENT_TIMESTAMP", 0, 0, 0, ""},
397
 
  { "CURRENT_USER", 0, 0, 0, ""},
398
 
  { "CURSOR", 0, 0, 0, ""},
399
 
  { "DATA", 0, 0, 0, ""},
400
 
  { "DATABASE", 0, 0, 0, ""},
401
 
  { "DATABASES", 0, 0, 0, ""},
402
 
  { "DATE", 0, 0, 0, ""},
403
 
  { "DATETIME", 0, 0, 0, ""},
404
 
  { "DAY", 0, 0, 0, ""},
405
 
  { "DAY_HOUR", 0, 0, 0, ""},
406
 
  { "DAY_MICROSECOND", 0, 0, 0, ""},
407
 
  { "DAY_MINUTE", 0, 0, 0, ""},
408
 
  { "DAY_SECOND", 0, 0, 0, ""},
409
 
  { "DEALLOCATE", 0, 0, 0, ""},
410
 
  { "DEC", 0, 0, 0, ""},
411
 
  { "DECIMAL", 0, 0, 0, ""},
412
 
  { "DECLARE", 0, 0, 0, ""},
413
 
  { "DEFAULT", 0, 0, 0, ""},
414
 
  { "DEFINER", 0, 0, 0, ""},
415
 
  { "DELAYED", 0, 0, 0, ""},
416
 
  { "DELAY_KEY_WRITE", 0, 0, 0, ""},
417
 
  { "DELETE", 0, 0, 0, ""},
418
 
  { "DESC", 0, 0, 0, ""},
419
 
  { "DESCRIBE", 0, 0, 0, ""},
420
 
  { "DES_KEY_FILE", 0, 0, 0, ""},
421
 
  { "DETERMINISTIC", 0, 0, 0, ""},
422
 
  { "DIRECTORY", 0, 0, 0, ""},
423
 
  { "DISABLE", 0, 0, 0, ""},
424
 
  { "DISCARD", 0, 0, 0, ""},
425
 
  { "DISTINCT", 0, 0, 0, ""},
426
 
  { "DISTINCTROW", 0, 0, 0, ""},
427
 
  { "DIV", 0, 0, 0, ""},
428
 
  { "DO", 0, 0, 0, ""},
429
 
  { "DOUBLE", 0, 0, 0, ""},
430
 
  { "DROP", 0, 0, 0, ""},
431
 
  { "DUAL", 0, 0, 0, ""},
432
 
  { "DUMPFILE", 0, 0, 0, ""},
433
 
  { "DUPLICATE", 0, 0, 0, ""},
434
 
  { "DYNAMIC", 0, 0, 0, ""},
435
 
  { "EACH", 0, 0, 0, ""},
436
 
  { "ELSE", 0, 0, 0, ""},
437
 
  { "ELSEIF", 0, 0, 0, ""},
438
 
  { "ENABLE", 0, 0, 0, ""},
439
 
  { "ENCLOSED", 0, 0, 0, ""},
440
 
  { "END", 0, 0, 0, ""},
441
 
  { "ENGINE", 0, 0, 0, ""},
442
 
  { "ENGINES", 0, 0, 0, ""},
443
 
  { "ENUM", 0, 0, 0, ""},
444
 
  { "ERRORS", 0, 0, 0, ""},
445
 
  { "ESCAPE", 0, 0, 0, ""},
446
 
  { "ESCAPED", 0, 0, 0, ""},
447
 
  { "EVENTS", 0, 0, 0, ""},
448
 
  { "EXECUTE", 0, 0, 0, ""},
449
 
  { "EXISTS", 0, 0, 0, ""},
450
 
  { "EXIT", 0, 0, 0, ""},
451
 
  { "EXPANSION", 0, 0, 0, ""},
452
 
  { "EXPLAIN", 0, 0, 0, ""},
453
 
  { "EXTENDED", 0, 0, 0, ""},
454
 
  { "FALSE", 0, 0, 0, ""},
455
 
  { "FAST", 0, 0, 0, ""},
456
 
  { "FETCH", 0, 0, 0, ""},
457
 
  { "FIELDS", 0, 0, 0, ""},
458
 
  { "FILE", 0, 0, 0, ""},
459
 
  { "FIRST", 0, 0, 0, ""},
460
 
  { "FIXED", 0, 0, 0, ""},
461
 
  { "FLOAT", 0, 0, 0, ""},
462
 
  { "FLOAT4", 0, 0, 0, ""},
463
 
  { "FLOAT8", 0, 0, 0, ""},
464
 
  { "FLUSH", 0, 0, 0, ""},
465
 
  { "FOR", 0, 0, 0, ""},
466
 
  { "FORCE", 0, 0, 0, ""},
467
 
  { "FOREIGN", 0, 0, 0, ""},
468
 
  { "FOUND", 0, 0, 0, ""},
469
 
  { "FRAC_SECOND", 0, 0, 0, ""},
470
 
  { "FROM", 0, 0, 0, ""},
471
 
  { "FULL", 0, 0, 0, ""},
472
 
  { "FULLTEXT", 0, 0, 0, ""},
473
 
  { "FUNCTION", 0, 0, 0, ""},
474
 
  { "GLOBAL", 0, 0, 0, ""},
475
 
  { "GRANT", 0, 0, 0, ""},
476
 
  { "GRANTS", 0, 0, 0, ""},
477
 
  { "GROUP", 0, 0, 0, ""},
478
 
  { "HANDLER", 0, 0, 0, ""},
479
 
  { "HASH", 0, 0, 0, ""},
480
 
  { "HAVING", 0, 0, 0, ""},
481
 
  { "HELP", 0, 0, 0, ""},
482
 
  { "HIGH_PRIORITY", 0, 0, 0, ""},
483
 
  { "HOSTS", 0, 0, 0, ""},
484
 
  { "HOUR", 0, 0, 0, ""},
485
 
  { "HOUR_MICROSECOND", 0, 0, 0, ""},
486
 
  { "HOUR_MINUTE", 0, 0, 0, ""},
487
 
  { "HOUR_SECOND", 0, 0, 0, ""},
488
 
  { "IDENTIFIED", 0, 0, 0, ""},
489
 
  { "IF", 0, 0, 0, ""},
490
 
  { "IGNORE", 0, 0, 0, ""},
491
 
  { "IMPORT", 0, 0, 0, ""},
492
 
  { "IN", 0, 0, 0, ""},
493
 
  { "INDEX", 0, 0, 0, ""},
494
 
  { "INDEXES", 0, 0, 0, ""},
495
 
  { "INFILE", 0, 0, 0, ""},
496
 
  { "INNER", 0, 0, 0, ""},
497
 
  { "INNOBASE", 0, 0, 0, ""},
498
 
  { "INNODB", 0, 0, 0, ""},
499
 
  { "INOUT", 0, 0, 0, ""},
500
 
  { "INSENSITIVE", 0, 0, 0, ""},
501
 
  { "INSERT", 0, 0, 0, ""},
502
 
  { "INSERT_METHOD", 0, 0, 0, ""},
503
 
  { "INT", 0, 0, 0, ""},
504
 
  { "INT1", 0, 0, 0, ""},
505
 
  { "INT2", 0, 0, 0, ""},
506
 
  { "INT3", 0, 0, 0, ""},
507
 
  { "INT4", 0, 0, 0, ""},
508
 
  { "INT8", 0, 0, 0, ""},
509
 
  { "INTEGER", 0, 0, 0, ""},
510
 
  { "INTERVAL", 0, 0, 0, ""},
511
 
  { "INTO", 0, 0, 0, ""},
512
 
  { "IO_THREAD", 0, 0, 0, ""},
513
 
  { "IS", 0, 0, 0, ""},
514
 
  { "ISOLATION", 0, 0, 0, ""},
515
 
  { "ISSUER", 0, 0, 0, ""},
516
 
  { "ITERATE", 0, 0, 0, ""},
517
 
  { "INVOKER", 0, 0, 0, ""},
518
 
  { "JOIN", 0, 0, 0, ""},
519
 
  { "KEY", 0, 0, 0, ""},
520
 
  { "KEYS", 0, 0, 0, ""},
521
 
  { "KILL", 0, 0, 0, ""},
522
 
  { "LANGUAGE", 0, 0, 0, ""},
523
 
  { "LAST", 0, 0, 0, ""},
524
 
  { "LEADING", 0, 0, 0, ""},
525
 
  { "LEAVE", 0, 0, 0, ""},
526
 
  { "LEAVES", 0, 0, 0, ""},
527
 
  { "LEFT", 0, 0, 0, ""},
528
 
  { "LEVEL", 0, 0, 0, ""},
529
 
  { "LIKE", 0, 0, 0, ""},
530
 
  { "LIMIT", 0, 0, 0, ""},
531
 
  { "LINES", 0, 0, 0, ""},
532
 
  { "LINESTRING", 0, 0, 0, ""},
533
 
  { "LOAD", 0, 0, 0, ""},
534
 
  { "LOCAL", 0, 0, 0, ""},
535
 
  { "LOCALTIMESTAMP", 0, 0, 0, ""},
536
 
  { "LOCK", 0, 0, 0, ""},
537
 
  { "LOCKS", 0, 0, 0, ""},
538
 
  { "LOGS", 0, 0, 0, ""},
539
 
  { "LONG", 0, 0, 0, ""},
540
 
  { "LONGTEXT", 0, 0, 0, ""},
541
 
  { "LOOP", 0, 0, 0, ""},
542
 
  { "LOW_PRIORITY", 0, 0, 0, ""},
543
 
  { "MASTER", 0, 0, 0, ""},
544
 
  { "MASTER_CONNECT_RETRY", 0, 0, 0, ""},
545
 
  { "MASTER_HOST", 0, 0, 0, ""},
546
 
  { "MASTER_LOG_FILE", 0, 0, 0, ""},
547
 
  { "MASTER_LOG_POS", 0, 0, 0, ""},
548
 
  { "MASTER_PASSWORD", 0, 0, 0, ""},
549
 
  { "MASTER_PORT", 0, 0, 0, ""},
550
 
  { "MASTER_SERVER_ID", 0, 0, 0, ""},
551
 
  { "MASTER_SSL", 0, 0, 0, ""},
552
 
  { "MASTER_SSL_CA", 0, 0, 0, ""},
553
 
  { "MASTER_SSL_CAPATH", 0, 0, 0, ""},
554
 
  { "MASTER_SSL_CERT", 0, 0, 0, ""},
555
 
  { "MASTER_SSL_CIPHER", 0, 0, 0, ""},
556
 
  { "MASTER_SSL_KEY", 0, 0, 0, ""},
557
 
  { "MASTER_USER", 0, 0, 0, ""},
558
 
  { "MATCH", 0, 0, 0, ""},
559
 
  { "MAX_CONNECTIONS_PER_HOUR", 0, 0, 0, ""},
560
 
  { "MAX_QUERIES_PER_HOUR", 0, 0, 0, ""},
561
 
  { "MAX_ROWS", 0, 0, 0, ""},
562
 
  { "MAX_UPDATES_PER_HOUR", 0, 0, 0, ""},
563
 
  { "MAX_USER_CONNECTIONS", 0, 0, 0, ""},
564
 
  { "MEDIUM", 0, 0, 0, ""},
565
 
  { "MEDIUMTEXT", 0, 0, 0, ""},
566
 
  { "MERGE", 0, 0, 0, ""},
567
 
  { "MICROSECOND", 0, 0, 0, ""},
568
 
  { "MIDDLEINT", 0, 0, 0, ""},
569
 
  { "MIGRATE", 0, 0, 0, ""},
570
 
  { "MINUTE", 0, 0, 0, ""},
571
 
  { "MINUTE_MICROSECOND", 0, 0, 0, ""},
572
 
  { "MINUTE_SECOND", 0, 0, 0, ""},
573
 
  { "MIN_ROWS", 0, 0, 0, ""},
574
 
  { "MOD", 0, 0, 0, ""},
575
 
  { "MODE", 0, 0, 0, ""},
576
 
  { "MODIFIES", 0, 0, 0, ""},
577
 
  { "MODIFY", 0, 0, 0, ""},
578
 
  { "MONTH", 0, 0, 0, ""},
579
 
  { "MULTILINESTRING", 0, 0, 0, ""},
580
 
  { "MULTIPOINT", 0, 0, 0, ""},
581
 
  { "MULTIPOLYGON", 0, 0, 0, ""},
582
 
  { "MUTEX", 0, 0, 0, ""},
583
 
  { "NAME", 0, 0, 0, ""},
584
 
  { "NAMES", 0, 0, 0, ""},
585
 
  { "NATIONAL", 0, 0, 0, ""},
586
 
  { "NATURAL", 0, 0, 0, ""},
587
 
  { "NDB", 0, 0, 0, ""},
588
 
  { "NDBCLUSTER", 0, 0, 0, ""},
589
 
  { "NCHAR", 0, 0, 0, ""},
590
 
  { "NEW", 0, 0, 0, ""},
591
 
  { "NEXT", 0, 0, 0, ""},
592
 
  { "NO", 0, 0, 0, ""},
593
 
  { "NONE", 0, 0, 0, ""},
594
 
  { "NOT", 0, 0, 0, ""},
595
 
  { "NO_WRITE_TO_BINLOG", 0, 0, 0, ""},
596
 
  { "NULL", 0, 0, 0, ""},
597
 
  { "NUMERIC", 0, 0, 0, ""},
598
 
  { "NVARCHAR", 0, 0, 0, ""},
599
 
  { "OFFSET", 0, 0, 0, ""},
600
 
  { "OLD_PASSWORD", 0, 0, 0, ""},
601
 
  { "ON", 0, 0, 0, ""},
602
 
  { "ONE", 0, 0, 0, ""},
603
 
  { "ONE_SHOT", 0, 0, 0, ""},
604
 
  { "OPEN", 0, 0, 0, ""},
605
 
  { "OPTIMIZE", 0, 0, 0, ""},
606
 
  { "OPTION", 0, 0, 0, ""},
607
 
  { "OPTIONALLY", 0, 0, 0, ""},
608
 
  { "OR", 0, 0, 0, ""},
609
 
  { "ORDER", 0, 0, 0, ""},
610
 
  { "OUT", 0, 0, 0, ""},
611
 
  { "OUTER", 0, 0, 0, ""},
612
 
  { "OUTFILE", 0, 0, 0, ""},
613
 
  { "PACK_KEYS", 0, 0, 0, ""},
614
 
  { "PARTIAL", 0, 0, 0, ""},
615
 
  { "PASSWORD", 0, 0, 0, ""},
616
 
  { "PHASE", 0, 0, 0, ""},
617
 
  { "POINT", 0, 0, 0, ""},
618
 
  { "POLYGON", 0, 0, 0, ""},
619
 
  { "PRECISION", 0, 0, 0, ""},
620
 
  { "PREPARE", 0, 0, 0, ""},
621
 
  { "PREV", 0, 0, 0, ""},
622
 
  { "PRIMARY", 0, 0, 0, ""},
623
 
  { "PRIVILEGES", 0, 0, 0, ""},
624
 
  { "PROCEDURE", 0, 0, 0, ""},
625
 
  { "PROCESS", 0, 0, 0, ""},
626
 
  { "PROCESSLIST", 0, 0, 0, ""},
627
 
  { "PURGE", 0, 0, 0, ""},
628
 
  { "QUARTER", 0, 0, 0, ""},
629
 
  { "QUERY", 0, 0, 0, ""},
630
 
  { "QUICK", 0, 0, 0, ""},
631
 
  { "READ", 0, 0, 0, ""},
632
 
  { "READS", 0, 0, 0, ""},
633
 
  { "REAL", 0, 0, 0, ""},
634
 
  { "RECOVER", 0, 0, 0, ""},
635
 
  { "REDUNDANT", 0, 0, 0, ""},
636
 
  { "REFERENCES", 0, 0, 0, ""},
637
 
  { "REGEXP", 0, 0, 0, ""},
638
 
  { "RELAY_LOG_FILE", 0, 0, 0, ""},
639
 
  { "RELAY_LOG_POS", 0, 0, 0, ""},
640
 
  { "RELAY_THREAD", 0, 0, 0, ""},
641
 
  { "RELEASE", 0, 0, 0, ""},
642
 
  { "RELOAD", 0, 0, 0, ""},
643
 
  { "RENAME", 0, 0, 0, ""},
644
 
  { "REPAIR", 0, 0, 0, ""},
645
 
  { "REPEATABLE", 0, 0, 0, ""},
646
 
  { "REPLACE", 0, 0, 0, ""},
647
 
  { "REPLICATION", 0, 0, 0, ""},
648
 
  { "REPEAT", 0, 0, 0, ""},
649
 
  { "REQUIRE", 0, 0, 0, ""},
650
 
  { "RESET", 0, 0, 0, ""},
651
 
  { "RESTORE", 0, 0, 0, ""},
652
 
  { "RESTRICT", 0, 0, 0, ""},
653
 
  { "RESUME", 0, 0, 0, ""},
654
 
  { "RETURN", 0, 0, 0, ""},
655
 
  { "RETURNS", 0, 0, 0, ""},
656
 
  { "REVOKE", 0, 0, 0, ""},
657
 
  { "RIGHT", 0, 0, 0, ""},
658
 
  { "RLIKE", 0, 0, 0, ""},
659
 
  { "ROLLBACK", 0, 0, 0, ""},
660
 
  { "ROLLUP", 0, 0, 0, ""},
661
 
  { "ROUTINE", 0, 0, 0, ""},
662
 
  { "ROW", 0, 0, 0, ""},
663
 
  { "ROWS", 0, 0, 0, ""},
664
 
  { "ROW_FORMAT", 0, 0, 0, ""},
665
 
  { "RTREE", 0, 0, 0, ""},
666
 
  { "SAVEPOINT", 0, 0, 0, ""},
667
 
  { "SCHEMA", 0, 0, 0, ""},
668
 
  { "SCHEMAS", 0, 0, 0, ""},
669
 
  { "SECOND", 0, 0, 0, ""},
670
 
  { "SECOND_MICROSECOND", 0, 0, 0, ""},
671
 
  { "SECURITY", 0, 0, 0, ""},
672
 
  { "SELECT", 0, 0, 0, ""},
673
 
  { "SENSITIVE", 0, 0, 0, ""},
674
 
  { "SEPARATOR", 0, 0, 0, ""},
675
 
  { "SERIAL", 0, 0, 0, ""},
676
 
  { "SERIALIZABLE", 0, 0, 0, ""},
677
 
  { "SESSION", 0, 0, 0, ""},
678
 
  { "SET", 0, 0, 0, ""},
679
 
  { "SHARE", 0, 0, 0, ""},
680
 
  { "SHOW", 0, 0, 0, ""},
681
 
  { "SHUTDOWN", 0, 0, 0, ""},
682
 
  { "SIGNED", 0, 0, 0, ""},
683
 
  { "SIMPLE", 0, 0, 0, ""},
684
 
  { "SLAVE", 0, 0, 0, ""},
685
 
  { "SNAPSHOT", 0, 0, 0, ""},
686
 
  { "SMALLINT", 0, 0, 0, ""},
687
 
  { "SOME", 0, 0, 0, ""},
688
 
  { "SONAME", 0, 0, 0, ""},
689
 
  { "SOUNDS", 0, 0, 0, ""},
690
 
  { "SPATIAL", 0, 0, 0, ""},
691
 
  { "SPECIFIC", 0, 0, 0, ""},
692
 
  { "SQL", 0, 0, 0, ""},
693
 
  { "SQLEXCEPTION", 0, 0, 0, ""},
694
 
  { "SQLSTATE", 0, 0, 0, ""},
695
 
  { "SQLWARNING", 0, 0, 0, ""},
696
 
  { "SQL_BIG_RESULT", 0, 0, 0, ""},
697
 
  { "SQL_BUFFER_RESULT", 0, 0, 0, ""},
698
 
  { "SQL_CACHE", 0, 0, 0, ""},
699
 
  { "SQL_CALC_FOUND_ROWS", 0, 0, 0, ""},
700
 
  { "SQL_NO_CACHE", 0, 0, 0, ""},
701
 
  { "SQL_SMALL_RESULT", 0, 0, 0, ""},
702
 
  { "SQL_THREAD", 0, 0, 0, ""},
703
 
  { "SQL_TSI_FRAC_SECOND", 0, 0, 0, ""},
704
 
  { "SQL_TSI_SECOND", 0, 0, 0, ""},
705
 
  { "SQL_TSI_MINUTE", 0, 0, 0, ""},
706
 
  { "SQL_TSI_HOUR", 0, 0, 0, ""},
707
 
  { "SQL_TSI_DAY", 0, 0, 0, ""},
708
 
  { "SQL_TSI_WEEK", 0, 0, 0, ""},
709
 
  { "SQL_TSI_MONTH", 0, 0, 0, ""},
710
 
  { "SQL_TSI_QUARTER", 0, 0, 0, ""},
711
 
  { "SQL_TSI_YEAR", 0, 0, 0, ""},
712
 
  { "SSL", 0, 0, 0, ""},
713
 
  { "START", 0, 0, 0, ""},
714
 
  { "STARTING", 0, 0, 0, ""},
715
 
  { "STATUS", 0, 0, 0, ""},
716
 
  { "STOP", 0, 0, 0, ""},
717
 
  { "STORAGE", 0, 0, 0, ""},
718
 
  { "STRAIGHT_JOIN", 0, 0, 0, ""},
719
 
  { "STRING", 0, 0, 0, ""},
720
 
  { "STRIPED", 0, 0, 0, ""},
721
 
  { "SUBJECT", 0, 0, 0, ""},
722
 
  { "SUPER", 0, 0, 0, ""},
723
 
  { "SUSPEND", 0, 0, 0, ""},
724
 
  { "TABLE", 0, 0, 0, ""},
725
 
  { "TABLES", 0, 0, 0, ""},
726
 
  { "TABLESPACE", 0, 0, 0, ""},
727
 
  { "TEMPORARY", 0, 0, 0, ""},
728
 
  { "TEMPTABLE", 0, 0, 0, ""},
729
 
  { "TERMINATED", 0, 0, 0, ""},
730
 
  { "TEXT", 0, 0, 0, ""},
731
 
  { "THEN", 0, 0, 0, ""},
732
 
  { "TIMESTAMP", 0, 0, 0, ""},
733
 
  { "TIMESTAMPADD", 0, 0, 0, ""},
734
 
  { "TIMESTAMPDIFF", 0, 0, 0, ""},
735
 
  { "TINYTEXT", 0, 0, 0, ""},
736
 
  { "TO", 0, 0, 0, ""},
737
 
  { "TRAILING", 0, 0, 0, ""},
738
 
  { "TRANSACTION", 0, 0, 0, ""},
739
 
  { "TRIGGER", 0, 0, 0, ""},
740
 
  { "TRIGGERS", 0, 0, 0, ""},
741
 
  { "TRUE", 0, 0, 0, ""},
742
 
  { "TRUNCATE", 0, 0, 0, ""},
743
 
  { "TYPE", 0, 0, 0, ""},
744
 
  { "TYPES", 0, 0, 0, ""},
745
 
  { "UNCOMMITTED", 0, 0, 0, ""},
746
 
  { "UNDEFINED", 0, 0, 0, ""},
747
 
  { "UNDO", 0, 0, 0, ""},
748
 
  { "UNICODE", 0, 0, 0, ""},
749
 
  { "UNION", 0, 0, 0, ""},
750
 
  { "UNIQUE", 0, 0, 0, ""},
751
 
  { "UNKNOWN", 0, 0, 0, ""},
752
 
  { "UNLOCK", 0, 0, 0, ""},
753
 
  { "UNSIGNED", 0, 0, 0, ""},
754
 
  { "UNTIL", 0, 0, 0, ""},
755
 
  { "UPDATE", 0, 0, 0, ""},
756
 
  { "UPGRADE", 0, 0, 0, ""},
757
 
  { "USAGE", 0, 0, 0, ""},
758
 
  { "USE", 0, 0, 0, ""},
759
 
  { "USER", 0, 0, 0, ""},
760
 
  { "USER_RESOURCES", 0, 0, 0, ""},
761
 
  { "USE_FRM", 0, 0, 0, ""},
762
 
  { "USING", 0, 0, 0, ""},
763
 
  { "UTC_DATE", 0, 0, 0, ""},
764
 
  { "UTC_TIMESTAMP", 0, 0, 0, ""},
765
 
  { "VALUE", 0, 0, 0, ""},
766
 
  { "VALUES", 0, 0, 0, ""},
767
 
  { "VARBINARY", 0, 0, 0, ""},
768
 
  { "VARCHAR", 0, 0, 0, ""},
769
 
  { "VARCHARACTER", 0, 0, 0, ""},
770
 
  { "VARIABLES", 0, 0, 0, ""},
771
 
  { "VARYING", 0, 0, 0, ""},
772
 
  { "WARNINGS", 0, 0, 0, ""},
773
 
  { "WEEK", 0, 0, 0, ""},
774
 
  { "WHEN", 0, 0, 0, ""},
775
 
  { "WHERE", 0, 0, 0, ""},
776
 
  { "WHILE", 0, 0, 0, ""},
777
 
  { "VIEW", 0, 0, 0, ""},
778
 
  { "WITH", 0, 0, 0, ""},
779
 
  { "WORK", 0, 0, 0, ""},
780
 
  { "WRITE", 0, 0, 0, ""},
781
 
  { "X509", 0, 0, 0, ""},
782
 
  { "XOR", 0, 0, 0, ""},
783
 
  { "XA", 0, 0, 0, ""},
784
 
  { "YEAR", 0, 0, 0, ""},
785
 
  { "YEAR_MONTH", 0, 0, 0, ""},
786
 
  { "ZEROFILL", 0, 0, 0, ""},
787
 
  { "ABS", 0, 0, 0, ""},
788
 
  { "ACOS", 0, 0, 0, ""},
789
 
  { "ADDDATE", 0, 0, 0, ""},
790
 
  { "AES_ENCRYPT", 0, 0, 0, ""},
791
 
  { "AES_DECRYPT", 0, 0, 0, ""},
792
 
  { "AREA", 0, 0, 0, ""},
793
 
  { "ASIN", 0, 0, 0, ""},
794
 
  { "ASBINARY", 0, 0, 0, ""},
795
 
  { "ASTEXT", 0, 0, 0, ""},
796
 
  { "ASWKB", 0, 0, 0, ""},
797
 
  { "ASWKT", 0, 0, 0, ""},
798
 
  { "ATAN", 0, 0, 0, ""},
799
 
  { "ATAN2", 0, 0, 0, ""},
800
 
  { "BENCHMARK", 0, 0, 0, ""},
801
 
  { "BIN", 0, 0, 0, ""},
802
 
  { "BIT_OR", 0, 0, 0, ""},
803
 
  { "BIT_AND", 0, 0, 0, ""},
804
 
  { "BIT_XOR", 0, 0, 0, ""},
805
 
  { "CAST", 0, 0, 0, ""},
806
 
  { "CEIL", 0, 0, 0, ""},
807
 
  { "CEILING", 0, 0, 0, ""},
808
 
  { "CENTROID", 0, 0, 0, ""},
809
 
  { "CHAR_LENGTH", 0, 0, 0, ""},
810
 
  { "CHARACTER_LENGTH", 0, 0, 0, ""},
811
 
  { "COALESCE", 0, 0, 0, ""},
812
 
  { "COERCIBILITY", 0, 0, 0, ""},
813
 
  { "COMPRESS", 0, 0, 0, ""},
814
 
  { "CONCAT", 0, 0, 0, ""},
815
 
  { "CONCAT_WS", 0, 0, 0, ""},
816
 
  { "CONNECTION_ID", 0, 0, 0, ""},
817
 
  { "CONV", 0, 0, 0, ""},
818
 
  { "CONVERT_TZ", 0, 0, 0, ""},
819
 
  { "COUNT", 0, 0, 0, ""},
820
 
  { "COS", 0, 0, 0, ""},
821
 
  { "COT", 0, 0, 0, ""},
822
 
  { "CRC32", 0, 0, 0, ""},
823
 
  { "CROSSES", 0, 0, 0, ""},
824
 
  { "CURDATE", 0, 0, 0, ""},
825
 
  { "DATE_ADD", 0, 0, 0, ""},
826
 
  { "DATEDIFF", 0, 0, 0, ""},
827
 
  { "DATE_FORMAT", 0, 0, 0, ""},
828
 
  { "DATE_SUB", 0, 0, 0, ""},
829
 
  { "DAYNAME", 0, 0, 0, ""},
830
 
  { "DAYOFMONTH", 0, 0, 0, ""},
831
 
  { "DAYOFWEEK", 0, 0, 0, ""},
832
 
  { "DAYOFYEAR", 0, 0, 0, ""},
833
 
  { "DECODE", 0, 0, 0, ""},
834
 
  { "DEGREES", 0, 0, 0, ""},
835
 
  { "DES_ENCRYPT", 0, 0, 0, ""},
836
 
  { "DES_DECRYPT", 0, 0, 0, ""},
837
 
  { "DIMENSION", 0, 0, 0, ""},
838
 
  { "DISJOINT", 0, 0, 0, ""},
839
 
  { "ELT", 0, 0, 0, ""},
840
 
  { "ENCODE", 0, 0, 0, ""},
841
 
  { "ENCRYPT", 0, 0, 0, ""},
842
 
  { "ENDPOINT", 0, 0, 0, ""},
843
 
  { "ENVELOPE", 0, 0, 0, ""},
844
 
  { "EQUALS", 0, 0, 0, ""},
845
 
  { "EXTERIORRING", 0, 0, 0, ""},
846
 
  { "EXTRACT", 0, 0, 0, ""},
847
 
  { "EXP", 0, 0, 0, ""},
848
 
  { "EXPORT_SET", 0, 0, 0, ""},
849
 
  { "FIELD", 0, 0, 0, ""},
850
 
  { "FIND_IN_SET", 0, 0, 0, ""},
851
 
  { "FLOOR", 0, 0, 0, ""},
852
 
  { "FORMAT", 0, 0, 0, ""},
853
 
  { "FOUND_ROWS", 0, 0, 0, ""},
854
 
  { "FROM_DAYS", 0, 0, 0, ""},
855
 
  { "FROM_UNIXTIME", 0, 0, 0, ""},
856
 
  { "GET_LOCK", 0, 0, 0, ""},
857
 
  { "GLENGTH", 0, 0, 0, ""},
858
 
  { "GREATEST", 0, 0, 0, ""},
859
 
  { "GROUP_CONCAT", 0, 0, 0, ""},
860
 
  { "GROUP_UNIQUE_USERS", 0, 0, 0, ""},
861
 
  { "HEX", 0, 0, 0, ""},
862
 
  { "IFNULL", 0, 0, 0, ""},
863
 
  { "INET_ATON", 0, 0, 0, ""},
864
 
  { "INET_NTOA", 0, 0, 0, ""},
865
 
  { "INSTR", 0, 0, 0, ""},
866
 
  { "INTERIORRINGN", 0, 0, 0, ""},
867
 
  { "INTERSECTS", 0, 0, 0, ""},
868
 
  { "ISCLOSED", 0, 0, 0, ""},
869
 
  { "ISEMPTY", 0, 0, 0, ""},
870
 
  { "ISNULL", 0, 0, 0, ""},
871
 
  { "IS_FREE_LOCK", 0, 0, 0, ""},
872
 
  { "IS_USED_LOCK", 0, 0, 0, ""},
873
 
  { "LAST_INSERT_ID", 0, 0, 0, ""},
874
 
  { "ISSIMPLE", 0, 0, 0, ""},
875
 
  { "LAST_DAY", 0, 0, 0, ""},
876
 
  { "LCASE", 0, 0, 0, ""},
877
 
  { "LEAST", 0, 0, 0, ""},
878
 
  { "LENGTH", 0, 0, 0, ""},
879
 
  { "LN", 0, 0, 0, ""},
880
 
  { "LINEFROMTEXT", 0, 0, 0, ""},
881
 
  { "LINEFROMWKB", 0, 0, 0, ""},
882
 
  { "LINESTRINGFROMTEXT", 0, 0, 0, ""},
883
 
  { "LINESTRINGFROMWKB", 0, 0, 0, ""},
884
 
  { "LOAD_FILE", 0, 0, 0, ""},
885
 
  { "LOCATE", 0, 0, 0, ""},
886
 
  { "LOG", 0, 0, 0, ""},
887
 
  { "LOG2", 0, 0, 0, ""},
888
 
  { "LOG10", 0, 0, 0, ""},
889
 
  { "LOWER", 0, 0, 0, ""},
890
 
  { "LPAD", 0, 0, 0, ""},
891
 
  { "LTRIM", 0, 0, 0, ""},
892
 
  { "MAKE_SET", 0, 0, 0, ""},
893
 
  { "MAKEDATE", 0, 0, 0, ""},
894
 
  { "MASTER_POS_WAIT", 0, 0, 0, ""},
895
 
  { "MAX", 0, 0, 0, ""},
896
 
  { "MBRCONTAINS", 0, 0, 0, ""},
897
 
  { "MBRDISJOINT", 0, 0, 0, ""},
898
 
  { "MBREQUAL", 0, 0, 0, ""},
899
 
  { "MBRINTERSECTS", 0, 0, 0, ""},
900
 
  { "MBROVERLAPS", 0, 0, 0, ""},
901
 
  { "MBRTOUCHES", 0, 0, 0, ""},
902
 
  { "MBRWITHIN", 0, 0, 0, ""},
903
 
  { "MD5", 0, 0, 0, ""},
904
 
  { "MID", 0, 0, 0, ""},
905
 
  { "MIN", 0, 0, 0, ""},
906
 
  { "MLINEFROMTEXT", 0, 0, 0, ""},
907
 
  { "MLINEFROMWKB", 0, 0, 0, ""},
908
 
  { "MPOINTFROMTEXT", 0, 0, 0, ""},
909
 
  { "MPOINTFROMWKB", 0, 0, 0, ""},
910
 
  { "MPOLYFROMTEXT", 0, 0, 0, ""},
911
 
  { "MPOLYFROMWKB", 0, 0, 0, ""},
912
 
  { "MONTHNAME", 0, 0, 0, ""},
913
 
  { "MULTILINESTRINGFROMTEXT", 0, 0, 0, ""},
914
 
  { "MULTILINESTRINGFROMWKB", 0, 0, 0, ""},
915
 
  { "MULTIPOINTFROMTEXT", 0, 0, 0, ""},
916
 
  { "MULTIPOINTFROMWKB", 0, 0, 0, ""},
917
 
  { "MULTIPOLYGONFROMTEXT", 0, 0, 0, ""},
918
 
  { "MULTIPOLYGONFROMWKB", 0, 0, 0, ""},
919
 
  { "NAME_CONST", 0, 0, 0, ""},
920
 
  { "NOW", 0, 0, 0, ""},
921
 
  { "NULLIF", 0, 0, 0, ""},
922
 
  { "NUMINTERIORRINGS", 0, 0, 0, ""},
923
 
  { "NUMPOINTS", 0, 0, 0, ""},
924
 
  { "OCTET_LENGTH", 0, 0, 0, ""},
925
 
  { "OCT", 0, 0, 0, ""},
926
 
  { "ORD", 0, 0, 0, ""},
927
 
  { "OVERLAPS", 0, 0, 0, ""},
928
 
  { "PERIOD_ADD", 0, 0, 0, ""},
929
 
  { "PERIOD_DIFF", 0, 0, 0, ""},
930
 
  { "PI", 0, 0, 0, ""},
931
 
  { "POINTFROMTEXT", 0, 0, 0, ""},
932
 
  { "POINTFROMWKB", 0, 0, 0, ""},
933
 
  { "POINTN", 0, 0, 0, ""},
934
 
  { "POLYFROMTEXT", 0, 0, 0, ""},
935
 
  { "POLYFROMWKB", 0, 0, 0, ""},
936
 
  { "POLYGONFROMTEXT", 0, 0, 0, ""},
937
 
  { "POLYGONFROMWKB", 0, 0, 0, ""},
938
 
  { "POSITION", 0, 0, 0, ""},
939
 
  { "POW", 0, 0, 0, ""},
940
 
  { "POWER", 0, 0, 0, ""},
941
 
  { "QUOTE", 0, 0, 0, ""},
942
 
  { "RADIANS", 0, 0, 0, ""},
943
 
  { "RAND", 0, 0, 0, ""},
944
 
  { "RELEASE_LOCK", 0, 0, 0, ""},
945
 
  { "REVERSE", 0, 0, 0, ""},
946
 
  { "ROUND", 0, 0, 0, ""},
947
 
  { "ROW_COUNT", 0, 0, 0, ""},
948
 
  { "RPAD", 0, 0, 0, ""},
949
 
  { "RTRIM", 0, 0, 0, ""},
950
 
  { "SESSION_USER", 0, 0, 0, ""},
951
 
  { "SUBDATE", 0, 0, 0, ""},
952
 
  { "SIGN", 0, 0, 0, ""},
953
 
  { "SIN", 0, 0, 0, ""},
954
 
  { "SHA", 0, 0, 0, ""},
955
 
  { "SHA1", 0, 0, 0, ""},
956
 
  { "SLEEP", 0, 0, 0, ""},
957
 
  { "SOUNDEX", 0, 0, 0, ""},
958
 
  { "SPACE", 0, 0, 0, ""},
959
 
  { "SQRT", 0, 0, 0, ""},
960
 
  { "SRID", 0, 0, 0, ""},
961
 
  { "STARTPOINT", 0, 0, 0, ""},
962
 
  { "STD", 0, 0, 0, ""},
963
 
  { "STDDEV", 0, 0, 0, ""},
964
 
  { "STDDEV_POP", 0, 0, 0, ""},
965
 
  { "STDDEV_SAMP", 0, 0, 0, ""},
966
 
  { "STR_TO_DATE", 0, 0, 0, ""},
967
 
  { "STRCMP", 0, 0, 0, ""},
968
 
  { "SUBSTR", 0, 0, 0, ""},
969
 
  { "SUBSTRING", 0, 0, 0, ""},
970
 
  { "SUBSTRING_INDEX", 0, 0, 0, ""},
971
 
  { "SUM", 0, 0, 0, ""},
972
 
  { "SYSDATE", 0, 0, 0, ""},
973
 
  { "SYSTEM_USER", 0, 0, 0, ""},
974
 
  { "TAN", 0, 0, 0, ""},
975
 
  { "TIME_FORMAT", 0, 0, 0, ""},
976
 
  { "TO_DAYS", 0, 0, 0, ""},
977
 
  { "TOUCHES", 0, 0, 0, ""},
978
 
  { "TRIM", 0, 0, 0, ""},
979
 
  { "UCASE", 0, 0, 0, ""},
980
 
  { "UNCOMPRESS", 0, 0, 0, ""},
981
 
  { "UNCOMPRESSED_LENGTH", 0, 0, 0, ""},
982
 
  { "UNHEX", 0, 0, 0, ""},
983
 
  { "UNIQUE_USERS", 0, 0, 0, ""},
984
 
  { "UNIX_TIMESTAMP", 0, 0, 0, ""},
985
 
  { "UPPER", 0, 0, 0, ""},
986
 
  { "UUID", 0, 0, 0, ""},
987
 
  { "VARIANCE", 0, 0, 0, ""},
988
 
  { "VAR_POP", 0, 0, 0, ""},
989
 
  { "VAR_SAMP", 0, 0, 0, ""},
990
 
  { "VERSION", 0, 0, 0, ""},
991
 
  { "WEEKDAY", 0, 0, 0, ""},
992
 
  { "WEEKOFYEAR", 0, 0, 0, ""},
993
 
  { "WITHIN", 0, 0, 0, ""},
994
 
  { "X", 0, 0, 0, ""},
995
 
  { "Y", 0, 0, 0, ""},
996
 
  { "YEARWEEK", 0, 0, 0, ""},
 
514
  Commands( "ACTION", 0, 0, 0, ""),
 
515
  Commands( "ADD", 0, 0, 0, ""),
 
516
  Commands( "AFTER", 0, 0, 0, ""),
 
517
  Commands( "AGAINST", 0, 0, 0, ""),
 
518
  Commands( "AGGREGATE", 0, 0, 0, ""),
 
519
  Commands( "ALL", 0, 0, 0, ""),
 
520
  Commands( "ALGORITHM", 0, 0, 0, ""),
 
521
  Commands( "ALTER", 0, 0, 0, ""),
 
522
  Commands( "ANALYZE", 0, 0, 0, ""),
 
523
  Commands( "AND", 0, 0, 0, ""),
 
524
  Commands( "ANY", 0, 0, 0, ""),
 
525
  Commands( "AS", 0, 0, 0, ""),
 
526
  Commands( "ASC", 0, 0, 0, ""),
 
527
  Commands( "ASCII", 0, 0, 0, ""),
 
528
  Commands( "ASENSITIVE", 0, 0, 0, ""),
 
529
  Commands( "AUTO_INCREMENT", 0, 0, 0, ""),
 
530
  Commands( "AVG", 0, 0, 0, ""),
 
531
  Commands( "AVG_ROW_LENGTH", 0, 0, 0, ""),
 
532
  Commands( "BEFORE", 0, 0, 0, ""),
 
533
  Commands( "BEGIN", 0, 0, 0, ""),
 
534
  Commands( "BETWEEN", 0, 0, 0, ""),
 
535
  Commands( "BIGINT", 0, 0, 0, ""),
 
536
  Commands( "BINARY", 0, 0, 0, ""),
 
537
  Commands( "BIT", 0, 0, 0, ""),
 
538
  Commands( "BLOB", 0, 0, 0, ""),
 
539
  Commands( "BOOL", 0, 0, 0, ""),
 
540
  Commands( "BOOLEAN", 0, 0, 0, ""),
 
541
  Commands( "BOTH", 0, 0, 0, ""),
 
542
  Commands( "BTREE", 0, 0, 0, ""),
 
543
  Commands( "BY", 0, 0, 0, ""),
 
544
  Commands( "BYTE", 0, 0, 0, ""),
 
545
  Commands( "CACHE", 0, 0, 0, ""),
 
546
  Commands( "CALL", 0, 0, 0, ""),
 
547
  Commands( "CASCADE", 0, 0, 0, ""),
 
548
  Commands( "CASCADED", 0, 0, 0, ""),
 
549
  Commands( "CASE", 0, 0, 0, ""),
 
550
  Commands( "CHAIN", 0, 0, 0, ""),
 
551
  Commands( "CHANGE", 0, 0, 0, ""),
 
552
  Commands( "CHANGED", 0, 0, 0, ""),
 
553
  Commands( "CHAR", 0, 0, 0, ""),
 
554
  Commands( "CHARACTER", 0, 0, 0, ""),
 
555
  Commands( "CHECK", 0, 0, 0, ""),
 
556
  Commands( "CHECKSUM", 0, 0, 0, ""),
 
557
  Commands( "CLIENT", 0, 0, 0, ""),
 
558
  Commands( "CLOSE", 0, 0, 0, ""),
 
559
  Commands( "COLLATE", 0, 0, 0, ""),
 
560
  Commands( "COLLATION", 0, 0, 0, ""),
 
561
  Commands( "COLUMN", 0, 0, 0, ""),
 
562
  Commands( "COLUMNS", 0, 0, 0, ""),
 
563
  Commands( "COMMENT", 0, 0, 0, ""),
 
564
  Commands( "COMMIT", 0, 0, 0, ""),
 
565
  Commands( "COMMITTED", 0, 0, 0, ""),
 
566
  Commands( "COMPACT", 0, 0, 0, ""),
 
567
  Commands( "COMPRESSED", 0, 0, 0, ""),
 
568
  Commands( "CONCURRENT", 0, 0, 0, ""),
 
569
  Commands( "CONDITION", 0, 0, 0, ""),
 
570
  Commands( "CONNECTION", 0, 0, 0, ""),
 
571
  Commands( "CONSISTENT", 0, 0, 0, ""),
 
572
  Commands( "CONSTRAINT", 0, 0, 0, ""),
 
573
  Commands( "CONTAINS", 0, 0, 0, ""),
 
574
  Commands( "CONTINUE", 0, 0, 0, ""),
 
575
  Commands( "CONVERT", 0, 0, 0, ""),
 
576
  Commands( "CREATE", 0, 0, 0, ""),
 
577
  Commands( "CROSS", 0, 0, 0, ""),
 
578
  Commands( "CUBE", 0, 0, 0, ""),
 
579
  Commands( "CURRENT_DATE", 0, 0, 0, ""),
 
580
  Commands( "CURRENT_TIMESTAMP", 0, 0, 0, ""),
 
581
  Commands( "CURRENT_USER", 0, 0, 0, ""),
 
582
  Commands( "CURSOR", 0, 0, 0, ""),
 
583
  Commands( "DATA", 0, 0, 0, ""),
 
584
  Commands( "DATABASE", 0, 0, 0, ""),
 
585
  Commands( "DATABASES", 0, 0, 0, ""),
 
586
  Commands( "DATE", 0, 0, 0, ""),
 
587
  Commands( "DATETIME", 0, 0, 0, ""),
 
588
  Commands( "DAY", 0, 0, 0, ""),
 
589
  Commands( "DAY_HOUR", 0, 0, 0, ""),
 
590
  Commands( "DAY_MICROSECOND", 0, 0, 0, ""),
 
591
  Commands( "DAY_MINUTE", 0, 0, 0, ""),
 
592
  Commands( "DAY_SECOND", 0, 0, 0, ""),
 
593
  Commands( "DEALLOCATE", 0, 0, 0, ""),
 
594
  Commands( "DEC", 0, 0, 0, ""),
 
595
  Commands( "DECIMAL", 0, 0, 0, ""),
 
596
  Commands( "DECLARE", 0, 0, 0, ""),
 
597
  Commands( "DEFAULT", 0, 0, 0, ""),
 
598
  Commands( "DEFINER", 0, 0, 0, ""),
 
599
  Commands( "DELAYED", 0, 0, 0, ""),
 
600
  Commands( "DELETE", 0, 0, 0, ""),
 
601
  Commands( "DESC", 0, 0, 0, ""),
 
602
  Commands( "DESCRIBE", 0, 0, 0, ""),
 
603
  Commands( "DETERMINISTIC", 0, 0, 0, ""),
 
604
  Commands( "DISABLE", 0, 0, 0, ""),
 
605
  Commands( "DISCARD", 0, 0, 0, ""),
 
606
  Commands( "DISTINCT", 0, 0, 0, ""),
 
607
  Commands( "DISTINCTROW", 0, 0, 0, ""),
 
608
  Commands( "DIV", 0, 0, 0, ""),
 
609
  Commands( "DOUBLE", 0, 0, 0, ""),
 
610
  Commands( "DROP", 0, 0, 0, ""),
 
611
  Commands( "DUMPFILE", 0, 0, 0, ""),
 
612
  Commands( "DUPLICATE", 0, 0, 0, ""),
 
613
  Commands( "DYNAMIC", 0, 0, 0, ""),
 
614
  Commands( "EACH", 0, 0, 0, ""),
 
615
  Commands( "ELSE", 0, 0, 0, ""),
 
616
  Commands( "ELSEIF", 0, 0, 0, ""),
 
617
  Commands( "ENABLE", 0, 0, 0, ""),
 
618
  Commands( "ENCLOSED", 0, 0, 0, ""),
 
619
  Commands( "END", 0, 0, 0, ""),
 
620
  Commands( "ENGINE", 0, 0, 0, ""),
 
621
  Commands( "ENGINES", 0, 0, 0, ""),
 
622
  Commands( "ENUM", 0, 0, 0, ""),
 
623
  Commands( "ERRORS", 0, 0, 0, ""),
 
624
  Commands( "ESCAPE", 0, 0, 0, ""),
 
625
  Commands( "ESCAPED", 0, 0, 0, ""),
 
626
  Commands( "EXISTS", 0, 0, 0, ""),
 
627
  Commands( "EXIT", 0, 0, 0, ""),
 
628
  Commands( "EXPLAIN", 0, 0, 0, ""),
 
629
  Commands( "EXTENDED", 0, 0, 0, ""),
 
630
  Commands( "FALSE", 0, 0, 0, ""),
 
631
  Commands( "FAST", 0, 0, 0, ""),
 
632
  Commands( "FETCH", 0, 0, 0, ""),
 
633
  Commands( "FIELDS", 0, 0, 0, ""),
 
634
  Commands( "FILE", 0, 0, 0, ""),
 
635
  Commands( "FIRST", 0, 0, 0, ""),
 
636
  Commands( "FIXED", 0, 0, 0, ""),
 
637
  Commands( "FLOAT", 0, 0, 0, ""),
 
638
  Commands( "FLOAT4", 0, 0, 0, ""),
 
639
  Commands( "FLOAT8", 0, 0, 0, ""),
 
640
  Commands( "FLUSH", 0, 0, 0, ""),
 
641
  Commands( "FOR", 0, 0, 0, ""),
 
642
  Commands( "FORCE", 0, 0, 0, ""),
 
643
  Commands( "FOREIGN", 0, 0, 0, ""),
 
644
  Commands( "FOUND", 0, 0, 0, ""),
 
645
  Commands( "FRAC_SECOND", 0, 0, 0, ""),
 
646
  Commands( "FROM", 0, 0, 0, ""),
 
647
  Commands( "FULL", 0, 0, 0, ""),
 
648
  Commands( "FUNCTION", 0, 0, 0, ""),
 
649
  Commands( "GLOBAL", 0, 0, 0, ""),
 
650
  Commands( "GRANT", 0, 0, 0, ""),
 
651
  Commands( "GRANTS", 0, 0, 0, ""),
 
652
  Commands( "GROUP", 0, 0, 0, ""),
 
653
  Commands( "HANDLER", 0, 0, 0, ""),
 
654
  Commands( "HASH", 0, 0, 0, ""),
 
655
  Commands( "HAVING", 0, 0, 0, ""),
 
656
  Commands( "HELP", 0, 0, 0, ""),
 
657
  Commands( "HIGH_PRIORITY", 0, 0, 0, ""),
 
658
  Commands( "HOSTS", 0, 0, 0, ""),
 
659
  Commands( "HOUR", 0, 0, 0, ""),
 
660
  Commands( "HOUR_MICROSECOND", 0, 0, 0, ""),
 
661
  Commands( "HOUR_MINUTE", 0, 0, 0, ""),
 
662
  Commands( "HOUR_SECOND", 0, 0, 0, ""),
 
663
  Commands( "IDENTIFIED", 0, 0, 0, ""),
 
664
  Commands( "IF", 0, 0, 0, ""),
 
665
  Commands( "IGNORE", 0, 0, 0, ""),
 
666
  Commands( "IMPORT", 0, 0, 0, ""),
 
667
  Commands( "IN", 0, 0, 0, ""),
 
668
  Commands( "INDEX", 0, 0, 0, ""),
 
669
  Commands( "INDEXES", 0, 0, 0, ""),
 
670
  Commands( "INFILE", 0, 0, 0, ""),
 
671
  Commands( "INNER", 0, 0, 0, ""),
 
672
  Commands( "INNOBASE", 0, 0, 0, ""),
 
673
  Commands( "INNODB", 0, 0, 0, ""),
 
674
  Commands( "INOUT", 0, 0, 0, ""),
 
675
  Commands( "INSENSITIVE", 0, 0, 0, ""),
 
676
  Commands( "INSERT", 0, 0, 0, ""),
 
677
  Commands( "INSERT_METHOD", 0, 0, 0, ""),
 
678
  Commands( "INT", 0, 0, 0, ""),
 
679
  Commands( "INT1", 0, 0, 0, ""),
 
680
  Commands( "INT2", 0, 0, 0, ""),
 
681
  Commands( "INT3", 0, 0, 0, ""),
 
682
  Commands( "INT4", 0, 0, 0, ""),
 
683
  Commands( "INT8", 0, 0, 0, ""),
 
684
  Commands( "INTEGER", 0, 0, 0, ""),
 
685
  Commands( "INTERVAL", 0, 0, 0, ""),
 
686
  Commands( "INTO", 0, 0, 0, ""),
 
687
  Commands( "IO_THREAD", 0, 0, 0, ""),
 
688
  Commands( "IS", 0, 0, 0, ""),
 
689
  Commands( "ISOLATION", 0, 0, 0, ""),
 
690
  Commands( "ISSUER", 0, 0, 0, ""),
 
691
  Commands( "ITERATE", 0, 0, 0, ""),
 
692
  Commands( "INVOKER", 0, 0, 0, ""),
 
693
  Commands( "JOIN", 0, 0, 0, ""),
 
694
  Commands( "KEY", 0, 0, 0, ""),
 
695
  Commands( "KEYS", 0, 0, 0, ""),
 
696
  Commands( "KILL", 0, 0, 0, ""),
 
697
  Commands( "LANGUAGE", 0, 0, 0, ""),
 
698
  Commands( "LAST", 0, 0, 0, ""),
 
699
  Commands( "LEADING", 0, 0, 0, ""),
 
700
  Commands( "LEAVE", 0, 0, 0, ""),
 
701
  Commands( "LEAVES", 0, 0, 0, ""),
 
702
  Commands( "LEFT", 0, 0, 0, ""),
 
703
  Commands( "LEVEL", 0, 0, 0, ""),
 
704
  Commands( "LIKE", 0, 0, 0, ""),
 
705
  Commands( "LIMIT", 0, 0, 0, ""),
 
706
  Commands( "LINES", 0, 0, 0, ""),
 
707
  Commands( "LINESTRING", 0, 0, 0, ""),
 
708
  Commands( "LOAD", 0, 0, 0, ""),
 
709
  Commands( "LOCAL", 0, 0, 0, ""),
 
710
  Commands( "LOCALTIMESTAMP", 0, 0, 0, ""),
 
711
  Commands( "LOCK", 0, 0, 0, ""),
 
712
  Commands( "LOCKS", 0, 0, 0, ""),
 
713
  Commands( "LOGS", 0, 0, 0, ""),
 
714
  Commands( "LONG", 0, 0, 0, ""),
 
715
  Commands( "LOOP", 0, 0, 0, ""),
 
716
  Commands( "MATCH", 0, 0, 0, ""),
 
717
  Commands( "MAX_CONNECTIONS_PER_HOUR", 0, 0, 0, ""),
 
718
  Commands( "MAX_QUERIES_PER_HOUR", 0, 0, 0, ""),
 
719
  Commands( "MAX_ROWS", 0, 0, 0, ""),
 
720
  Commands( "MAX_UPDATES_PER_HOUR", 0, 0, 0, ""),
 
721
  Commands( "MAX_USER_CONNECTIONS", 0, 0, 0, ""),
 
722
  Commands( "MEDIUM", 0, 0, 0, ""),
 
723
  Commands( "MERGE", 0, 0, 0, ""),
 
724
  Commands( "MICROSECOND", 0, 0, 0, ""),
 
725
  Commands( "MIGRATE", 0, 0, 0, ""),
 
726
  Commands( "MINUTE", 0, 0, 0, ""),
 
727
  Commands( "MINUTE_MICROSECOND", 0, 0, 0, ""),
 
728
  Commands( "MINUTE_SECOND", 0, 0, 0, ""),
 
729
  Commands( "MIN_ROWS", 0, 0, 0, ""),
 
730
  Commands( "MOD", 0, 0, 0, ""),
 
731
  Commands( "MODE", 0, 0, 0, ""),
 
732
  Commands( "MODIFIES", 0, 0, 0, ""),
 
733
  Commands( "MODIFY", 0, 0, 0, ""),
 
734
  Commands( "MONTH", 0, 0, 0, ""),
 
735
  Commands( "MULTILINESTRING", 0, 0, 0, ""),
 
736
  Commands( "MULTIPOINT", 0, 0, 0, ""),
 
737
  Commands( "MULTIPOLYGON", 0, 0, 0, ""),
 
738
  Commands( "MUTEX", 0, 0, 0, ""),
 
739
  Commands( "NAME", 0, 0, 0, ""),
 
740
  Commands( "NAMES", 0, 0, 0, ""),
 
741
  Commands( "NATIONAL", 0, 0, 0, ""),
 
742
  Commands( "NATURAL", 0, 0, 0, ""),
 
743
  Commands( "NCHAR", 0, 0, 0, ""),
 
744
  Commands( "NEW", 0, 0, 0, ""),
 
745
  Commands( "NEXT", 0, 0, 0, ""),
 
746
  Commands( "NO", 0, 0, 0, ""),
 
747
  Commands( "NONE", 0, 0, 0, ""),
 
748
  Commands( "NOT", 0, 0, 0, ""),
 
749
  Commands( "NULL", 0, 0, 0, ""),
 
750
  Commands( "NUMERIC", 0, 0, 0, ""),
 
751
  Commands( "NVARCHAR", 0, 0, 0, ""),
 
752
  Commands( "OFFSET", 0, 0, 0, ""),
 
753
  Commands( "ON", 0, 0, 0, ""),
 
754
  Commands( "ONE", 0, 0, 0, ""),
 
755
  Commands( "ONE_SHOT", 0, 0, 0, ""),
 
756
  Commands( "OPEN", 0, 0, 0, ""),
 
757
  Commands( "OPTIMIZE", 0, 0, 0, ""),
 
758
  Commands( "OPTION", 0, 0, 0, ""),
 
759
  Commands( "OPTIONALLY", 0, 0, 0, ""),
 
760
  Commands( "OR", 0, 0, 0, ""),
 
761
  Commands( "ORDER", 0, 0, 0, ""),
 
762
  Commands( "OUT", 0, 0, 0, ""),
 
763
  Commands( "OUTER", 0, 0, 0, ""),
 
764
  Commands( "OUTFILE", 0, 0, 0, ""),
 
765
  Commands( "PACK_KEYS", 0, 0, 0, ""),
 
766
  Commands( "PARTIAL", 0, 0, 0, ""),
 
767
  Commands( "PASSWORD", 0, 0, 0, ""),
 
768
  Commands( "PHASE", 0, 0, 0, ""),
 
769
  Commands( "PRECISION", 0, 0, 0, ""),
 
770
  Commands( "PREPARE", 0, 0, 0, ""),
 
771
  Commands( "PREV", 0, 0, 0, ""),
 
772
  Commands( "PRIMARY", 0, 0, 0, ""),
 
773
  Commands( "PRIVILEGES", 0, 0, 0, ""),
 
774
  Commands( "PROCEDURE", 0, 0, 0, ""),
 
775
  Commands( "PROCESS", 0, 0, 0, ""),
 
776
  Commands( "PROCESSLIST", 0, 0, 0, ""),
 
777
  Commands( "PURGE", 0, 0, 0, ""),
 
778
  Commands( "QUARTER", 0, 0, 0, ""),
 
779
  Commands( "QUERY", 0, 0, 0, ""),
 
780
  Commands( "QUICK", 0, 0, 0, ""),
 
781
  Commands( "READ", 0, 0, 0, ""),
 
782
  Commands( "READS", 0, 0, 0, ""),
 
783
  Commands( "REAL", 0, 0, 0, ""),
 
784
  Commands( "RECOVER", 0, 0, 0, ""),
 
785
  Commands( "REDUNDANT", 0, 0, 0, ""),
 
786
  Commands( "REFERENCES", 0, 0, 0, ""),
 
787
  Commands( "REGEXP", 0, 0, 0, ""),
 
788
  Commands( "RELEASE", 0, 0, 0, ""),
 
789
  Commands( "RELOAD", 0, 0, 0, ""),
 
790
  Commands( "RENAME", 0, 0, 0, ""),
 
791
  Commands( "REPAIR", 0, 0, 0, ""),
 
792
  Commands( "REPEATABLE", 0, 0, 0, ""),
 
793
  Commands( "REPLACE", 0, 0, 0, ""),
 
794
  Commands( "REPEAT", 0, 0, 0, ""),
 
795
  Commands( "REQUIRE", 0, 0, 0, ""),
 
796
  Commands( "RESET", 0, 0, 0, ""),
 
797
  Commands( "RESTORE", 0, 0, 0, ""),
 
798
  Commands( "RESTRICT", 0, 0, 0, ""),
 
799
  Commands( "RESUME", 0, 0, 0, ""),
 
800
  Commands( "RETURN", 0, 0, 0, ""),
 
801
  Commands( "RETURNS", 0, 0, 0, ""),
 
802
  Commands( "REVOKE", 0, 0, 0, ""),
 
803
  Commands( "RIGHT", 0, 0, 0, ""),
 
804
  Commands( "RLIKE", 0, 0, 0, ""),
 
805
  Commands( "ROLLBACK", 0, 0, 0, ""),
 
806
  Commands( "ROLLUP", 0, 0, 0, ""),
 
807
  Commands( "ROUTINE", 0, 0, 0, ""),
 
808
  Commands( "ROW", 0, 0, 0, ""),
 
809
  Commands( "ROWS", 0, 0, 0, ""),
 
810
  Commands( "ROW_FORMAT", 0, 0, 0, ""),
 
811
  Commands( "RTREE", 0, 0, 0, ""),
 
812
  Commands( "SAVEPOINT", 0, 0, 0, ""),
 
813
  Commands( "SCHEMA", 0, 0, 0, ""),
 
814
  Commands( "SCHEMAS", 0, 0, 0, ""),
 
815
  Commands( "SECOND", 0, 0, 0, ""),
 
816
  Commands( "SECOND_MICROSECOND", 0, 0, 0, ""),
 
817
  Commands( "SECURITY", 0, 0, 0, ""),
 
818
  Commands( "SELECT", 0, 0, 0, ""),
 
819
  Commands( "SENSITIVE", 0, 0, 0, ""),
 
820
  Commands( "SEPARATOR", 0, 0, 0, ""),
 
821
  Commands( "SERIAL", 0, 0, 0, ""),
 
822
  Commands( "SERIALIZABLE", 0, 0, 0, ""),
 
823
  Commands( "SESSION", 0, 0, 0, ""),
 
824
  Commands( "SET", 0, 0, 0, ""),
 
825
  Commands( "SHARE", 0, 0, 0, ""),
 
826
  Commands( "SHOW", 0, 0, 0, ""),
 
827
  Commands( "SHUTDOWN", 0, 0, 0, ""),
 
828
  Commands( "SIGNED", 0, 0, 0, ""),
 
829
  Commands( "SIMPLE", 0, 0, 0, ""),
 
830
  Commands( "SLAVE", 0, 0, 0, ""),
 
831
  Commands( "SNAPSHOT", 0, 0, 0, ""),
 
832
  Commands( "SOME", 0, 0, 0, ""),
 
833
  Commands( "SONAME", 0, 0, 0, ""),
 
834
  Commands( "SOUNDS", 0, 0, 0, ""),
 
835
  Commands( "SPATIAL", 0, 0, 0, ""),
 
836
  Commands( "SPECIFIC", 0, 0, 0, ""),
 
837
  Commands( "SQL", 0, 0, 0, ""),
 
838
  Commands( "SQLEXCEPTION", 0, 0, 0, ""),
 
839
  Commands( "SQLSTATE", 0, 0, 0, ""),
 
840
  Commands( "SQLWARNING", 0, 0, 0, ""),
 
841
  Commands( "SQL_BIG_RESULT", 0, 0, 0, ""),
 
842
  Commands( "SQL_BUFFER_RESULT", 0, 0, 0, ""),
 
843
  Commands( "SQL_CACHE", 0, 0, 0, ""),
 
844
  Commands( "SQL_CALC_FOUND_ROWS", 0, 0, 0, ""),
 
845
  Commands( "SQL_NO_CACHE", 0, 0, 0, ""),
 
846
  Commands( "SQL_SMALL_RESULT", 0, 0, 0, ""),
 
847
  Commands( "SQL_THREAD", 0, 0, 0, ""),
 
848
  Commands( "SQL_TSI_FRAC_SECOND", 0, 0, 0, ""),
 
849
  Commands( "SQL_TSI_SECOND", 0, 0, 0, ""),
 
850
  Commands( "SQL_TSI_MINUTE", 0, 0, 0, ""),
 
851
  Commands( "SQL_TSI_HOUR", 0, 0, 0, ""),
 
852
  Commands( "SQL_TSI_DAY", 0, 0, 0, ""),
 
853
  Commands( "SQL_TSI_WEEK", 0, 0, 0, ""),
 
854
  Commands( "SQL_TSI_MONTH", 0, 0, 0, ""),
 
855
  Commands( "SQL_TSI_QUARTER", 0, 0, 0, ""),
 
856
  Commands( "SQL_TSI_YEAR", 0, 0, 0, ""),
 
857
  Commands( "SSL", 0, 0, 0, ""),
 
858
  Commands( "START", 0, 0, 0, ""),
 
859
  Commands( "STARTING", 0, 0, 0, ""),
 
860
  Commands( "STATUS", 0, 0, 0, ""),
 
861
  Commands( "STOP", 0, 0, 0, ""),
 
862
  Commands( "STORAGE", 0, 0, 0, ""),
 
863
  Commands( "STRAIGHT_JOIN", 0, 0, 0, ""),
 
864
  Commands( "STRING", 0, 0, 0, ""),
 
865
  Commands( "STRIPED", 0, 0, 0, ""),
 
866
  Commands( "SUBJECT", 0, 0, 0, ""),
 
867
  Commands( "SUPER", 0, 0, 0, ""),
 
868
  Commands( "SUSPEND", 0, 0, 0, ""),
 
869
  Commands( "TABLE", 0, 0, 0, ""),
 
870
  Commands( "TABLES", 0, 0, 0, ""),
 
871
  Commands( "TABLESPACE", 0, 0, 0, ""),
 
872
  Commands( "TEMPORARY", 0, 0, 0, ""),
 
873
  Commands( "TEMPTABLE", 0, 0, 0, ""),
 
874
  Commands( "TERMINATED", 0, 0, 0, ""),
 
875
  Commands( "TEXT", 0, 0, 0, ""),
 
876
  Commands( "THEN", 0, 0, 0, ""),
 
877
  Commands( "TIMESTAMP", 0, 0, 0, ""),
 
878
  Commands( "TIMESTAMPADD", 0, 0, 0, ""),
 
879
  Commands( "TIMESTAMPDIFF", 0, 0, 0, ""),
 
880
  Commands( "TO", 0, 0, 0, ""),
 
881
  Commands( "TRAILING", 0, 0, 0, ""),
 
882
  Commands( "TRANSACTION", 0, 0, 0, ""),
 
883
  Commands( "TRUE", 0, 0, 0, ""),
 
884
  Commands( "TRUNCATE", 0, 0, 0, ""),
 
885
  Commands( "TYPE", 0, 0, 0, ""),
 
886
  Commands( "TYPES", 0, 0, 0, ""),
 
887
  Commands( "UNCOMMITTED", 0, 0, 0, ""),
 
888
  Commands( "UNDEFINED", 0, 0, 0, ""),
 
889
  Commands( "UNDO", 0, 0, 0, ""),
 
890
  Commands( "UNICODE", 0, 0, 0, ""),
 
891
  Commands( "UNION", 0, 0, 0, ""),
 
892
  Commands( "UNIQUE", 0, 0, 0, ""),
 
893
  Commands( "UNKNOWN", 0, 0, 0, ""),
 
894
  Commands( "UNLOCK", 0, 0, 0, ""),
 
895
  Commands( "UNTIL", 0, 0, 0, ""),
 
896
  Commands( "UPDATE", 0, 0, 0, ""),
 
897
  Commands( "UPGRADE", 0, 0, 0, ""),
 
898
  Commands( "USAGE", 0, 0, 0, ""),
 
899
  Commands( "USE", 0, 0, 0, ""),
 
900
  Commands( "USER", 0, 0, 0, ""),
 
901
  Commands( "USER_RESOURCES", 0, 0, 0, ""),
 
902
  Commands( "USING", 0, 0, 0, ""),
 
903
  Commands( "UTC_DATE", 0, 0, 0, ""),
 
904
  Commands( "UTC_TIMESTAMP", 0, 0, 0, ""),
 
905
  Commands( "VALUE", 0, 0, 0, ""),
 
906
  Commands( "VALUES", 0, 0, 0, ""),
 
907
  Commands( "VARBINARY", 0, 0, 0, ""),
 
908
  Commands( "VARCHAR", 0, 0, 0, ""),
 
909
  Commands( "VARCHARACTER", 0, 0, 0, ""),
 
910
  Commands( "VARIABLES", 0, 0, 0, ""),
 
911
  Commands( "VARYING", 0, 0, 0, ""),
 
912
  Commands( "WARNINGS", 0, 0, 0, ""),
 
913
  Commands( "WEEK", 0, 0, 0, ""),
 
914
  Commands( "WHEN", 0, 0, 0, ""),
 
915
  Commands( "WHERE", 0, 0, 0, ""),
 
916
  Commands( "WHILE", 0, 0, 0, ""),
 
917
  Commands( "VIEW", 0, 0, 0, ""),
 
918
  Commands( "WITH", 0, 0, 0, ""),
 
919
  Commands( "WORK", 0, 0, 0, ""),
 
920
  Commands( "WRITE", 0, 0, 0, ""),
 
921
  Commands( "XOR", 0, 0, 0, ""),
 
922
  Commands( "XA", 0, 0, 0, ""),
 
923
  Commands( "YEAR", 0, 0, 0, ""),
 
924
  Commands( "YEAR_MONTH", 0, 0, 0, ""),
 
925
  Commands( "ZEROFILL", 0, 0, 0, ""),
 
926
  Commands( "ABS", 0, 0, 0, ""),
 
927
  Commands( "ACOS", 0, 0, 0, ""),
 
928
  Commands( "ADDDATE", 0, 0, 0, ""),
 
929
  Commands( "AREA", 0, 0, 0, ""),
 
930
  Commands( "ASIN", 0, 0, 0, ""),
 
931
  Commands( "ASBINARY", 0, 0, 0, ""),
 
932
  Commands( "ASTEXT", 0, 0, 0, ""),
 
933
  Commands( "ATAN", 0, 0, 0, ""),
 
934
  Commands( "ATAN2", 0, 0, 0, ""),
 
935
  Commands( "BENCHMARK", 0, 0, 0, ""),
 
936
  Commands( "BIN", 0, 0, 0, ""),
 
937
  Commands( "BIT_OR", 0, 0, 0, ""),
 
938
  Commands( "BIT_AND", 0, 0, 0, ""),
 
939
  Commands( "BIT_XOR", 0, 0, 0, ""),
 
940
  Commands( "CAST", 0, 0, 0, ""),
 
941
  Commands( "CEIL", 0, 0, 0, ""),
 
942
  Commands( "CEILING", 0, 0, 0, ""),
 
943
  Commands( "CENTROID", 0, 0, 0, ""),
 
944
  Commands( "CHAR_LENGTH", 0, 0, 0, ""),
 
945
  Commands( "CHARACTER_LENGTH", 0, 0, 0, ""),
 
946
  Commands( "COALESCE", 0, 0, 0, ""),
 
947
  Commands( "COERCIBILITY", 0, 0, 0, ""),
 
948
  Commands( "COMPRESS", 0, 0, 0, ""),
 
949
  Commands( "CONCAT", 0, 0, 0, ""),
 
950
  Commands( "CONCAT_WS", 0, 0, 0, ""),
 
951
  Commands( "CONNECTION_ID", 0, 0, 0, ""),
 
952
  Commands( "CONV", 0, 0, 0, ""),
 
953
  Commands( "CONVERT_TZ", 0, 0, 0, ""),
 
954
  Commands( "COUNT", 0, 0, 0, ""),
 
955
  Commands( "COS", 0, 0, 0, ""),
 
956
  Commands( "COT", 0, 0, 0, ""),
 
957
  Commands( "CRC32", 0, 0, 0, ""),
 
958
  Commands( "CROSSES", 0, 0, 0, ""),
 
959
  Commands( "CURDATE", 0, 0, 0, ""),
 
960
  Commands( "DATE_ADD", 0, 0, 0, ""),
 
961
  Commands( "DATEDIFF", 0, 0, 0, ""),
 
962
  Commands( "DATE_FORMAT", 0, 0, 0, ""),
 
963
  Commands( "DATE_SUB", 0, 0, 0, ""),
 
964
  Commands( "DAYNAME", 0, 0, 0, ""),
 
965
  Commands( "DAYOFMONTH", 0, 0, 0, ""),
 
966
  Commands( "DAYOFWEEK", 0, 0, 0, ""),
 
967
  Commands( "DAYOFYEAR", 0, 0, 0, ""),
 
968
  Commands( "DECODE", 0, 0, 0, ""),
 
969
  Commands( "DEGREES", 0, 0, 0, ""),
 
970
  Commands( "DES_ENCRYPT", 0, 0, 0, ""),
 
971
  Commands( "DES_DECRYPT", 0, 0, 0, ""),
 
972
  Commands( "DIMENSION", 0, 0, 0, ""),
 
973
  Commands( "DISJOINT", 0, 0, 0, ""),
 
974
  Commands( "ELT", 0, 0, 0, ""),
 
975
  Commands( "ENCODE", 0, 0, 0, ""),
 
976
  Commands( "ENCRYPT", 0, 0, 0, ""),
 
977
  Commands( "ENDPOINT", 0, 0, 0, ""),
 
978
  Commands( "ENVELOPE", 0, 0, 0, ""),
 
979
  Commands( "EQUALS", 0, 0, 0, ""),
 
980
  Commands( "EXTERIORRING", 0, 0, 0, ""),
 
981
  Commands( "EXTRACT", 0, 0, 0, ""),
 
982
  Commands( "EXP", 0, 0, 0, ""),
 
983
  Commands( "EXPORT_SET", 0, 0, 0, ""),
 
984
  Commands( "FIELD", 0, 0, 0, ""),
 
985
  Commands( "FIND_IN_SET", 0, 0, 0, ""),
 
986
  Commands( "FLOOR", 0, 0, 0, ""),
 
987
  Commands( "FORMAT", 0, 0, 0, ""),
 
988
  Commands( "FOUND_ROWS", 0, 0, 0, ""),
 
989
  Commands( "FROM_DAYS", 0, 0, 0, ""),
 
990
  Commands( "FROM_UNIXTIME", 0, 0, 0, ""),
 
991
  Commands( "GET_LOCK", 0, 0, 0, ""),
 
992
  Commands( "GLENGTH", 0, 0, 0, ""),
 
993
  Commands( "GREATEST", 0, 0, 0, ""),
 
994
  Commands( "GROUP_CONCAT", 0, 0, 0, ""),
 
995
  Commands( "GROUP_UNIQUE_USERS", 0, 0, 0, ""),
 
996
  Commands( "HEX", 0, 0, 0, ""),
 
997
  Commands( "IFNULL", 0, 0, 0, ""),
 
998
  Commands( "INSTR", 0, 0, 0, ""),
 
999
  Commands( "INTERIORRINGN", 0, 0, 0, ""),
 
1000
  Commands( "INTERSECTS", 0, 0, 0, ""),
 
1001
  Commands( "ISCLOSED", 0, 0, 0, ""),
 
1002
  Commands( "ISEMPTY", 0, 0, 0, ""),
 
1003
  Commands( "ISNULL", 0, 0, 0, ""),
 
1004
  Commands( "IS_FREE_LOCK", 0, 0, 0, ""),
 
1005
  Commands( "IS_USED_LOCK", 0, 0, 0, ""),
 
1006
  Commands( "LAST_INSERT_ID", 0, 0, 0, ""),
 
1007
  Commands( "ISSIMPLE", 0, 0, 0, ""),
 
1008
  Commands( "LAST_DAY", 0, 0, 0, ""),
 
1009
  Commands( "LCASE", 0, 0, 0, ""),
 
1010
  Commands( "LEAST", 0, 0, 0, ""),
 
1011
  Commands( "LENGTH", 0, 0, 0, ""),
 
1012
  Commands( "LN", 0, 0, 0, ""),
 
1013
  Commands( "LOAD_FILE", 0, 0, 0, ""),
 
1014
  Commands( "LOCATE", 0, 0, 0, ""),
 
1015
  Commands( "LOG", 0, 0, 0, ""),
 
1016
  Commands( "LOG2", 0, 0, 0, ""),
 
1017
  Commands( "LOG10", 0, 0, 0, ""),
 
1018
  Commands( "LOWER", 0, 0, 0, ""),
 
1019
  Commands( "LPAD", 0, 0, 0, ""),
 
1020
  Commands( "LTRIM", 0, 0, 0, ""),
 
1021
  Commands( "MAKE_SET", 0, 0, 0, ""),
 
1022
  Commands( "MAKEDATE", 0, 0, 0, ""),
 
1023
  Commands( "MASTER_POS_WAIT", 0, 0, 0, ""),
 
1024
  Commands( "MAX", 0, 0, 0, ""),
 
1025
  Commands( "MBRCONTAINS", 0, 0, 0, ""),
 
1026
  Commands( "MBRDISJOINT", 0, 0, 0, ""),
 
1027
  Commands( "MBREQUAL", 0, 0, 0, ""),
 
1028
  Commands( "MBRINTERSECTS", 0, 0, 0, ""),
 
1029
  Commands( "MBROVERLAPS", 0, 0, 0, ""),
 
1030
  Commands( "MBRTOUCHES", 0, 0, 0, ""),
 
1031
  Commands( "MBRWITHIN", 0, 0, 0, ""),
 
1032
  Commands( "MD5", 0, 0, 0, ""),
 
1033
  Commands( "MID", 0, 0, 0, ""),
 
1034
  Commands( "MIN", 0, 0, 0, ""),
 
1035
  Commands( "MONTHNAME", 0, 0, 0, ""),
 
1036
  Commands( "NAME_CONST", 0, 0, 0, ""),
 
1037
  Commands( "NOW", 0, 0, 0, ""),
 
1038
  Commands( "NULLIF", 0, 0, 0, ""),
 
1039
  Commands( "NUMPOINTS", 0, 0, 0, ""),
 
1040
  Commands( "OCTET_LENGTH", 0, 0, 0, ""),
 
1041
  Commands( "OCT", 0, 0, 0, ""),
 
1042
  Commands( "ORD", 0, 0, 0, ""),
 
1043
  Commands( "OVERLAPS", 0, 0, 0, ""),
 
1044
  Commands( "PERIOD_ADD", 0, 0, 0, ""),
 
1045
  Commands( "PERIOD_DIFF", 0, 0, 0, ""),
 
1046
  Commands( "PI", 0, 0, 0, ""),
 
1047
  Commands( "POINTN", 0, 0, 0, ""),
 
1048
  Commands( "POSITION", 0, 0, 0, ""),
 
1049
  Commands( "POW", 0, 0, 0, ""),
 
1050
  Commands( "POWER", 0, 0, 0, ""),
 
1051
  Commands( "QUOTE", 0, 0, 0, ""),
 
1052
  Commands( "RADIANS", 0, 0, 0, ""),
 
1053
  Commands( "RAND", 0, 0, 0, ""),
 
1054
  Commands( "RELEASE_LOCK", 0, 0, 0, ""),
 
1055
  Commands( "REVERSE", 0, 0, 0, ""),
 
1056
  Commands( "ROUND", 0, 0, 0, ""),
 
1057
  Commands( "ROW_COUNT", 0, 0, 0, ""),
 
1058
  Commands( "RPAD", 0, 0, 0, ""),
 
1059
  Commands( "RTRIM", 0, 0, 0, ""),
 
1060
  Commands( "SESSION_USER", 0, 0, 0, ""),
 
1061
  Commands( "SUBDATE", 0, 0, 0, ""),
 
1062
  Commands( "SIGN", 0, 0, 0, ""),
 
1063
  Commands( "SIN", 0, 0, 0, ""),
 
1064
  Commands( "SHA", 0, 0, 0, ""),
 
1065
  Commands( "SHA1", 0, 0, 0, ""),
 
1066
  Commands( "SLEEP", 0, 0, 0, ""),
 
1067
  Commands( "SOUNDEX", 0, 0, 0, ""),
 
1068
  Commands( "SPACE", 0, 0, 0, ""),
 
1069
  Commands( "SQRT", 0, 0, 0, ""),
 
1070
  Commands( "SRID", 0, 0, 0, ""),
 
1071
  Commands( "STARTPOINT", 0, 0, 0, ""),
 
1072
  Commands( "STD", 0, 0, 0, ""),
 
1073
  Commands( "STDDEV", 0, 0, 0, ""),
 
1074
  Commands( "STDDEV_POP", 0, 0, 0, ""),
 
1075
  Commands( "STDDEV_SAMP", 0, 0, 0, ""),
 
1076
  Commands( "STR_TO_DATE", 0, 0, 0, ""),
 
1077
  Commands( "STRCMP", 0, 0, 0, ""),
 
1078
  Commands( "SUBSTR", 0, 0, 0, ""),
 
1079
  Commands( "SUBSTRING", 0, 0, 0, ""),
 
1080
  Commands( "SUBSTRING_INDEX", 0, 0, 0, ""),
 
1081
  Commands( "SUM", 0, 0, 0, ""),
 
1082
  Commands( "SYSDATE", 0, 0, 0, ""),
 
1083
  Commands( "SYSTEM_USER", 0, 0, 0, ""),
 
1084
  Commands( "TAN", 0, 0, 0, ""),
 
1085
  Commands( "TIME_FORMAT", 0, 0, 0, ""),
 
1086
  Commands( "TO_DAYS", 0, 0, 0, ""),
 
1087
  Commands( "TOUCHES", 0, 0, 0, ""),
 
1088
  Commands( "TRIM", 0, 0, 0, ""),
 
1089
  Commands( "UCASE", 0, 0, 0, ""),
 
1090
  Commands( "UNCOMPRESS", 0, 0, 0, ""),
 
1091
  Commands( "UNCOMPRESSED_LENGTH", 0, 0, 0, ""),
 
1092
  Commands( "UNHEX", 0, 0, 0, ""),
 
1093
  Commands( "UNIQUE_USERS", 0, 0, 0, ""),
 
1094
  Commands( "UNIX_TIMESTAMP", 0, 0, 0, ""),
 
1095
  Commands( "UPPER", 0, 0, 0, ""),
 
1096
  Commands( "UUID", 0, 0, 0, ""),
 
1097
  Commands( "VARIANCE", 0, 0, 0, ""),
 
1098
  Commands( "VAR_POP", 0, 0, 0, ""),
 
1099
  Commands( "VAR_SAMP", 0, 0, 0, ""),
 
1100
  Commands( "VERSION", 0, 0, 0, ""),
 
1101
  Commands( "WEEKDAY", 0, 0, 0, ""),
 
1102
  Commands( "WEEKOFYEAR", 0, 0, 0, ""),
 
1103
  Commands( "WITHIN", 0, 0, 0, ""),
 
1104
  Commands( "X", 0, 0, 0, ""),
 
1105
  Commands( "Y", 0, 0, 0, ""),
 
1106
  Commands( "YEARWEEK", 0, 0, 0, ""),
997
1107
  /* end sentinel */
998
 
  { (char *)NULL,       0, 0, 0, ""}
 
1108
  Commands((char *)NULL,       0, 0, 0, "")
999
1109
};
1000
1110
 
1001
 
static const char *load_default_groups[]= { "drizzle","client",0 };
1002
1111
 
1003
1112
int history_length;
1004
1113
static int not_in_history(const char *line);
1005
1114
static void initialize_readline (char *name);
1006
1115
static void fix_history(string *final_command);
1007
1116
 
1008
 
static COMMANDS *find_command(const char *name,char cmd_name);
 
1117
static Commands *find_command(const char *name,char cmd_name);
1009
1118
static bool add_line(string *buffer,char *line,char *in_string,
1010
1119
                     bool *ml_comment);
1011
1120
static void remove_cntrl(string *buffer);
1027
1136
  Shutdown the server that we are currently connected to.
1028
1137
 
1029
1138
  @retval
1030
 
  true success
 
1139
    true success
1031
1140
  @retval
1032
 
  false failure
 
1141
    false failure
1033
1142
*/
1034
1143
static bool server_shutdown(void)
1035
1144
{
1038
1147
 
1039
1148
  if (verbose)
1040
1149
  {
1041
 
    printf("shutting down drizzled");
 
1150
    printf(_("shutting down drizzled"));
1042
1151
    if (opt_drizzle_port > 0)
1043
 
      printf(" on port %d", opt_drizzle_port);
 
1152
      printf(_(" on port %d"), opt_drizzle_port);
1044
1153
    printf("... ");
1045
1154
  }
1046
1155
 
1049
1158
  {
1050
1159
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
1051
1160
    {
1052
 
      fprintf(stderr, "shutdown failed; error: '%s'",
 
1161
      fprintf(stderr, _("shutdown failed; error: '%s'"),
1053
1162
              drizzle_result_error(&result));
1054
1163
      drizzle_result_free(&result);
1055
1164
    }
1056
1165
    else
1057
1166
    {
1058
 
      fprintf(stderr, "shutdown failed; error: '%s'",
 
1167
      fprintf(stderr, _("shutdown failed; error: '%s'"),
1059
1168
              drizzle_con_error(&con));
1060
1169
    }
1061
1170
    return false;
1064
1173
  drizzle_result_free(&result);
1065
1174
 
1066
1175
  if (verbose)
1067
 
    printf("done\n");
 
1176
    printf(_("done\n"));
1068
1177
 
1069
1178
  return true;
1070
1179
}
1073
1182
  Ping the server that we are currently connected to.
1074
1183
 
1075
1184
  @retval
1076
 
  true success
 
1185
    true success
1077
1186
  @retval
1078
 
  false failure
 
1187
    false failure
1079
1188
*/
1080
1189
static bool server_ping(void)
1081
1190
{
1085
1194
  if (drizzle_ping(&con, &result, &ret) != NULL && ret == DRIZZLE_RETURN_OK)
1086
1195
  {
1087
1196
    if (opt_silent < 2)
1088
 
      printf("drizzled is alive\n");
 
1197
      printf(_("drizzled is alive\n"));
1089
1198
  }
1090
1199
  else
1091
1200
  {
1092
1201
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
1093
1202
    {
1094
 
      fprintf(stderr, "ping failed; error: '%s'",
 
1203
      fprintf(stderr, _("ping failed; error: '%s'"),
1095
1204
              drizzle_result_error(&result));
1096
1205
      drizzle_result_free(&result);
1097
1206
    }
1098
1207
    else
1099
1208
    {
1100
 
      fprintf(stderr, "drizzled won't answer to ping, error: '%s'",
 
1209
      fprintf(stderr, _("drizzled won't answer to ping, error: '%s'"),
1101
1210
              drizzle_con_error(&con));
1102
1211
    }
1103
1212
    return false;
1110
1219
  Execute command(s) specified by the user.
1111
1220
 
1112
1221
  @param error  error status of command execution.
1113
 
  If an error had occurred, this variable will be set
1114
 
  to 1 whereas on success, it shall be set to 0. This
1115
 
  value will be supplied to the exit() function used
1116
 
  by the caller.
 
1222
                If an error had occurred, this variable will be set
 
1223
                to 1 whereas on success, it shall be set to 0. This
 
1224
                value will be supplied to the exit() function used
 
1225
                by the caller.
1117
1226
 
1118
1227
  @retval
1119
 
  false no commands were executed
 
1228
    false no commands were executed
1120
1229
  @retval
1121
 
  true  at least one command was executed
 
1230
    true  at least one command was executed
1122
1231
*/
1123
1232
static bool execute_commands(int *error)
1124
1233
{
1141
1250
  return executed;
1142
1251
}
1143
1252
 
 
1253
static void check_timeout_value(uint32_t in_connect_timeout)
 
1254
{
 
1255
  opt_connect_timeout= 0;
 
1256
  if (in_connect_timeout > 3600*12)
 
1257
  {
 
1258
    cout << _("Error: Invalid Value for connect_timeout"); 
 
1259
    exit(-1);
 
1260
  }
 
1261
  opt_connect_timeout= in_connect_timeout;
 
1262
}
 
1263
 
 
1264
static void check_max_input_line(uint32_t in_max_input_line)
 
1265
{
 
1266
  opt_max_input_line= 0;
 
1267
  if (in_max_input_line < 4096 || in_max_input_line > (int64_t)2*1024L*1024L*1024L)
 
1268
  {
 
1269
    cout << _("Error: Invalid Value for max_input_line");
 
1270
    exit(-1);
 
1271
  }
 
1272
  opt_max_input_line= in_max_input_line - (in_max_input_line % 1024);
 
1273
}
 
1274
 
1144
1275
int main(int argc,char *argv[])
1145
1276
{
 
1277
try
 
1278
{
 
1279
 
1146
1280
#if defined(ENABLE_NLS)
1147
1281
# if defined(HAVE_LOCALE_H)
1148
1282
  setlocale(LC_ALL, "");
1151
1285
  textdomain("drizzle");
1152
1286
#endif
1153
1287
 
1154
 
  MY_INIT(argv[0]);
1155
 
  delimiter_str= delimiter;
 
1288
  po::options_description commandline_options(N_("Options used only in command line"));
 
1289
  commandline_options.add_options()
 
1290
  ("help,?",N_("Displays this help and exit."))
 
1291
  ("batch,B",N_("Don't use history file. Disable interactive behavior. (Enables --silent)"))
 
1292
  ("column-type-info", po::value<bool>(&column_types_flag)->default_value(false)->zero_tokens(),
 
1293
  N_("Display column type information."))
 
1294
  ("comments,c", po::value<bool>(&preserve_comments)->default_value(false)->zero_tokens(),
 
1295
  N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"))
 
1296
  ("vertical,E", po::value<bool>(&vertical)->default_value(false)->zero_tokens(),
 
1297
  N_("Print the output of a query (rows) vertically."))
 
1298
  ("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
 
1299
  N_("Continue even if we get an sql error."))
 
1300
  ("named-commands,G", po::value<bool>(&named_cmds)->default_value(false)->zero_tokens(),
 
1301
  N_("Enable named commands. Named commands mean this program's internal commands; see drizzle> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter."))
 
1302
  ("no-beep,b", po::value<bool>(&opt_nobeep)->default_value(false)->zero_tokens(),
 
1303
  N_("Turn off beep on error."))
 
1304
  ("disable-line-numbers", N_("Do not write line numbers for errors."))
 
1305
  ("disable-column-names", N_("Do not write column names in results."))
 
1306
  ("skip-column-names,N", 
 
1307
  N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."))
 
1308
  ("set-variable,O", po::value<string>(),
 
1309
  N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."))
 
1310
  ("table,t", po::value<bool>(&output_tables)->default_value(false)->zero_tokens(),
 
1311
  N_("Output in table format.")) 
 
1312
  ("safe-updates,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
 
1313
  N_("Only allow UPDATE and DELETE that uses keys."))
 
1314
  ("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
 
1315
  N_("Synonym for option --safe-updates, -U."))
 
1316
  ("verbose,v", po::value<string>(&opt_verbose)->default_value(""),
 
1317
  N_("-v vvv implies that verbose= 3, Used to specify verbose"))
 
1318
  ("version,V", N_("Output version information and exit."))
 
1319
  ("secure-auth", po::value<bool>(&opt_secure_auth)->default_value(false)->zero_tokens(),
 
1320
  N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"))
 
1321
  ("show-warnings", po::value<bool>(&show_warnings)->default_value(false)->zero_tokens(),
 
1322
  N_("Show warnings after every statement."))
 
1323
  ("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(0),
 
1324
  N_("Number of lines before each import progress report."))
 
1325
  ("ping", po::value<bool>(&opt_ping)->default_value(false)->zero_tokens(),
 
1326
  N_("Ping the server to check if it's alive."))
 
1327
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
 
1328
  N_("Configuration file defaults are not used if no-defaults is set"))
 
1329
  ;
 
1330
 
 
1331
  po::options_description drizzle_options(N_("Options specific to the drizzle client"));
 
1332
  drizzle_options.add_options()
 
1333
  ("disable-auto-rehash,A",
 
1334
  N_("Disable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time."))
 
1335
  ("auto-vertical-output", po::value<bool>(&auto_vertical_output)->default_value(false)->zero_tokens(),
 
1336
  N_("Automatically switch to vertical output mode if the result is wider than the terminal width."))
 
1337
  ("database,D", po::value<string>(&current_db)->default_value(""),
 
1338
  N_("Database to use."))
 
1339
  ("default-character-set",po::value<string>(),
 
1340
  N_("(not used)"))
 
1341
  ("delimiter", po::value<string>(&delimiter_str)->default_value(";"),
 
1342
  N_("Delimiter to be used."))
 
1343
  ("execute,e", po::value<string>(),
 
1344
  N_("Execute command and quit. (Disables --force and history file)"))
 
1345
  ("local-infile", po::value<bool>(&opt_local_infile)->default_value(false)->zero_tokens(),
 
1346
  N_("Enable LOAD DATA LOCAL INFILE."))
 
1347
  ("unbuffered,n", po::value<bool>(&unbuffered)->default_value(false)->zero_tokens(),
 
1348
  N_("Flush buffer after each query."))
 
1349
  ("sigint-ignore", po::value<bool>(&opt_sigint_ignore)->default_value(false)->zero_tokens(),
 
1350
  N_("Ignore SIGINT (CTRL-C)"))
 
1351
  ("one-database,o", po::value<bool>(&one_database)->default_value(false)->zero_tokens(),
 
1352
  N_("Only update the default database. This is useful for skipping updates to other database in the update log."))
 
1353
  ("pager", po::value<string>(),
 
1354
  N_("Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default."))
 
1355
  ("disable-pager", po::value<bool>(&opt_nopager)->default_value(false)->zero_tokens(),
 
1356
  N_("Disable pager and print to stdout. See interactive help (\\h) also."))
 
1357
  ("prompt", po::value<string>(&current_prompt)->default_value(""),  
 
1358
  N_("Set the drizzle prompt to this value."))
 
1359
  ("quick,q", po::value<bool>(&quick)->default_value(false)->zero_tokens(),
 
1360
  N_("Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file."))
 
1361
  ("raw,r", po::value<bool>(&opt_raw_data)->default_value(false)->zero_tokens(),
 
1362
  N_("Write fields without conversion. Used with --batch.")) 
 
1363
  ("disable-reconnect", N_("Do not reconnect if the connection is lost."))
 
1364
  ("shutdown", po::value<bool>()->zero_tokens(),
 
1365
  N_("Shutdown the server"))
 
1366
  ("silent,s", N_("Be more silent. Print results with a tab as separator, each row on new line."))
 
1367
  ("tee", po::value<string>(),
 
1368
  N_("Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default."))
 
1369
  ("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(), 
 
1370
  N_("Disable outfile. See interactive help (\\h) also."))
 
1371
  ("connect-timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value),
 
1372
  N_("Number of seconds before connection timeout."))
 
1373
  ("max-input-line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line),
 
1374
  N_("Max length of input line"))
 
1375
  ("select-limit", po::value<uint32_t>(&select_limit)->default_value(1000L),
 
1376
  N_("Automatic limit for SELECT when using --safe-updates"))
 
1377
  ("max-join-size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
 
1378
  N_("Automatic limit for rows in a join when using --safe-updates"))
 
1379
  ;
 
1380
 
 
1381
  po::options_description client_options(N_("Options specific to the client"));
 
1382
  client_options.add_options()
 
1383
  ("host,h", po::value<string>(&current_host)->default_value("localhost"),
 
1384
  N_("Connect to host"))
 
1385
  ("password,P", po::value<string>(&current_password)->default_value(PASSWORD_SENTINEL),
 
1386
  N_("Password to use when connecting to server. If password is not given it's asked from the tty."))
 
1387
  ("port,p", po::value<uint32_t>()->default_value(0),
 
1388
  N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
 
1389
#ifdef DRIZZLE_ADMIN_TOOL
 
1390
  ("user,u", po::value<string>(&current_user)->default_value("root"),
 
1391
#else
 
1392
  ("user,u", po::value<string>(&current_user)->default_value(""),
 
1393
#endif
 
1394
  N_("User for login if not current user."))
 
1395
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
 
1396
  N_("The protocol of connection (mysql or drizzle)."))
 
1397
  ;
 
1398
 
 
1399
  po::options_description long_options(N_("Allowed Options"));
 
1400
  long_options.add(commandline_options).add(drizzle_options).add(client_options);
 
1401
 
 
1402
  std::string system_config_dir_drizzle(SYSCONFDIR); 
 
1403
  system_config_dir_drizzle.append("/drizzle/drizzle.cnf");
 
1404
 
 
1405
  std::string system_config_dir_client(SYSCONFDIR); 
 
1406
  system_config_dir_client.append("/drizzle/client.cnf");
 
1407
 
 
1408
  std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
 
1409
 
 
1410
  if (user_config_dir.compare(0, 2, "~/") == 0)
 
1411
  {
 
1412
    char *homedir;
 
1413
    homedir= getenv("HOME");
 
1414
    if (homedir != NULL)
 
1415
      user_config_dir.replace(0, 1, homedir);
 
1416
  }
 
1417
 
 
1418
  po::variables_map vm;
 
1419
 
 
1420
  po::positional_options_description p;
 
1421
  p.add("database", 1);
 
1422
 
 
1423
  // Disable allow_guessing
 
1424
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
 
1425
 
 
1426
  po::store(po::command_line_parser(argc, argv).options(long_options).
 
1427
            style(style).positional(p).extra_parser(parse_password_arg).run(),
 
1428
            vm);
 
1429
 
 
1430
  if (! vm["no-defaults"].as<bool>())
 
1431
  {
 
1432
    std::string user_config_dir_drizzle(user_config_dir);
 
1433
    user_config_dir_drizzle.append("/drizzle/drizzle.cnf"); 
 
1434
 
 
1435
    std::string user_config_dir_client(user_config_dir);
 
1436
    user_config_dir_client.append("/drizzle/client.cnf");
 
1437
 
 
1438
    ifstream user_drizzle_ifs(user_config_dir_drizzle.c_str());
 
1439
    po::store(dpo::parse_config_file(user_drizzle_ifs, drizzle_options), vm);
 
1440
 
 
1441
    ifstream user_client_ifs(user_config_dir_client.c_str());
 
1442
    po::store(dpo::parse_config_file(user_client_ifs, client_options), vm);
 
1443
 
 
1444
    ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str());
 
1445
    store(dpo::parse_config_file(system_drizzle_ifs, drizzle_options), vm);
 
1446
 
 
1447
    ifstream system_client_ifs(system_config_dir_client.c_str());
 
1448
    po::store(dpo::parse_config_file(system_client_ifs, client_options), vm);
 
1449
  }
 
1450
 
 
1451
  po::notify(vm);
 
1452
 
 
1453
#ifdef DRIZZLE_ADMIN_TOOL
 
1454
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
 
1455
                         getenv("DRIZZLE_PS1") :
 
1456
                         "drizzleadmin> ");
 
1457
#else
1156
1458
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1157
1459
                         getenv("DRIZZLE_PS1") :
1158
1460
                         "drizzle> ");
1159
 
 
 
1461
#endif
1160
1462
  if (default_prompt == NULL)
1161
1463
  {
1162
1464
    fprintf(stderr, _("Memory allocation error while constructing initial "
1164
1466
    exit(ENOMEM);
1165
1467
  }
1166
1468
  current_prompt= strdup(default_prompt);
1167
 
  if (current_prompt == NULL)
 
1469
  if (current_prompt.empty())
1168
1470
  {
1169
1471
    fprintf(stderr, _("Memory allocation error while constructing initial "
1170
1472
                      "prompt. Aborting.\n"));
1175
1477
 
1176
1478
  prompt_counter=0;
1177
1479
 
1178
 
  outfile[0]=0;      // no (default) outfile
1179
 
  strcpy(pager, "stdout");  // the default, if --pager wasn't given
 
1480
  outfile.clear();      // no (default) outfile
 
1481
  pager.assign("stdout");  // the default, if --pager wasn't given
1180
1482
  {
1181
 
    char *tmp=getenv("PAGER");
 
1483
    const char *tmp= getenv("PAGER");
1182
1484
    if (tmp && strlen(tmp))
1183
1485
    {
1184
1486
      default_pager_set= 1;
1185
 
      strcpy(default_pager, tmp);
 
1487
      default_pager.assign(tmp);
1186
1488
    }
1187
1489
  }
1188
 
  if (!isatty(0) || !isatty(1))
 
1490
  if (! isatty(0) || ! isatty(1))
1189
1491
  {
1190
 
    status.batch=1; opt_silent=1;
 
1492
    status.setBatch(1); opt_silent=1;
1191
1493
    ignore_errors=0;
1192
1494
  }
1193
1495
  else
1194
 
    status.add_to_history=1;
1195
 
  status.exit_status=1;
 
1496
    status.setAddToHistory(1);
 
1497
  status.setExitStatus(1);
1196
1498
 
1197
1499
  {
1198
1500
    /*
1208
1510
      close(stdout_fileno_copy);             /* Clean up dup(). */
1209
1511
  }
1210
1512
 
1211
 
  internal::load_defaults("drizzle",load_default_groups,&argc,&argv);
1212
 
  defaults_argv=argv;
1213
 
  if (get_options(argc, (char **) argv))
1214
 
  {
1215
 
    internal::free_defaults(defaults_argv);
1216
 
    internal::my_end();
 
1513
  /* Inverted Booleans */
 
1514
 
 
1515
  line_numbers= (vm.count("disable-line-numbers")) ? false : true;
 
1516
  column_names= (vm.count("disable-column-names")) ? false : true;
 
1517
  opt_rehash= (vm.count("disable-auto-rehash")) ? false : true;
 
1518
  opt_reconnect= (vm.count("disable-reconnect")) ? false : true;
 
1519
 
 
1520
  /* Don't rehash with --shutdown */
 
1521
  if (vm.count("shutdown"))
 
1522
  {
 
1523
    opt_rehash= false;
 
1524
    opt_shutdown= true;
 
1525
  }
 
1526
 
 
1527
  if (vm.count("delimiter"))
 
1528
  {
 
1529
    /* Check that delimiter does not contain a backslash */
 
1530
    if (! strstr(delimiter_str.c_str(), "\\"))
 
1531
    {
 
1532
      delimiter= (char *)delimiter_str.c_str();  
 
1533
    }
 
1534
    else
 
1535
    {
 
1536
      put_info(_("DELIMITER cannot contain a backslash character"),
 
1537
      INFO_ERROR,0,0);
 
1538
      exit(-1);
 
1539
    }
 
1540
   
 
1541
    delimiter_length= (uint32_t)strlen(delimiter);
 
1542
  }
 
1543
  if (vm.count("tee"))
 
1544
  { 
 
1545
    if (vm["tee"].as<string>().empty())
 
1546
    {
 
1547
      if (opt_outfile)
 
1548
        end_tee();
 
1549
    }
 
1550
    else
 
1551
      init_tee(vm["tee"].as<string>().c_str());
 
1552
  }
 
1553
  if (vm["disable-tee"].as<bool>() == true)
 
1554
  {
 
1555
    if (opt_outfile)
 
1556
      end_tee();
 
1557
  }
 
1558
  if (vm.count("pager"))
 
1559
  {
 
1560
    if (vm["pager"].as<string>().empty())
 
1561
      opt_nopager= 1;
 
1562
    else
 
1563
    {
 
1564
      opt_nopager= 0;
 
1565
      if (vm[pager].as<string>().length())
 
1566
      {
 
1567
        default_pager_set= 1;
 
1568
        pager.assign(vm["pager"].as<string>());
 
1569
        default_pager.assign(pager);
 
1570
      }
 
1571
      else if (default_pager_set)
 
1572
        pager.assign(default_pager);
 
1573
      else
 
1574
        opt_nopager= 1;
 
1575
    }
 
1576
  }
 
1577
  if (vm.count("disable-pager"))
 
1578
  {
 
1579
    opt_nopager= 1;
 
1580
  }
 
1581
 
 
1582
  if (vm.count("no-auto-rehash"))
 
1583
    opt_rehash= 0;
 
1584
 
 
1585
  if (vm.count("skip-column-names"))
 
1586
    column_names= 0;
 
1587
    
 
1588
  if (vm.count("execute"))
 
1589
  {  
 
1590
    status.setBatch(1);
 
1591
    status.setAddToHistory(1);
 
1592
    if (status.getLineBuff() == NULL)
 
1593
      status.setLineBuff(opt_max_input_line,NULL);
 
1594
    if (status.getLineBuff() == NULL)
 
1595
    {
 
1596
      exit(1);
 
1597
    }
 
1598
    status.getLineBuff()->addString(vm["execute"].as<string>().c_str());
 
1599
  }
 
1600
 
 
1601
  if (one_database)
 
1602
    skip_updates= true;
 
1603
 
 
1604
  if (vm.count("protocol"))
 
1605
  {
 
1606
    std::transform(opt_protocol.begin(), opt_protocol.end(), 
 
1607
      opt_protocol.begin(), ::tolower);
 
1608
 
 
1609
    if (not opt_protocol.compare("mysql"))
 
1610
      use_drizzle_protocol=false;
 
1611
    else if (not opt_protocol.compare("drizzle"))
 
1612
      use_drizzle_protocol=true;
 
1613
    else
 
1614
    {
 
1615
      cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
 
1616
      exit(-1);
 
1617
    }
 
1618
  }
 
1619
 
 
1620
  if (vm.count("port"))
 
1621
  {
 
1622
    opt_drizzle_port= vm["port"].as<uint32_t>();
 
1623
 
 
1624
    /* If the port number is > 65535 it is not a valid port
 
1625
       This also helps with potential data loss casting unsigned long to a
 
1626
       uint32_t. */
 
1627
    if (opt_drizzle_port > 65535)
 
1628
    {
 
1629
      printf(_("Error: Value of %" PRIu32 " supplied for port is not valid.\n"), opt_drizzle_port);
 
1630
      exit(-1);
 
1631
    }
 
1632
  }
 
1633
 
 
1634
  if (vm.count("password"))
 
1635
  {
 
1636
    if (!opt_password.empty())
 
1637
      opt_password.erase();
 
1638
    if (current_password == PASSWORD_SENTINEL)
 
1639
    {
 
1640
      opt_password= "";
 
1641
    }
 
1642
    else
 
1643
    {
 
1644
      opt_password= current_password;
 
1645
      tty_password= false;
 
1646
    }
 
1647
  }
 
1648
  else
 
1649
  {
 
1650
      tty_password= true;
 
1651
  }
 
1652
  
 
1653
 
 
1654
  if (!opt_verbose.empty())
 
1655
  {
 
1656
    verbose= opt_verbose.length();
 
1657
  }
 
1658
 
 
1659
  if (vm.count("batch"))
 
1660
  {
 
1661
    status.setBatch(1);
 
1662
    status.setAddToHistory(0);
 
1663
    if (opt_silent < 1)
 
1664
    {
 
1665
      opt_silent= 1;
 
1666
    }
 
1667
  }
 
1668
  if (vm.count("silent"))
 
1669
  {
 
1670
    opt_silent++;
 
1671
  }
 
1672
  
 
1673
  if (vm.count("help") || vm.count("version"))
 
1674
  {
 
1675
    printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
 
1676
           drizzle_version(), VERSION,
 
1677
           HOST_VENDOR, HOST_OS, HOST_CPU,
 
1678
           rl_library_version);
 
1679
    if (vm.count("version"))
 
1680
      exit(0);
 
1681
    printf(_("Copyright (C) 2008 Sun Microsystems\n"
 
1682
           "This software comes with ABSOLUTELY NO WARRANTY. "
 
1683
           "This is free software,\n"
 
1684
           "and you are welcome to modify and redistribute it "
 
1685
           "under the GPL license\n"));
 
1686
    printf(_("Usage: drizzle [OPTIONS] [database]\n"));
 
1687
    cout << long_options;
 
1688
    exit(0);
 
1689
  }
 
1690
 
 
1691
 
 
1692
  if (process_options())
 
1693
  {
1217
1694
    exit(1);
1218
1695
  }
1219
1696
 
1220
1697
  memset(&drizzle, 0, sizeof(drizzle));
1221
 
  if (sql_connect(current_host,current_db,current_user,opt_password,
1222
 
                  opt_silent))
 
1698
  if (sql_connect(current_host, current_db, current_user, opt_password,opt_silent))
1223
1699
  {
1224
1700
    quick= 1;          // Avoid history
1225
 
    status.exit_status= 1;
 
1701
    status.setExitStatus(1);
1226
1702
    drizzle_end(-1);
1227
1703
  }
1228
1704
 
1230
1706
  if (execute_commands(&command_error) != false)
1231
1707
  {
1232
1708
    /* we've executed a command so exit before we go into readline mode */
1233
 
    internal::free_defaults(defaults_argv);
1234
 
    internal::my_end();
1235
1709
    exit(command_error);
1236
1710
  }
1237
1711
 
1238
 
  if (status.batch && !status.line_buff)
 
1712
  if (status.getBatch() && !status.getLineBuff())
1239
1713
  {
1240
 
    status.line_buff= new(std::nothrow) LineBuffer(opt_max_input_line, stdin);
1241
 
    if (status.line_buff == NULL)
 
1714
    status.setLineBuff(opt_max_input_line, stdin);
 
1715
    if (status.getLineBuff() == NULL)
1242
1716
    {
1243
 
      internal::free_defaults(defaults_argv);
1244
 
      internal::my_end();
1245
1717
      exit(1);
1246
1718
    }
1247
1719
  }
1248
1720
 
1249
 
  if (!status.batch)
 
1721
  if (!status.getBatch())
1250
1722
    ignore_errors=1;        // Don't abort monitor
1251
1723
 
1252
1724
  if (opt_sigint_ignore)
1261
1733
  /* call the SIGWINCH handler to get the default term width */
1262
1734
  window_resize(0);
1263
1735
#endif
1264
 
 
1265
 
  put_info(_("Welcome to the Drizzle client..  Commands end with ; or \\g."),
1266
 
           INFO_INFO,0,0);
 
1736
  std::vector<char> output_buff;
 
1737
  output_buff.resize(512);
 
1738
 
 
1739
  snprintf(&output_buff[0], output_buff.size(), 
 
1740
           _("Welcome to the Drizzle client..  Commands end with %s or \\g."), 
 
1741
           delimiter);
 
1742
 
 
1743
  put_info(&output_buff[0], INFO_INFO, 0, 0);
1267
1744
 
1268
1745
  glob_buffer= new string();
1269
1746
  glob_buffer->reserve(512);
1270
1747
 
1271
 
  size_t output_buff_size = 512;
1272
 
  char * output_buff= (char *)malloc(output_buff_size);
1273
 
  memset(output_buff, '\0', output_buff_size);
1274
 
 
1275
 
  snprintf(output_buff, output_buff_size,
1276
 
           _("Your Drizzle connection id is %u\nServer version: %s\n"),
1277
 
           drizzle_con_thread_id(&con),
1278
 
           server_version_string(&con));
1279
 
  put_info(output_buff, INFO_INFO, 0, 0);
1280
 
 
1281
 
  initialize_readline(current_prompt);
1282
 
  if (!status.batch && !quick)
 
1748
  snprintf(&output_buff[0], output_buff.size(),
 
1749
          _("Your Drizzle connection id is %u\nConnection protocol: %s\nServer version: %s\n"),
 
1750
          drizzle_con_thread_id(&con),
 
1751
          opt_protocol.c_str(),
 
1752
          server_version_string(&con));
 
1753
  put_info(&output_buff[0], INFO_INFO, 0, 0);
 
1754
 
 
1755
 
 
1756
  initialize_readline((char *)current_prompt.c_str());
 
1757
  if (!status.getBatch() && !quick)
1283
1758
  {
1284
1759
    /* read-history from file, default ~/.drizzle_history*/
1285
1760
    if (getenv("DRIZZLE_HISTFILE"))
1286
1761
      histfile= strdup(getenv("DRIZZLE_HISTFILE"));
1287
1762
    else if (getenv("HOME"))
1288
1763
    {
1289
 
      size_t histfile_size = strlen(getenv("HOME")) +
1290
 
        strlen("/.drizzle_history") + 2;
1291
 
      histfile=(char*) malloc(histfile_size);
 
1764
      histfile=(char*) malloc(strlen(getenv("HOME")) + strlen("/.drizzle_history") + 2);
1292
1765
      if (histfile)
1293
 
        snprintf(histfile, histfile_size, "%s/.drizzle_history",getenv("HOME"));
 
1766
        sprintf(histfile,"%s/.drizzle_history",getenv("HOME"));
1294
1767
      char link_name[FN_REFLEN];
1295
1768
      ssize_t sym_link_size= readlink(histfile,link_name,FN_REFLEN-1);
1296
1769
      if (sym_link_size >= 0)
1309
1782
      if (verbose)
1310
1783
        tee_fprintf(stdout, _("Reading history-file %s\n"),histfile);
1311
1784
      read_history(histfile);
1312
 
      size_t histfile_tmp_size = strlen(histfile) + 5;
1313
 
      if (!(histfile_tmp= (char*) malloc(histfile_tmp_size)))
 
1785
      if (!(histfile_tmp= (char*) malloc((uint32_t) strlen(histfile) + 5)))
1314
1786
      {
1315
1787
        fprintf(stderr, _("Couldn't allocate memory for temp histfile!\n"));
1316
1788
        exit(1);
1317
1789
      }
1318
 
      snprintf(histfile_tmp, histfile_tmp_size, "%s.TMP", histfile);
 
1790
      sprintf(histfile_tmp, "%s.TMP", histfile);
1319
1791
    }
1320
1792
  }
1321
1793
 
1322
1794
  put_info(_("Type 'help;' or '\\h' for help. "
1323
1795
             "Type '\\c' to clear the buffer.\n"),INFO_INFO,0,0);
1324
 
  status.exit_status= read_and_execute(!status.batch);
 
1796
  status.setExitStatus(read_and_execute(!status.getBatch()));
1325
1797
  if (opt_outfile)
1326
1798
    end_tee();
1327
1799
  drizzle_end(0);
 
1800
}
1328
1801
 
 
1802
  catch(exception &err)
 
1803
  {
 
1804
    cerr << _("Error:") << err.what() << endl;
 
1805
  }
1329
1806
  return(0);        // Keep compiler happy
1330
1807
}
1331
1808
 
1333
1810
{
1334
1811
  drizzle_con_free(&con);
1335
1812
  drizzle_free(&drizzle);
1336
 
  if (!status.batch && !quick && histfile)
 
1813
  if (!status.getBatch() && !quick && histfile)
1337
1814
  {
1338
1815
    /* write-history */
1339
1816
    if (verbose)
1340
1817
      tee_fprintf(stdout, _("Writing history-file %s\n"),histfile);
1341
1818
    if (!write_history(histfile_tmp))
1342
 
      internal::my_rename(histfile_tmp, histfile, MYF(MY_WME));
 
1819
      rename(histfile_tmp, histfile);
1343
1820
  }
1344
 
  delete status.line_buff;
1345
 
  status.line_buff= 0;
 
1821
  delete status.getLineBuff();
 
1822
  status.setLineBuff(0);
1346
1823
 
1347
1824
  if (sig >= 0)
1348
1825
    put_info(sig ? _("Aborted") : _("Bye"), INFO_RESULT,0,0);
1349
 
  if (glob_buffer)
1350
 
    delete glob_buffer;
1351
 
  if (processed_prompt)
1352
 
    delete processed_prompt;
1353
 
  free(opt_password);
 
1826
  delete glob_buffer;
 
1827
  delete processed_prompt;
 
1828
  opt_password.erase();
1354
1829
  free(histfile);
1355
1830
  free(histfile_tmp);
1356
 
  free(current_db);
1357
 
  free(current_host);
1358
 
  free(current_user);
 
1831
  current_db.erase();
 
1832
  current_host.erase();
 
1833
  current_user.erase();
1359
1834
  free(full_username);
1360
1835
  free(part_username);
1361
1836
  free(default_prompt);
1362
 
  free(current_prompt);
1363
 
  internal::free_defaults(defaults_argv);
1364
 
  internal::my_end();
1365
 
  exit(status.exit_status);
 
1837
  current_prompt.erase();
 
1838
  exit(status.getExitStatus());
1366
1839
}
1367
1840
 
1368
1841
 
1375
1848
void handle_sigint(int sig)
1376
1849
{
1377
1850
  char kill_buffer[40];
1378
 
  drizzle_con_st kill_drizzle;
 
1851
  boost::scoped_ptr<drizzle_con_st> kill_drizzle(new drizzle_con_st);
1379
1852
  drizzle_result_st res;
1380
1853
  drizzle_return_t ret;
1381
1854
 
1384
1857
    goto err;
1385
1858
  }
1386
1859
 
1387
 
  if (drizzle_con_add_tcp(&drizzle, &kill_drizzle, current_host,
1388
 
                          opt_drizzle_port, current_user, opt_password, NULL,
1389
 
                          opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
 
1860
  if (drizzle_con_add_tcp(&drizzle, kill_drizzle.get(), current_host.c_str(),
 
1861
    opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL,
 
1862
    use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
1390
1863
  {
1391
1864
    goto err;
1392
1865
  }
1393
1866
 
1394
1867
  /* kill_buffer is always big enough because max length of %lu is 15 */
1395
 
  snprintf(kill_buffer, sizeof(kill_buffer), "KILL /*!50000 QUERY */ %u",
1396
 
           drizzle_con_thread_id(&con));
 
1868
  sprintf(kill_buffer, "KILL /*!50000 QUERY */ %u",
 
1869
          drizzle_con_thread_id(&con));
1397
1870
 
1398
 
  if (drizzle_query_str(&kill_drizzle, &res, kill_buffer, &ret) != NULL)
 
1871
  if (drizzle_query_str(kill_drizzle.get(), &res, kill_buffer, &ret) != NULL)
1399
1872
    drizzle_result_free(&res);
1400
1873
 
1401
 
  drizzle_con_free(&kill_drizzle);
 
1874
  drizzle_con_free(kill_drizzle.get());
1402
1875
  tee_fprintf(stdout, _("Query aborted by Ctrl+C\n"));
1403
1876
 
1404
1877
  interrupted_query= 1;
1420
1893
}
1421
1894
#endif
1422
1895
 
1423
 
static struct my_option my_long_options[] =
1424
 
{
1425
 
  {"help", '?', N_("Display this help and exit."), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1426
 
    0, 0, 0, 0, 0},
1427
 
  {"help", 'I', N_("Synonym for -?"), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1428
 
    0, 0, 0, 0, 0},
1429
 
  {"auto-rehash", OPT_AUTO_REHASH,
1430
 
    N_("Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash."),
1431
 
    (char**) &opt_rehash, (char**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
1432
 
    0, 0},
1433
 
  {"no-auto-rehash", 'A',
1434
 
    N_("No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of drizzle_st and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead."),
1435
 
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1436
 
  {"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
1437
 
    N_("Automatically switch to vertical output mode if the result is wider than the terminal width."),
1438
 
    (char**) &auto_vertical_output, (char**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1439
 
  {"batch", 'B',
1440
 
    N_("Don't use history file. Disable interactive behavior. (Enables --silent)"), 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1441
 
  {"column-type-info", OPT_COLUMN_TYPES, N_("Display column type information."),
1442
 
    (char**) &column_types_flag, (char**) &column_types_flag,
1443
 
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1444
 
  {"comments", 'c', N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"),
1445
 
    (char**) &preserve_comments, (char**) &preserve_comments,
1446
 
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1447
 
  {"compress", 'C', N_("Use compression in server/client protocol."),
1448
 
    (char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1449
 
    0, 0, 0},
1450
 
  {"database", 'D', N_("Database to use."), (char**) &current_db,
1451
 
    (char**) &current_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1452
 
  {"default-character-set", OPT_DEFAULT_CHARSET,
1453
 
    N_("(not used)"), 0,
1454
 
    0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1455
 
  {"delimiter", OPT_DELIMITER, N_("Delimiter to be used."), (char**) &delimiter_str,
1456
 
    (char**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1457
 
  {"execute", 'e', N_("Execute command and quit. (Disables --force and history file)"), 0,
1458
 
    0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1459
 
  {"vertical", 'E', N_("Print the output of a query (rows) vertically."),
1460
 
    (char**) &vertical, (char**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
1461
 
    0},
1462
 
  {"force", 'f', N_("Continue even if we get an sql error."),
1463
 
    (char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
1464
 
    0, 0, 0, 0},
1465
 
  {"named-commands", 'G',
1466
 
    N_("Enable named commands. Named commands mean this program's internal commands; see drizzle> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default."),
1467
 
    (char**) &named_cmds, (char**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1468
 
    0, 0},
1469
 
  {"no-named-commands", 'g',
1470
 
    N_("Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead."),
1471
 
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1472
 
  {"ignore-spaces", 'i', N_("Ignore space after function names."), 0, 0, 0,
1473
 
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1474
 
  {"local-infile", OPT_LOCAL_INFILE, N_("Enable/disable LOAD DATA LOCAL INFILE."),
1475
 
    (char**) &opt_local_infile,
1476
 
    (char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1477
 
  {"no-beep", 'b', N_("Turn off beep on error."), (char**) &opt_nobeep,
1478
 
    (char**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1479
 
  {"host", 'h', N_("Connect to host."), (char**) &current_host,
1480
 
    (char**) &current_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1481
 
  {"line-numbers", OPT_LINE_NUMBERS, N_("Write line numbers for errors."),
1482
 
    (char**) &line_numbers, (char**) &line_numbers, 0, GET_BOOL,
1483
 
    NO_ARG, 1, 0, 0, 0, 0, 0},
1484
 
  {"skip-line-numbers", 'L', N_("Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead."), 0, 0, 0, GET_NO_ARG,
1485
 
    NO_ARG, 0, 0, 0, 0, 0, 0},
1486
 
  {"unbuffered", 'n', N_("Flush buffer after each query."), (char**) &unbuffered,
1487
 
    (char**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1488
 
  {"column-names", OPT_COLUMN_NAMES, N_("Write column names in results."),
1489
 
    (char**) &column_names, (char**) &column_names, 0, GET_BOOL,
1490
 
    NO_ARG, 1, 0, 0, 0, 0, 0},
1491
 
  {"skip-column-names", 'N',
1492
 
    N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."),
1493
 
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1494
 
  {"set-variable", 'O',
1495
 
    N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."),
1496
 
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1497
 
  {"sigint-ignore", OPT_SIGINT_IGNORE, N_("Ignore SIGINT (CTRL-C)"),
1498
 
    (char**) &opt_sigint_ignore,  (char**) &opt_sigint_ignore, 0, GET_BOOL,
1499
 
    NO_ARG, 0, 0, 0, 0, 0, 0},
1500
 
  {"one-database", 'o',
1501
 
    N_("Only update the default database. This is useful for skipping updates to other database in the update log."),
1502
 
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1503
 
  {"pager", OPT_PAGER,
1504
 
    N_("Pager to use to display results. If you don't supply an option the default pager is taken from your ENV variable PAGER. Valid pagers are less, more, cat [> filename], etc. See interactive help (\\h) also. This option does not work in batch mode. Disable with --disable-pager. This option is disabled by default."),
1505
 
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1506
 
  {"no-pager", OPT_NOPAGER,
1507
 
    N_("Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead."),
1508
 
    0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1509
 
  {"password", 'P',
1510
 
    N_("Password to use when connecting to server. If password is not given it's asked from the tty."),
1511
 
    0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1512
 
  {"port", 'p', N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, ")
1513
 
    N_("built-in default") " (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
1514
 
    0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1515
 
  {"prompt", OPT_PROMPT, N_("Set the drizzle prompt to this value."),
1516
 
    (char**) &current_prompt, (char**) &current_prompt, 0, GET_STR_ALLOC,
1517
 
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1518
 
  {"quick", 'q',
1519
 
    N_("Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file."),
1520
 
    (char**) &quick, (char**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1521
 
  {"raw", 'r', N_("Write fields without conversion. Used with --batch."),
1522
 
    (char**) &opt_raw_data, (char**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1523
 
    0, 0, 0},
1524
 
  {"reconnect", OPT_RECONNECT, N_("Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default."),
1525
 
    (char**) &opt_reconnect, (char**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
1526
 
  {"shutdown", OPT_SHUTDOWN, N_("Shutdown the server."),
1527
 
    (char**) &opt_shutdown, (char**) &opt_shutdown, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1528
 
  {"silent", 's', N_("Be more silent. Print results with a tab as separator, each row on new line."), 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
1529
 
    0, 0},
1530
 
  {"table", 't', N_("Output in table format."), (char**) &output_tables,
1531
 
    (char**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1532
 
  {"tee", OPT_TEE,
1533
 
    N_("Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default."),
1534
 
    0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1535
 
  {"no-tee", OPT_NOTEE, N_("Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead"), 0, 0, 0, GET_NO_ARG,
1536
 
    NO_ARG, 0, 0, 0, 0, 0, 0},
1537
 
  {"user", 'u', N_("User for login if not current user."), (char**) &current_user,
1538
 
    (char**) &current_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1539
 
  {"safe-updates", 'U', N_("Only allow UPDATE and DELETE that uses keys."),
1540
 
    (char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1541
 
    0, 0, 0, 0},
1542
 
  {"i-am-a-dummy", 'U', N_("Synonym for option --safe-updates, -U."),
1543
 
    (char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1544
 
    0, 0, 0, 0},
1545
 
  {"verbose", 'v', N_("Write more. (-v -v -v gives the table output format)."), 0,
1546
 
    0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1547
 
  {"version", 'V', N_("Output version information and exit."), 0, 0, 0,
1548
 
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1549
 
  {"wait", 'w', N_("Wait and retry if connection is down."), 0, 0, 0, GET_NO_ARG,
1550
 
    NO_ARG, 0, 0, 0, 0, 0, 0},
1551
 
  {"connect_timeout", OPT_CONNECT_TIMEOUT,
1552
 
    N_("Number of seconds before connection timeout."),
1553
 
    (char**) &opt_connect_timeout,
1554
 
    (char**) &opt_connect_timeout, 0, GET_UINT32, REQUIRED_ARG, 0, 0, 3600*12, 0,
1555
 
    0, 0},
1556
 
  {"max_input_line", OPT_MAX_INPUT_LINE,
1557
 
    N_("Max length of input line"),
1558
 
    (char**) &opt_max_input_line, (char**) &opt_max_input_line, 0,
1559
 
    GET_UINT32, REQUIRED_ARG, 16 *1024L*1024L, 4096,
1560
 
    (int64_t) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1561
 
  {"select_limit", OPT_SELECT_LIMIT,
1562
 
    N_("Automatic limit for SELECT when using --safe-updates"),
1563
 
    (char**) &select_limit,
1564
 
    (char**) &select_limit, 0, GET_UINT32, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
1565
 
    0, 1, 0},
1566
 
  {"max_join_size", OPT_MAX_JOIN_SIZE,
1567
 
    N_("Automatic limit for rows in a join when using --safe-updates"),
1568
 
    (char**) &max_join_size,
1569
 
    (char**) &max_join_size, 0, GET_UINT32, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
1570
 
    0, 1, 0},
1571
 
  {"secure-auth", OPT_SECURE_AUTH, N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"), (char**) &opt_secure_auth,
1572
 
    (char**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1573
 
  {"show-warnings", OPT_SHOW_WARNINGS, N_("Show warnings after every statement."),
1574
 
    (char**) &show_warnings, (char**) &show_warnings, 0, GET_BOOL, NO_ARG,
1575
 
    0, 0, 0, 0, 0, 0},
1576
 
  {"show-progress-size", OPT_SHOW_PROGRESS_SIZE, N_("Number of lines before each import progress report."),
1577
 
    (char**) &show_progress_size, (char**) &show_progress_size, 0, GET_UINT32, REQUIRED_ARG,
1578
 
    0, 0, 0, 0, 0, 0},
1579
 
  {"ping", OPT_PING, N_("Ping the server to check if it's alive."),
1580
 
    (char**) &opt_ping, (char**) &opt_ping, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1581
 
  {"mysql", 'm', N_("Use MySQL Protocol."),
1582
 
    (char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0,
1583
 
    0, 0, 0},
1584
 
  { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1585
 
};
1586
 
 
1587
 
 
1588
 
static void usage(int version)
1589
 
{
1590
 
  const char* readline= "readline";
1591
 
 
1592
 
  printf(_("%s  Ver %s Distrib %s, for %s-%s (%s) using %s %s\n"),
1593
 
         internal::my_progname, VER.c_str(), drizzle_version(),
1594
 
         HOST_VENDOR, HOST_OS, HOST_CPU,
1595
 
         readline, rl_library_version);
1596
 
 
1597
 
  if (version)
1598
 
    return;
1599
 
  printf(_("Copyright (C) 2008 Sun Microsystems\n"
1600
 
           "This software comes with ABSOLUTELY NO WARRANTY. "
1601
 
           "This is free software,\n"
1602
 
           "and you are welcome to modify and redistribute it "
1603
 
           "under the GPL license\n"));
1604
 
  printf(_("Usage: %s [OPTIONS] [database]\n"), internal::my_progname);
1605
 
  my_print_help(my_long_options);
1606
 
  internal::print_defaults("drizzle", load_default_groups);
1607
 
  my_print_variables(my_long_options);
1608
 
}
1609
 
 
1610
 
 
1611
 
static int get_one_option(int optid, const struct my_option *, char *argument)
1612
 
{
1613
 
  char *endchar= NULL;
1614
 
  uint64_t temp_drizzle_port= 0;
1615
 
 
1616
 
  switch(optid) {
1617
 
  case  OPT_DEFAULT_CHARSET:
1618
 
    default_charset_used= 1;
1619
 
    break;
1620
 
  case OPT_DELIMITER:
1621
 
    if (argument == disabled_my_option)
1622
 
    {
1623
 
      strcpy(delimiter, DEFAULT_DELIMITER);
1624
 
    }
1625
 
    else
1626
 
    {
1627
 
      /* Check that delimiter does not contain a backslash */
1628
 
      if (!strstr(argument, "\\"))
1629
 
      {
1630
 
        strncpy(delimiter, argument, sizeof(delimiter) - 1);
1631
 
      }
1632
 
      else
1633
 
      {
1634
 
        put_info(_("DELIMITER cannot contain a backslash character"),
1635
 
                 INFO_ERROR,0,0);
1636
 
        return EXIT_ARGUMENT_INVALID;
1637
 
      }
1638
 
    }
1639
 
    delimiter_length= (uint32_t)strlen(delimiter);
1640
 
    delimiter_str= delimiter;
1641
 
    break;
1642
 
  case OPT_TEE:
1643
 
    if (argument == disabled_my_option)
1644
 
    {
1645
 
      if (opt_outfile)
1646
 
        end_tee();
1647
 
    }
1648
 
    else
1649
 
      init_tee(argument);
1650
 
    break;
1651
 
  case OPT_NOTEE:
1652
 
    printf(_("WARNING: option deprecated; use --disable-tee instead.\n"));
1653
 
    if (opt_outfile)
1654
 
      end_tee();
1655
 
    break;
1656
 
  case OPT_PAGER:
1657
 
    if (argument == disabled_my_option)
1658
 
      opt_nopager= 1;
1659
 
    else
1660
 
    {
1661
 
      opt_nopager= 0;
1662
 
      if (argument && strlen(argument))
1663
 
      {
1664
 
        default_pager_set= 1;
1665
 
        strncpy(pager, argument, sizeof(pager) - 1);
1666
 
        strcpy(default_pager, pager);
1667
 
      }
1668
 
      else if (default_pager_set)
1669
 
        strcpy(pager, default_pager);
1670
 
      else
1671
 
        opt_nopager= 1;
1672
 
    }
1673
 
    break;
1674
 
  case OPT_NOPAGER:
1675
 
    printf(_("WARNING: option deprecated; use --disable-pager instead.\n"));
1676
 
    opt_nopager= 1;
1677
 
    break;
1678
 
  case OPT_SERVER_ARG:
1679
 
    printf(_("WARNING: --server-arg option not supported in this configuration.\n"));
1680
 
    break;
1681
 
  case 'A':
1682
 
    opt_rehash= 0;
1683
 
    break;
1684
 
  case 'N':
1685
 
    column_names= 0;
1686
 
    break;
1687
 
  case 'e':
1688
 
    status.batch= 1;
1689
 
    status.add_to_history= 0;
1690
 
    if (status.line_buff == NULL)
1691
 
      status.line_buff= new(std::nothrow) LineBuffer(opt_max_input_line,NULL);
1692
 
    if (status.line_buff == NULL)
1693
 
    {
1694
 
      internal::my_end();
1695
 
      exit(1);
1696
 
    }
1697
 
    status.line_buff->addString(argument);
1698
 
    break;
1699
 
  case 'o':
1700
 
    if (argument == disabled_my_option)
1701
 
      one_database= 0;
1702
 
    else
1703
 
      one_database= skip_updates= 1;
1704
 
    break;
1705
 
  case 'p':
1706
 
    temp_drizzle_port= (uint64_t) strtoul(argument, &endchar, 10);
1707
 
    /* if there is an alpha character this is not a valid port */
1708
 
    if (strlen(endchar) != 0)
1709
 
    {
1710
 
      put_info(_("Non-integer value supplied for port.  If you are trying to enter a password please use --password instead."), INFO_ERROR, 0, 0);
1711
 
      return EXIT_ARGUMENT_INVALID;
1712
 
    }
1713
 
    /* If the port number is > 65535 it is not a valid port
1714
 
      This also helps with potential data loss casting unsigned long to a
1715
 
      uint32_t. */
1716
 
    if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
1717
 
    {
1718
 
      put_info(_("Value supplied for port is not valid."), INFO_ERROR, 0, 0);
1719
 
      return EXIT_ARGUMENT_INVALID;
1720
 
    }
1721
 
    else
1722
 
    {
1723
 
      opt_drizzle_port= (uint32_t) temp_drizzle_port;
1724
 
    }
1725
 
    break;
1726
 
  case 'P':
1727
 
    /* Don't require password */
1728
 
    if (argument == disabled_my_option)
1729
 
    {
1730
 
      argument= (char*) "";
1731
 
    }
1732
 
    if (argument)
1733
 
    {
1734
 
      char *start= argument;
1735
 
      free(opt_password);
1736
 
      opt_password= strdup(argument);
1737
 
      while (*argument)
1738
 
      {
1739
 
        /* Overwriting password with 'x' */
1740
 
        *argument++= 'x';
1741
 
      }
1742
 
      if (*start)
1743
 
      {
1744
 
        start[1]= 0;
1745
 
      }
1746
 
      tty_password= 0;
1747
 
    }
1748
 
    else
1749
 
    {
1750
 
      tty_password= 1;
1751
 
    }
1752
 
    break;
1753
 
  case 's':
1754
 
    if (argument == disabled_my_option)
1755
 
      opt_silent= 0;
1756
 
    else
1757
 
      opt_silent++;
1758
 
    break;
1759
 
  case 'v':
1760
 
    if (argument == disabled_my_option)
1761
 
      verbose= 0;
1762
 
    else
1763
 
      verbose++;
1764
 
    break;
1765
 
  case 'B':
1766
 
    status.batch= 1;
1767
 
    status.add_to_history= 0;
1768
 
    set_if_bigger(opt_silent,1);                         // more silent
1769
 
    break;
1770
 
  case 'V':
1771
 
    usage(1);
1772
 
    exit(0);
1773
 
  case 'I':
1774
 
  case '?':
1775
 
    usage(0);
1776
 
    exit(0);
1777
 
  }
1778
 
  return 0;
1779
 
}
1780
 
 
1781
 
 
1782
 
static int get_options(int argc, char **argv)
 
1896
 
 
1897
 
 
1898
static int process_options(void)
1783
1899
{
1784
1900
  char *tmp, *pagpoint;
1785
 
  int ho_error;
 
1901
  
1786
1902
 
1787
1903
  tmp= (char *) getenv("DRIZZLE_HOST");
1788
1904
  if (tmp)
1789
 
    current_host= strdup(tmp);
 
1905
    current_host.assign(tmp);
1790
1906
 
1791
1907
  pagpoint= getenv("PAGER");
1792
1908
  if (!((char*) (pagpoint)))
1793
1909
  {
1794
 
    strcpy(pager, "stdout");
 
1910
    pager.assign("stdout");
1795
1911
    opt_nopager= 1;
1796
1912
  }
1797
1913
  else
1798
 
    strcpy(pager, pagpoint);
1799
 
  strcpy(default_pager, pager);
1800
 
 
1801
 
  if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
1802
 
    exit(ho_error);
1803
 
 
1804
 
  if (status.batch) /* disable pager and outfile in this case */
1805
 
  {
1806
 
    strcpy(default_pager, "stdout");
1807
 
    strcpy(pager, "stdout");
 
1914
  {
 
1915
    pager.assign(pagpoint);
 
1916
  }
 
1917
  default_pager.assign(pager);
 
1918
 
 
1919
  //
 
1920
 
 
1921
  if (status.getBatch()) /* disable pager and outfile in this case */
 
1922
  {
 
1923
    default_pager.assign("stdout");
 
1924
    pager.assign("stdout");
1808
1925
    opt_nopager= 1;
1809
1926
    default_pager_set= 0;
1810
1927
    opt_outfile= 0;
1812
1929
    connect_flag= DRIZZLE_CAPABILITIES_NONE; /* Not in interactive mode */
1813
1930
  }
1814
1931
 
1815
 
  if (argc > 1)
1816
 
  {
1817
 
    usage(0);
1818
 
    exit(1);
1819
 
  }
1820
 
  if (argc == 1)
1821
 
  {
1822
 
    skip_updates= 0;
1823
 
    free(current_db);
1824
 
    current_db= strdup(*argv);
1825
 
  }
1826
1932
  if (tty_password)
1827
1933
    opt_password= client_get_tty_password(NULL);
1828
 
 
1829
1934
  return(0);
1830
1935
}
1831
1936
 
1835
1940
  char in_string=0;
1836
1941
  uint32_t line_number=0;
1837
1942
  bool ml_comment= 0;
1838
 
  COMMANDS *com;
1839
 
  status.exit_status=1;
 
1943
  Commands *com;
 
1944
  status.setExitStatus(1);
1840
1945
 
1841
1946
  for (;;)
1842
1947
  {
1843
1948
    if (!interactive)
1844
1949
    {
1845
 
      if (status.line_buff)
1846
 
        line= status.line_buff->readline();
 
1950
      if (status.getLineBuff())
 
1951
        line= status.getLineBuff()->readline();
1847
1952
      else
1848
1953
        line= 0;
1849
1954
 
1854
1959
          fprintf(stderr, _("Processing line: %"PRIu32"\n"), line_number);
1855
1960
      }
1856
1961
      if (!glob_buffer->empty())
1857
 
        status.query_start_line= line_number;
 
1962
        status.setQueryStartLine(line_number);
1858
1963
    }
1859
1964
    else
1860
1965
    {
1861
 
      const char *prompt= (const char*) (ml_comment ? "   /*> " :
1862
 
                                         (glob_buffer->empty())
1863
 
                                         ?  construct_prompt()
1864
 
                                         : !in_string ? "    -> " :
1865
 
                                         in_string == '\'' ?
1866
 
                                         "    '> " : (in_string == '`' ?
1867
 
                                                      "    `> " :
1868
 
                                                      "    \"> "));
 
1966
      string prompt(ml_comment
 
1967
                      ? "   /*> " 
 
1968
                      : glob_buffer->empty()
 
1969
                        ? construct_prompt()
 
1970
                        : not in_string
 
1971
                          ? "    -> "
 
1972
                          : in_string == '\''
 
1973
                            ? "    '> "
 
1974
                            : in_string == '`'
 
1975
                              ? "    `> "
 
1976
                              : "    \"> ");
1869
1977
      if (opt_outfile && glob_buffer->empty())
1870
1978
        fflush(OUTFILE);
1871
1979
 
1872
1980
      if (opt_outfile)
1873
 
        fputs(prompt, OUTFILE);
1874
 
      line= readline(prompt);
 
1981
        fputs(prompt.c_str(), OUTFILE);
 
1982
      line= readline(prompt.c_str());
1875
1983
      /*
1876
1984
        When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS
1877
1985
        which may cause coredump.
1882
1990
    // End of file
1883
1991
    if (!line)
1884
1992
    {
1885
 
      status.exit_status=0;
 
1993
      status.setExitStatus(0);
1886
1994
      break;
1887
1995
    }
1888
1996
 
1898
2006
      // If buffer was emptied
1899
2007
      if (glob_buffer->empty())
1900
2008
        in_string=0;
1901
 
      if (interactive && status.add_to_history && not_in_history(line))
 
2009
      if (interactive && status.getAddToHistory() && not_in_history(line))
1902
2010
        add_history(line);
1903
2011
      continue;
1904
2012
    }
1907
2015
  }
1908
2016
  /* if in batch mode, send last query even if it doesn't end with \g or go */
1909
2017
 
1910
 
  if (!interactive && !status.exit_status)
 
2018
  if (!interactive && !status.getExitStatus())
1911
2019
  {
1912
2020
    remove_cntrl(glob_buffer);
1913
2021
    if (!glob_buffer->empty())
1914
2022
    {
1915
 
      status.exit_status=1;
 
2023
      status.setExitStatus(1);
1916
2024
      if (com_go(glob_buffer,line) <= 0)
1917
 
        status.exit_status=0;
 
2025
        status.setExitStatus(0);
1918
2026
    }
1919
2027
  }
1920
2028
 
1921
 
  return status.exit_status;
 
2029
  return status.getExitStatus();
1922
2030
}
1923
2031
 
1924
2032
 
1925
 
static COMMANDS *find_command(const char *name,char cmd_char)
 
2033
static Commands *find_command(const char *name,char cmd_char)
1926
2034
{
1927
2035
  uint32_t len;
1928
2036
  const char *end;
1934
2042
  }
1935
2043
  else
1936
2044
  {
1937
 
    while (my_isspace(charset_info,*name))
 
2045
    while (isspace(*name))
1938
2046
      name++;
1939
2047
    /*
1940
2048
      If there is an \\g in the row or if the row has a delimiter but
1943
2051
    */
1944
2052
    if (strstr(name, "\\g") || (strstr(name, delimiter) &&
1945
2053
                                !(strlen(name) >= 9 &&
1946
 
                                  !my_strnncoll(charset_info,
1947
 
                                                (unsigned char*) name, 9,
1948
 
                                                (const unsigned char*) "delimiter",
1949
 
                                                9))))
1950
 
      return((COMMANDS *) 0);
 
2054
                                  !strcmp(name, "delimiter"))))
 
2055
      return(NULL);
1951
2056
    if ((end=strcont(name," \t")))
1952
2057
    {
1953
2058
      len=(uint32_t) (end - name);
1954
 
      while (my_isspace(charset_info,*end))
 
2059
      while (isspace(*end))
1955
2060
        end++;
1956
2061
      if (!*end)
1957
2062
        end=0;          // no arguments to function
1960
2065
      len=(uint32_t) strlen(name);
1961
2066
  }
1962
2067
 
1963
 
  for (uint32_t i= 0; commands[i].name; i++)
 
2068
  for (uint32_t i= 0; commands[i].getName(); i++)
1964
2069
  {
1965
2070
    if (commands[i].func &&
1966
 
        ((name && !my_strnncoll(charset_info,(const unsigned char*)name,len, (const unsigned char*)commands[i].name,len) && !commands[i].name[len] && (!end || (end && commands[i].takes_params))) || (!name && commands[i].cmd_char == cmd_char)))
 
2071
        ((name && !strncmp(name, commands[i].getName(), len)
 
2072
          && !commands[i].getName()[len] && (!end || (end && commands[i].getTakesParams()))) || (!name && commands[i].getCmdChar() == cmd_char)))
1967
2073
    {
1968
2074
      return(&commands[i]);
1969
2075
    }
1970
2076
  }
1971
 
  return((COMMANDS *) 0);
 
2077
  return(NULL);
1972
2078
}
1973
2079
 
1974
2080
 
1975
2081
static bool add_line(string *buffer, char *line, char *in_string,
1976
 
                     bool *ml_comment)
 
2082
                        bool *ml_comment)
1977
2083
{
1978
2084
  unsigned char inchar;
1979
2085
  char *pos, *out;
1980
 
  COMMANDS *com;
 
2086
  Commands *com;
1981
2087
  bool need_space= 0;
1982
2088
  bool ss_comment= 0;
1983
2089
 
1984
2090
 
1985
2091
  if (!line[0] && (buffer->empty()))
1986
2092
    return(0);
1987
 
  if (status.add_to_history && line[0] && not_in_history(line))
 
2093
  if (status.getAddToHistory() && line[0] && not_in_history(line))
1988
2094
    add_history(line);
1989
2095
  char *end_of_line=line+(uint32_t) strlen(line);
1990
2096
 
1993
2099
    if (!preserve_comments)
1994
2100
    {
1995
2101
      // Skip spaces at the beggining of a statement
1996
 
      if (my_isspace(charset_info,inchar) && (out == line) &&
 
2102
      if (isspace(inchar) && (out == line) &&
1997
2103
          (buffer->empty()))
1998
2104
        continue;
1999
2105
    }
2000
2106
 
2001
2107
    // Accept multi-byte characters as-is
2002
 
    int length;
2003
 
    if (use_mb(charset_info) &&
2004
 
        (length= my_ismbchar(charset_info, pos, end_of_line)))
 
2108
    if (not drizzled::utf8::is_single(*pos))
2005
2109
    {
2006
 
      if (!*ml_comment || preserve_comments)
 
2110
      int length;
 
2111
      if ((length= drizzled::utf8::sequence_length(*pos)))
2007
2112
      {
2008
 
        while (length--)
2009
 
          *out++ = *pos++;
2010
 
        pos--;
 
2113
        if (!*ml_comment || preserve_comments)
 
2114
        {
 
2115
          while (length--)
 
2116
            *out++ = *pos++;
 
2117
          pos--;
 
2118
        }
 
2119
        else
 
2120
          pos+= length - 1;
 
2121
        continue;
2011
2122
      }
2012
 
      else
2013
 
        pos+= length - 1;
2014
 
      continue;
2015
2123
    }
2016
2124
    if (!*ml_comment && inchar == '\\' &&
2017
2125
        !(*in_string && (drizzle_con_status(&con) & DRIZZLE_CON_STATUS_NO_BACKSLASH_ESCAPES)))
2037
2145
 
2038
2146
        if ((*com->func)(buffer,pos-1) > 0)
2039
2147
          return(1);                       // Quit
2040
 
        if (com->takes_params)
 
2148
        if (com->getTakesParams())
2041
2149
        {
2042
2150
          if (ss_comment)
2043
2151
          {
2080
2188
    }
2081
2189
    else if (!*ml_comment && !*in_string &&
2082
2190
             (end_of_line - pos) >= 10 &&
2083
 
             !my_strnncoll(charset_info, (unsigned char*) pos, 10,
2084
 
                           (const unsigned char*) "delimiter ", 10))
 
2191
             !strncmp(pos, "delimiter ", 10))
2085
2192
    {
2086
2193
      // Flush previously accepted characters
2087
2194
      if (out != line)
2118
2225
 
2119
2226
      if (preserve_comments)
2120
2227
      {
2121
 
        while (my_isspace(charset_info, *pos))
 
2228
        while (isspace(*pos))
2122
2229
          *out++= *pos++;
2123
2230
      }
2124
2231
      // Flush previously accepted characters
2131
2238
      if (preserve_comments && ((*pos == '#') ||
2132
2239
                                ((*pos == '-') &&
2133
2240
                                 (pos[1] == '-') &&
2134
 
                                 my_isspace(charset_info, pos[2]))))
 
2241
                                 isspace(pos[2]))))
2135
2242
      {
2136
2243
        // Add trailing single line comments to this statement
2137
2244
        buffer->append(pos);
2158
2265
                 && (inchar == '#'
2159
2266
                     || (inchar == '-'
2160
2267
                         && pos[1] == '-'
2161
 
                         && my_isspace(charset_info,pos[2])))))
 
2268
                         && isspace(pos[2])))))
2162
2269
    {
2163
2270
      // Flush previously accepted characters
2164
2271
      if (out != line)
2224
2331
        *in_string= (char) inchar;
2225
2332
      if (!*ml_comment || preserve_comments)
2226
2333
      {
2227
 
        if (need_space && !my_isspace(charset_info, (char)inchar))
 
2334
        if (need_space && !isspace((char)inchar))
2228
2335
          *out++= ' ';
2229
2336
        need_space= 0;
2230
2337
        *out++= (char) inchar;
2235
2342
  {
2236
2343
    *out++='\n';
2237
2344
    uint32_t length=(uint32_t) (out-line);
 
2345
    if ((buffer->length() + length) > opt_max_input_line)
 
2346
    {
 
2347
      status.setExitStatus(1);
 
2348
      put_info(_("Not found a delimiter within max_input_line of input"), INFO_ERROR, 0, 0);
 
2349
      return 1;
 
2350
    }
2238
2351
    if ((!*ml_comment || preserve_comments))
2239
2352
      buffer->append(line, length);
2240
2353
  }
2242
2355
}
2243
2356
 
2244
2357
/*****************************************************************
2245
 
  Interface to Readline Completion
2246
 
 ******************************************************************/
 
2358
            Interface to Readline Completion
 
2359
******************************************************************/
2247
2360
 
2248
2361
 
2249
2362
static char **mysql_completion (const char *text, int start, int end);
2351
2464
*/
2352
2465
char **mysql_completion (const char *text, int, int)
2353
2466
{
2354
 
  if (!status.batch && !quick)
 
2467
  if (!status.getBatch() && !quick)
2355
2468
    return rl_completion_matches(text, new_command_generator);
2356
2469
  else
2357
2470
    return (char**) 0;
2420
2533
 
2421
2534
static void build_completion_hash(bool rehash, bool write_info)
2422
2535
{
2423
 
  COMMANDS *cmd=commands;
 
2536
  Commands *cmd=commands;
2424
2537
  drizzle_return_t ret;
2425
2538
  drizzle_result_st databases,tables,fields;
2426
2539
  drizzle_row_t database_row,table_row;
2427
2540
  drizzle_column_st *sql_field;
2428
2541
  string tmp_str, tmp_str_lower;
2429
2542
 
2430
 
  if (status.batch || quick || !current_db)
 
2543
  if (status.getBatch() || quick || current_db.empty())
2431
2544
    return;      // We don't need completion in batches
2432
2545
  if (!rehash)
2433
2546
    return;
2435
2548
  completion_map.clear();
2436
2549
 
2437
2550
  /* hash this file's known subset of SQL commands */
2438
 
  while (cmd->name) {
2439
 
    tmp_str= cmd->name;
 
2551
  while (cmd->getName()) {
 
2552
    tmp_str= cmd->getName();
2440
2553
    tmp_str_lower= lower_string(tmp_str);
2441
2554
    completion_map[tmp_str_lower]= tmp_str;
2442
2555
    cmd++;
2480
2593
    {
2481
2594
      if (drizzle_result_row_count(&tables) > 0 && !opt_silent && write_info)
2482
2595
      {
2483
 
        tee_fprintf(stdout, _("\
2484
 
                              Reading table information for completion of table and column names\n    \
2485
 
                              You can turn off this feature to get a quicker startup with -A\n\n"));
 
2596
        tee_fprintf(stdout,
 
2597
                    _("Reading table information for completion of "
 
2598
                      "table and column names\n"
 
2599
                      "You can turn off this feature to get a quicker "
 
2600
                      "startup with -A\n\n"));
2486
2601
      }
2487
2602
      while ((table_row=drizzle_row_next(&tables)))
2488
2603
      {
2508
2623
  {
2509
2624
    string query;
2510
2625
 
2511
 
    query.append("show fields in '");
 
2626
    query.append("show fields in `");
2512
2627
    query.append(table_row[0]);
2513
 
    query.append("'");
2514
 
 
 
2628
    query.append("`");
 
2629
    
2515
2630
    if (drizzle_query(&con, &fields, query.c_str(), query.length(),
2516
2631
                      &ret) != NULL)
2517
2632
    {
2560
2675
  drizzle_return_t ret;
2561
2676
  drizzle_result_st res;
2562
2677
 
2563
 
  free(current_db);
2564
 
  current_db= NULL;
 
2678
  current_db.erase();
 
2679
  current_db= "";
2565
2680
  /* In case of error below current_db will be NULL */
2566
2681
  if (drizzle_query_str(&con, &res, "SELECT DATABASE()", &ret) != NULL)
2567
2682
  {
2570
2685
    {
2571
2686
      drizzle_row_t row= drizzle_row_next(&res);
2572
2687
      if (row[0])
2573
 
        current_db= strdup(row[0]);
 
2688
        current_db.assign(row[0]);
2574
2689
      drizzle_result_free(&res);
2575
2690
    }
2576
2691
  }
2577
2692
}
2578
2693
 
2579
2694
/***************************************************************************
2580
 
  The different commands
2581
 
 ***************************************************************************/
 
2695
 The different commands
 
2696
***************************************************************************/
2582
2697
 
2583
 
int drizzleclient_real_query_for_lazy(const char *buf, int length,
 
2698
int drizzleclient_real_query_for_lazy(const char *buf, size_t length,
2584
2699
                                      drizzle_result_st *result,
2585
2700
                                      uint32_t *error_code)
2586
2701
{
2619
2734
    return 0;
2620
2735
 
2621
2736
  if (drizzle_con_error(&con)[0])
2622
 
    return put_error(&con, result);
 
2737
  {
 
2738
    int ret= put_error(&con, result);
 
2739
    drizzle_result_free(result);
 
2740
    return ret;
 
2741
  }
2623
2742
  return 0;
2624
2743
}
2625
2744
 
2628
2747
{
2629
2748
  register int i, j;
2630
2749
  char buff[32], *end;
 
2750
  std::vector<char> output_buff;
 
2751
  output_buff.resize(512);
2631
2752
 
2632
2753
  put_info(_("List of all Drizzle commands:"), INFO_INFO,0,0);
2633
2754
  if (!named_cmds)
2634
 
    put_info(_("Note that all text commands must be first on line and end with ';'"),INFO_INFO,0,0);
2635
 
  for (i = 0; commands[i].name; i++)
2636
 
  {
2637
 
    end= strcpy(buff, commands[i].name);
2638
 
    end+= strlen(commands[i].name);
2639
 
    for (j= (int)strlen(commands[i].name); j < 10; j++)
 
2755
  {
 
2756
    snprintf(&output_buff[0], output_buff.size(),
 
2757
             _("Note that all text commands must be first on line and end with '%s' or \\g"),
 
2758
             delimiter);
 
2759
    put_info(&output_buff[0], INFO_INFO, 0, 0);
 
2760
  }
 
2761
  for (i = 0; commands[i].getName(); i++)
 
2762
  {
 
2763
    end= strcpy(buff, commands[i].getName());
 
2764
    end+= strlen(commands[i].getName());
 
2765
    for (j= (int)strlen(commands[i].getName()); j < 10; j++)
2640
2766
      end= strcpy(end, " ")+1;
2641
2767
    if (commands[i].func)
2642
2768
      tee_fprintf(stdout, "%s(\\%c) %s\n", buff,
2643
 
                  commands[i].cmd_char, _(commands[i].doc));
 
2769
                  commands[i].getCmdChar(), _(commands[i].getDoc()));
2644
2770
  }
2645
2771
  tee_fprintf(stdout, "\n");
2646
2772
  buffer->clear();
2651
2777
static int
2652
2778
com_clear(string *buffer, const char *)
2653
2779
{
2654
 
  if (status.add_to_history)
 
2780
  if (status.getAddToHistory())
2655
2781
    fix_history(buffer);
2656
2782
  buffer->clear();
2657
2783
  return 0;
2660
2786
 
2661
2787
/*
2662
2788
  Execute command
2663
 
Returns: 0  if ok
2664
 
-1 if not fatal error
2665
 
1  if fatal error
 
2789
  Returns: 0  if ok
 
2790
  -1 if not fatal error
 
2791
  1  if fatal error
2666
2792
*/
2667
2793
static int
2668
2794
com_go(string *buffer, const char *)
2684
2810
  if (buffer->empty())
2685
2811
  {
2686
2812
    // Ignore empty quries
2687
 
    if (status.batch)
 
2813
    if (status.getBatch())
2688
2814
      return 0;
2689
2815
    return put_info(_("No query specified\n"),INFO_ERROR,0,0);
2690
2816
 
2709
2835
  executing_query= 1;
2710
2836
  error= drizzleclient_real_query_for_lazy(buffer->c_str(),buffer->length(),&result, &error_code);
2711
2837
 
2712
 
  if (status.add_to_history)
 
2838
  if (status.getAddToHistory())
2713
2839
  {
2714
2840
    buffer->append(vertical ? "\\G" : delimiter);
2715
2841
    /* Append final command onto history */
2763
2889
          print_tab_data(&result);
2764
2890
        else
2765
2891
          print_table_data(&result);
2766
 
        snprintf(buff, sizeof(buff), 
2767
 
                 ngettext("%ld row in set","%ld rows in set",
2768
 
                          (long) drizzle_result_row_count(&result)),
2769
 
                 (long) drizzle_result_row_count(&result));
 
2892
        sprintf(buff,
 
2893
                ngettext("%ld row in set","%ld rows in set",
 
2894
                         (long) drizzle_result_row_count(&result)),
 
2895
                (long) drizzle_result_row_count(&result));
2770
2896
        end_pager();
2771
2897
        if (drizzle_result_error_code(&result))
2772
2898
          error= put_error(&con, &result);
2775
2901
    else if (drizzle_result_affected_rows(&result) == ~(uint64_t) 0)
2776
2902
      strcpy(buff,_("Query OK"));
2777
2903
    else
2778
 
      snprintf(buff, sizeof(buff), ngettext("Query OK, %ld row affected",
2779
 
                                            "Query OK, %ld rows affected",
2780
 
                                            (long) drizzle_result_affected_rows(&result)),
2781
 
               (long) drizzle_result_affected_rows(&result));
 
2904
      sprintf(buff, ngettext("Query OK, %ld row affected",
 
2905
                             "Query OK, %ld rows affected",
 
2906
                             (long) drizzle_result_affected_rows(&result)),
 
2907
              (long) drizzle_result_affected_rows(&result));
2782
2908
 
2783
2909
    pos= strchr(buff, '\0');
2784
2910
    if ((warnings= drizzle_result_warning_count(&result)))
2787
2913
      *pos++= ' ';
2788
2914
      char warnings_buff[20];
2789
2915
      memset(warnings_buff,0,20);
2790
 
      snprintf(warnings_buff, sizeof(warnings_buff), "%d", warnings);
 
2916
      sprintf(warnings_buff, "%d", warnings);
2791
2917
      strcpy(pos, warnings_buff);
2792
2918
      pos+= strlen(warnings_buff);
2793
2919
      pos= strcpy(pos, " warning")+8;
2830
2956
  if (show_warnings == 1 && (warnings >= 1 || error))
2831
2957
    print_warnings(error_code);
2832
2958
 
2833
 
  if (!error && !status.batch &&
 
2959
  if (!error && !status.getBatch() &&
2834
2960
      drizzle_con_status(&con) & DRIZZLE_CON_STATUS_DB_DROPPED)
2835
2961
  {
2836
2962
    get_current_db();
2845
2971
{
2846
2972
  if (!opt_nopager)
2847
2973
  {
2848
 
    if (!(PAGER= popen(pager, "w")))
 
2974
    if (!(PAGER= popen(pager.c_str(), "w")))
2849
2975
    {
2850
 
      tee_fprintf(stdout, "popen() failed! defaulting PAGER to stdout!\n");
 
2976
      tee_fprintf(stdout,_( "popen() failed! defaulting PAGER to stdout!\n"));
2851
2977
      PAGER= stdout;
2852
2978
    }
2853
2979
  }
2869
2995
    end_tee();
2870
2996
  if (!(new_outfile= fopen(file_name, "a")))
2871
2997
  {
2872
 
    tee_fprintf(stdout, "Error logging to file '%s'\n", file_name);
 
2998
    tee_fprintf(stdout, _("Error logging to file '%s'\n"), file_name);
2873
2999
    return;
2874
3000
  }
2875
3001
  OUTFILE = new_outfile;
2876
 
  strncpy(outfile, file_name, FN_REFLEN-1);
2877
 
  tee_fprintf(stdout, "Logging to file '%s'\n", file_name);
 
3002
  outfile.assign(file_name);
 
3003
  tee_fprintf(stdout, _("Logging to file '%s'\n"), file_name);
2878
3004
  opt_outfile= 1;
2879
3005
 
2880
3006
  return;
2905
3031
static const char *fieldtype2str(drizzle_column_type_t type)
2906
3032
{
2907
3033
  switch (type) {
2908
 
  case DRIZZLE_COLUMN_TYPE_BLOB:        return "BLOB";
2909
 
  case DRIZZLE_COLUMN_TYPE_DATE:        return "DATE";
2910
 
  case DRIZZLE_COLUMN_TYPE_DATETIME:    return "DATETIME";
2911
 
  case DRIZZLE_COLUMN_TYPE_NEWDECIMAL:  return "DECIMAL";
2912
 
  case DRIZZLE_COLUMN_TYPE_DOUBLE:      return "DOUBLE";
2913
 
  case DRIZZLE_COLUMN_TYPE_ENUM:        return "ENUM";
2914
 
  case DRIZZLE_COLUMN_TYPE_LONG:        return "LONG";
2915
 
  case DRIZZLE_COLUMN_TYPE_LONGLONG:    return "LONGLONG";
2916
 
  case DRIZZLE_COLUMN_TYPE_NULL:        return "NULL";
2917
 
  case DRIZZLE_COLUMN_TYPE_TIMESTAMP:   return "TIMESTAMP";
2918
 
  default:                     return "?-unknown-?";
 
3034
    case DRIZZLE_COLUMN_TYPE_BLOB:        return "BLOB";
 
3035
    case DRIZZLE_COLUMN_TYPE_DATE:        return "DATE";
 
3036
    case DRIZZLE_COLUMN_TYPE_DATETIME:    return "DATETIME";
 
3037
    case DRIZZLE_COLUMN_TYPE_NEWDECIMAL:  return "DECIMAL";
 
3038
    case DRIZZLE_COLUMN_TYPE_DOUBLE:      return "DOUBLE";
 
3039
    case DRIZZLE_COLUMN_TYPE_ENUM:        return "ENUM";
 
3040
    case DRIZZLE_COLUMN_TYPE_LONG:        return "LONG";
 
3041
    case DRIZZLE_COLUMN_TYPE_LONGLONG:    return "LONGLONG";
 
3042
    case DRIZZLE_COLUMN_TYPE_NULL:        return "NULL";
 
3043
    case DRIZZLE_COLUMN_TYPE_TIMESTAMP:   return "TIMESTAMP";
 
3044
    default:                     return "?-unknown-?";
2919
3045
  }
2920
3046
}
2921
3047
 
2925
3051
  *s=0;
2926
3052
#define ff2s_check_flag(X)                                              \
2927
3053
  if (f & DRIZZLE_COLUMN_FLAGS_ ## X) { s=strcpy(s, # X " ")+strlen(# X " "); \
2928
 
    f &= ~ DRIZZLE_COLUMN_FLAGS_ ## X; }
 
3054
                        f &= ~ DRIZZLE_COLUMN_FLAGS_ ## X; }
2929
3055
  ff2s_check_flag(NOT_NULL);
2930
3056
  ff2s_check_flag(PRI_KEY);
2931
3057
  ff2s_check_flag(UNIQUE_KEY);
2946
3072
  ff2s_check_flag(ON_UPDATE_NOW);
2947
3073
#undef ff2s_check_flag
2948
3074
  if (f)
2949
 
    snprintf(s, sizeof(buf), " unknows=0x%04x", f);
 
3075
    sprintf(s, " unknows=0x%04x", f);
2950
3076
  return buf;
2951
3077
}
2952
3078
 
2958
3084
 
2959
3085
  while ((field = drizzle_column_next(result)))
2960
3086
  {
2961
 
    tee_fprintf(PAGER, "Field %3u:  `%s`\n"
 
3087
    tee_fprintf(PAGER, _("Field %3u:  `%s`\n"
2962
3088
                "Catalog:    `%s`\n"
2963
3089
                "Database:   `%s`\n"
2964
3090
                "Table:      `%s`\n"
2965
3091
                "Org_table:  `%s`\n"
2966
 
                "Type:       %s\n"
 
3092
                "Type:       UTF-8\n"
2967
3093
                "Collation:  %s (%u)\n"
2968
3094
                "Length:     %lu\n"
2969
3095
                "Max_length: %lu\n"
2970
3096
                "Decimals:   %u\n"
2971
 
                "Flags:      %s\n\n",
 
3097
                "Flags:      %s\n\n"),
2972
3098
                ++i,
2973
3099
                drizzle_column_name(field), drizzle_column_catalog(field),
2974
3100
                drizzle_column_db(field), drizzle_column_table(field),
2975
3101
                drizzle_column_orig_table(field),
2976
3102
                fieldtype2str(drizzle_column_type(field)),
2977
 
                get_charset_name(drizzle_column_charset(field)),
2978
3103
                drizzle_column_charset(field), drizzle_column_size(field),
2979
3104
                drizzle_column_max_size(field), drizzle_column_decimals(field),
2980
3105
                fieldflags2str(drizzle_column_flags(field)));
2982
3107
  tee_puts("", PAGER);
2983
3108
}
2984
3109
 
2985
 
 
2986
3110
static void
2987
3111
print_table_data(drizzle_result_st *result)
2988
3112
{
2989
3113
  drizzle_row_t cur;
2990
3114
  drizzle_return_t ret;
2991
3115
  drizzle_column_st *field;
2992
 
  bool *num_flag;
 
3116
  std::vector<bool> num_flag;
2993
3117
  string separator;
2994
3118
 
2995
3119
  separator.reserve(256);
2996
3120
 
2997
 
  num_flag=(bool*) malloc(sizeof(bool)*drizzle_result_column_count(result));
 
3121
  num_flag.resize(drizzle_result_column_count(result));
2998
3122
  if (column_types_flag)
2999
3123
  {
3000
3124
    print_field_types(result);
3012
3136
      uint32_t name_length= strlen(drizzle_column_name(field));
3013
3137
 
3014
3138
      /* Check if the max_byte value is really the maximum in terms
3015
 
        of visual length since multibyte characters can affect the
3016
 
        length of the separator. */
3017
 
      length= charset_info->cset->numcells(charset_info,
3018
 
                                           drizzle_column_name(field),
3019
 
                                           drizzle_column_name(field) +
3020
 
                                           name_length);
 
3139
         of visual length since multibyte characters can affect the
 
3140
         length of the separator. */
 
3141
      length= drizzled::utf8::char_length(drizzle_column_name(field));
3021
3142
 
3022
3143
      if (name_length == drizzle_column_max_size(field))
3023
3144
      {
3029
3150
        length= name_length;
3030
3151
      }
3031
3152
    }
3032
 
 
 
3153
  
3033
3154
    if (quick)
3034
3155
      length=max(length,drizzle_column_size(field));
3035
3156
    else
3055
3176
    for (uint32_t off=0; (field = drizzle_column_next(result)) ; off++)
3056
3177
    {
3057
3178
      uint32_t name_length= (uint32_t) strlen(drizzle_column_name(field));
3058
 
      uint32_t numcells= charset_info->cset->numcells(charset_info,
3059
 
                                                      drizzle_column_name(field),
3060
 
                                                      drizzle_column_name(field) +
3061
 
                                                      name_length);
 
3179
      uint32_t numcells= drizzled::utf8::char_length(drizzle_column_name(field));
3062
3180
      uint32_t display_length= drizzle_column_max_size(field) + name_length -
3063
 
        numcells;
 
3181
                               numcells;
3064
3182
      tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
3065
3183
                                             MAX_COLUMN_LENGTH),
3066
3184
                  drizzle_column_name(field));
3121
3239
        We need to find how much screen real-estate we will occupy to know how
3122
3240
        many extra padding-characters we should send with the printing function.
3123
3241
      */
3124
 
      visible_length= charset_info->cset->numcells(charset_info, buffer, buffer + data_length);
 
3242
      visible_length= drizzled::utf8::char_length(buffer);
3125
3243
      extra_padding= data_length - visible_length;
3126
3244
 
3127
3245
      if (field_max_length > MAX_COLUMN_LENGTH)
3141
3259
      drizzle_row_free(result, cur);
3142
3260
  }
3143
3261
  tee_puts(separator.c_str(), PAGER);
3144
 
  free(num_flag);
3145
3262
}
3146
3263
 
3147
3264
/**
3148
 
  Return the length of a field after it would be rendered into text.
3149
 
 
3150
 
  This doesn't know or care about multibyte characters.  Assume we're
3151
 
  using such a charset.  We can't know that all of the upcoming rows
3152
 
  for this column will have bytes that each render into some fraction
3153
 
  of a character.  It's at least possible that a row has bytes that
3154
 
  all render into one character each, and so the maximum length is
3155
 
  still the number of bytes.  (Assumption 1:  This can't be better
3156
 
  because we can never know the number of characters that the DB is
3157
 
  going to send -- only the number of bytes.  2: Chars <= Bytes.)
3158
 
 
3159
 
  @param  field  Pointer to a field to be inspected
3160
 
 
3161
 
  @returns  number of character positions to be used, at most
 
3265
   Return the length of a field after it would be rendered into text.
 
3266
 
 
3267
   This doesn't know or care about multibyte characters.  Assume we're
 
3268
   using such a charset.  We can't know that all of the upcoming rows
 
3269
   for this column will have bytes that each render into some fraction
 
3270
   of a character.  It's at least possible that a row has bytes that
 
3271
   all render into one character each, and so the maximum length is
 
3272
   still the number of bytes.  (Assumption 1:  This can't be better
 
3273
   because we can never know the number of characters that the DB is
 
3274
   going to send -- only the number of bytes.  2: Chars <= Bytes.)
 
3275
 
 
3276
   @param  field  Pointer to a field to be inspected
 
3277
 
 
3278
   @returns  number of character positions to be used, at most
3162
3279
*/
3163
3280
static int get_field_disp_length(drizzle_column_st *field)
3164
3281
{
3170
3287
    length= max(length, (uint32_t)drizzle_column_max_size(field));
3171
3288
 
3172
3289
  if (length < 4 &&
3173
 
      !(drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_NOT_NULL))
 
3290
    !(drizzle_column_flags(field) & DRIZZLE_COLUMN_FLAGS_NOT_NULL))
3174
3291
  {
3175
3292
    length= 4;        /* Room for "NULL" */
3176
3293
  }
3179
3296
}
3180
3297
 
3181
3298
/**
3182
 
  For a new result, return the max number of characters that any
3183
 
  upcoming row may return.
3184
 
 
3185
 
  @param  result  Pointer to the result to judge
3186
 
 
3187
 
  @returns  The max number of characters in any row of this result
 
3299
   For a new result, return the max number of characters that any
 
3300
   upcoming row may return.
 
3301
 
 
3302
   @param  result  Pointer to the result to judge
 
3303
 
 
3304
   @returns  The max number of characters in any row of this result
3188
3305
*/
3189
3306
static int get_result_width(drizzle_result_st *result)
3190
3307
{
3289
3406
  drizzle_row_t cur;
3290
3407
  uint64_t num_rows;
3291
3408
  uint32_t new_code= 0;
 
3409
  FILE *out;
3292
3410
 
3293
3411
  /* Get the warnings */
3294
3412
  query= "show warnings";
3308
3426
    warning.
3309
3427
  */
3310
3428
  if (!cur || (num_rows == 1 &&
3311
 
               error_code == (uint32_t) strtoul(cur[1], NULL, 10)))
 
3429
      error_code == (uint32_t) strtoul(cur[1], NULL, 10)))
3312
3430
  {
3313
3431
    goto end;
3314
3432
  }
3315
3433
 
3316
3434
  /* Print the warnings */
3317
 
  init_pager();
 
3435
  if (status.getBatch()) 
 
3436
  {
 
3437
    out= stderr;
 
3438
  } 
 
3439
  else 
 
3440
  {
 
3441
    init_pager();
 
3442
    out= PAGER;
 
3443
  }
3318
3444
  do
3319
3445
  {
3320
 
    tee_fprintf(PAGER, "%s (Code %s): %s\n", cur[0], cur[1], cur[2]);
 
3446
    tee_fprintf(out, "%s (Code %s): %s\n", cur[0], cur[1], cur[2]);
3321
3447
  } while ((cur= drizzle_row_next(&result)));
3322
 
  end_pager();
 
3448
 
 
3449
  if (not status.getBatch())
 
3450
    end_pager();
3323
3451
 
3324
3452
end:
3325
3453
  drizzle_result_free(&result);
3338
3466
    else for (const char *end=pos+length ; pos != end ; pos++)
3339
3467
    {
3340
3468
      int l;
3341
 
      if (use_mb(charset_info) &&
3342
 
          (l = my_ismbchar(charset_info, pos, end)))
 
3469
      if ((l = drizzled::utf8::sequence_length(*pos)))
3343
3470
      {
3344
3471
        while (l--)
3345
3472
          tee_putc(*pos++, PAGER);
3416
3543
  char file_name[FN_REFLEN], *end;
3417
3544
  const char *param;
3418
3545
 
3419
 
  if (status.batch)
 
3546
  if (status.getBatch())
3420
3547
    return 0;
3421
 
  while (my_isspace(charset_info,*line))
 
3548
  while (isspace(*line))
3422
3549
    line++;
3423
 
  if (!(param = strchr(line, ' '))) // if outfile wasn't given, use the default
 
3550
  if (!(param =strchr(line, ' '))) // if outfile wasn't given, use the default
3424
3551
  {
3425
 
    if (!strlen(outfile))
 
3552
    if (outfile.empty())
3426
3553
    {
3427
 
      printf("No previous outfile available, you must give a filename!\n");
 
3554
      printf(_("No previous outfile available, you must give a filename!\n"));
3428
3555
      return 0;
3429
3556
    }
3430
3557
    else if (opt_outfile)
3431
3558
    {
3432
 
      tee_fprintf(stdout, "Currently logging to file '%s'\n", outfile);
 
3559
      tee_fprintf(stdout, _("Currently logging to file '%s'\n"), outfile.c_str());
3433
3560
      return 0;
3434
3561
    }
3435
3562
    else
3436
 
      param = outfile;      //resume using the old outfile
 
3563
      param= outfile.c_str();      //resume using the old outfile
3437
3564
  }
3438
3565
 
 
3566
  /* @TODO: Replace this with string methods */
3439
3567
  /* eliminate the spaces before the parameters */
3440
 
  while (my_isspace(charset_info,*param))
 
3568
  while (isspace(*param))
3441
3569
    param++;
3442
3570
  strncpy(file_name, param, sizeof(file_name) - 1);
3443
3571
  end= file_name + strlen(file_name);
3444
3572
  /* remove end space from command line */
3445
 
  while (end > file_name && (my_isspace(charset_info,end[-1]) ||
3446
 
                             my_iscntrl(charset_info,end[-1])))
 
3573
  while (end > file_name && (isspace(end[-1]) ||
 
3574
                             iscntrl(end[-1])))
3447
3575
    end--;
3448
3576
  end[0]= 0;
3449
3577
  if (end == file_name)
3450
3578
  {
3451
 
    printf("No outfile specified!\n");
 
3579
    printf(_("No outfile specified!\n"));
3452
3580
    return 0;
3453
3581
  }
3454
3582
  init_tee(file_name);
3461
3589
{
3462
3590
  if (opt_outfile)
3463
3591
    end_tee();
3464
 
  tee_fprintf(stdout, "Outfile disabled.\n");
 
3592
  tee_fprintf(stdout, _("Outfile disabled.\n"));
3465
3593
  return 0;
3466
3594
}
3467
3595
 
3472
3600
static int
3473
3601
com_pager(string *, const char *line)
3474
3602
{
3475
 
  char pager_name[FN_REFLEN], *end;
3476
3603
  const char *param;
3477
3604
 
3478
 
  if (status.batch)
 
3605
  if (status.getBatch())
3479
3606
    return 0;
3480
3607
  /* Skip spaces in front of the pager command */
3481
 
  while (my_isspace(charset_info, *line))
 
3608
  while (isspace(*line))
3482
3609
    line++;
3483
3610
  /* Skip the pager command */
3484
3611
  param= strchr(line, ' ');
3485
3612
  /* Skip the spaces between the command and the argument */
3486
 
  while (param && my_isspace(charset_info, *param))
 
3613
  while (param && isspace(*param))
3487
3614
    param++;
3488
 
  if (!param || !strlen(param)) // if pager was not given, use the default
 
3615
  if (!param || (*param == '\0')) // if pager was not given, use the default
3489
3616
  {
3490
3617
    if (!default_pager_set)
3491
3618
    {
3492
 
      tee_fprintf(stdout, "Default pager wasn't set, using stdout.\n");
 
3619
      tee_fprintf(stdout, _("Default pager wasn't set, using stdout.\n"));
3493
3620
      opt_nopager=1;
3494
 
      strcpy(pager, "stdout");
 
3621
      pager.assign("stdout");
3495
3622
      PAGER= stdout;
3496
3623
      return 0;
3497
3624
    }
3498
 
    strcpy(pager, default_pager);
 
3625
    pager.assign(default_pager);
3499
3626
  }
3500
3627
  else
3501
3628
  {
3502
 
    end= strncpy(pager_name, param, sizeof(pager_name)-1);
3503
 
    end+= strlen(pager_name);
3504
 
    while (end > pager_name && (my_isspace(charset_info,end[-1]) ||
3505
 
                                my_iscntrl(charset_info,end[-1])))
3506
 
      end--;
3507
 
    end[0]=0;
3508
 
    strcpy(pager, pager_name);
3509
 
    strcpy(default_pager, pager_name);
 
3629
    string pager_name(param);
 
3630
    string::iterator end= pager_name.end();
 
3631
    while (end > pager_name.begin() &&
 
3632
           (isspace(*(end-1)) || iscntrl(*(end-1))))
 
3633
      --end;
 
3634
    pager_name.erase(end, pager_name.end());
 
3635
    pager.assign(pager_name);
 
3636
    default_pager.assign(pager_name);
3510
3637
  }
3511
3638
  opt_nopager=0;
3512
 
  tee_fprintf(stdout, "PAGER set to '%s'\n", pager);
 
3639
  tee_fprintf(stdout, _("PAGER set to '%s'\n"), pager.c_str());
3513
3640
  return 0;
3514
3641
}
3515
3642
 
3517
3644
static int
3518
3645
com_nopager(string *, const char *)
3519
3646
{
3520
 
  strcpy(pager, "stdout");
 
3647
  pager.assign("stdout");
3521
3648
  opt_nopager=1;
3522
3649
  PAGER= stdout;
3523
 
  tee_fprintf(stdout, "PAGER set to stdout\n");
 
3650
  tee_fprintf(stdout, _("PAGER set to stdout\n"));
3524
3651
  return 0;
3525
3652
}
3526
3653
 
3530
3657
com_quit(string *, const char *)
3531
3658
{
3532
3659
  /* let the screen auto close on a normal shutdown */
3533
 
  status.exit_status=0;
 
3660
  status.setExitStatus(0);
3534
3661
  return 1;
3535
3662
}
3536
3663
 
3578
3705
    tmp= get_arg(buff, 0);
3579
3706
    if (tmp && *tmp)
3580
3707
    {
3581
 
      free(current_db);
3582
 
      current_db= strdup(tmp);
 
3708
      current_db.erase();
 
3709
      current_db.assign(tmp);
3583
3710
      tmp= get_arg(buff, 1);
3584
3711
      if (tmp)
3585
3712
      {
3586
 
        free(current_host);
 
3713
        current_host.erase();
3587
3714
        current_host=strdup(tmp);
3588
3715
      }
3589
3716
    }
3598
3725
  }
3599
3726
  else
3600
3727
    opt_rehash= 0;
3601
 
  error=sql_connect(current_host,current_db,current_user,opt_password,0);
 
3728
  error=sql_connect(current_host, current_db, current_user, opt_password,0);
3602
3729
  opt_rehash= save_rehash;
3603
3730
 
3604
3731
  if (connected)
3605
3732
  {
3606
 
    snprintf(buff, sizeof(buff), "Connection id:    %u",drizzle_con_thread_id(&con));
 
3733
    sprintf(buff, _("Connection id:    %u"), drizzle_con_thread_id(&con));
3607
3734
    put_info(buff,INFO_INFO,0,0);
3608
 
    snprintf(buff, sizeof(buff), "Current database: %.128s\n",
3609
 
             current_db ? current_db : "*** NONE ***");
 
3735
    sprintf(buff, _("Current database: %.128s\n"),
 
3736
            !current_db.empty() ? current_db.c_str() : _("*** NONE ***"));
3610
3737
    put_info(buff,INFO_INFO,0,0);
3611
3738
  }
3612
3739
  return error;
3619
3746
  const char *param;
3620
3747
  LineBuffer *line_buff;
3621
3748
  int error;
3622
 
  STATUS old_status;
 
3749
  Status old_status;
3623
3750
  FILE *sql_file;
3624
3751
 
3625
3752
  /* Skip space from file name */
3626
 
  while (my_isspace(charset_info,*line))
 
3753
  while (isspace(*line))
3627
3754
    line++;
3628
3755
  if (!(param = strchr(line, ' ')))    // Skip command name
3629
 
    return put_info("Usage: \\. <filename> | source <filename>",
 
3756
    return put_info(_("Usage: \\. <filename> | source <filename>"),
3630
3757
                    INFO_ERROR, 0,0);
3631
 
  while (my_isspace(charset_info,*param))
 
3758
  while (isspace(*param))
3632
3759
    param++;
3633
3760
  end= strncpy(source_name,param,sizeof(source_name)-1);
3634
3761
  end+= strlen(source_name);
3635
 
  while (end > source_name && (my_isspace(charset_info,end[-1]) ||
3636
 
                               my_iscntrl(charset_info,end[-1])))
 
3762
  while (end > source_name && (isspace(end[-1]) ||
 
3763
                               iscntrl(end[-1])))
3637
3764
    end--;
3638
3765
  end[0]=0;
3639
 
  internal::unpack_filename(source_name,source_name);
 
3766
 
3640
3767
  /* open file name */
3641
3768
  if (!(sql_file = fopen(source_name, "r")))
3642
3769
  {
3643
3770
    char buff[FN_REFLEN+60];
3644
 
    snprintf(buff, sizeof(buff), "Failed to open file '%s', error: %d", source_name,errno);
 
3771
    sprintf(buff, _("Failed to open file '%s', error: %d"), source_name,errno);
3645
3772
    return put_info(buff, INFO_ERROR, 0 ,0);
3646
3773
  }
3647
3774
 
3649
3776
  if (line_buff == NULL)
3650
3777
  {
3651
3778
    fclose(sql_file);
3652
 
    return put_info("Can't initialize LineBuffer", INFO_ERROR, 0, 0);
 
3779
    return put_info(_("Can't initialize LineBuffer"), INFO_ERROR, 0, 0);
3653
3780
  }
3654
3781
 
3655
3782
  /* Save old status */
3657
3784
  memset(&status, 0, sizeof(status));
3658
3785
 
3659
3786
  // Run in batch mode
3660
 
  status.batch=old_status.batch;
3661
 
  status.line_buff=line_buff;
3662
 
  status.file_name=source_name;
 
3787
  status.setBatch(old_status.getBatch());
 
3788
  status.setLineBuff(line_buff);
 
3789
  status.setFileName(source_name);
3663
3790
  // Empty command buffer
3664
3791
  assert(glob_buffer!=NULL);
3665
3792
  glob_buffer->clear();
3667
3794
  // Continue as before
3668
3795
  status=old_status;
3669
3796
  fclose(sql_file);
3670
 
  delete status.line_buff;
3671
 
  line_buff= status.line_buff= 0;
 
3797
  delete status.getLineBuff();
 
3798
  line_buff=0;
 
3799
  status.setLineBuff(0);
3672
3800
  return error;
3673
3801
}
3674
3802
 
3684
3812
 
3685
3813
  if (!tmp || !*tmp)
3686
3814
  {
3687
 
    put_info("DELIMITER must be followed by a 'delimiter' character or string",
 
3815
    put_info(_("DELIMITER must be followed by a 'delimiter' character or string"),
3688
3816
             INFO_ERROR, 0, 0);
3689
3817
    return 0;
3690
3818
  }
3692
3820
  {
3693
3821
    if (strstr(tmp, "\\"))
3694
3822
    {
3695
 
      put_info("DELIMITER cannot contain a backslash character",
 
3823
      put_info(_("DELIMITER cannot contain a backslash character"),
3696
3824
               INFO_ERROR, 0, 0);
3697
3825
      return 0;
3698
3826
    }
3717
3845
  tmp= get_arg(buff, 0);
3718
3846
  if (!tmp || !*tmp)
3719
3847
  {
3720
 
    put_info("USE must be followed by a database name", INFO_ERROR, 0, 0);
 
3848
    put_info(_("USE must be followed by a database name"), INFO_ERROR, 0, 0);
3721
3849
    return 0;
3722
3850
  }
3723
3851
  /*
3727
3855
  */
3728
3856
  get_current_db();
3729
3857
 
3730
 
  if (!current_db || strcmp(current_db,tmp))
 
3858
  if (current_db.empty() || strcmp(current_db.c_str(),tmp))
3731
3859
  {
3732
3860
    if (one_database)
3733
3861
    {
3779
3907
      else
3780
3908
        drizzle_result_free(&result);
3781
3909
    }
3782
 
    free(current_db);
3783
 
    current_db= strdup(tmp);
 
3910
    current_db.erase();
 
3911
    current_db.assign(tmp);
3784
3912
    if (select_db > 1)
3785
3913
      build_completion_hash(opt_rehash, 1);
3786
3914
  }
3787
3915
 
3788
 
  put_info("Database changed",INFO_INFO, 0, 0);
 
3916
  put_info(_("Database changed"),INFO_INFO, 0, 0);
3789
3917
  return 0;
3790
3918
}
3791
3919
 
 
3920
static int com_shutdown(string *, const char *)
 
3921
{
 
3922
  drizzle_result_st result;
 
3923
  drizzle_return_t ret;
 
3924
 
 
3925
  if (verbose)
 
3926
  {
 
3927
    printf(_("shutting down drizzled"));
 
3928
    if (opt_drizzle_port > 0)
 
3929
      printf(_(" on port %d"), opt_drizzle_port);
 
3930
    printf("... ");
 
3931
  }
 
3932
 
 
3933
  if (drizzle_shutdown(&con, &result, DRIZZLE_SHUTDOWN_DEFAULT,
 
3934
                       &ret) == NULL || ret != DRIZZLE_RETURN_OK)
 
3935
  {
 
3936
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
3937
    {
 
3938
      fprintf(stderr, _("shutdown failed; error: '%s'"),
 
3939
              drizzle_result_error(&result));
 
3940
      drizzle_result_free(&result);
 
3941
    }
 
3942
    else
 
3943
    {
 
3944
      fprintf(stderr, _("shutdown failed; error: '%s'"),
 
3945
              drizzle_con_error(&con));
 
3946
    }
 
3947
    return false;
 
3948
  }
 
3949
 
 
3950
  drizzle_result_free(&result);
 
3951
 
 
3952
  if (verbose)
 
3953
    printf(_("done\n"));
 
3954
 
 
3955
  return false;
 
3956
}
 
3957
 
3792
3958
static int
3793
3959
com_warnings(string *, const char *)
3794
3960
{
3795
3961
  show_warnings = 1;
3796
 
  put_info("Show warnings enabled.",INFO_INFO, 0, 0);
 
3962
  put_info(_("Show warnings enabled."),INFO_INFO, 0, 0);
3797
3963
  return 0;
3798
3964
}
3799
3965
 
3801
3967
com_nowarnings(string *, const char *)
3802
3968
{
3803
3969
  show_warnings = 0;
3804
 
  put_info("Show warnings disabled.",INFO_INFO, 0, 0);
 
3970
  put_info(_("Show warnings disabled."),INFO_INFO, 0, 0);
3805
3971
  return 0;
3806
3972
}
3807
3973
 
3831
3997
  else
3832
3998
  {
3833
3999
    /* skip leading white spaces */
3834
 
    while (my_isspace(charset_info, *ptr))
 
4000
    while (isspace(*ptr))
3835
4001
      ptr++;
3836
4002
    if (*ptr == '\\') // short command was used
3837
4003
      ptr+= 2;
3838
4004
    else
3839
 
      while (*ptr &&!my_isspace(charset_info, *ptr)) // skip command
 
4005
      while (*ptr &&!isspace(*ptr)) // skip command
3840
4006
        ptr++;
3841
4007
  }
3842
4008
  if (!*ptr)
3843
4009
    return NULL;
3844
 
  while (my_isspace(charset_info, *ptr))
 
4010
  while (isspace(*ptr))
3845
4011
    ptr++;
3846
4012
  if (*ptr == '\'' || *ptr == '\"' || *ptr == '`')
3847
4013
  {
3868
4034
 
3869
4035
 
3870
4036
static int
3871
 
sql_connect(char *host,char *database,char *user,char *password,
3872
 
            uint32_t silent)
 
4037
sql_connect(const string &host, const string &database, const string &user, const string &password,
 
4038
                 uint32_t silent)
3873
4039
{
3874
4040
  drizzle_return_t ret;
3875
 
 
3876
4041
  if (connected)
3877
4042
  {
3878
4043
    connected= 0;
3880
4045
    drizzle_free(&drizzle);
3881
4046
  }
3882
4047
  drizzle_create(&drizzle);
3883
 
  if (drizzle_con_add_tcp(&drizzle, &con, host, opt_drizzle_port, user,
3884
 
                          password, database, opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
 
4048
 
 
4049
#ifdef DRIZZLE_ADMIN_TOOL
 
4050
  drizzle_con_options_t options= (drizzle_con_options_t) (DRIZZLE_CON_ADMIN | (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL));
 
4051
#else
 
4052
  drizzle_con_options_t options= (drizzle_con_options_t) (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
 
4053
#endif
 
4054
 
 
4055
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(),
 
4056
    opt_drizzle_port, (char *)user.c_str(),
 
4057
    (char *)password.c_str(), (char *)database.c_str(),
 
4058
    options) == NULL)
3885
4059
  {
3886
4060
    (void) put_error(&con, NULL);
3887
4061
    (void) fflush(stdout);
3888
4062
    return 1;
3889
4063
  }
3890
4064
 
3891
 
  /* XXX add this back in
3892
 
    if (opt_connect_timeout)
3893
 
    {
 
4065
/* XXX add this back in
 
4066
  if (opt_connect_timeout)
 
4067
  {
3894
4068
    uint32_t timeout=opt_connect_timeout;
3895
4069
    drizzleclient_options(&drizzle,DRIZZLE_OPT_CONNECT_TIMEOUT,
3896
 
    (char*) &timeout);
3897
 
    }
3898
 
  */
 
4070
                  (char*) &timeout);
 
4071
  }
 
4072
*/
3899
4073
 
3900
 
  /* XXX Do we need this?
3901
 
    if (safe_updates)
3902
 
    {
 
4074
/* XXX Do we need this?
 
4075
  if (safe_updates)
 
4076
  {
3903
4077
    char init_command[100];
3904
4078
    sprintf(init_command,
3905
 
    "SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%"PRIu32
3906
 
    ",MAX_JOIN_SIZE=%"PRIu32,
3907
 
    select_limit, max_join_size);
 
4079
            "SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%"PRIu32
 
4080
            ",MAX_JOIN_SIZE=%"PRIu32,
 
4081
            select_limit, max_join_size);
3908
4082
    drizzleclient_options(&drizzle, DRIZZLE_INIT_COMMAND, init_command);
3909
 
    }
3910
 
  */
 
4083
  }
 
4084
*/
3911
4085
  if ((ret= drizzle_con_connect(&con)) != DRIZZLE_RETURN_OK)
3912
4086
  {
3913
4087
    if (!silent || (ret != DRIZZLE_RETURN_GETADDRINFO &&
3929
4103
static int
3930
4104
com_status(string *, const char *)
3931
4105
{
3932
 
  /*
3933
 
    char buff[40];
3934
 
    uint64_t id;
3935
 
  */
 
4106
/*
 
4107
  char buff[40];
 
4108
  uint64_t id;
 
4109
*/
3936
4110
  drizzle_result_st result;
3937
4111
  drizzle_return_t ret;
3938
4112
 
3939
4113
  tee_puts("--------------", stdout);
3940
 
  usage(1);          /* Print version */
 
4114
  printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
 
4115
         drizzle_version(), VERSION,
 
4116
         HOST_VENDOR, HOST_OS, HOST_CPU,
 
4117
         rl_library_version);
 
4118
 
3941
4119
  if (connected)
3942
4120
  {
3943
 
    tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",drizzle_con_thread_id(&con));
 
4121
    tee_fprintf(stdout, _("\nConnection id:\t\t%lu\n"),drizzle_con_thread_id(&con));
3944
4122
    /*
3945
4123
      Don't remove "limit 1",
3946
4124
      it is protection againts SQL_SELECT_LIMIT=0
3952
4130
      drizzle_row_t cur=drizzle_row_next(&result);
3953
4131
      if (cur)
3954
4132
      {
3955
 
        tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
3956
 
        tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
 
4133
        tee_fprintf(stdout, _("Current database:\t%s\n"), cur[0] ? cur[0] : "");
 
4134
        tee_fprintf(stdout, _("Current user:\t\t%s\n"), cur[1]);
3957
4135
      }
3958
4136
      drizzle_result_free(&result);
3959
4137
    }
3960
4138
    else if (ret == DRIZZLE_RETURN_ERROR_CODE)
3961
4139
      drizzle_result_free(&result);
3962
 
    tee_puts("SSL:\t\t\tNot in use", stdout);
 
4140
    tee_puts(_("SSL:\t\t\tNot in use"), stdout);
3963
4141
  }
3964
4142
  else
3965
4143
  {
3966
4144
    vidattr(A_BOLD);
3967
 
    tee_fprintf(stdout, "\nNo connection\n");
 
4145
    tee_fprintf(stdout, _("\nNo connection\n"));
3968
4146
    vidattr(A_NORMAL);
3969
4147
    return 0;
3970
4148
  }
3971
4149
  if (skip_updates)
3972
4150
  {
3973
4151
    vidattr(A_BOLD);
3974
 
    tee_fprintf(stdout, "\nAll updates ignored to this database\n");
 
4152
    tee_fprintf(stdout, _("\nAll updates ignored to this database\n"));
3975
4153
    vidattr(A_NORMAL);
3976
4154
  }
3977
 
  tee_fprintf(stdout, "Current pager:\t\t%s\n", pager);
3978
 
  tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile : "");
3979
 
  tee_fprintf(stdout, "Using delimiter:\t%s\n", delimiter);
3980
 
  tee_fprintf(stdout, "Server version:\t\t%s\n", server_version_string(&con));
3981
 
  tee_fprintf(stdout, "Protocol version:\t%d\n", drizzle_con_protocol_version(&con));
3982
 
  tee_fprintf(stdout, "Connection:\t\t%s\n", drizzle_con_host(&con));
3983
 
  /* XXX need to save this from result
3984
 
    if ((id= drizzleclient_insert_id(&drizzle)))
 
4155
  tee_fprintf(stdout, _("Current pager:\t\t%s\n"), pager.c_str());
 
4156
  tee_fprintf(stdout, _("Using outfile:\t\t'%s'\n"), opt_outfile ? outfile.c_str() : "");
 
4157
  tee_fprintf(stdout, _("Using delimiter:\t%s\n"), delimiter);
 
4158
  tee_fprintf(stdout, _("Server version:\t\t%s\n"), server_version_string(&con));
 
4159
  tee_fprintf(stdout, _("Protocol:\t\t%s\n"), opt_protocol.c_str());
 
4160
  tee_fprintf(stdout, _("Protocol version:\t%d\n"), drizzle_con_protocol_version(&con));
 
4161
  tee_fprintf(stdout, _("Connection:\t\t%s\n"), drizzle_con_host(&con));
 
4162
/* XXX need to save this from result
 
4163
  if ((id= drizzleclient_insert_id(&drizzle)))
3985
4164
    tee_fprintf(stdout, "Insert id:\t\t%s\n", internal::llstr(id, buff));
3986
 
  */
 
4165
*/
3987
4166
 
3988
4167
  if (drizzle_con_uds(&con))
3989
 
    tee_fprintf(stdout, "UNIX socket:\t\t%s\n", drizzle_con_uds(&con));
 
4168
    tee_fprintf(stdout, _("UNIX socket:\t\t%s\n"), drizzle_con_uds(&con));
3990
4169
  else
3991
 
    tee_fprintf(stdout, "TCP port:\t\t%d\n", drizzle_con_port(&con));
 
4170
    tee_fprintf(stdout, _("TCP port:\t\t%d\n"), drizzle_con_port(&con));
3992
4171
 
3993
4172
  if (safe_updates)
3994
4173
  {
3995
4174
    vidattr(A_BOLD);
3996
 
    tee_fprintf(stdout, "\nNote that you are running in safe_update_mode:\n");
 
4175
    tee_fprintf(stdout, _("\nNote that you are running in safe_update_mode:\n"));
3997
4176
    vidattr(A_NORMAL);
3998
 
    tee_fprintf(stdout, "\
3999
 
                UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\
4000
 
                (One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n \
4001
 
                SELECT has an automatic 'LIMIT %lu' if LIMIT is not used.\n             \
4002
 
                Max number of examined row combination in a join is set to: %lu\n\n",
 
4177
    tee_fprintf(stdout, _("\
 
4178
UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\
 
4179
(One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n \
 
4180
SELECT has an automatic 'LIMIT %lu' if LIMIT is not used.\n             \
 
4181
Max number of examined row combination in a join is set to: %lu\n\n"),
4003
4182
                select_limit, max_join_size);
4004
4183
  }
4005
4184
  tee_puts("--------------\n", stdout);
4052
4231
  FILE *file= (info_type == INFO_ERROR ? stderr : stdout);
4053
4232
  static int inited=0;
4054
4233
 
4055
 
  if (status.batch)
 
4234
  if (status.getBatch())
4056
4235
  {
4057
4236
    if (info_type == INFO_ERROR)
4058
4237
    {
4059
4238
      (void) fflush(file);
4060
 
      fprintf(file,"ERROR");
 
4239
      fprintf(file,_("ERROR"));
4061
4240
      if (error)
4062
4241
      {
4063
4242
        if (sqlstate)
4065
4244
        else
4066
4245
          (void) fprintf(file," %d",error);
4067
4246
      }
4068
 
      if (status.query_start_line && line_numbers)
 
4247
      if (status.getQueryStartLine() && line_numbers)
4069
4248
      {
4070
 
        (void) fprintf(file," at line %"PRIu32,status.query_start_line);
4071
 
        if (status.file_name)
4072
 
          (void) fprintf(file," in file: '%s'", status.file_name);
 
4249
        (void) fprintf(file," at line %"PRIu32,status.getQueryStartLine());
 
4250
        if (status.getFileName())
 
4251
          (void) fprintf(file," in file: '%s'", status.getFileName());
4073
4252
      }
4074
4253
      (void) fprintf(file,": %s\n",str);
4075
4254
      (void) fflush(file);
4100
4279
      if (error)
4101
4280
      {
4102
4281
        if (sqlstate)
4103
 
          (void) tee_fprintf(file, "ERROR %d (%s): ", error, sqlstate);
 
4282
          (void) tee_fprintf(file, _("ERROR %d (%s): "), error, sqlstate);
4104
4283
        else
4105
 
          (void) tee_fprintf(file, "ERROR %d: ", error);
 
4284
          (void) tee_fprintf(file, _("ERROR %d: "), error);
4106
4285
      }
4107
4286
      else
4108
 
        tee_puts("ERROR: ", file);
 
4287
        tee_puts(_("ERROR: "), file);
4109
4288
    }
4110
4289
    else
4111
4290
      vidattr(A_BOLD);
4134
4313
 
4135
4314
  return put_info(error, INFO_ERROR,
4136
4315
                  res == NULL ? drizzle_con_error_code(local_con) :
4137
 
                  drizzle_result_error_code(res),
 
4316
                                drizzle_result_error_code(res),
4138
4317
                  res == NULL ? drizzle_con_sqlstate(local_con) :
4139
 
                  drizzle_result_sqlstate(res));
 
4318
                                drizzle_result_sqlstate(res));
4140
4319
}
4141
4320
 
4142
4321
 
4144
4323
{
4145
4324
  const char *start=  buffer->c_str();
4146
4325
  const char *end= start + (buffer->length());
4147
 
  while (start < end && !my_isgraph(charset_info,end[-1]))
 
4326
  while (start < end && !isgraph(end[-1]))
4148
4327
    end--;
4149
4328
  uint32_t pos_to_truncate= (end-start);
4150
4329
  if (buffer->length() > pos_to_truncate)
4209
4388
 
4210
4389
 
4211
4390
/**
4212
 
  Write as many as 52+1 bytes to buff, in the form of a legible
4213
 
  duration of time.
 
4391
   Write as many as 52+1 bytes to buff, in the form of a legible
 
4392
   duration of time.
4214
4393
 
4215
 
  len("4294967296 days, 23 hours, 59 minutes, 60.00 seconds")  ->  52
 
4394
   len("4294967296 days, 23 hours, 59 minutes, 60.00 seconds")  ->  52
4216
4395
*/
4217
4396
static void nice_time(double sec,char *buff,bool part_second)
4218
4397
{
4238
4417
    tmp_buff_str << tmp;
4239
4418
 
4240
4419
    if (tmp > 1)
4241
 
      tmp_buff_str << " hours ";
 
4420
      tmp_buff_str << _(" hours ");
4242
4421
    else
4243
 
      tmp_buff_str << " hour ";
 
4422
      tmp_buff_str << _(" hour ");
4244
4423
  }
4245
4424
  if (sec >= 60.0)
4246
4425
  {
4247
4426
    tmp=(uint32_t) floor(sec/60.0);
4248
4427
    sec-=60.0*tmp;
4249
 
    tmp_buff_str << tmp << " min ";
 
4428
    tmp_buff_str << tmp << _(" min ");
4250
4429
  }
4251
4430
  if (part_second)
4252
4431
    tmp_buff_str.precision(2);
4253
4432
  else
4254
4433
    tmp_buff_str.precision(0);
4255
 
  tmp_buff_str << sec << " sec";
 
4434
  tmp_buff_str << sec << _(" sec");
4256
4435
  strcpy(buff, tmp_buff_str.str().c_str());
4257
4436
}
4258
4437
 
4283
4462
  struct tm *t = localtime(&lclock);
4284
4463
 
4285
4464
  /* parse thru the settings for the prompt */
4286
 
  for (char *c= current_prompt; *c; (void)*c++)
 
4465
  string::iterator c= current_prompt.begin();
 
4466
  while (c != current_prompt.end())
4287
4467
  {
4288
4468
    if (*c != PROMPT_CHAR)
4289
4469
    {
4290
 
      processed_prompt->append(c, 1);
 
4470
      processed_prompt->push_back(*c);
4291
4471
    }
4292
4472
    else
4293
4473
    {
4298
4478
      switch (*++c) {
4299
4479
      case '\0':
4300
4480
        // stop it from going beyond if ends with %
4301
 
        c--;
 
4481
        --c;
4302
4482
        break;
4303
4483
      case 'c':
4304
4484
        add_int_to_prompt(++prompt_counter);
4310
4490
          processed_prompt->append("not_connected");
4311
4491
        break;
4312
4492
      case 'd':
4313
 
        processed_prompt->append(current_db ? current_db : "(none)");
 
4493
        processed_prompt->append(not current_db.empty() ? current_db : "(none)");
4314
4494
        break;
4315
4495
      case 'h':
4316
 
        {
4317
 
          const char *prompt;
4318
 
          prompt= connected ? drizzle_con_host(&con) : "not_connected";
4319
 
          if (strstr(prompt, "Localhost"))
4320
 
            processed_prompt->append("localhost");
4321
 
          else
4322
 
          {
4323
 
            const char *end=strrchr(prompt,' ');
4324
 
            if (end != NULL)
4325
 
              processed_prompt->append(prompt, (end-prompt));
4326
 
          }
 
4496
      {
 
4497
        const char *prompt= connected ? drizzle_con_host(&con) : "not_connected";
 
4498
        if (strstr(prompt, "Localhost"))
 
4499
          processed_prompt->append("localhost");
 
4500
        else
 
4501
        {
 
4502
          const char *end=strrchr(prompt,' ');
 
4503
          if (end != NULL)
 
4504
            processed_prompt->append(prompt, (end-prompt));
 
4505
        }
 
4506
        break;
 
4507
      }
 
4508
      case 'p':
 
4509
      {
 
4510
        if (!connected)
 
4511
        {
 
4512
          processed_prompt->append("not_connected");
4327
4513
          break;
4328
4514
        }
4329
 
      case 'p':
 
4515
 
 
4516
        if (drizzle_con_uds(&con))
4330
4517
        {
4331
 
          if (!connected)
4332
 
          {
4333
 
            processed_prompt->append("not_connected");
4334
 
            break;
4335
 
          }
4336
 
 
4337
 
          if (drizzle_con_uds(&con))
4338
 
          {
4339
 
            const char *pos=strrchr(drizzle_con_uds(&con),'/');
4340
 
            processed_prompt->append(pos ? pos+1 : drizzle_con_uds(&con));
4341
 
          }
4342
 
          else
4343
 
            add_int_to_prompt(drizzle_con_port(&con));
 
4518
          const char *pos=strrchr(drizzle_con_uds(&con),'/');
 
4519
          processed_prompt->append(pos ? pos+1 : drizzle_con_uds(&con));
4344
4520
        }
4345
 
        break;
 
4521
        else
 
4522
          add_int_to_prompt(drizzle_con_port(&con));
 
4523
      }
 
4524
      break;
4346
4525
      case 'U':
4347
4526
        if (!full_username)
4348
4527
          init_username();
4349
4528
        processed_prompt->append(full_username ? full_username :
4350
 
                                 (current_user ?  current_user : "(unknown)"));
 
4529
                                 (!current_user.empty() ?  current_user : "(unknown)"));
4351
4530
        break;
4352
4531
      case 'u':
4353
4532
        if (!full_username)
4354
4533
          init_username();
4355
4534
        processed_prompt->append(part_username ? part_username :
4356
 
                                 (current_user ?  current_user : "(unknown)"));
 
4535
                                 (!current_user.empty() ?  current_user : _("(unknown)")));
4357
4536
        break;
4358
4537
      case PROMPT_CHAR:
4359
4538
        {
4435
4614
        processed_prompt->append(delimiter_str);
4436
4615
        break;
4437
4616
      default:
4438
 
        processed_prompt->append(c, 1);
 
4617
        processed_prompt->push_back(*c);
4439
4618
      }
4440
4619
    }
 
4620
    ++c;
4441
4621
  }
4442
4622
  return processed_prompt->c_str();
4443
4623
}
4452
4632
 
4453
4633
static void init_username()
4454
4634
{
4455
 
  /* XXX need this?
4456
 
    free(full_username);
4457
 
    free(part_username);
 
4635
/* XXX need this?
 
4636
  free(full_username);
 
4637
  free(part_username);
4458
4638
 
4459
 
    drizzle_result_st *result;
4460
 
    if (!drizzleclient_query(&drizzle,"select USER()") &&
4461
 
    (result=drizzleclient_use_result(&drizzle)))
4462
 
    {
 
4639
  drizzle_result_st *result;
 
4640
  if (!drizzleclient_query(&drizzle,"select USER()") &&
 
4641
      (result=drizzleclient_use_result(&drizzle)))
 
4642
  {
4463
4643
    drizzle_row_t cur=drizzleclient_fetch_row(result);
4464
4644
    full_username= strdup(cur[0]);
4465
4645
    part_username= strdup(strtok(cur[0],"@"));
4466
4646
    (void) drizzleclient_fetch_row(result);        // Read eof
4467
 
    }
4468
 
  */
 
4647
  }
 
4648
*/
4469
4649
}
4470
4650
 
4471
4651
static int com_prompt(string *, const char *line)
4472
4652
{
4473
4653
  const char *ptr=strchr(line, ' ');
4474
4654
  if (ptr == NULL)
4475
 
    tee_fprintf(stdout, "Returning to default PROMPT of %s\n",
 
4655
    tee_fprintf(stdout, _("Returning to default PROMPT of %s\n"),
4476
4656
                default_prompt);
4477
4657
  prompt_counter = 0;
4478
4658
  char * tmpptr= strdup(ptr ? ptr+1 : default_prompt);
4479
4659
  if (tmpptr == NULL)
4480
 
    tee_fprintf(stdout, "Memory allocation error. Not changing prompt\n");
 
4660
    tee_fprintf(stdout, _("Memory allocation error. Not changing prompt\n"));
4481
4661
  else
4482
4662
  {
4483
 
    free(current_prompt);
 
4663
    current_prompt.erase();
4484
4664
    current_prompt= tmpptr;
4485
 
    tee_fprintf(stdout, "PROMPT set to '%s'\n", current_prompt);
 
4665
    tee_fprintf(stdout, _("PROMPT set to '%s'\n"), current_prompt.c_str());
4486
4666
  }
4487
4667
  return 0;
4488
4668
}
4489
4669
 
4490
4670
/*
4491
 
  strcont(str, set) if str contanies any character in the string set.
4492
 
  The result is the position of the first found character in str, or NULL
4493
 
  if there isn't anything found.
 
4671
    strcont(str, set) if str contanies any character in the string set.
 
4672
    The result is the position of the first found character in str, or NULL
 
4673
    if there isn't anything found.
4494
4674
*/
4495
4675
 
4496
4676
static const char * strcont(register const char *str, register const char *set)