~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Brian Aker
  • Date: 2010-08-18 16:12:58 UTC
  • mto: This revision was merged to the branch mainline in revision 1720.
  • Revision ID: brian@tangent.org-20100818161258-1vm71da888dfvwsx
Remove the code surrounding stack trace.

Show diffs side-by-side

added added

removed removed

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