~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
 
4
 *  Copyright (C) 2010 Vijay Samuel
4
5
 *  Copyright (C) 2008 MySQL
5
6
 *
6
7
 *  This program is free software; you can redistribute it and/or modify
33
34
 *
34
35
 **/
35
36
 
36
 
#include "client_priv.h"
 
37
#include "config.h"
 
38
#include <libdrizzle/drizzle_client.h>
 
39
 
 
40
#include "client/get_password.h"
 
41
 
 
42
#if TIME_WITH_SYS_TIME
 
43
# include <sys/time.h>
 
44
# include <time.h>
 
45
#else
 
46
# if HAVE_SYS_TIME_H
 
47
#  include <sys/time.h>
 
48
# else
 
49
#  include <time.h>
 
50
# endif
 
51
#endif
 
52
 
 
53
#include <cerrno>
37
54
#include <string>
38
55
#include <drizzled/gettext.h>
39
56
#include <iostream>
 
57
#include <fstream>
40
58
#include <map>
41
59
#include <algorithm>
42
60
#include <limits.h>
43
61
#include <cassert>
44
 
#include "drizzled/charset_info.h"
45
62
#include <stdarg.h>
46
63
#include <math.h>
47
64
#include "client/linebuffer.h"
48
65
#include <signal.h>
49
66
#include <sys/ioctl.h>
50
67
#include <drizzled/configmake.h>
51
 
#include "drizzled/charset.h"
 
68
#include "drizzled/utf8/utf8.h"
 
69
#include <cstdlib>
52
70
 
53
71
#if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H)
54
72
#include <curses.h>
139
157
#undef vidattr
140
158
#define vidattr(A) {}      // Can't get this to work
141
159
#endif
 
160
#include <boost/program_options.hpp>
142
161
 
143
 
using namespace drizzled;
144
162
using namespace std;
 
163
namespace po=boost::program_options;
145
164
 
146
 
const string VER("14.14");
147
165
/* Don't try to make a nice table if the data is too big */
148
166
const uint32_t MAX_COLUMN_LENGTH= 1024;
149
167
 
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;
182
290
  opt_compress= false, opt_shutdown= false, opt_ping= false,
183
291
  vertical= false, line_numbers= true, column_names= true,
184
292
  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,
 
293
  opt_nobeep= false, opt_reconnect= true,
 
294
  opt_secure_auth= false,
187
295
  default_pager_set= false, opt_sigint_ignore= false,
188
296
  auto_vertical_output= false,
189
297
  show_warnings= false, executing_query= false, interrupted_query= false,
190
 
  opt_mysql= false;
191
 
static uint32_t  show_progress_size= 0;
 
298
  use_drizzle_protocol= 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,
 
324
  opt_protocol;
209
325
// TODO: Need to i18n these
210
326
static const char *day_names[]= {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
211
327
static const char *month_names[]= {"Jan","Feb","Mar","Apr","May","Jun","Jul",
212
328
                                  "Aug","Sep","Oct","Nov","Dec"};
213
 
static char default_pager[FN_REFLEN];
214
 
static char pager[FN_REFLEN], outfile[FN_REFLEN];
 
329
/* @TODO: Remove this */
 
330
#define FN_REFLEN 512
 
331
 
 
332
static string default_pager("");
 
333
static string pager("");
 
334
static string outfile("");
215
335
static FILE *PAGER, *OUTFILE;
216
336
static uint32_t prompt_counter;
217
 
static char delimiter[16]= DEFAULT_DELIMITER;
 
337
static char *delimiter= NULL;
218
338
static uint32_t delimiter_length= 1;
219
339
unsigned short terminal_width= 80;
220
340
 
221
 
static const CHARSET_INFO *charset_info= &my_charset_utf8_general_ci;
222
 
 
223
341
int drizzleclient_real_query_for_lazy(const char *buf, int length,
224
342
                                      drizzle_result_st *result,
225
343
                                      uint32_t *error_code);
232
350
void tee_putc(int c, FILE *file);
233
351
static void tee_print_sized_data(const char *, unsigned int, unsigned int, bool);
234
352
/* The names of functions that actually do the manipulation. */
235
 
static int get_options(int argc,char **argv);
 
353
static int process_options(void);
236
354
static int com_quit(string *str,const char*),
237
355
  com_go(string *str,const char*), com_ego(string *str,const char*),
238
356
  com_print(string *str,const char*),
246
364
  com_nopager(string *str, const char*), com_pager(string *str, const char*);
247
365
 
248
366
static int read_and_execute(bool interactive);
249
 
static int sql_connect(char *host,char *database,char *user,char *password,
 
367
static int sql_connect(const string &host, const string &database, const string &user, const string &password,
250
368
                       uint32_t silent);
251
369
static const char *server_version_string(drizzle_con_st *con);
252
370
static int put_info(const char *str,INFO_TYPE info,uint32_t error,
265
383
static int get_field_disp_length(drizzle_column_st * field);
266
384
static const char * strcont(register const char *str, register const char *set);
267
385
 
268
 
/* A structure which contains information on the commands this program
 
386
/* A class which contains information on the commands this program
269
387
   can understand. */
270
 
typedef struct {
 
388
class Commands
 
389
{
 
390
private:
271
391
  const char *name;        /* User printable name of the function. */
272
392
  char cmd_char;        /* msql command character */
273
 
  int (*func)(string *str,const char *); /* Function to call to do the job. */
 
393
public:
 
394
Commands(const char *in_name,
 
395
         char in_cmd_char,
 
396
         int (*in_func)(string *str,const char *name),
 
397
         bool in_takes_params,
 
398
         const char *in_doc)
 
399
  :
 
400
  name(in_name),
 
401
  cmd_char(in_cmd_char),
 
402
  func(in_func),
 
403
  takes_params(in_takes_params),
 
404
  doc(in_doc)
 
405
  {}
 
406
 
 
407
  Commands()
 
408
  :
 
409
  name(),
 
410
  cmd_char(),
 
411
  func(NULL),
 
412
  takes_params(false),
 
413
  doc()
 
414
  {}
 
415
 
 
416
  int (*func)(string *str,const char *);/* Function to call to do the job. */
 
417
 
 
418
  const char *getName() const
 
419
  {
 
420
    return name;
 
421
  }
 
422
 
 
423
  char getCmdChar() const
 
424
  {
 
425
    return cmd_char;
 
426
  }
 
427
 
 
428
  bool getTakesParams() const
 
429
  {
 
430
    return takes_params;
 
431
  }
 
432
 
 
433
  const char *getDoc() const
 
434
  {
 
435
    return doc;
 
436
  }
 
437
 
 
438
  void setName(const char *in_name)
 
439
  {
 
440
     name= in_name;
 
441
  }
 
442
 
 
443
  void setCmdChar(char in_cmd_char)
 
444
  {
 
445
    cmd_char= in_cmd_char;
 
446
  }
 
447
 
 
448
  void setTakesParams(bool in_takes_params)
 
449
  {
 
450
    takes_params= in_takes_params;
 
451
  }
 
452
 
 
453
  void setDoc(const char *in_doc)
 
454
  {
 
455
    doc= in_doc;
 
456
  }
 
457
 
 
458
private:
274
459
  bool takes_params;        /* Max parameters for command */
275
460
  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.") },
 
461
}; 
 
462
 
 
463
 
 
464
static Commands commands[] = {
 
465
  Commands( "?",      '?', com_help,   0, N_("Synonym for `help'.") ),
 
466
  Commands( "clear",  'c', com_clear,  0, N_("Clear command.")),
 
467
  Commands( "connect",'r', com_connect,1,
 
468
    N_("Reconnect to the server. Optional arguments are db and host.")),
 
469
  Commands( "delimiter", 'd', com_delimiter,    1,
 
470
    N_("Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.") ),
 
471
  Commands( "ego",    'G', com_ego,    0,
 
472
    N_("Send command to drizzle server, display result vertically.")),
 
473
  Commands( "exit",   'q', com_quit,   0, N_("Exit drizzle. Same as quit.")),
 
474
  Commands( "go",     'g', com_go,     0, N_("Send command to drizzle server.") ),
 
475
  Commands( "help",   'h', com_help,   0, N_("Display this help.") ),
 
476
  Commands( "nopager",'n', com_nopager,0, N_("Disable pager, print to stdout.") ),
 
477
  Commands( "notee",  't', com_notee,  0, N_("Don't write into outfile.") ),
 
478
  Commands( "pager",  'P', com_pager,  1,
 
479
    N_("Set PAGER [to_pager]. Print the query results via PAGER.") ),
 
480
  Commands( "print",  'p', com_print,  0, N_("Print current command.") ),
 
481
  Commands( "prompt", 'R', com_prompt, 1, N_("Change your drizzle prompt.")),
 
482
  Commands( "quit",   'q', com_quit,   0, N_("Quit drizzle.") ),
 
483
  Commands( "rehash", '#', com_rehash, 0, N_("Rebuild completion hash.") ),
 
484
  Commands( "source", '.', com_source, 1,
 
485
    N_("Execute an SQL script file. Takes a file name as an argument.")),
 
486
  Commands( "status", 's', com_status, 0, N_("Get status information from the server.")),
 
487
  Commands( "tee",    'T', com_tee,    1,
 
488
    N_("Set outfile [to_outfile]. Append everything into given outfile.") ),
 
489
  Commands( "use",    'u', com_use,    1,
 
490
    N_("Use another database. Takes database name as argument.") ),
 
491
  Commands( "warnings", 'W', com_warnings,  0,
 
492
    N_("Show warnings after every statement.") ),
 
493
  Commands( "nowarning", 'w', com_nowarnings, 0,
 
494
    N_("Don't show warnings after every statement.") ),
310
495
  /* 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, ""},
 
496
  Commands( "create table",     0, 0, 0, ""),
 
497
  Commands( "create database",  0, 0, 0, ""),
 
498
  Commands( "show databases",   0, 0, 0, ""),
 
499
  Commands( "show fields from", 0, 0, 0, ""),
 
500
  Commands( "show keys from",   0, 0, 0, ""),
 
501
  Commands( "show tables",      0, 0, 0, ""),
 
502
  Commands( "load data from",   0, 0, 0, ""),
 
503
  Commands( "alter table",      0, 0, 0, ""),
 
504
  Commands( "set option",       0, 0, 0, ""),
 
505
  Commands( "lock tables",      0, 0, 0, ""),
 
506
  Commands( "unlock tables",    0, 0, 0, ""),
322
507
  /* 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, ""},
 
508
  Commands( "ACTION", 0, 0, 0, ""),
 
509
  Commands( "ADD", 0, 0, 0, ""),
 
510
  Commands( "AFTER", 0, 0, 0, ""),
 
511
  Commands( "AGAINST", 0, 0, 0, ""),
 
512
  Commands( "AGGREGATE", 0, 0, 0, ""),
 
513
  Commands( "ALL", 0, 0, 0, ""),
 
514
  Commands( "ALGORITHM", 0, 0, 0, ""),
 
515
  Commands( "ALTER", 0, 0, 0, ""),
 
516
  Commands( "ANALYZE", 0, 0, 0, ""),
 
517
  Commands( "AND", 0, 0, 0, ""),
 
518
  Commands( "ANY", 0, 0, 0, ""),
 
519
  Commands( "AS", 0, 0, 0, ""),
 
520
  Commands( "ASC", 0, 0, 0, ""),
 
521
  Commands( "ASCII", 0, 0, 0, ""),
 
522
  Commands( "ASENSITIVE", 0, 0, 0, ""),
 
523
  Commands( "AUTO_INCREMENT", 0, 0, 0, ""),
 
524
  Commands( "AVG", 0, 0, 0, ""),
 
525
  Commands( "AVG_ROW_LENGTH", 0, 0, 0, ""),
 
526
  Commands( "BEFORE", 0, 0, 0, ""),
 
527
  Commands( "BEGIN", 0, 0, 0, ""),
 
528
  Commands( "BETWEEN", 0, 0, 0, ""),
 
529
  Commands( "BIGINT", 0, 0, 0, ""),
 
530
  Commands( "BINARY", 0, 0, 0, ""),
 
531
  Commands( "BIT", 0, 0, 0, ""),
 
532
  Commands( "BLOB", 0, 0, 0, ""),
 
533
  Commands( "BOOL", 0, 0, 0, ""),
 
534
  Commands( "BOOLEAN", 0, 0, 0, ""),
 
535
  Commands( "BOTH", 0, 0, 0, ""),
 
536
  Commands( "BTREE", 0, 0, 0, ""),
 
537
  Commands( "BY", 0, 0, 0, ""),
 
538
  Commands( "BYTE", 0, 0, 0, ""),
 
539
  Commands( "CACHE", 0, 0, 0, ""),
 
540
  Commands( "CALL", 0, 0, 0, ""),
 
541
  Commands( "CASCADE", 0, 0, 0, ""),
 
542
  Commands( "CASCADED", 0, 0, 0, ""),
 
543
  Commands( "CASE", 0, 0, 0, ""),
 
544
  Commands( "CHAIN", 0, 0, 0, ""),
 
545
  Commands( "CHANGE", 0, 0, 0, ""),
 
546
  Commands( "CHANGED", 0, 0, 0, ""),
 
547
  Commands( "CHAR", 0, 0, 0, ""),
 
548
  Commands( "CHARACTER", 0, 0, 0, ""),
 
549
  Commands( "CHECK", 0, 0, 0, ""),
 
550
  Commands( "CHECKSUM", 0, 0, 0, ""),
 
551
  Commands( "CLIENT", 0, 0, 0, ""),
 
552
  Commands( "CLOSE", 0, 0, 0, ""),
 
553
  Commands( "COLLATE", 0, 0, 0, ""),
 
554
  Commands( "COLLATION", 0, 0, 0, ""),
 
555
  Commands( "COLUMN", 0, 0, 0, ""),
 
556
  Commands( "COLUMNS", 0, 0, 0, ""),
 
557
  Commands( "COMMENT", 0, 0, 0, ""),
 
558
  Commands( "COMMIT", 0, 0, 0, ""),
 
559
  Commands( "COMMITTED", 0, 0, 0, ""),
 
560
  Commands( "COMPACT", 0, 0, 0, ""),
 
561
  Commands( "COMPRESSED", 0, 0, 0, ""),
 
562
  Commands( "CONCURRENT", 0, 0, 0, ""),
 
563
  Commands( "CONDITION", 0, 0, 0, ""),
 
564
  Commands( "CONNECTION", 0, 0, 0, ""),
 
565
  Commands( "CONSISTENT", 0, 0, 0, ""),
 
566
  Commands( "CONSTRAINT", 0, 0, 0, ""),
 
567
  Commands( "CONTAINS", 0, 0, 0, ""),
 
568
  Commands( "CONTINUE", 0, 0, 0, ""),
 
569
  Commands( "CONVERT", 0, 0, 0, ""),
 
570
  Commands( "CREATE", 0, 0, 0, ""),
 
571
  Commands( "CROSS", 0, 0, 0, ""),
 
572
  Commands( "CUBE", 0, 0, 0, ""),
 
573
  Commands( "CURRENT_DATE", 0, 0, 0, ""),
 
574
  Commands( "CURRENT_TIMESTAMP", 0, 0, 0, ""),
 
575
  Commands( "CURRENT_USER", 0, 0, 0, ""),
 
576
  Commands( "CURSOR", 0, 0, 0, ""),
 
577
  Commands( "DATA", 0, 0, 0, ""),
 
578
  Commands( "DATABASE", 0, 0, 0, ""),
 
579
  Commands( "DATABASES", 0, 0, 0, ""),
 
580
  Commands( "DATE", 0, 0, 0, ""),
 
581
  Commands( "DATETIME", 0, 0, 0, ""),
 
582
  Commands( "DAY", 0, 0, 0, ""),
 
583
  Commands( "DAY_HOUR", 0, 0, 0, ""),
 
584
  Commands( "DAY_MICROSECOND", 0, 0, 0, ""),
 
585
  Commands( "DAY_MINUTE", 0, 0, 0, ""),
 
586
  Commands( "DAY_SECOND", 0, 0, 0, ""),
 
587
  Commands( "DEALLOCATE", 0, 0, 0, ""),
 
588
  Commands( "DEC", 0, 0, 0, ""),
 
589
  Commands( "DECIMAL", 0, 0, 0, ""),
 
590
  Commands( "DECLARE", 0, 0, 0, ""),
 
591
  Commands( "DEFAULT", 0, 0, 0, ""),
 
592
  Commands( "DEFINER", 0, 0, 0, ""),
 
593
  Commands( "DELAYED", 0, 0, 0, ""),
 
594
  Commands( "DELETE", 0, 0, 0, ""),
 
595
  Commands( "DESC", 0, 0, 0, ""),
 
596
  Commands( "DESCRIBE", 0, 0, 0, ""),
 
597
  Commands( "DETERMINISTIC", 0, 0, 0, ""),
 
598
  Commands( "DISABLE", 0, 0, 0, ""),
 
599
  Commands( "DISCARD", 0, 0, 0, ""),
 
600
  Commands( "DISTINCT", 0, 0, 0, ""),
 
601
  Commands( "DISTINCTROW", 0, 0, 0, ""),
 
602
  Commands( "DIV", 0, 0, 0, ""),
 
603
  Commands( "DOUBLE", 0, 0, 0, ""),
 
604
  Commands( "DROP", 0, 0, 0, ""),
 
605
  Commands( "DUMPFILE", 0, 0, 0, ""),
 
606
  Commands( "DUPLICATE", 0, 0, 0, ""),
 
607
  Commands( "DYNAMIC", 0, 0, 0, ""),
 
608
  Commands( "EACH", 0, 0, 0, ""),
 
609
  Commands( "ELSE", 0, 0, 0, ""),
 
610
  Commands( "ELSEIF", 0, 0, 0, ""),
 
611
  Commands( "ENABLE", 0, 0, 0, ""),
 
612
  Commands( "ENCLOSED", 0, 0, 0, ""),
 
613
  Commands( "END", 0, 0, 0, ""),
 
614
  Commands( "ENGINE", 0, 0, 0, ""),
 
615
  Commands( "ENGINES", 0, 0, 0, ""),
 
616
  Commands( "ENUM", 0, 0, 0, ""),
 
617
  Commands( "ERRORS", 0, 0, 0, ""),
 
618
  Commands( "ESCAPE", 0, 0, 0, ""),
 
619
  Commands( "ESCAPED", 0, 0, 0, ""),
 
620
  Commands( "EXISTS", 0, 0, 0, ""),
 
621
  Commands( "EXIT", 0, 0, 0, ""),
 
622
  Commands( "EXPLAIN", 0, 0, 0, ""),
 
623
  Commands( "EXTENDED", 0, 0, 0, ""),
 
624
  Commands( "FALSE", 0, 0, 0, ""),
 
625
  Commands( "FAST", 0, 0, 0, ""),
 
626
  Commands( "FETCH", 0, 0, 0, ""),
 
627
  Commands( "FIELDS", 0, 0, 0, ""),
 
628
  Commands( "FILE", 0, 0, 0, ""),
 
629
  Commands( "FIRST", 0, 0, 0, ""),
 
630
  Commands( "FIXED", 0, 0, 0, ""),
 
631
  Commands( "FLOAT", 0, 0, 0, ""),
 
632
  Commands( "FLOAT4", 0, 0, 0, ""),
 
633
  Commands( "FLOAT8", 0, 0, 0, ""),
 
634
  Commands( "FLUSH", 0, 0, 0, ""),
 
635
  Commands( "FOR", 0, 0, 0, ""),
 
636
  Commands( "FORCE", 0, 0, 0, ""),
 
637
  Commands( "FOREIGN", 0, 0, 0, ""),
 
638
  Commands( "FOUND", 0, 0, 0, ""),
 
639
  Commands( "FRAC_SECOND", 0, 0, 0, ""),
 
640
  Commands( "FROM", 0, 0, 0, ""),
 
641
  Commands( "FULL", 0, 0, 0, ""),
 
642
  Commands( "FUNCTION", 0, 0, 0, ""),
 
643
  Commands( "GLOBAL", 0, 0, 0, ""),
 
644
  Commands( "GRANT", 0, 0, 0, ""),
 
645
  Commands( "GRANTS", 0, 0, 0, ""),
 
646
  Commands( "GROUP", 0, 0, 0, ""),
 
647
  Commands( "HANDLER", 0, 0, 0, ""),
 
648
  Commands( "HASH", 0, 0, 0, ""),
 
649
  Commands( "HAVING", 0, 0, 0, ""),
 
650
  Commands( "HELP", 0, 0, 0, ""),
 
651
  Commands( "HIGH_PRIORITY", 0, 0, 0, ""),
 
652
  Commands( "HOSTS", 0, 0, 0, ""),
 
653
  Commands( "HOUR", 0, 0, 0, ""),
 
654
  Commands( "HOUR_MICROSECOND", 0, 0, 0, ""),
 
655
  Commands( "HOUR_MINUTE", 0, 0, 0, ""),
 
656
  Commands( "HOUR_SECOND", 0, 0, 0, ""),
 
657
  Commands( "IDENTIFIED", 0, 0, 0, ""),
 
658
  Commands( "IF", 0, 0, 0, ""),
 
659
  Commands( "IGNORE", 0, 0, 0, ""),
 
660
  Commands( "IMPORT", 0, 0, 0, ""),
 
661
  Commands( "IN", 0, 0, 0, ""),
 
662
  Commands( "INDEX", 0, 0, 0, ""),
 
663
  Commands( "INDEXES", 0, 0, 0, ""),
 
664
  Commands( "INFILE", 0, 0, 0, ""),
 
665
  Commands( "INNER", 0, 0, 0, ""),
 
666
  Commands( "INNOBASE", 0, 0, 0, ""),
 
667
  Commands( "INNODB", 0, 0, 0, ""),
 
668
  Commands( "INOUT", 0, 0, 0, ""),
 
669
  Commands( "INSENSITIVE", 0, 0, 0, ""),
 
670
  Commands( "INSERT", 0, 0, 0, ""),
 
671
  Commands( "INSERT_METHOD", 0, 0, 0, ""),
 
672
  Commands( "INT", 0, 0, 0, ""),
 
673
  Commands( "INT1", 0, 0, 0, ""),
 
674
  Commands( "INT2", 0, 0, 0, ""),
 
675
  Commands( "INT3", 0, 0, 0, ""),
 
676
  Commands( "INT4", 0, 0, 0, ""),
 
677
  Commands( "INT8", 0, 0, 0, ""),
 
678
  Commands( "INTEGER", 0, 0, 0, ""),
 
679
  Commands( "INTERVAL", 0, 0, 0, ""),
 
680
  Commands( "INTO", 0, 0, 0, ""),
 
681
  Commands( "IO_THREAD", 0, 0, 0, ""),
 
682
  Commands( "IS", 0, 0, 0, ""),
 
683
  Commands( "ISOLATION", 0, 0, 0, ""),
 
684
  Commands( "ISSUER", 0, 0, 0, ""),
 
685
  Commands( "ITERATE", 0, 0, 0, ""),
 
686
  Commands( "INVOKER", 0, 0, 0, ""),
 
687
  Commands( "JOIN", 0, 0, 0, ""),
 
688
  Commands( "KEY", 0, 0, 0, ""),
 
689
  Commands( "KEYS", 0, 0, 0, ""),
 
690
  Commands( "KILL", 0, 0, 0, ""),
 
691
  Commands( "LANGUAGE", 0, 0, 0, ""),
 
692
  Commands( "LAST", 0, 0, 0, ""),
 
693
  Commands( "LEADING", 0, 0, 0, ""),
 
694
  Commands( "LEAVE", 0, 0, 0, ""),
 
695
  Commands( "LEAVES", 0, 0, 0, ""),
 
696
  Commands( "LEFT", 0, 0, 0, ""),
 
697
  Commands( "LEVEL", 0, 0, 0, ""),
 
698
  Commands( "LIKE", 0, 0, 0, ""),
 
699
  Commands( "LIMIT", 0, 0, 0, ""),
 
700
  Commands( "LINES", 0, 0, 0, ""),
 
701
  Commands( "LINESTRING", 0, 0, 0, ""),
 
702
  Commands( "LOAD", 0, 0, 0, ""),
 
703
  Commands( "LOCAL", 0, 0, 0, ""),
 
704
  Commands( "LOCALTIMESTAMP", 0, 0, 0, ""),
 
705
  Commands( "LOCK", 0, 0, 0, ""),
 
706
  Commands( "LOCKS", 0, 0, 0, ""),
 
707
  Commands( "LOGS", 0, 0, 0, ""),
 
708
  Commands( "LONG", 0, 0, 0, ""),
 
709
  Commands( "LOOP", 0, 0, 0, ""),
 
710
  Commands( "MATCH", 0, 0, 0, ""),
 
711
  Commands( "MAX_CONNECTIONS_PER_HOUR", 0, 0, 0, ""),
 
712
  Commands( "MAX_QUERIES_PER_HOUR", 0, 0, 0, ""),
 
713
  Commands( "MAX_ROWS", 0, 0, 0, ""),
 
714
  Commands( "MAX_UPDATES_PER_HOUR", 0, 0, 0, ""),
 
715
  Commands( "MAX_USER_CONNECTIONS", 0, 0, 0, ""),
 
716
  Commands( "MEDIUM", 0, 0, 0, ""),
 
717
  Commands( "MERGE", 0, 0, 0, ""),
 
718
  Commands( "MICROSECOND", 0, 0, 0, ""),
 
719
  Commands( "MIGRATE", 0, 0, 0, ""),
 
720
  Commands( "MINUTE", 0, 0, 0, ""),
 
721
  Commands( "MINUTE_MICROSECOND", 0, 0, 0, ""),
 
722
  Commands( "MINUTE_SECOND", 0, 0, 0, ""),
 
723
  Commands( "MIN_ROWS", 0, 0, 0, ""),
 
724
  Commands( "MOD", 0, 0, 0, ""),
 
725
  Commands( "MODE", 0, 0, 0, ""),
 
726
  Commands( "MODIFIES", 0, 0, 0, ""),
 
727
  Commands( "MODIFY", 0, 0, 0, ""),
 
728
  Commands( "MONTH", 0, 0, 0, ""),
 
729
  Commands( "MULTILINESTRING", 0, 0, 0, ""),
 
730
  Commands( "MULTIPOINT", 0, 0, 0, ""),
 
731
  Commands( "MULTIPOLYGON", 0, 0, 0, ""),
 
732
  Commands( "MUTEX", 0, 0, 0, ""),
 
733
  Commands( "NAME", 0, 0, 0, ""),
 
734
  Commands( "NAMES", 0, 0, 0, ""),
 
735
  Commands( "NATIONAL", 0, 0, 0, ""),
 
736
  Commands( "NATURAL", 0, 0, 0, ""),
 
737
  Commands( "NCHAR", 0, 0, 0, ""),
 
738
  Commands( "NEW", 0, 0, 0, ""),
 
739
  Commands( "NEXT", 0, 0, 0, ""),
 
740
  Commands( "NO", 0, 0, 0, ""),
 
741
  Commands( "NONE", 0, 0, 0, ""),
 
742
  Commands( "NOT", 0, 0, 0, ""),
 
743
  Commands( "NULL", 0, 0, 0, ""),
 
744
  Commands( "NUMERIC", 0, 0, 0, ""),
 
745
  Commands( "NVARCHAR", 0, 0, 0, ""),
 
746
  Commands( "OFFSET", 0, 0, 0, ""),
 
747
  Commands( "ON", 0, 0, 0, ""),
 
748
  Commands( "ONE", 0, 0, 0, ""),
 
749
  Commands( "ONE_SHOT", 0, 0, 0, ""),
 
750
  Commands( "OPEN", 0, 0, 0, ""),
 
751
  Commands( "OPTIMIZE", 0, 0, 0, ""),
 
752
  Commands( "OPTION", 0, 0, 0, ""),
 
753
  Commands( "OPTIONALLY", 0, 0, 0, ""),
 
754
  Commands( "OR", 0, 0, 0, ""),
 
755
  Commands( "ORDER", 0, 0, 0, ""),
 
756
  Commands( "OUT", 0, 0, 0, ""),
 
757
  Commands( "OUTER", 0, 0, 0, ""),
 
758
  Commands( "OUTFILE", 0, 0, 0, ""),
 
759
  Commands( "PACK_KEYS", 0, 0, 0, ""),
 
760
  Commands( "PARTIAL", 0, 0, 0, ""),
 
761
  Commands( "PASSWORD", 0, 0, 0, ""),
 
762
  Commands( "PHASE", 0, 0, 0, ""),
 
763
  Commands( "PRECISION", 0, 0, 0, ""),
 
764
  Commands( "PREPARE", 0, 0, 0, ""),
 
765
  Commands( "PREV", 0, 0, 0, ""),
 
766
  Commands( "PRIMARY", 0, 0, 0, ""),
 
767
  Commands( "PRIVILEGES", 0, 0, 0, ""),
 
768
  Commands( "PROCEDURE", 0, 0, 0, ""),
 
769
  Commands( "PROCESS", 0, 0, 0, ""),
 
770
  Commands( "PROCESSLIST", 0, 0, 0, ""),
 
771
  Commands( "PURGE", 0, 0, 0, ""),
 
772
  Commands( "QUARTER", 0, 0, 0, ""),
 
773
  Commands( "QUERY", 0, 0, 0, ""),
 
774
  Commands( "QUICK", 0, 0, 0, ""),
 
775
  Commands( "READ", 0, 0, 0, ""),
 
776
  Commands( "READS", 0, 0, 0, ""),
 
777
  Commands( "REAL", 0, 0, 0, ""),
 
778
  Commands( "RECOVER", 0, 0, 0, ""),
 
779
  Commands( "REDUNDANT", 0, 0, 0, ""),
 
780
  Commands( "REFERENCES", 0, 0, 0, ""),
 
781
  Commands( "REGEXP", 0, 0, 0, ""),
 
782
  Commands( "RELEASE", 0, 0, 0, ""),
 
783
  Commands( "RELOAD", 0, 0, 0, ""),
 
784
  Commands( "RENAME", 0, 0, 0, ""),
 
785
  Commands( "REPAIR", 0, 0, 0, ""),
 
786
  Commands( "REPEATABLE", 0, 0, 0, ""),
 
787
  Commands( "REPLACE", 0, 0, 0, ""),
 
788
  Commands( "REPEAT", 0, 0, 0, ""),
 
789
  Commands( "REQUIRE", 0, 0, 0, ""),
 
790
  Commands( "RESET", 0, 0, 0, ""),
 
791
  Commands( "RESTORE", 0, 0, 0, ""),
 
792
  Commands( "RESTRICT", 0, 0, 0, ""),
 
793
  Commands( "RESUME", 0, 0, 0, ""),
 
794
  Commands( "RETURN", 0, 0, 0, ""),
 
795
  Commands( "RETURNS", 0, 0, 0, ""),
 
796
  Commands( "REVOKE", 0, 0, 0, ""),
 
797
  Commands( "RIGHT", 0, 0, 0, ""),
 
798
  Commands( "RLIKE", 0, 0, 0, ""),
 
799
  Commands( "ROLLBACK", 0, 0, 0, ""),
 
800
  Commands( "ROLLUP", 0, 0, 0, ""),
 
801
  Commands( "ROUTINE", 0, 0, 0, ""),
 
802
  Commands( "ROW", 0, 0, 0, ""),
 
803
  Commands( "ROWS", 0, 0, 0, ""),
 
804
  Commands( "ROW_FORMAT", 0, 0, 0, ""),
 
805
  Commands( "RTREE", 0, 0, 0, ""),
 
806
  Commands( "SAVEPOINT", 0, 0, 0, ""),
 
807
  Commands( "SCHEMA", 0, 0, 0, ""),
 
808
  Commands( "SCHEMAS", 0, 0, 0, ""),
 
809
  Commands( "SECOND", 0, 0, 0, ""),
 
810
  Commands( "SECOND_MICROSECOND", 0, 0, 0, ""),
 
811
  Commands( "SECURITY", 0, 0, 0, ""),
 
812
  Commands( "SELECT", 0, 0, 0, ""),
 
813
  Commands( "SENSITIVE", 0, 0, 0, ""),
 
814
  Commands( "SEPARATOR", 0, 0, 0, ""),
 
815
  Commands( "SERIAL", 0, 0, 0, ""),
 
816
  Commands( "SERIALIZABLE", 0, 0, 0, ""),
 
817
  Commands( "SESSION", 0, 0, 0, ""),
 
818
  Commands( "SET", 0, 0, 0, ""),
 
819
  Commands( "SHARE", 0, 0, 0, ""),
 
820
  Commands( "SHOW", 0, 0, 0, ""),
 
821
  Commands( "SHUTDOWN", 0, 0, 0, ""),
 
822
  Commands( "SIGNED", 0, 0, 0, ""),
 
823
  Commands( "SIMPLE", 0, 0, 0, ""),
 
824
  Commands( "SLAVE", 0, 0, 0, ""),
 
825
  Commands( "SNAPSHOT", 0, 0, 0, ""),
 
826
  Commands( "SOME", 0, 0, 0, ""),
 
827
  Commands( "SONAME", 0, 0, 0, ""),
 
828
  Commands( "SOUNDS", 0, 0, 0, ""),
 
829
  Commands( "SPATIAL", 0, 0, 0, ""),
 
830
  Commands( "SPECIFIC", 0, 0, 0, ""),
 
831
  Commands( "SQL", 0, 0, 0, ""),
 
832
  Commands( "SQLEXCEPTION", 0, 0, 0, ""),
 
833
  Commands( "SQLSTATE", 0, 0, 0, ""),
 
834
  Commands( "SQLWARNING", 0, 0, 0, ""),
 
835
  Commands( "SQL_BIG_RESULT", 0, 0, 0, ""),
 
836
  Commands( "SQL_BUFFER_RESULT", 0, 0, 0, ""),
 
837
  Commands( "SQL_CACHE", 0, 0, 0, ""),
 
838
  Commands( "SQL_CALC_FOUND_ROWS", 0, 0, 0, ""),
 
839
  Commands( "SQL_NO_CACHE", 0, 0, 0, ""),
 
840
  Commands( "SQL_SMALL_RESULT", 0, 0, 0, ""),
 
841
  Commands( "SQL_THREAD", 0, 0, 0, ""),
 
842
  Commands( "SQL_TSI_FRAC_SECOND", 0, 0, 0, ""),
 
843
  Commands( "SQL_TSI_SECOND", 0, 0, 0, ""),
 
844
  Commands( "SQL_TSI_MINUTE", 0, 0, 0, ""),
 
845
  Commands( "SQL_TSI_HOUR", 0, 0, 0, ""),
 
846
  Commands( "SQL_TSI_DAY", 0, 0, 0, ""),
 
847
  Commands( "SQL_TSI_WEEK", 0, 0, 0, ""),
 
848
  Commands( "SQL_TSI_MONTH", 0, 0, 0, ""),
 
849
  Commands( "SQL_TSI_QUARTER", 0, 0, 0, ""),
 
850
  Commands( "SQL_TSI_YEAR", 0, 0, 0, ""),
 
851
  Commands( "SSL", 0, 0, 0, ""),
 
852
  Commands( "START", 0, 0, 0, ""),
 
853
  Commands( "STARTING", 0, 0, 0, ""),
 
854
  Commands( "STATUS", 0, 0, 0, ""),
 
855
  Commands( "STOP", 0, 0, 0, ""),
 
856
  Commands( "STORAGE", 0, 0, 0, ""),
 
857
  Commands( "STRAIGHT_JOIN", 0, 0, 0, ""),
 
858
  Commands( "STRING", 0, 0, 0, ""),
 
859
  Commands( "STRIPED", 0, 0, 0, ""),
 
860
  Commands( "SUBJECT", 0, 0, 0, ""),
 
861
  Commands( "SUPER", 0, 0, 0, ""),
 
862
  Commands( "SUSPEND", 0, 0, 0, ""),
 
863
  Commands( "TABLE", 0, 0, 0, ""),
 
864
  Commands( "TABLES", 0, 0, 0, ""),
 
865
  Commands( "TABLESPACE", 0, 0, 0, ""),
 
866
  Commands( "TEMPORARY", 0, 0, 0, ""),
 
867
  Commands( "TEMPTABLE", 0, 0, 0, ""),
 
868
  Commands( "TERMINATED", 0, 0, 0, ""),
 
869
  Commands( "TEXT", 0, 0, 0, ""),
 
870
  Commands( "THEN", 0, 0, 0, ""),
 
871
  Commands( "TIMESTAMP", 0, 0, 0, ""),
 
872
  Commands( "TIMESTAMPADD", 0, 0, 0, ""),
 
873
  Commands( "TIMESTAMPDIFF", 0, 0, 0, ""),
 
874
  Commands( "TO", 0, 0, 0, ""),
 
875
  Commands( "TRAILING", 0, 0, 0, ""),
 
876
  Commands( "TRANSACTION", 0, 0, 0, ""),
 
877
  Commands( "TRUE", 0, 0, 0, ""),
 
878
  Commands( "TRUNCATE", 0, 0, 0, ""),
 
879
  Commands( "TYPE", 0, 0, 0, ""),
 
880
  Commands( "TYPES", 0, 0, 0, ""),
 
881
  Commands( "UNCOMMITTED", 0, 0, 0, ""),
 
882
  Commands( "UNDEFINED", 0, 0, 0, ""),
 
883
  Commands( "UNDO", 0, 0, 0, ""),
 
884
  Commands( "UNICODE", 0, 0, 0, ""),
 
885
  Commands( "UNION", 0, 0, 0, ""),
 
886
  Commands( "UNIQUE", 0, 0, 0, ""),
 
887
  Commands( "UNKNOWN", 0, 0, 0, ""),
 
888
  Commands( "UNLOCK", 0, 0, 0, ""),
 
889
  Commands( "UNTIL", 0, 0, 0, ""),
 
890
  Commands( "UPDATE", 0, 0, 0, ""),
 
891
  Commands( "UPGRADE", 0, 0, 0, ""),
 
892
  Commands( "USAGE", 0, 0, 0, ""),
 
893
  Commands( "USE", 0, 0, 0, ""),
 
894
  Commands( "USER", 0, 0, 0, ""),
 
895
  Commands( "USER_RESOURCES", 0, 0, 0, ""),
 
896
  Commands( "USING", 0, 0, 0, ""),
 
897
  Commands( "UTC_DATE", 0, 0, 0, ""),
 
898
  Commands( "UTC_TIMESTAMP", 0, 0, 0, ""),
 
899
  Commands( "VALUE", 0, 0, 0, ""),
 
900
  Commands( "VALUES", 0, 0, 0, ""),
 
901
  Commands( "VARBINARY", 0, 0, 0, ""),
 
902
  Commands( "VARCHAR", 0, 0, 0, ""),
 
903
  Commands( "VARCHARACTER", 0, 0, 0, ""),
 
904
  Commands( "VARIABLES", 0, 0, 0, ""),
 
905
  Commands( "VARYING", 0, 0, 0, ""),
 
906
  Commands( "WARNINGS", 0, 0, 0, ""),
 
907
  Commands( "WEEK", 0, 0, 0, ""),
 
908
  Commands( "WHEN", 0, 0, 0, ""),
 
909
  Commands( "WHERE", 0, 0, 0, ""),
 
910
  Commands( "WHILE", 0, 0, 0, ""),
 
911
  Commands( "VIEW", 0, 0, 0, ""),
 
912
  Commands( "WITH", 0, 0, 0, ""),
 
913
  Commands( "WORK", 0, 0, 0, ""),
 
914
  Commands( "WRITE", 0, 0, 0, ""),
 
915
  Commands( "XOR", 0, 0, 0, ""),
 
916
  Commands( "XA", 0, 0, 0, ""),
 
917
  Commands( "YEAR", 0, 0, 0, ""),
 
918
  Commands( "YEAR_MONTH", 0, 0, 0, ""),
 
919
  Commands( "ZEROFILL", 0, 0, 0, ""),
 
920
  Commands( "ABS", 0, 0, 0, ""),
 
921
  Commands( "ACOS", 0, 0, 0, ""),
 
922
  Commands( "ADDDATE", 0, 0, 0, ""),
 
923
  Commands( "AREA", 0, 0, 0, ""),
 
924
  Commands( "ASIN", 0, 0, 0, ""),
 
925
  Commands( "ASBINARY", 0, 0, 0, ""),
 
926
  Commands( "ASTEXT", 0, 0, 0, ""),
 
927
  Commands( "ATAN", 0, 0, 0, ""),
 
928
  Commands( "ATAN2", 0, 0, 0, ""),
 
929
  Commands( "BENCHMARK", 0, 0, 0, ""),
 
930
  Commands( "BIN", 0, 0, 0, ""),
 
931
  Commands( "BIT_OR", 0, 0, 0, ""),
 
932
  Commands( "BIT_AND", 0, 0, 0, ""),
 
933
  Commands( "BIT_XOR", 0, 0, 0, ""),
 
934
  Commands( "CAST", 0, 0, 0, ""),
 
935
  Commands( "CEIL", 0, 0, 0, ""),
 
936
  Commands( "CEILING", 0, 0, 0, ""),
 
937
  Commands( "CENTROID", 0, 0, 0, ""),
 
938
  Commands( "CHAR_LENGTH", 0, 0, 0, ""),
 
939
  Commands( "CHARACTER_LENGTH", 0, 0, 0, ""),
 
940
  Commands( "COALESCE", 0, 0, 0, ""),
 
941
  Commands( "COERCIBILITY", 0, 0, 0, ""),
 
942
  Commands( "COMPRESS", 0, 0, 0, ""),
 
943
  Commands( "CONCAT", 0, 0, 0, ""),
 
944
  Commands( "CONCAT_WS", 0, 0, 0, ""),
 
945
  Commands( "CONNECTION_ID", 0, 0, 0, ""),
 
946
  Commands( "CONV", 0, 0, 0, ""),
 
947
  Commands( "CONVERT_TZ", 0, 0, 0, ""),
 
948
  Commands( "COUNT", 0, 0, 0, ""),
 
949
  Commands( "COS", 0, 0, 0, ""),
 
950
  Commands( "COT", 0, 0, 0, ""),
 
951
  Commands( "CRC32", 0, 0, 0, ""),
 
952
  Commands( "CROSSES", 0, 0, 0, ""),
 
953
  Commands( "CURDATE", 0, 0, 0, ""),
 
954
  Commands( "DATE_ADD", 0, 0, 0, ""),
 
955
  Commands( "DATEDIFF", 0, 0, 0, ""),
 
956
  Commands( "DATE_FORMAT", 0, 0, 0, ""),
 
957
  Commands( "DATE_SUB", 0, 0, 0, ""),
 
958
  Commands( "DAYNAME", 0, 0, 0, ""),
 
959
  Commands( "DAYOFMONTH", 0, 0, 0, ""),
 
960
  Commands( "DAYOFWEEK", 0, 0, 0, ""),
 
961
  Commands( "DAYOFYEAR", 0, 0, 0, ""),
 
962
  Commands( "DECODE", 0, 0, 0, ""),
 
963
  Commands( "DEGREES", 0, 0, 0, ""),
 
964
  Commands( "DES_ENCRYPT", 0, 0, 0, ""),
 
965
  Commands( "DES_DECRYPT", 0, 0, 0, ""),
 
966
  Commands( "DIMENSION", 0, 0, 0, ""),
 
967
  Commands( "DISJOINT", 0, 0, 0, ""),
 
968
  Commands( "ELT", 0, 0, 0, ""),
 
969
  Commands( "ENCODE", 0, 0, 0, ""),
 
970
  Commands( "ENCRYPT", 0, 0, 0, ""),
 
971
  Commands( "ENDPOINT", 0, 0, 0, ""),
 
972
  Commands( "ENVELOPE", 0, 0, 0, ""),
 
973
  Commands( "EQUALS", 0, 0, 0, ""),
 
974
  Commands( "EXTERIORRING", 0, 0, 0, ""),
 
975
  Commands( "EXTRACT", 0, 0, 0, ""),
 
976
  Commands( "EXP", 0, 0, 0, ""),
 
977
  Commands( "EXPORT_SET", 0, 0, 0, ""),
 
978
  Commands( "FIELD", 0, 0, 0, ""),
 
979
  Commands( "FIND_IN_SET", 0, 0, 0, ""),
 
980
  Commands( "FLOOR", 0, 0, 0, ""),
 
981
  Commands( "FORMAT", 0, 0, 0, ""),
 
982
  Commands( "FOUND_ROWS", 0, 0, 0, ""),
 
983
  Commands( "FROM_DAYS", 0, 0, 0, ""),
 
984
  Commands( "FROM_UNIXTIME", 0, 0, 0, ""),
 
985
  Commands( "GET_LOCK", 0, 0, 0, ""),
 
986
  Commands( "GLENGTH", 0, 0, 0, ""),
 
987
  Commands( "GREATEST", 0, 0, 0, ""),
 
988
  Commands( "GROUP_CONCAT", 0, 0, 0, ""),
 
989
  Commands( "GROUP_UNIQUE_USERS", 0, 0, 0, ""),
 
990
  Commands( "HEX", 0, 0, 0, ""),
 
991
  Commands( "IFNULL", 0, 0, 0, ""),
 
992
  Commands( "INSTR", 0, 0, 0, ""),
 
993
  Commands( "INTERIORRINGN", 0, 0, 0, ""),
 
994
  Commands( "INTERSECTS", 0, 0, 0, ""),
 
995
  Commands( "ISCLOSED", 0, 0, 0, ""),
 
996
  Commands( "ISEMPTY", 0, 0, 0, ""),
 
997
  Commands( "ISNULL", 0, 0, 0, ""),
 
998
  Commands( "IS_FREE_LOCK", 0, 0, 0, ""),
 
999
  Commands( "IS_USED_LOCK", 0, 0, 0, ""),
 
1000
  Commands( "LAST_INSERT_ID", 0, 0, 0, ""),
 
1001
  Commands( "ISSIMPLE", 0, 0, 0, ""),
 
1002
  Commands( "LAST_DAY", 0, 0, 0, ""),
 
1003
  Commands( "LCASE", 0, 0, 0, ""),
 
1004
  Commands( "LEAST", 0, 0, 0, ""),
 
1005
  Commands( "LENGTH", 0, 0, 0, ""),
 
1006
  Commands( "LN", 0, 0, 0, ""),
 
1007
  Commands( "LOAD_FILE", 0, 0, 0, ""),
 
1008
  Commands( "LOCATE", 0, 0, 0, ""),
 
1009
  Commands( "LOG", 0, 0, 0, ""),
 
1010
  Commands( "LOG2", 0, 0, 0, ""),
 
1011
  Commands( "LOG10", 0, 0, 0, ""),
 
1012
  Commands( "LOWER", 0, 0, 0, ""),
 
1013
  Commands( "LPAD", 0, 0, 0, ""),
 
1014
  Commands( "LTRIM", 0, 0, 0, ""),
 
1015
  Commands( "MAKE_SET", 0, 0, 0, ""),
 
1016
  Commands( "MAKEDATE", 0, 0, 0, ""),
 
1017
  Commands( "MASTER_POS_WAIT", 0, 0, 0, ""),
 
1018
  Commands( "MAX", 0, 0, 0, ""),
 
1019
  Commands( "MBRCONTAINS", 0, 0, 0, ""),
 
1020
  Commands( "MBRDISJOINT", 0, 0, 0, ""),
 
1021
  Commands( "MBREQUAL", 0, 0, 0, ""),
 
1022
  Commands( "MBRINTERSECTS", 0, 0, 0, ""),
 
1023
  Commands( "MBROVERLAPS", 0, 0, 0, ""),
 
1024
  Commands( "MBRTOUCHES", 0, 0, 0, ""),
 
1025
  Commands( "MBRWITHIN", 0, 0, 0, ""),
 
1026
  Commands( "MD5", 0, 0, 0, ""),
 
1027
  Commands( "MID", 0, 0, 0, ""),
 
1028
  Commands( "MIN", 0, 0, 0, ""),
 
1029
  Commands( "MONTHNAME", 0, 0, 0, ""),
 
1030
  Commands( "NAME_CONST", 0, 0, 0, ""),
 
1031
  Commands( "NOW", 0, 0, 0, ""),
 
1032
  Commands( "NULLIF", 0, 0, 0, ""),
 
1033
  Commands( "NUMPOINTS", 0, 0, 0, ""),
 
1034
  Commands( "OCTET_LENGTH", 0, 0, 0, ""),
 
1035
  Commands( "OCT", 0, 0, 0, ""),
 
1036
  Commands( "ORD", 0, 0, 0, ""),
 
1037
  Commands( "OVERLAPS", 0, 0, 0, ""),
 
1038
  Commands( "PERIOD_ADD", 0, 0, 0, ""),
 
1039
  Commands( "PERIOD_DIFF", 0, 0, 0, ""),
 
1040
  Commands( "PI", 0, 0, 0, ""),
 
1041
  Commands( "POINTN", 0, 0, 0, ""),
 
1042
  Commands( "POSITION", 0, 0, 0, ""),
 
1043
  Commands( "POW", 0, 0, 0, ""),
 
1044
  Commands( "POWER", 0, 0, 0, ""),
 
1045
  Commands( "QUOTE", 0, 0, 0, ""),
 
1046
  Commands( "RADIANS", 0, 0, 0, ""),
 
1047
  Commands( "RAND", 0, 0, 0, ""),
 
1048
  Commands( "RELEASE_LOCK", 0, 0, 0, ""),
 
1049
  Commands( "REVERSE", 0, 0, 0, ""),
 
1050
  Commands( "ROUND", 0, 0, 0, ""),
 
1051
  Commands( "ROW_COUNT", 0, 0, 0, ""),
 
1052
  Commands( "RPAD", 0, 0, 0, ""),
 
1053
  Commands( "RTRIM", 0, 0, 0, ""),
 
1054
  Commands( "SESSION_USER", 0, 0, 0, ""),
 
1055
  Commands( "SUBDATE", 0, 0, 0, ""),
 
1056
  Commands( "SIGN", 0, 0, 0, ""),
 
1057
  Commands( "SIN", 0, 0, 0, ""),
 
1058
  Commands( "SHA", 0, 0, 0, ""),
 
1059
  Commands( "SHA1", 0, 0, 0, ""),
 
1060
  Commands( "SLEEP", 0, 0, 0, ""),
 
1061
  Commands( "SOUNDEX", 0, 0, 0, ""),
 
1062
  Commands( "SPACE", 0, 0, 0, ""),
 
1063
  Commands( "SQRT", 0, 0, 0, ""),
 
1064
  Commands( "SRID", 0, 0, 0, ""),
 
1065
  Commands( "STARTPOINT", 0, 0, 0, ""),
 
1066
  Commands( "STD", 0, 0, 0, ""),
 
1067
  Commands( "STDDEV", 0, 0, 0, ""),
 
1068
  Commands( "STDDEV_POP", 0, 0, 0, ""),
 
1069
  Commands( "STDDEV_SAMP", 0, 0, 0, ""),
 
1070
  Commands( "STR_TO_DATE", 0, 0, 0, ""),
 
1071
  Commands( "STRCMP", 0, 0, 0, ""),
 
1072
  Commands( "SUBSTR", 0, 0, 0, ""),
 
1073
  Commands( "SUBSTRING", 0, 0, 0, ""),
 
1074
  Commands( "SUBSTRING_INDEX", 0, 0, 0, ""),
 
1075
  Commands( "SUM", 0, 0, 0, ""),
 
1076
  Commands( "SYSDATE", 0, 0, 0, ""),
 
1077
  Commands( "SYSTEM_USER", 0, 0, 0, ""),
 
1078
  Commands( "TAN", 0, 0, 0, ""),
 
1079
  Commands( "TIME_FORMAT", 0, 0, 0, ""),
 
1080
  Commands( "TO_DAYS", 0, 0, 0, ""),
 
1081
  Commands( "TOUCHES", 0, 0, 0, ""),
 
1082
  Commands( "TRIM", 0, 0, 0, ""),
 
1083
  Commands( "UCASE", 0, 0, 0, ""),
 
1084
  Commands( "UNCOMPRESS", 0, 0, 0, ""),
 
1085
  Commands( "UNCOMPRESSED_LENGTH", 0, 0, 0, ""),
 
1086
  Commands( "UNHEX", 0, 0, 0, ""),
 
1087
  Commands( "UNIQUE_USERS", 0, 0, 0, ""),
 
1088
  Commands( "UNIX_TIMESTAMP", 0, 0, 0, ""),
 
1089
  Commands( "UPPER", 0, 0, 0, ""),
 
1090
  Commands( "UUID", 0, 0, 0, ""),
 
1091
  Commands( "VARIANCE", 0, 0, 0, ""),
 
1092
  Commands( "VAR_POP", 0, 0, 0, ""),
 
1093
  Commands( "VAR_SAMP", 0, 0, 0, ""),
 
1094
  Commands( "VERSION", 0, 0, 0, ""),
 
1095
  Commands( "WEEKDAY", 0, 0, 0, ""),
 
1096
  Commands( "WEEKOFYEAR", 0, 0, 0, ""),
 
1097
  Commands( "WITHIN", 0, 0, 0, ""),
 
1098
  Commands( "X", 0, 0, 0, ""),
 
1099
  Commands( "Y", 0, 0, 0, ""),
 
1100
  Commands( "YEARWEEK", 0, 0, 0, ""),
997
1101
  /* end sentinel */
998
 
  { (char *)NULL,       0, 0, 0, ""}
 
1102
  Commands((char *)NULL,       0, 0, 0, "")
999
1103
};
1000
1104
 
1001
 
static const char *load_default_groups[]= { "drizzle","client",0 };
1002
1105
 
1003
1106
int history_length;
1004
1107
static int not_in_history(const char *line);
1005
1108
static void initialize_readline (char *name);
1006
1109
static void fix_history(string *final_command);
1007
1110
 
1008
 
static COMMANDS *find_command(const char *name,char cmd_name);
 
1111
static Commands *find_command(const char *name,char cmd_name);
1009
1112
static bool add_line(string *buffer,char *line,char *in_string,
1010
1113
                     bool *ml_comment);
1011
1114
static void remove_cntrl(string *buffer);
1038
1141
 
1039
1142
  if (verbose)
1040
1143
  {
1041
 
    printf("shutting down drizzled");
 
1144
    printf(_("shutting down drizzled"));
1042
1145
    if (opt_drizzle_port > 0)
1043
 
      printf(" on port %d", opt_drizzle_port);
 
1146
      printf(_(" on port %d"), opt_drizzle_port);
1044
1147
    printf("... ");
1045
1148
  }
1046
1149
 
1049
1152
  {
1050
1153
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
1051
1154
    {
1052
 
      fprintf(stderr, "shutdown failed; error: '%s'",
 
1155
      fprintf(stderr, _("shutdown failed; error: '%s'"),
1053
1156
              drizzle_result_error(&result));
1054
1157
      drizzle_result_free(&result);
1055
1158
    }
1056
1159
    else
1057
1160
    {
1058
 
      fprintf(stderr, "shutdown failed; error: '%s'",
 
1161
      fprintf(stderr, _("shutdown failed; error: '%s'"),
1059
1162
              drizzle_con_error(&con));
1060
1163
    }
1061
1164
    return false;
1064
1167
  drizzle_result_free(&result);
1065
1168
 
1066
1169
  if (verbose)
1067
 
    printf("done\n");
 
1170
    printf(_("done\n"));
1068
1171
 
1069
1172
  return true;
1070
1173
}
1085
1188
  if (drizzle_ping(&con, &result, &ret) != NULL && ret == DRIZZLE_RETURN_OK)
1086
1189
  {
1087
1190
    if (opt_silent < 2)
1088
 
      printf("drizzled is alive\n");
 
1191
      printf(_("drizzled is alive\n"));
1089
1192
  }
1090
1193
  else
1091
1194
  {
1092
1195
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
1093
1196
    {
1094
 
      fprintf(stderr, "ping failed; error: '%s'",
 
1197
      fprintf(stderr, _("ping failed; error: '%s'"),
1095
1198
              drizzle_result_error(&result));
1096
1199
      drizzle_result_free(&result);
1097
1200
    }
1098
1201
    else
1099
1202
    {
1100
 
      fprintf(stderr, "drizzled won't answer to ping, error: '%s'",
 
1203
      fprintf(stderr, _("drizzled won't answer to ping, error: '%s'"),
1101
1204
              drizzle_con_error(&con));
1102
1205
    }
1103
1206
    return false;
1141
1244
  return executed;
1142
1245
}
1143
1246
 
 
1247
static void check_timeout_value(uint32_t in_connect_timeout)
 
1248
{
 
1249
  opt_connect_timeout= 0;
 
1250
  if (in_connect_timeout > 3600*12)
 
1251
  {
 
1252
    cout << _("Error: Invalid Value for connect_timeout"); 
 
1253
    exit(-1);
 
1254
  }
 
1255
  opt_connect_timeout= in_connect_timeout;
 
1256
}
 
1257
 
 
1258
static void check_max_input_line(uint32_t in_max_input_line)
 
1259
{
 
1260
  opt_max_input_line= 0;
 
1261
  if (in_max_input_line < 4096 || in_max_input_line > (int64_t)2*1024L*1024L*1024L)
 
1262
  {
 
1263
    cout << _("Error: Invalid Value for max_input_line");
 
1264
    exit(-1);
 
1265
  }
 
1266
  opt_max_input_line= in_max_input_line - (in_max_input_line % 1024);
 
1267
}
 
1268
 
1144
1269
int main(int argc,char *argv[])
1145
1270
{
 
1271
try
 
1272
{
 
1273
 
1146
1274
#if defined(ENABLE_NLS)
1147
1275
# if defined(HAVE_LOCALE_H)
1148
1276
  setlocale(LC_ALL, "");
1151
1279
  textdomain("drizzle");
1152
1280
#endif
1153
1281
 
1154
 
  MY_INIT(argv[0]);
1155
 
  delimiter_str= delimiter;
 
1282
  po::options_description commandline_options(N_("Options used only in command line"));
 
1283
  commandline_options.add_options()
 
1284
  ("help,?",N_("Displays this help and exit."))
 
1285
  ("batch,B",N_("Don't use history file. Disable interactive behavior. (Enables --silent)"))
 
1286
  ("column-type-info", po::value<bool>(&column_types_flag)->default_value(false)->zero_tokens(),
 
1287
  N_("Display column type information."))
 
1288
  ("comments,c", po::value<bool>(&preserve_comments)->default_value(false)->zero_tokens(),
 
1289
  N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"))
 
1290
  ("compress,C", po::value<bool>(&opt_compress)->default_value(false)->zero_tokens(),
 
1291
  N_("Use compression in server/client protocol."))  
 
1292
  ("vertical,E", po::value<bool>(&vertical)->default_value(false)->zero_tokens(),
 
1293
  N_("Print the output of a query (rows) vertically."))
 
1294
  ("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
 
1295
  N_("Continue even if we get an sql error."))
 
1296
  ("named-commands,G", po::value<bool>(&named_cmds)->default_value(false)->zero_tokens(),
 
1297
  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."))
 
1298
  ("no-beep,b", po::value<bool>(&opt_nobeep)->default_value(false)->zero_tokens(),
 
1299
  N_("Turn off beep on error."))
 
1300
  ("disable-line-numbers", N_("Do not write line numbers for errors."))
 
1301
  ("disable-column-names", N_("Do not write column names in results."))
 
1302
  ("skip-column-names,N", 
 
1303
  N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."))
 
1304
  ("set-variable,O", po::value<string>(),
 
1305
  N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."))
 
1306
  ("table,t", po::value<bool>(&output_tables)->default_value(false)->zero_tokens(),
 
1307
  N_("Output in table format.")) 
 
1308
  ("safe-updates,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
 
1309
  N_("Only allow UPDATE and DELETE that uses keys."))
 
1310
  ("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
 
1311
  N_("Synonym for option --safe-updates, -U."))
 
1312
  ("verbose,v", po::value<string>(&opt_verbose)->default_value(""),
 
1313
  N_("-v vvv implies that verbose= 3, Used to specify verbose"))
 
1314
  ("version,V", N_("Output version information and exit."))
 
1315
  ("secure-auth", po::value<bool>(&opt_secure_auth)->default_value(false)->zero_tokens(),
 
1316
  N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"))
 
1317
  ("show-warnings", po::value<bool>(&show_warnings)->default_value(false)->zero_tokens(),
 
1318
  N_("Show warnings after every statement."))
 
1319
  ("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(0),
 
1320
  N_("Number of lines before each import progress report."))
 
1321
  ("ping", po::value<bool>(&opt_ping)->default_value(false)->zero_tokens(),
 
1322
  N_("Ping the server to check if it's alive."))
 
1323
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
 
1324
  N_("Configuration file defaults are not used if no-defaults is set"))
 
1325
  ;
 
1326
 
 
1327
  po::options_description drizzle_options(N_("Options specific to the drizzle client"));
 
1328
  drizzle_options.add_options()
 
1329
  ("disable-auto-rehash",
 
1330
  N_("Disable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time."))
 
1331
  ("auto-vertical-output", po::value<bool>(&auto_vertical_output)->default_value(false)->zero_tokens(),
 
1332
  N_("Automatically switch to vertical output mode if the result is wider than the terminal width."))
 
1333
  ("database,D", po::value<string>(&current_db)->default_value(""),
 
1334
  N_("Database to use."))
 
1335
  ("default-character-set",po::value<string>(),
 
1336
  N_("(not used)"))
 
1337
  ("delimiter", po::value<string>(&delimiter_str)->default_value(";"),
 
1338
  N_("Delimiter to be used."))
 
1339
  ("execute,e", po::value<string>(),
 
1340
  N_("Execute command and quit. (Disables --force and history file)"))
 
1341
  ("local-infile", po::value<bool>(&opt_local_infile)->default_value(false)->zero_tokens(),
 
1342
  N_("Enable LOAD DATA LOCAL INFILE."))
 
1343
  ("unbuffered,n", po::value<bool>(&unbuffered)->default_value(false)->zero_tokens(),
 
1344
  N_("Flush buffer after each query."))
 
1345
  ("sigint-ignore", po::value<bool>(&opt_sigint_ignore)->default_value(false)->zero_tokens(),
 
1346
  N_("Ignore SIGINT (CTRL-C)"))
 
1347
  ("one-database,o", po::value<bool>(&one_database)->default_value(false)->zero_tokens(),
 
1348
  N_("Only update the default database. This is useful for skipping updates to other database in the update log."))
 
1349
  ("pager", po::value<string>(),
 
1350
  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."))
 
1351
  ("disable-pager", po::value<bool>(&opt_nopager)->default_value(false)->zero_tokens(),
 
1352
  N_("Disable pager and print to stdout. See interactive help (\\h) also."))
 
1353
  ("prompt", po::value<string>(&current_prompt)->default_value(""),  
 
1354
  N_("Set the drizzle prompt to this value."))
 
1355
  ("quick,q", po::value<bool>(&quick)->default_value(false)->zero_tokens(),
 
1356
  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."))
 
1357
  ("raw,r", po::value<bool>(&opt_raw_data)->default_value(false)->zero_tokens(),
 
1358
  N_("Write fields without conversion. Used with --batch.")) 
 
1359
  ("disable-reconnect", N_("Do not reconnect if the connection is lost."))
 
1360
  ("shutdown", po::value<bool>(&opt_shutdown)->default_value(false)->zero_tokens(),
 
1361
  N_("Shutdown the server"))
 
1362
  ("silent,s", N_("Be more silent. Print results with a tab as separator, each row on new line."))
 
1363
  ("tee", po::value<string>(),
 
1364
  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."))
 
1365
  ("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(), 
 
1366
  N_("Disable outfile. See interactive help (\\h) also."))
 
1367
  ("connect_timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value),
 
1368
  N_("Number of seconds before connection timeout."))
 
1369
  ("max_input_line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line),
 
1370
  N_("Max length of input line"))
 
1371
  ("select_limit", po::value<uint32_t>(&select_limit)->default_value(1000L),
 
1372
  N_("Automatic limit for SELECT when using --safe-updates"))
 
1373
  ("max_join_size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
 
1374
  N_("Automatic limit for rows in a join when using --safe-updates"))
 
1375
  ;
 
1376
 
 
1377
  po::options_description client_options(N_("Options specific to the client"));
 
1378
  client_options.add_options()
 
1379
  ("host,h", po::value<string>(&current_host)->default_value("localhost"),
 
1380
  N_("Connect to host"))
 
1381
  ("password,P", po::value<string>(&current_password)->default_value(PASSWORD_SENTINEL),
 
1382
  N_("Password to use when connecting to server. If password is not given it's asked from the tty."))
 
1383
  ("port,p", po::value<uint32_t>()->default_value(0),
 
1384
  N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
 
1385
  ("user,u", po::value<string>(&current_user)->default_value(""),
 
1386
  N_("User for login if not current user."))
 
1387
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
 
1388
  N_("The protocol of connection (mysql or drizzle)."))
 
1389
  ;
 
1390
 
 
1391
  po::options_description long_options(N_("Allowed Options"));
 
1392
  long_options.add(commandline_options).add(drizzle_options).add(client_options);
 
1393
 
 
1394
  std::string system_config_dir_drizzle(SYSCONFDIR); 
 
1395
  system_config_dir_drizzle.append("/drizzle/drizzle.cnf");
 
1396
 
 
1397
  std::string system_config_dir_client(SYSCONFDIR); 
 
1398
  system_config_dir_client.append("/drizzle/client.cnf");
 
1399
 
 
1400
  std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
 
1401
  
 
1402
  po::variables_map vm;
 
1403
 
 
1404
  po::positional_options_description p;
 
1405
  p.add("database", 1);
 
1406
 
 
1407
  // Disable allow_guessing
 
1408
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
 
1409
 
 
1410
  po::store(po::command_line_parser(argc, argv).options(long_options).
 
1411
            style(style).positional(p).extra_parser(parse_password_arg).run(),
 
1412
            vm);
 
1413
 
 
1414
  if (! vm["no-defaults"].as<bool>())
 
1415
  {
 
1416
    std::string user_config_dir_drizzle(user_config_dir);
 
1417
    user_config_dir_drizzle.append("/drizzle/drizzle.cnf"); 
 
1418
 
 
1419
    std::string user_config_dir_client(user_config_dir);
 
1420
    user_config_dir_client.append("/drizzle/client.cnf");
 
1421
 
 
1422
    ifstream user_drizzle_ifs(user_config_dir_drizzle.c_str());
 
1423
    po::store(parse_config_file(user_drizzle_ifs, drizzle_options), vm);
 
1424
 
 
1425
    ifstream user_client_ifs(user_config_dir_client.c_str());
 
1426
    po::store(parse_config_file(user_client_ifs, client_options), vm);
 
1427
 
 
1428
    ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str());
 
1429
    store(parse_config_file(system_drizzle_ifs, drizzle_options), vm);
 
1430
 
 
1431
    ifstream system_client_ifs(system_config_dir_client.c_str());
 
1432
    po::store(parse_config_file(system_client_ifs, client_options), vm);
 
1433
  }
 
1434
 
 
1435
  po::notify(vm);
 
1436
 
1156
1437
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1157
1438
                         getenv("DRIZZLE_PS1") :
1158
1439
                         "drizzle> ");
1159
 
  
1160
1440
  if (default_prompt == NULL)
1161
1441
  {
1162
1442
    fprintf(stderr, _("Memory allocation error while constructing initial "
1164
1444
    exit(ENOMEM);
1165
1445
  }
1166
1446
  current_prompt= strdup(default_prompt);
1167
 
  if (current_prompt == NULL)
 
1447
  if (current_prompt.empty())
1168
1448
  {
1169
1449
    fprintf(stderr, _("Memory allocation error while constructing initial "
1170
1450
                      "prompt. Aborting.\n"));
1175
1455
 
1176
1456
  prompt_counter=0;
1177
1457
 
1178
 
  outfile[0]=0;      // no (default) outfile
1179
 
  strcpy(pager, "stdout");  // the default, if --pager wasn't given
 
1458
  outfile.clear();      // no (default) outfile
 
1459
  pager.assign("stdout");  // the default, if --pager wasn't given
1180
1460
  {
1181
 
    char *tmp=getenv("PAGER");
 
1461
    const char *tmp= getenv("PAGER");
1182
1462
    if (tmp && strlen(tmp))
1183
1463
    {
1184
1464
      default_pager_set= 1;
1185
 
      strcpy(default_pager, tmp);
 
1465
      default_pager.assign(tmp);
1186
1466
    }
1187
1467
  }
1188
 
  if (!isatty(0) || !isatty(1))
 
1468
  if (! isatty(0) || ! isatty(1))
1189
1469
  {
1190
 
    status.batch=1; opt_silent=1;
 
1470
    status.setBatch(1); opt_silent=1;
1191
1471
    ignore_errors=0;
1192
1472
  }
1193
1473
  else
1194
 
    status.add_to_history=1;
1195
 
  status.exit_status=1;
 
1474
    status.setAddToHistory(1);
 
1475
  status.setExitStatus(1);
1196
1476
 
1197
1477
  {
1198
1478
    /*
1208
1488
      close(stdout_fileno_copy);             /* Clean up dup(). */
1209
1489
  }
1210
1490
 
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();
 
1491
  /* Inverted Booleans */
 
1492
 
 
1493
  line_numbers= (vm.count("disable-line-numbers")) ? false : true;
 
1494
  column_names= (vm.count("disable-column-names")) ? false : true;
 
1495
  opt_rehash= (vm.count("disable-auto-rehash")) ? false : true;
 
1496
  opt_reconnect= (vm.count("disable-reconnect")) ? false : true;
 
1497
 
 
1498
  if (vm.count("delimiter"))
 
1499
  {
 
1500
    /* Check that delimiter does not contain a backslash */
 
1501
    if (! strstr(delimiter_str.c_str(), "\\"))
 
1502
    {
 
1503
      delimiter= (char *)delimiter_str.c_str();  
 
1504
    }
 
1505
    else
 
1506
    {
 
1507
      put_info(_("DELIMITER cannot contain a backslash character"),
 
1508
      INFO_ERROR,0,0);
 
1509
      exit(-1);
 
1510
    }
 
1511
   
 
1512
    delimiter_length= (uint32_t)strlen(delimiter);
 
1513
  }
 
1514
  if (vm.count("tee"))
 
1515
  { 
 
1516
    if (vm["tee"].as<string>().empty())
 
1517
    {
 
1518
      if (opt_outfile)
 
1519
        end_tee();
 
1520
    }
 
1521
    else
 
1522
      init_tee(vm["tee"].as<string>().c_str());
 
1523
  }
 
1524
  if (vm["disable-tee"].as<bool>() == true)
 
1525
  {
 
1526
    if (opt_outfile)
 
1527
      end_tee();
 
1528
  }
 
1529
  if (vm.count("pager"))
 
1530
  {
 
1531
    if (vm["pager"].as<string>().empty())
 
1532
      opt_nopager= 1;
 
1533
    else
 
1534
    {
 
1535
      opt_nopager= 0;
 
1536
      if (vm[pager].as<string>().length())
 
1537
      {
 
1538
        default_pager_set= 1;
 
1539
        pager.assign(vm["pager"].as<string>());
 
1540
        default_pager.assign(pager);
 
1541
      }
 
1542
      else if (default_pager_set)
 
1543
        pager.assign(default_pager);
 
1544
      else
 
1545
        opt_nopager= 1;
 
1546
    }
 
1547
  }
 
1548
  if (vm.count("disable-pager"))
 
1549
  {
 
1550
    opt_nopager= 1;
 
1551
  }
 
1552
 
 
1553
  if (vm.count("no-auto-rehash"))
 
1554
    opt_rehash= 0;
 
1555
 
 
1556
  if (vm.count("skip-column-names"))
 
1557
    column_names= 0;
 
1558
    
 
1559
  if (vm.count("execute"))
 
1560
  {  
 
1561
    status.setBatch(1);
 
1562
    status.setAddToHistory(1);
 
1563
    if (status.getLineBuff() == NULL)
 
1564
      status.setLineBuff(opt_max_input_line,NULL);
 
1565
    if (status.getLineBuff() == NULL)
 
1566
    {
 
1567
      exit(1);
 
1568
    }
 
1569
    status.getLineBuff()->addString(vm["execute"].as<string>().c_str());
 
1570
  }
 
1571
 
 
1572
  if (one_database)
 
1573
    skip_updates= true;
 
1574
 
 
1575
  if (vm.count("protocol"))
 
1576
  {
 
1577
    std::transform(opt_protocol.begin(), opt_protocol.end(), 
 
1578
      opt_protocol.begin(), ::tolower);
 
1579
 
 
1580
    if (not opt_protocol.compare("mysql"))
 
1581
      use_drizzle_protocol=false;
 
1582
    else if (not opt_protocol.compare("drizzle"))
 
1583
      use_drizzle_protocol=true;
 
1584
    else
 
1585
    {
 
1586
      cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
 
1587
      exit(-1);
 
1588
    }
 
1589
  }
 
1590
 
 
1591
  if (vm.count("port"))
 
1592
  {
 
1593
    opt_drizzle_port= vm["port"].as<uint32_t>();
 
1594
 
 
1595
    /* If the port number is > 65535 it is not a valid port
 
1596
       This also helps with potential data loss casting unsigned long to a
 
1597
       uint32_t. */
 
1598
    if (opt_drizzle_port > 65535)
 
1599
    {
 
1600
      printf(_("Error: Value of %" PRIu32 " supplied for port is not valid.\n"), opt_drizzle_port);
 
1601
      exit(-1);
 
1602
    }
 
1603
  }
 
1604
 
 
1605
  if (vm.count("password"))
 
1606
  {
 
1607
    if (!opt_password.empty())
 
1608
      opt_password.erase();
 
1609
    if (current_password == PASSWORD_SENTINEL)
 
1610
    {
 
1611
      opt_password= "";
 
1612
    }
 
1613
    else
 
1614
    {
 
1615
      opt_password= current_password;
 
1616
      tty_password= false;
 
1617
    }
 
1618
  }
 
1619
  else
 
1620
  {
 
1621
      tty_password= true;
 
1622
  }
 
1623
  
 
1624
 
 
1625
  if (!opt_verbose.empty())
 
1626
  {
 
1627
    verbose= opt_verbose.length();
 
1628
  }
 
1629
 
 
1630
  if (vm.count("batch"))
 
1631
  {
 
1632
    status.setBatch(1);
 
1633
    status.setAddToHistory(0);
 
1634
    if (opt_silent < 1)
 
1635
    {
 
1636
      opt_silent= 1;
 
1637
    }
 
1638
  }
 
1639
  if (vm.count("silent"))
 
1640
  {
 
1641
    opt_silent++;
 
1642
  }
 
1643
  
 
1644
  if (vm.count("help") || vm.count("version"))
 
1645
  {
 
1646
    printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
 
1647
           drizzle_version(), VERSION,
 
1648
           HOST_VENDOR, HOST_OS, HOST_CPU,
 
1649
           rl_library_version);
 
1650
    if (vm.count("version"))
 
1651
      exit(0);
 
1652
    printf(_("Copyright (C) 2008 Sun Microsystems\n"
 
1653
           "This software comes with ABSOLUTELY NO WARRANTY. "
 
1654
           "This is free software,\n"
 
1655
           "and you are welcome to modify and redistribute it "
 
1656
           "under the GPL license\n"));
 
1657
    printf(_("Usage: drizzle [OPTIONS] [database]\n"));
 
1658
    cout << long_options;
 
1659
    exit(0);
 
1660
  }
 
1661
 
 
1662
 
 
1663
  if (process_options())
 
1664
  {
1217
1665
    exit(1);
1218
1666
  }
1219
1667
 
1220
1668
  memset(&drizzle, 0, sizeof(drizzle));
1221
 
  if (sql_connect(current_host,current_db,current_user,opt_password,
1222
 
                  opt_silent))
 
1669
  if (sql_connect(current_host, current_db, current_user, opt_password,opt_silent))
1223
1670
  {
1224
1671
    quick= 1;          // Avoid history
1225
 
    status.exit_status= 1;
 
1672
    status.setExitStatus(1);
1226
1673
    drizzle_end(-1);
1227
1674
  }
1228
1675
 
1230
1677
  if (execute_commands(&command_error) != false)
1231
1678
  {
1232
1679
    /* we've executed a command so exit before we go into readline mode */
1233
 
    internal::free_defaults(defaults_argv);
1234
 
    internal::my_end();
1235
1680
    exit(command_error);
1236
1681
  }
1237
1682
 
1238
 
  if (status.batch && !status.line_buff)
 
1683
  if (status.getBatch() && !status.getLineBuff())
1239
1684
  {
1240
 
    status.line_buff= new(std::nothrow) LineBuffer(opt_max_input_line, stdin);
1241
 
    if (status.line_buff == NULL)
 
1685
    status.setLineBuff(opt_max_input_line, stdin);
 
1686
    if (status.getLineBuff() == NULL)
1242
1687
    {
1243
 
      internal::free_defaults(defaults_argv);
1244
 
      internal::my_end();
1245
1688
      exit(1);
1246
1689
    }
1247
1690
  }
1248
1691
 
1249
 
  if (!status.batch)
 
1692
  if (!status.getBatch())
1250
1693
    ignore_errors=1;        // Don't abort monitor
1251
1694
 
1252
1695
  if (opt_sigint_ignore)
1261
1704
  /* call the SIGWINCH handler to get the default term width */
1262
1705
  window_resize(0);
1263
1706
#endif
1264
 
 
1265
 
  put_info(_("Welcome to the Drizzle client..  Commands end with ; or \\g."),
1266
 
           INFO_INFO,0,0);
 
1707
  std::vector<char> output_buff;
 
1708
  output_buff.resize(512);
 
1709
 
 
1710
  snprintf(&output_buff[0], output_buff.size(), 
 
1711
           _("Welcome to the Drizzle client..  Commands end with %s or \\g."), 
 
1712
           delimiter);
 
1713
 
 
1714
  put_info(&output_buff[0], INFO_INFO, 0, 0);
1267
1715
 
1268
1716
  glob_buffer= new string();
1269
1717
  glob_buffer->reserve(512);
1270
1718
 
1271
 
  char * output_buff= (char *)malloc(512);
1272
 
  memset(output_buff, '\0', 512);
1273
 
 
1274
 
  sprintf(output_buff,
1275
 
          _("Your Drizzle connection id is %u\nServer version: %s\n"),
 
1719
  snprintf(&output_buff[0], output_buff.size(),
 
1720
          _("Your Drizzle connection id is %u\nConnection protocol: %s\nServer version: %s\n"),
1276
1721
          drizzle_con_thread_id(&con),
 
1722
          opt_protocol.c_str(),
1277
1723
          server_version_string(&con));
1278
 
  put_info(output_buff, INFO_INFO, 0, 0);
1279
 
 
1280
 
  initialize_readline(current_prompt);
1281
 
  if (!status.batch && !quick)
 
1724
  put_info(&output_buff[0], INFO_INFO, 0, 0);
 
1725
 
 
1726
 
 
1727
  initialize_readline((char *)current_prompt.c_str());
 
1728
  if (!status.getBatch() && !quick)
1282
1729
  {
1283
1730
    /* read-history from file, default ~/.drizzle_history*/
1284
1731
    if (getenv("DRIZZLE_HISTFILE"))
1317
1764
 
1318
1765
  put_info(_("Type 'help;' or '\\h' for help. "
1319
1766
             "Type '\\c' to clear the buffer.\n"),INFO_INFO,0,0);
1320
 
  status.exit_status= read_and_execute(!status.batch);
 
1767
  status.setExitStatus(read_and_execute(!status.getBatch()));
1321
1768
  if (opt_outfile)
1322
1769
    end_tee();
1323
1770
  drizzle_end(0);
 
1771
}
1324
1772
 
 
1773
  catch(exception &err)
 
1774
  {
 
1775
    cerr << _("Error:") << err.what() << endl;
 
1776
  }
1325
1777
  return(0);        // Keep compiler happy
1326
1778
}
1327
1779
 
1329
1781
{
1330
1782
  drizzle_con_free(&con);
1331
1783
  drizzle_free(&drizzle);
1332
 
  if (!status.batch && !quick && histfile)
 
1784
  if (!status.getBatch() && !quick && histfile)
1333
1785
  {
1334
1786
    /* write-history */
1335
1787
    if (verbose)
1336
1788
      tee_fprintf(stdout, _("Writing history-file %s\n"),histfile);
1337
1789
    if (!write_history(histfile_tmp))
1338
 
      internal::my_rename(histfile_tmp, histfile, MYF(MY_WME));
 
1790
      rename(histfile_tmp, histfile);
1339
1791
  }
1340
 
  delete status.line_buff;
1341
 
  status.line_buff= 0;
 
1792
  delete status.getLineBuff();
 
1793
  status.setLineBuff(0);
1342
1794
 
1343
1795
  if (sig >= 0)
1344
1796
    put_info(sig ? _("Aborted") : _("Bye"), INFO_RESULT,0,0);
1346
1798
    delete glob_buffer;
1347
1799
  if (processed_prompt)
1348
1800
    delete processed_prompt;
1349
 
  free(opt_password);
 
1801
  opt_password.erase();
1350
1802
  free(histfile);
1351
1803
  free(histfile_tmp);
1352
 
  free(current_db);
1353
 
  free(current_host);
1354
 
  free(current_user);
 
1804
  current_db.erase();
 
1805
  current_host.erase();
 
1806
  current_user.erase();
1355
1807
  free(full_username);
1356
1808
  free(part_username);
1357
1809
  free(default_prompt);
1358
 
  free(current_prompt);
1359
 
  internal::free_defaults(defaults_argv);
1360
 
  internal::my_end();
1361
 
  exit(status.exit_status);
 
1810
  current_prompt.erase();
 
1811
  exit(status.getExitStatus());
1362
1812
}
1363
1813
 
1364
1814
 
1380
1830
    goto err;
1381
1831
  }
1382
1832
 
1383
 
  if (drizzle_con_add_tcp(&drizzle, &kill_drizzle, current_host,
1384
 
                          opt_drizzle_port, current_user, opt_password, NULL,
1385
 
                          opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
 
1833
  if (drizzle_con_add_tcp(&drizzle, &kill_drizzle, current_host.c_str(),
 
1834
    opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL,
 
1835
    use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
1386
1836
  {
1387
1837
    goto err;
1388
1838
  }
1416
1866
}
1417
1867
#endif
1418
1868
 
1419
 
static struct my_option my_long_options[] =
1420
 
{
1421
 
  {"help", '?', N_("Display this help and exit."), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1422
 
   0, 0, 0, 0, 0},
1423
 
  {"help", 'I', N_("Synonym for -?"), 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
1424
 
   0, 0, 0, 0, 0},
1425
 
  {"auto-rehash", OPT_AUTO_REHASH,
1426
 
   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."),
1427
 
   (char**) &opt_rehash, (char**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
1428
 
   0, 0},
1429
 
  {"no-auto-rehash", 'A',
1430
 
   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."),
1431
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1432
 
  {"auto-vertical-output", OPT_AUTO_VERTICAL_OUTPUT,
1433
 
   N_("Automatically switch to vertical output mode if the result is wider than the terminal width."),
1434
 
   (char**) &auto_vertical_output, (char**) &auto_vertical_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1435
 
  {"batch", 'B',
1436
 
   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},
1437
 
  {"column-type-info", OPT_COLUMN_TYPES, N_("Display column type information."),
1438
 
   (char**) &column_types_flag, (char**) &column_types_flag,
1439
 
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1440
 
  {"comments", 'c', N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"),
1441
 
   (char**) &preserve_comments, (char**) &preserve_comments,
1442
 
   0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1443
 
  {"compress", 'C', N_("Use compression in server/client protocol."),
1444
 
   (char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1445
 
   0, 0, 0},
1446
 
  {"database", 'D', N_("Database to use."), (char**) &current_db,
1447
 
   (char**) &current_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1448
 
  {"default-character-set", OPT_DEFAULT_CHARSET,
1449
 
   N_("(not used)"), 0,
1450
 
   0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1451
 
  {"delimiter", OPT_DELIMITER, N_("Delimiter to be used."), (char**) &delimiter_str,
1452
 
   (char**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1453
 
  {"execute", 'e', N_("Execute command and quit. (Disables --force and history file)"), 0,
1454
 
   0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1455
 
  {"vertical", 'E', N_("Print the output of a query (rows) vertically."),
1456
 
   (char**) &vertical, (char**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
1457
 
   0},
1458
 
  {"force", 'f', N_("Continue even if we get an sql error."),
1459
 
   (char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0,
1460
 
   0, 0, 0, 0},
1461
 
  {"named-commands", 'G',
1462
 
   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."),
1463
 
   (char**) &named_cmds, (char**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
1464
 
   0, 0},
1465
 
  {"no-named-commands", 'g',
1466
 
   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."),
1467
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1468
 
  {"ignore-spaces", 'i', N_("Ignore space after function names."), 0, 0, 0,
1469
 
   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1470
 
  {"local-infile", OPT_LOCAL_INFILE, N_("Enable/disable LOAD DATA LOCAL INFILE."),
1471
 
   (char**) &opt_local_infile,
1472
 
   (char**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
1473
 
  {"no-beep", 'b', N_("Turn off beep on error."), (char**) &opt_nobeep,
1474
 
   (char**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1475
 
  {"host", 'h', N_("Connect to host."), (char**) &current_host,
1476
 
   (char**) &current_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1477
 
  {"line-numbers", OPT_LINE_NUMBERS, N_("Write line numbers for errors."),
1478
 
   (char**) &line_numbers, (char**) &line_numbers, 0, GET_BOOL,
1479
 
   NO_ARG, 1, 0, 0, 0, 0, 0},
1480
 
  {"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,
1481
 
   NO_ARG, 0, 0, 0, 0, 0, 0},
1482
 
  {"unbuffered", 'n', N_("Flush buffer after each query."), (char**) &unbuffered,
1483
 
   (char**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1484
 
  {"column-names", OPT_COLUMN_NAMES, N_("Write column names in results."),
1485
 
   (char**) &column_names, (char**) &column_names, 0, GET_BOOL,
1486
 
   NO_ARG, 1, 0, 0, 0, 0, 0},
1487
 
  {"skip-column-names", 'N',
1488
 
   N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."),
1489
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1490
 
  {"set-variable", 'O',
1491
 
   N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."),
1492
 
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1493
 
  {"sigint-ignore", OPT_SIGINT_IGNORE, N_("Ignore SIGINT (CTRL-C)"),
1494
 
   (char**) &opt_sigint_ignore,  (char**) &opt_sigint_ignore, 0, GET_BOOL,
1495
 
   NO_ARG, 0, 0, 0, 0, 0, 0},
1496
 
  {"one-database", 'o',
1497
 
   N_("Only update the default database. This is useful for skipping updates to other database in the update log."),
1498
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1499
 
  {"pager", OPT_PAGER,
1500
 
   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."),
1501
 
   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1502
 
  {"no-pager", OPT_NOPAGER,
1503
 
   N_("Disable pager and print to stdout. See interactive help (\\h) also. WARNING: option deprecated; use --disable-pager instead."),
1504
 
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1505
 
  {"password", 'P',
1506
 
   N_("Password to use when connecting to server. If password is not given it's asked from the tty."),
1507
 
   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
1508
 
  {"port", 'p', N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, ")
1509
 
   N_("built-in default") " (" STRINGIFY_ARG(DRIZZLE_PORT) ").",
1510
 
   0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1511
 
  {"prompt", OPT_PROMPT, N_("Set the drizzle prompt to this value."),
1512
 
   (char**) &current_prompt, (char**) &current_prompt, 0, GET_STR_ALLOC,
1513
 
   REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1514
 
  {"quick", 'q',
1515
 
   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."),
1516
 
   (char**) &quick, (char**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1517
 
  {"raw", 'r', N_("Write fields without conversion. Used with --batch."),
1518
 
   (char**) &opt_raw_data, (char**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0,
1519
 
   0, 0, 0},
1520
 
  {"reconnect", OPT_RECONNECT, N_("Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default."),
1521
 
   (char**) &opt_reconnect, (char**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
1522
 
  {"shutdown", OPT_SHUTDOWN, N_("Shutdown the server."),
1523
 
   (char**) &opt_shutdown, (char**) &opt_shutdown, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1524
 
  {"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,
1525
 
   0, 0},
1526
 
  {"table", 't', N_("Output in table format."), (char**) &output_tables,
1527
 
   (char**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1528
 
  {"tee", OPT_TEE,
1529
 
   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."),
1530
 
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1531
 
  {"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,
1532
 
   NO_ARG, 0, 0, 0, 0, 0, 0},
1533
 
  {"user", 'u', N_("User for login if not current user."), (char**) &current_user,
1534
 
   (char**) &current_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1535
 
  {"safe-updates", 'U', N_("Only allow UPDATE and DELETE that uses keys."),
1536
 
   (char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1537
 
   0, 0, 0, 0},
1538
 
  {"i-am-a-dummy", 'U', N_("Synonym for option --safe-updates, -U."),
1539
 
   (char**) &safe_updates, (char**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0,
1540
 
   0, 0, 0, 0},
1541
 
  {"verbose", 'v', N_("Write more. (-v -v -v gives the table output format)."), 0,
1542
 
   0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1543
 
  {"version", 'V', N_("Output version information and exit."), 0, 0, 0,
1544
 
   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
1545
 
  {"wait", 'w', N_("Wait and retry if connection is down."), 0, 0, 0, GET_NO_ARG,
1546
 
   NO_ARG, 0, 0, 0, 0, 0, 0},
1547
 
  {"connect_timeout", OPT_CONNECT_TIMEOUT,
1548
 
   N_("Number of seconds before connection timeout."),
1549
 
   (char**) &opt_connect_timeout,
1550
 
   (char**) &opt_connect_timeout, 0, GET_UINT32, REQUIRED_ARG, 0, 0, 3600*12, 0,
1551
 
   0, 0},
1552
 
  {"max_input_line", OPT_MAX_INPUT_LINE,
1553
 
   N_("Max length of input line"),
1554
 
   (char**) &opt_max_input_line, (char**) &opt_max_input_line, 0,
1555
 
   GET_UINT32, REQUIRED_ARG, 16 *1024L*1024L, 4096,
1556
 
   (int64_t) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
1557
 
  {"select_limit", OPT_SELECT_LIMIT,
1558
 
   N_("Automatic limit for SELECT when using --safe-updates"),
1559
 
   (char**) &select_limit,
1560
 
   (char**) &select_limit, 0, GET_UINT32, REQUIRED_ARG, 1000L, 1, ULONG_MAX,
1561
 
   0, 1, 0},
1562
 
  {"max_join_size", OPT_MAX_JOIN_SIZE,
1563
 
   N_("Automatic limit for rows in a join when using --safe-updates"),
1564
 
   (char**) &max_join_size,
1565
 
   (char**) &max_join_size, 0, GET_UINT32, REQUIRED_ARG, 1000000L, 1, ULONG_MAX,
1566
 
   0, 1, 0},
1567
 
  {"secure-auth", OPT_SECURE_AUTH, N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"), (char**) &opt_secure_auth,
1568
 
   (char**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1569
 
  {"show-warnings", OPT_SHOW_WARNINGS, N_("Show warnings after every statement."),
1570
 
   (char**) &show_warnings, (char**) &show_warnings, 0, GET_BOOL, NO_ARG,
1571
 
   0, 0, 0, 0, 0, 0},
1572
 
  {"show-progress-size", OPT_SHOW_PROGRESS_SIZE, N_("Number of lines before each import progress report."),
1573
 
   (char**) &show_progress_size, (char**) &show_progress_size, 0, GET_UINT32, REQUIRED_ARG,
1574
 
   0, 0, 0, 0, 0, 0},
1575
 
  {"ping", OPT_PING, N_("Ping the server to check if it's alive."),
1576
 
   (char**) &opt_ping, (char**) &opt_ping, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
1577
 
  {"mysql", 'm', N_("Use MySQL Protocol."),
1578
 
   (char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0,
1579
 
   0, 0, 0},
1580
 
  { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
1581
 
};
1582
 
 
1583
 
 
1584
 
static void usage(int version)
1585
 
{
1586
 
  const char* readline= "readline";
1587
 
 
1588
 
  printf(_("%s  Ver %s Distrib %s, for %s-%s (%s) using %s %s\n"),
1589
 
         internal::my_progname, VER.c_str(), drizzle_version(),
1590
 
         HOST_VENDOR, HOST_OS, HOST_CPU,
1591
 
         readline, rl_library_version);
1592
 
 
1593
 
  if (version)
1594
 
    return;
1595
 
  printf(_("Copyright (C) 2008 Sun Microsystems\n"
1596
 
           "This software comes with ABSOLUTELY NO WARRANTY. "
1597
 
           "This is free software,\n"
1598
 
           "and you are welcome to modify and redistribute it "
1599
 
           "under the GPL license\n"));
1600
 
  printf(_("Usage: %s [OPTIONS] [database]\n"), internal::my_progname);
1601
 
  my_print_help(my_long_options);
1602
 
  internal::print_defaults("drizzle", load_default_groups);
1603
 
  my_print_variables(my_long_options);
1604
 
}
1605
 
 
1606
 
 
1607
 
static bool get_one_option(int optid, const struct my_option *, char *argument)
1608
 
{
1609
 
  char *endchar= NULL;
1610
 
  uint64_t temp_drizzle_port= 0;
1611
 
 
1612
 
  switch(optid) {
1613
 
  case  OPT_DEFAULT_CHARSET:
1614
 
    default_charset_used= 1;
1615
 
    break;
1616
 
  case OPT_DELIMITER:
1617
 
    if (argument == disabled_my_option)
1618
 
    {
1619
 
      strcpy(delimiter, DEFAULT_DELIMITER);
1620
 
    }
1621
 
    else
1622
 
    {
1623
 
      /* Check that delimiter does not contain a backslash */
1624
 
      if (!strstr(argument, "\\"))
1625
 
      {
1626
 
        strncpy(delimiter, argument, sizeof(delimiter) - 1);
1627
 
      }
1628
 
      else
1629
 
      {
1630
 
        put_info(_("DELIMITER cannot contain a backslash character"),
1631
 
                 INFO_ERROR,0,0);
1632
 
        return false;
1633
 
      }
1634
 
    }
1635
 
    delimiter_length= (uint32_t)strlen(delimiter);
1636
 
    delimiter_str= delimiter;
1637
 
    break;
1638
 
  case OPT_TEE:
1639
 
    if (argument == disabled_my_option)
1640
 
    {
1641
 
      if (opt_outfile)
1642
 
        end_tee();
1643
 
    }
1644
 
    else
1645
 
      init_tee(argument);
1646
 
    break;
1647
 
  case OPT_NOTEE:
1648
 
    printf(_("WARNING: option deprecated; use --disable-tee instead.\n"));
1649
 
    if (opt_outfile)
1650
 
      end_tee();
1651
 
    break;
1652
 
  case OPT_PAGER:
1653
 
    if (argument == disabled_my_option)
1654
 
      opt_nopager= 1;
1655
 
    else
1656
 
    {
1657
 
      opt_nopager= 0;
1658
 
      if (argument && strlen(argument))
1659
 
      {
1660
 
        default_pager_set= 1;
1661
 
        strncpy(pager, argument, sizeof(pager) - 1);
1662
 
        strcpy(default_pager, pager);
1663
 
      }
1664
 
      else if (default_pager_set)
1665
 
        strcpy(pager, default_pager);
1666
 
      else
1667
 
        opt_nopager= 1;
1668
 
    }
1669
 
    break;
1670
 
  case OPT_NOPAGER:
1671
 
    printf(_("WARNING: option deprecated; use --disable-pager instead.\n"));
1672
 
    opt_nopager= 1;
1673
 
    break;
1674
 
  case OPT_SERVER_ARG:
1675
 
    printf(_("WARNING: --server-arg option not supported in this configuration.\n"));
1676
 
    break;
1677
 
  case 'A':
1678
 
    opt_rehash= 0;
1679
 
    break;
1680
 
  case 'N':
1681
 
    column_names= 0;
1682
 
    break;
1683
 
  case 'e':
1684
 
    status.batch= 1;
1685
 
    status.add_to_history= 0;
1686
 
    if (status.line_buff == NULL)
1687
 
      status.line_buff= new(std::nothrow) LineBuffer(opt_max_input_line,NULL);
1688
 
    if (status.line_buff == NULL)
1689
 
    {
1690
 
      internal::my_end();
1691
 
      exit(1);
1692
 
    }
1693
 
    status.line_buff->addString(argument);
1694
 
    break;
1695
 
  case 'o':
1696
 
    if (argument == disabled_my_option)
1697
 
      one_database= 0;
1698
 
    else
1699
 
      one_database= skip_updates= 1;
1700
 
    break;
1701
 
  case 'p':
1702
 
    temp_drizzle_port= (uint64_t) strtoul(argument, &endchar, 10);
1703
 
    /* if there is an alpha character this is not a valid port */
1704
 
    if (strlen(endchar) != 0)
1705
 
    {
1706
 
      put_info(_("Non-integer value supplied for port.  If you are trying to enter a password please use --password instead."), INFO_ERROR, 0, 0);
1707
 
      return false;
1708
 
    }
1709
 
    /* If the port number is > 65535 it is not a valid port
1710
 
       This also helps with potential data loss casting unsigned long to a
1711
 
       uint32_t. */
1712
 
    if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
1713
 
    {
1714
 
      put_info(_("Value supplied for port is not valid."), INFO_ERROR, 0, 0);
1715
 
      return false;
1716
 
    }
1717
 
    else
1718
 
    {
1719
 
      opt_drizzle_port= (uint32_t) temp_drizzle_port;
1720
 
    }
1721
 
    break;
1722
 
  case 'P':
1723
 
    /* Don't require password */
1724
 
    if (argument == disabled_my_option)
1725
 
    {
1726
 
      argument= (char*) "";
1727
 
    }
1728
 
    if (argument)
1729
 
    {
1730
 
      char *start= argument;
1731
 
      free(opt_password);
1732
 
      opt_password= strdup(argument);
1733
 
      while (*argument)
1734
 
      {
1735
 
        /* Overwriting password with 'x' */
1736
 
        *argument++= 'x';
1737
 
      }
1738
 
      if (*start)
1739
 
      {
1740
 
        start[1]= 0;
1741
 
      }
1742
 
      tty_password= 0;
1743
 
    }
1744
 
    else
1745
 
    {
1746
 
      tty_password= 1;
1747
 
    }
1748
 
    break;
1749
 
  case 's':
1750
 
    if (argument == disabled_my_option)
1751
 
      opt_silent= 0;
1752
 
    else
1753
 
      opt_silent++;
1754
 
    break;
1755
 
  case 'v':
1756
 
    if (argument == disabled_my_option)
1757
 
      verbose= 0;
1758
 
    else
1759
 
      verbose++;
1760
 
    break;
1761
 
  case 'B':
1762
 
    status.batch= 1;
1763
 
    status.add_to_history= 0;
1764
 
    set_if_bigger(opt_silent,1);                         // more silent
1765
 
    break;
1766
 
  case 'V':
1767
 
    usage(1);
1768
 
    exit(0);
1769
 
  case 'I':
1770
 
  case '?':
1771
 
    usage(0);
1772
 
    exit(0);
1773
 
  }
1774
 
  return 0;
1775
 
}
1776
 
 
1777
 
 
1778
 
static int get_options(int argc, char **argv)
 
1869
 
 
1870
 
 
1871
static int process_options(void)
1779
1872
{
1780
1873
  char *tmp, *pagpoint;
1781
 
  int ho_error;
 
1874
  
1782
1875
 
1783
1876
  tmp= (char *) getenv("DRIZZLE_HOST");
1784
1877
  if (tmp)
1785
 
    current_host= strdup(tmp);
 
1878
    current_host.assign(tmp);
1786
1879
 
1787
1880
  pagpoint= getenv("PAGER");
1788
1881
  if (!((char*) (pagpoint)))
1789
1882
  {
1790
 
    strcpy(pager, "stdout");
 
1883
    pager.assign("stdout");
1791
1884
    opt_nopager= 1;
1792
1885
  }
1793
1886
  else
1794
 
    strcpy(pager, pagpoint);
1795
 
  strcpy(default_pager, pager);
1796
 
 
1797
 
  if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
1798
 
    exit(ho_error);
1799
 
 
1800
 
  if (status.batch) /* disable pager and outfile in this case */
1801
 
  {
1802
 
    strcpy(default_pager, "stdout");
1803
 
    strcpy(pager, "stdout");
 
1887
  {
 
1888
    pager.assign(pagpoint);
 
1889
  }
 
1890
  default_pager.assign(pager);
 
1891
 
 
1892
  //
 
1893
 
 
1894
  if (status.getBatch()) /* disable pager and outfile in this case */
 
1895
  {
 
1896
    default_pager.assign("stdout");
 
1897
    pager.assign("stdout");
1804
1898
    opt_nopager= 1;
1805
1899
    default_pager_set= 0;
1806
1900
    opt_outfile= 0;
1808
1902
    connect_flag= DRIZZLE_CAPABILITIES_NONE; /* Not in interactive mode */
1809
1903
  }
1810
1904
 
1811
 
  if (argc > 1)
1812
 
  {
1813
 
    usage(0);
1814
 
    exit(1);
1815
 
  }
1816
 
  if (argc == 1)
1817
 
  {
1818
 
    skip_updates= 0;
1819
 
    free(current_db);
1820
 
    current_db= strdup(*argv);
1821
 
  }
1822
1905
  if (tty_password)
1823
1906
    opt_password= client_get_tty_password(NULL);
1824
 
 
1825
1907
  return(0);
1826
1908
}
1827
1909
 
1831
1913
  char in_string=0;
1832
1914
  uint32_t line_number=0;
1833
1915
  bool ml_comment= 0;
1834
 
  COMMANDS *com;
1835
 
  status.exit_status=1;
 
1916
  Commands *com;
 
1917
  status.setExitStatus(1);
1836
1918
 
1837
1919
  for (;;)
1838
1920
  {
1839
1921
    if (!interactive)
1840
1922
    {
1841
 
      if (status.line_buff)
1842
 
        line= status.line_buff->readline();
 
1923
      if (status.getLineBuff())
 
1924
        line= status.getLineBuff()->readline();
1843
1925
      else
1844
1926
        line= 0;
1845
1927
 
1850
1932
          fprintf(stderr, _("Processing line: %"PRIu32"\n"), line_number);
1851
1933
      }
1852
1934
      if (!glob_buffer->empty())
1853
 
        status.query_start_line= line_number;
 
1935
        status.setQueryStartLine(line_number);
1854
1936
    }
1855
1937
    else
1856
1938
    {
1857
 
      const char *prompt= (const char*) (ml_comment ? "   /*> " :
1858
 
                                         (glob_buffer->empty())
1859
 
                                         ?  construct_prompt()
1860
 
                                         : !in_string ? "    -> " :
1861
 
                                         in_string == '\'' ?
1862
 
                                         "    '> " : (in_string == '`' ?
1863
 
                                                      "    `> " :
1864
 
                                                      "    \"> "));
 
1939
      string prompt(ml_comment
 
1940
                      ? "   /*> " 
 
1941
                      : glob_buffer->empty()
 
1942
                        ? construct_prompt()
 
1943
                        : not in_string
 
1944
                          ? "    -> "
 
1945
                          : in_string == '\''
 
1946
                            ? "    '> "
 
1947
                            : in_string == '`'
 
1948
                              ? "    `> "
 
1949
                              : "    \"> ");
1865
1950
      if (opt_outfile && glob_buffer->empty())
1866
1951
        fflush(OUTFILE);
1867
1952
 
1868
1953
      if (opt_outfile)
1869
 
        fputs(prompt, OUTFILE);
1870
 
      line= readline(prompt);
 
1954
        fputs(prompt.c_str(), OUTFILE);
 
1955
      line= readline(prompt.c_str());
1871
1956
      /*
1872
1957
        When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS
1873
1958
        which may cause coredump.
1878
1963
    // End of file
1879
1964
    if (!line)
1880
1965
    {
1881
 
      status.exit_status=0;
 
1966
      status.setExitStatus(0);
1882
1967
      break;
1883
1968
    }
1884
1969
 
1894
1979
      // If buffer was emptied
1895
1980
      if (glob_buffer->empty())
1896
1981
        in_string=0;
1897
 
      if (interactive && status.add_to_history && not_in_history(line))
 
1982
      if (interactive && status.getAddToHistory() && not_in_history(line))
1898
1983
        add_history(line);
1899
1984
      continue;
1900
1985
    }
1903
1988
  }
1904
1989
  /* if in batch mode, send last query even if it doesn't end with \g or go */
1905
1990
 
1906
 
  if (!interactive && !status.exit_status)
 
1991
  if (!interactive && !status.getExitStatus())
1907
1992
  {
1908
1993
    remove_cntrl(glob_buffer);
1909
1994
    if (!glob_buffer->empty())
1910
1995
    {
1911
 
      status.exit_status=1;
 
1996
      status.setExitStatus(1);
1912
1997
      if (com_go(glob_buffer,line) <= 0)
1913
 
        status.exit_status=0;
 
1998
        status.setExitStatus(0);
1914
1999
    }
1915
2000
  }
1916
2001
 
1917
 
  return status.exit_status;
 
2002
  return status.getExitStatus();
1918
2003
}
1919
2004
 
1920
2005
 
1921
 
static COMMANDS *find_command(const char *name,char cmd_char)
 
2006
static Commands *find_command(const char *name,char cmd_char)
1922
2007
{
1923
2008
  uint32_t len;
1924
2009
  const char *end;
1930
2015
  }
1931
2016
  else
1932
2017
  {
1933
 
    while (my_isspace(charset_info,*name))
 
2018
    while (isspace(*name))
1934
2019
      name++;
1935
2020
    /*
1936
2021
      If there is an \\g in the row or if the row has a delimiter but
1939
2024
    */
1940
2025
    if (strstr(name, "\\g") || (strstr(name, delimiter) &&
1941
2026
                                !(strlen(name) >= 9 &&
1942
 
                                  !my_strnncoll(charset_info,
1943
 
                                                (unsigned char*) name, 9,
1944
 
                                                (const unsigned char*) "delimiter",
1945
 
                                                9))))
1946
 
      return((COMMANDS *) 0);
 
2027
                                  !strcmp(name, "delimiter"))))
 
2028
      return(NULL);
1947
2029
    if ((end=strcont(name," \t")))
1948
2030
    {
1949
2031
      len=(uint32_t) (end - name);
1950
 
      while (my_isspace(charset_info,*end))
 
2032
      while (isspace(*end))
1951
2033
        end++;
1952
2034
      if (!*end)
1953
2035
        end=0;          // no arguments to function
1956
2038
      len=(uint32_t) strlen(name);
1957
2039
  }
1958
2040
 
1959
 
  for (uint32_t i= 0; commands[i].name; i++)
 
2041
  for (uint32_t i= 0; commands[i].getName(); i++)
1960
2042
  {
1961
2043
    if (commands[i].func &&
1962
 
        ((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)))
 
2044
        ((name && !strncmp(name, commands[i].getName(), len)
 
2045
          && !commands[i].getName()[len] && (!end || (end && commands[i].getTakesParams()))) || (!name && commands[i].getCmdChar() == cmd_char)))
1963
2046
    {
1964
2047
      return(&commands[i]);
1965
2048
    }
1966
2049
  }
1967
 
  return((COMMANDS *) 0);
 
2050
  return(NULL);
1968
2051
}
1969
2052
 
1970
2053
 
1973
2056
{
1974
2057
  unsigned char inchar;
1975
2058
  char *pos, *out;
1976
 
  COMMANDS *com;
 
2059
  Commands *com;
1977
2060
  bool need_space= 0;
1978
2061
  bool ss_comment= 0;
1979
2062
 
1980
2063
 
1981
2064
  if (!line[0] && (buffer->empty()))
1982
2065
    return(0);
1983
 
  if (status.add_to_history && line[0] && not_in_history(line))
 
2066
  if (status.getAddToHistory() && line[0] && not_in_history(line))
1984
2067
    add_history(line);
1985
2068
  char *end_of_line=line+(uint32_t) strlen(line);
1986
2069
 
1989
2072
    if (!preserve_comments)
1990
2073
    {
1991
2074
      // Skip spaces at the beggining of a statement
1992
 
      if (my_isspace(charset_info,inchar) && (out == line) &&
 
2075
      if (isspace(inchar) && (out == line) &&
1993
2076
          (buffer->empty()))
1994
2077
        continue;
1995
2078
    }
1996
2079
 
1997
2080
    // Accept multi-byte characters as-is
1998
 
    int length;
1999
 
    if (use_mb(charset_info) &&
2000
 
        (length= my_ismbchar(charset_info, pos, end_of_line)))
 
2081
    if (not drizzled::utf8::is_single(*pos))
2001
2082
    {
2002
 
      if (!*ml_comment || preserve_comments)
 
2083
      int length;
 
2084
      if ((length= drizzled::utf8::sequence_length(*pos)))
2003
2085
      {
2004
 
        while (length--)
2005
 
          *out++ = *pos++;
2006
 
        pos--;
 
2086
        if (!*ml_comment || preserve_comments)
 
2087
        {
 
2088
          while (length--)
 
2089
            *out++ = *pos++;
 
2090
          pos--;
 
2091
        }
 
2092
        else
 
2093
          pos+= length - 1;
 
2094
        continue;
2007
2095
      }
2008
 
      else
2009
 
        pos+= length - 1;
2010
 
      continue;
2011
2096
    }
2012
2097
    if (!*ml_comment && inchar == '\\' &&
2013
2098
        !(*in_string && (drizzle_con_status(&con) & DRIZZLE_CON_STATUS_NO_BACKSLASH_ESCAPES)))
2033
2118
 
2034
2119
        if ((*com->func)(buffer,pos-1) > 0)
2035
2120
          return(1);                       // Quit
2036
 
        if (com->takes_params)
 
2121
        if (com->getTakesParams())
2037
2122
        {
2038
2123
          if (ss_comment)
2039
2124
          {
2076
2161
    }
2077
2162
    else if (!*ml_comment && !*in_string &&
2078
2163
             (end_of_line - pos) >= 10 &&
2079
 
             !my_strnncoll(charset_info, (unsigned char*) pos, 10,
2080
 
                           (const unsigned char*) "delimiter ", 10))
 
2164
             !strncmp(pos, "delimiter ", 10))
2081
2165
    {
2082
2166
      // Flush previously accepted characters
2083
2167
      if (out != line)
2114
2198
 
2115
2199
      if (preserve_comments)
2116
2200
      {
2117
 
        while (my_isspace(charset_info, *pos))
 
2201
        while (isspace(*pos))
2118
2202
          *out++= *pos++;
2119
2203
      }
2120
2204
      // Flush previously accepted characters
2127
2211
      if (preserve_comments && ((*pos == '#') ||
2128
2212
                                ((*pos == '-') &&
2129
2213
                                 (pos[1] == '-') &&
2130
 
                                 my_isspace(charset_info, pos[2]))))
 
2214
                                 isspace(pos[2]))))
2131
2215
      {
2132
2216
        // Add trailing single line comments to this statement
2133
2217
        buffer->append(pos);
2154
2238
                 && (inchar == '#'
2155
2239
                     || (inchar == '-'
2156
2240
                         && pos[1] == '-'
2157
 
                         && my_isspace(charset_info,pos[2])))))
 
2241
                         && isspace(pos[2])))))
2158
2242
    {
2159
2243
      // Flush previously accepted characters
2160
2244
      if (out != line)
2220
2304
        *in_string= (char) inchar;
2221
2305
      if (!*ml_comment || preserve_comments)
2222
2306
      {
2223
 
        if (need_space && !my_isspace(charset_info, (char)inchar))
 
2307
        if (need_space && !isspace((char)inchar))
2224
2308
          *out++= ' ';
2225
2309
        need_space= 0;
2226
2310
        *out++= (char) inchar;
2347
2431
*/
2348
2432
char **mysql_completion (const char *text, int, int)
2349
2433
{
2350
 
  if (!status.batch && !quick)
 
2434
  if (!status.getBatch() && !quick)
2351
2435
    return rl_completion_matches(text, new_command_generator);
2352
2436
  else
2353
2437
    return (char**) 0;
2416
2500
 
2417
2501
static void build_completion_hash(bool rehash, bool write_info)
2418
2502
{
2419
 
  COMMANDS *cmd=commands;
 
2503
  Commands *cmd=commands;
2420
2504
  drizzle_return_t ret;
2421
2505
  drizzle_result_st databases,tables,fields;
2422
2506
  drizzle_row_t database_row,table_row;
2423
2507
  drizzle_column_st *sql_field;
2424
2508
  string tmp_str, tmp_str_lower;
2425
2509
 
2426
 
  if (status.batch || quick || !current_db)
 
2510
  if (status.getBatch() || quick || current_db.empty())
2427
2511
    return;      // We don't need completion in batches
2428
2512
  if (!rehash)
2429
2513
    return;
2431
2515
  completion_map.clear();
2432
2516
 
2433
2517
  /* hash this file's known subset of SQL commands */
2434
 
  while (cmd->name) {
2435
 
    tmp_str= cmd->name;
 
2518
  while (cmd->getName()) {
 
2519
    tmp_str= cmd->getName();
2436
2520
    tmp_str_lower= lower_string(tmp_str);
2437
2521
    completion_map[tmp_str_lower]= tmp_str;
2438
2522
    cmd++;
2476
2560
    {
2477
2561
      if (drizzle_result_row_count(&tables) > 0 && !opt_silent && write_info)
2478
2562
      {
2479
 
        tee_fprintf(stdout, _("\
2480
 
Reading table information for completion of table and column names\n    \
2481
 
You can turn off this feature to get a quicker startup with -A\n\n"));
 
2563
        tee_fprintf(stdout,
 
2564
                    _("Reading table information for completion of "
 
2565
                      "table and column names\n"
 
2566
                      "You can turn off this feature to get a quicker "
 
2567
                      "startup with -A\n\n"));
2482
2568
      }
2483
2569
      while ((table_row=drizzle_row_next(&tables)))
2484
2570
      {
2556
2642
  drizzle_return_t ret;
2557
2643
  drizzle_result_st res;
2558
2644
 
2559
 
  free(current_db);
2560
 
  current_db= NULL;
 
2645
  current_db.erase();
 
2646
  current_db= "";
2561
2647
  /* In case of error below current_db will be NULL */
2562
2648
  if (drizzle_query_str(&con, &res, "SELECT DATABASE()", &ret) != NULL)
2563
2649
  {
2566
2652
    {
2567
2653
      drizzle_row_t row= drizzle_row_next(&res);
2568
2654
      if (row[0])
2569
 
        current_db= strdup(row[0]);
 
2655
        current_db.assign(row[0]);
2570
2656
      drizzle_result_free(&res);
2571
2657
    }
2572
2658
  }
2615
2701
    return 0;
2616
2702
 
2617
2703
  if (drizzle_con_error(&con)[0])
2618
 
    return put_error(&con, result);
 
2704
  {
 
2705
    int ret= put_error(&con, result);
 
2706
    drizzle_result_free(result);
 
2707
    return ret;
 
2708
  }
2619
2709
  return 0;
2620
2710
}
2621
2711
 
2624
2714
{
2625
2715
  register int i, j;
2626
2716
  char buff[32], *end;
 
2717
  std::vector<char> output_buff;
 
2718
  output_buff.resize(512);
2627
2719
 
2628
2720
  put_info(_("List of all Drizzle commands:"), INFO_INFO,0,0);
2629
2721
  if (!named_cmds)
2630
 
    put_info(_("Note that all text commands must be first on line and end with ';'"),INFO_INFO,0,0);
2631
 
  for (i = 0; commands[i].name; i++)
2632
 
  {
2633
 
    end= strcpy(buff, commands[i].name);
2634
 
    end+= strlen(commands[i].name);
2635
 
    for (j= (int)strlen(commands[i].name); j < 10; j++)
 
2722
  {
 
2723
    snprintf(&output_buff[0], output_buff.size(),
 
2724
             _("Note that all text commands must be first on line and end with '%s' or \\g"),
 
2725
             delimiter);
 
2726
    put_info(&output_buff[0], INFO_INFO, 0, 0);
 
2727
  }
 
2728
  for (i = 0; commands[i].getName(); i++)
 
2729
  {
 
2730
    end= strcpy(buff, commands[i].getName());
 
2731
    end+= strlen(commands[i].getName());
 
2732
    for (j= (int)strlen(commands[i].getName()); j < 10; j++)
2636
2733
      end= strcpy(end, " ")+1;
2637
2734
    if (commands[i].func)
2638
2735
      tee_fprintf(stdout, "%s(\\%c) %s\n", buff,
2639
 
                  commands[i].cmd_char, _(commands[i].doc));
 
2736
                  commands[i].getCmdChar(), _(commands[i].getDoc()));
2640
2737
  }
2641
2738
  tee_fprintf(stdout, "\n");
2642
2739
  buffer->clear();
2647
2744
static int
2648
2745
com_clear(string *buffer, const char *)
2649
2746
{
2650
 
  if (status.add_to_history)
 
2747
  if (status.getAddToHistory())
2651
2748
    fix_history(buffer);
2652
2749
  buffer->clear();
2653
2750
  return 0;
2680
2777
  if (buffer->empty())
2681
2778
  {
2682
2779
    // Ignore empty quries
2683
 
    if (status.batch)
 
2780
    if (status.getBatch())
2684
2781
      return 0;
2685
2782
    return put_info(_("No query specified\n"),INFO_ERROR,0,0);
2686
2783
 
2705
2802
  executing_query= 1;
2706
2803
  error= drizzleclient_real_query_for_lazy(buffer->c_str(),buffer->length(),&result, &error_code);
2707
2804
 
2708
 
  if (status.add_to_history)
 
2805
  if (status.getAddToHistory())
2709
2806
  {
2710
2807
    buffer->append(vertical ? "\\G" : delimiter);
2711
2808
    /* Append final command onto history */
2826
2923
  if (show_warnings == 1 && (warnings >= 1 || error))
2827
2924
    print_warnings(error_code);
2828
2925
 
2829
 
  if (!error && !status.batch &&
 
2926
  if (!error && !status.getBatch() &&
2830
2927
      drizzle_con_status(&con) & DRIZZLE_CON_STATUS_DB_DROPPED)
2831
2928
  {
2832
2929
    get_current_db();
2841
2938
{
2842
2939
  if (!opt_nopager)
2843
2940
  {
2844
 
    if (!(PAGER= popen(pager, "w")))
 
2941
    if (!(PAGER= popen(pager.c_str(), "w")))
2845
2942
    {
2846
 
      tee_fprintf(stdout, "popen() failed! defaulting PAGER to stdout!\n");
 
2943
      tee_fprintf(stdout,_( "popen() failed! defaulting PAGER to stdout!\n"));
2847
2944
      PAGER= stdout;
2848
2945
    }
2849
2946
  }
2865
2962
    end_tee();
2866
2963
  if (!(new_outfile= fopen(file_name, "a")))
2867
2964
  {
2868
 
    tee_fprintf(stdout, "Error logging to file '%s'\n", file_name);
 
2965
    tee_fprintf(stdout, _("Error logging to file '%s'\n"), file_name);
2869
2966
    return;
2870
2967
  }
2871
2968
  OUTFILE = new_outfile;
2872
 
  strncpy(outfile, file_name, FN_REFLEN-1);
2873
 
  tee_fprintf(stdout, "Logging to file '%s'\n", file_name);
 
2969
  outfile.assign(file_name);
 
2970
  tee_fprintf(stdout, _("Logging to file '%s'\n"), file_name);
2874
2971
  opt_outfile= 1;
2875
2972
 
2876
2973
  return;
2954
3051
 
2955
3052
  while ((field = drizzle_column_next(result)))
2956
3053
  {
2957
 
    tee_fprintf(PAGER, "Field %3u:  `%s`\n"
 
3054
    tee_fprintf(PAGER, _("Field %3u:  `%s`\n"
2958
3055
                "Catalog:    `%s`\n"
2959
3056
                "Database:   `%s`\n"
2960
3057
                "Table:      `%s`\n"
2961
3058
                "Org_table:  `%s`\n"
2962
 
                "Type:       %s\n"
 
3059
                "Type:       UTF-8\n"
2963
3060
                "Collation:  %s (%u)\n"
2964
3061
                "Length:     %lu\n"
2965
3062
                "Max_length: %lu\n"
2966
3063
                "Decimals:   %u\n"
2967
 
                "Flags:      %s\n\n",
 
3064
                "Flags:      %s\n\n"),
2968
3065
                ++i,
2969
3066
                drizzle_column_name(field), drizzle_column_catalog(field),
2970
3067
                drizzle_column_db(field), drizzle_column_table(field),
2971
3068
                drizzle_column_orig_table(field),
2972
3069
                fieldtype2str(drizzle_column_type(field)),
2973
 
                get_charset_name(drizzle_column_charset(field)),
2974
3070
                drizzle_column_charset(field), drizzle_column_size(field),
2975
3071
                drizzle_column_max_size(field), drizzle_column_decimals(field),
2976
3072
                fieldflags2str(drizzle_column_flags(field)));
2978
3074
  tee_puts("", PAGER);
2979
3075
}
2980
3076
 
2981
 
 
2982
3077
static void
2983
3078
print_table_data(drizzle_result_st *result)
2984
3079
{
2985
3080
  drizzle_row_t cur;
2986
3081
  drizzle_return_t ret;
2987
3082
  drizzle_column_st *field;
2988
 
  bool *num_flag;
 
3083
  std::vector<bool> num_flag;
2989
3084
  string separator;
2990
3085
 
2991
3086
  separator.reserve(256);
2992
3087
 
2993
 
  num_flag=(bool*) malloc(sizeof(bool)*drizzle_result_column_count(result));
 
3088
  num_flag.resize(drizzle_result_column_count(result));
2994
3089
  if (column_types_flag)
2995
3090
  {
2996
3091
    print_field_types(result);
3010
3105
      /* Check if the max_byte value is really the maximum in terms
3011
3106
         of visual length since multibyte characters can affect the
3012
3107
         length of the separator. */
3013
 
      length= charset_info->cset->numcells(charset_info,
3014
 
                                           drizzle_column_name(field),
3015
 
                                           drizzle_column_name(field) +
3016
 
                                           name_length);
 
3108
      length= drizzled::utf8::char_length(drizzle_column_name(field));
3017
3109
 
3018
3110
      if (name_length == drizzle_column_max_size(field))
3019
3111
      {
3051
3143
    for (uint32_t off=0; (field = drizzle_column_next(result)) ; off++)
3052
3144
    {
3053
3145
      uint32_t name_length= (uint32_t) strlen(drizzle_column_name(field));
3054
 
      uint32_t numcells= charset_info->cset->numcells(charset_info,
3055
 
                                                  drizzle_column_name(field),
3056
 
                                                  drizzle_column_name(field) +
3057
 
                                                  name_length);
 
3146
      uint32_t numcells= drizzled::utf8::char_length(drizzle_column_name(field));
3058
3147
      uint32_t display_length= drizzle_column_max_size(field) + name_length -
3059
3148
                               numcells;
3060
3149
      tee_fprintf(PAGER, " %-*s |",(int) min(display_length,
3117
3206
        We need to find how much screen real-estate we will occupy to know how
3118
3207
        many extra padding-characters we should send with the printing function.
3119
3208
      */
3120
 
      visible_length= charset_info->cset->numcells(charset_info, buffer, buffer + data_length);
 
3209
      visible_length= drizzled::utf8::char_length(buffer);
3121
3210
      extra_padding= data_length - visible_length;
3122
3211
 
3123
3212
      if (field_max_length > MAX_COLUMN_LENGTH)
3137
3226
      drizzle_row_free(result, cur);
3138
3227
  }
3139
3228
  tee_puts(separator.c_str(), PAGER);
3140
 
  free(num_flag);
3141
3229
}
3142
3230
 
3143
3231
/**
3285
3373
  drizzle_row_t cur;
3286
3374
  uint64_t num_rows;
3287
3375
  uint32_t new_code= 0;
 
3376
  FILE *out;
3288
3377
 
3289
3378
  /* Get the warnings */
3290
3379
  query= "show warnings";
3310
3399
  }
3311
3400
 
3312
3401
  /* Print the warnings */
3313
 
  init_pager();
 
3402
  if (status.getBatch()) 
 
3403
  {
 
3404
    out= stderr;
 
3405
  } 
 
3406
  else 
 
3407
  {
 
3408
    init_pager();
 
3409
    out= PAGER;
 
3410
  }
3314
3411
  do
3315
3412
  {
3316
 
    tee_fprintf(PAGER, "%s (Code %s): %s\n", cur[0], cur[1], cur[2]);
 
3413
    tee_fprintf(out, "%s (Code %s): %s\n", cur[0], cur[1], cur[2]);
3317
3414
  } while ((cur= drizzle_row_next(&result)));
3318
 
  end_pager();
 
3415
 
 
3416
  if (not status.getBatch())
 
3417
    end_pager();
3319
3418
 
3320
3419
end:
3321
3420
  drizzle_result_free(&result);
3334
3433
    else for (const char *end=pos+length ; pos != end ; pos++)
3335
3434
    {
3336
3435
      int l;
3337
 
      if (use_mb(charset_info) &&
3338
 
          (l = my_ismbchar(charset_info, pos, end)))
 
3436
      if ((l = drizzled::utf8::sequence_length(*pos)))
3339
3437
      {
3340
3438
        while (l--)
3341
3439
          tee_putc(*pos++, PAGER);
3412
3510
  char file_name[FN_REFLEN], *end;
3413
3511
  const char *param;
3414
3512
 
3415
 
  if (status.batch)
 
3513
  if (status.getBatch())
3416
3514
    return 0;
3417
 
  while (my_isspace(charset_info,*line))
 
3515
  while (isspace(*line))
3418
3516
    line++;
3419
 
  if (!(param = strchr(line, ' '))) // if outfile wasn't given, use the default
 
3517
  if (!(param =strchr(line, ' '))) // if outfile wasn't given, use the default
3420
3518
  {
3421
 
    if (!strlen(outfile))
 
3519
    if (outfile.empty())
3422
3520
    {
3423
 
      printf("No previous outfile available, you must give a filename!\n");
 
3521
      printf(_("No previous outfile available, you must give a filename!\n"));
3424
3522
      return 0;
3425
3523
    }
3426
3524
    else if (opt_outfile)
3427
3525
    {
3428
 
      tee_fprintf(stdout, "Currently logging to file '%s'\n", outfile);
 
3526
      tee_fprintf(stdout, _("Currently logging to file '%s'\n"), outfile.c_str());
3429
3527
      return 0;
3430
3528
    }
3431
3529
    else
3432
 
      param = outfile;      //resume using the old outfile
 
3530
      param= outfile.c_str();      //resume using the old outfile
3433
3531
  }
3434
3532
 
 
3533
  /* @TODO: Replace this with string methods */
3435
3534
  /* eliminate the spaces before the parameters */
3436
 
  while (my_isspace(charset_info,*param))
 
3535
  while (isspace(*param))
3437
3536
    param++;
3438
3537
  strncpy(file_name, param, sizeof(file_name) - 1);
3439
3538
  end= file_name + strlen(file_name);
3440
3539
  /* remove end space from command line */
3441
 
  while (end > file_name && (my_isspace(charset_info,end[-1]) ||
3442
 
                             my_iscntrl(charset_info,end[-1])))
 
3540
  while (end > file_name && (isspace(end[-1]) ||
 
3541
                             iscntrl(end[-1])))
3443
3542
    end--;
3444
3543
  end[0]= 0;
3445
3544
  if (end == file_name)
3446
3545
  {
3447
 
    printf("No outfile specified!\n");
 
3546
    printf(_("No outfile specified!\n"));
3448
3547
    return 0;
3449
3548
  }
3450
3549
  init_tee(file_name);
3457
3556
{
3458
3557
  if (opt_outfile)
3459
3558
    end_tee();
3460
 
  tee_fprintf(stdout, "Outfile disabled.\n");
 
3559
  tee_fprintf(stdout, _("Outfile disabled.\n"));
3461
3560
  return 0;
3462
3561
}
3463
3562
 
3468
3567
static int
3469
3568
com_pager(string *, const char *line)
3470
3569
{
3471
 
  char pager_name[FN_REFLEN], *end;
3472
3570
  const char *param;
3473
3571
 
3474
 
  if (status.batch)
 
3572
  if (status.getBatch())
3475
3573
    return 0;
3476
3574
  /* Skip spaces in front of the pager command */
3477
 
  while (my_isspace(charset_info, *line))
 
3575
  while (isspace(*line))
3478
3576
    line++;
3479
3577
  /* Skip the pager command */
3480
3578
  param= strchr(line, ' ');
3481
3579
  /* Skip the spaces between the command and the argument */
3482
 
  while (param && my_isspace(charset_info, *param))
 
3580
  while (param && isspace(*param))
3483
3581
    param++;
3484
3582
  if (!param || !strlen(param)) // if pager was not given, use the default
3485
3583
  {
3486
3584
    if (!default_pager_set)
3487
3585
    {
3488
 
      tee_fprintf(stdout, "Default pager wasn't set, using stdout.\n");
 
3586
      tee_fprintf(stdout, _("Default pager wasn't set, using stdout.\n"));
3489
3587
      opt_nopager=1;
3490
 
      strcpy(pager, "stdout");
 
3588
      pager.assign("stdout");
3491
3589
      PAGER= stdout;
3492
3590
      return 0;
3493
3591
    }
3494
 
    strcpy(pager, default_pager);
 
3592
    pager.assign(default_pager);
3495
3593
  }
3496
3594
  else
3497
3595
  {
3498
 
    end= strncpy(pager_name, param, sizeof(pager_name)-1);
3499
 
    end+= strlen(pager_name);
3500
 
    while (end > pager_name && (my_isspace(charset_info,end[-1]) ||
3501
 
                                my_iscntrl(charset_info,end[-1])))
3502
 
      end--;
3503
 
    end[0]=0;
3504
 
    strcpy(pager, pager_name);
3505
 
    strcpy(default_pager, pager_name);
 
3596
    string pager_name(param);
 
3597
    string::iterator end= pager_name.end();
 
3598
    while (end > pager_name.begin() &&
 
3599
           (isspace(*(end-1)) || iscntrl(*(end-1))))
 
3600
      --end;
 
3601
    pager_name.erase(end, pager_name.end());
 
3602
    pager.assign(pager_name);
 
3603
    default_pager.assign(pager_name);
3506
3604
  }
3507
3605
  opt_nopager=0;
3508
 
  tee_fprintf(stdout, "PAGER set to '%s'\n", pager);
 
3606
  tee_fprintf(stdout, _("PAGER set to '%s'\n"), pager.c_str());
3509
3607
  return 0;
3510
3608
}
3511
3609
 
3513
3611
static int
3514
3612
com_nopager(string *, const char *)
3515
3613
{
3516
 
  strcpy(pager, "stdout");
 
3614
  pager.assign("stdout");
3517
3615
  opt_nopager=1;
3518
3616
  PAGER= stdout;
3519
 
  tee_fprintf(stdout, "PAGER set to stdout\n");
 
3617
  tee_fprintf(stdout, _("PAGER set to stdout\n"));
3520
3618
  return 0;
3521
3619
}
3522
3620
 
3526
3624
com_quit(string *, const char *)
3527
3625
{
3528
3626
  /* let the screen auto close on a normal shutdown */
3529
 
  status.exit_status=0;
 
3627
  status.setExitStatus(0);
3530
3628
  return 1;
3531
3629
}
3532
3630
 
3574
3672
    tmp= get_arg(buff, 0);
3575
3673
    if (tmp && *tmp)
3576
3674
    {
3577
 
      free(current_db);
3578
 
      current_db= strdup(tmp);
 
3675
      current_db.erase();
 
3676
      current_db.assign(tmp);
3579
3677
      tmp= get_arg(buff, 1);
3580
3678
      if (tmp)
3581
3679
      {
3582
 
        free(current_host);
 
3680
        current_host.erase();
3583
3681
        current_host=strdup(tmp);
3584
3682
      }
3585
3683
    }
3594
3692
  }
3595
3693
  else
3596
3694
    opt_rehash= 0;
3597
 
  error=sql_connect(current_host,current_db,current_user,opt_password,0);
 
3695
  error=sql_connect(current_host, current_db, current_user, opt_password,0);
3598
3696
  opt_rehash= save_rehash;
3599
3697
 
3600
3698
  if (connected)
3601
3699
  {
3602
 
    sprintf(buff,"Connection id:    %u",drizzle_con_thread_id(&con));
 
3700
    sprintf(buff, _("Connection id:    %u"), drizzle_con_thread_id(&con));
3603
3701
    put_info(buff,INFO_INFO,0,0);
3604
 
    sprintf(buff,"Current database: %.128s\n",
3605
 
            current_db ? current_db : "*** NONE ***");
 
3702
    sprintf(buff, _("Current database: %.128s\n"),
 
3703
            !current_db.empty() ? current_db.c_str() : _("*** NONE ***"));
3606
3704
    put_info(buff,INFO_INFO,0,0);
3607
3705
  }
3608
3706
  return error;
3615
3713
  const char *param;
3616
3714
  LineBuffer *line_buff;
3617
3715
  int error;
3618
 
  STATUS old_status;
 
3716
  Status old_status;
3619
3717
  FILE *sql_file;
3620
3718
 
3621
3719
  /* Skip space from file name */
3622
 
  while (my_isspace(charset_info,*line))
 
3720
  while (isspace(*line))
3623
3721
    line++;
3624
3722
  if (!(param = strchr(line, ' ')))    // Skip command name
3625
 
    return put_info("Usage: \\. <filename> | source <filename>",
 
3723
    return put_info(_("Usage: \\. <filename> | source <filename>"),
3626
3724
                    INFO_ERROR, 0,0);
3627
 
  while (my_isspace(charset_info,*param))
 
3725
  while (isspace(*param))
3628
3726
    param++;
3629
3727
  end= strncpy(source_name,param,sizeof(source_name)-1);
3630
3728
  end+= strlen(source_name);
3631
 
  while (end > source_name && (my_isspace(charset_info,end[-1]) ||
3632
 
                               my_iscntrl(charset_info,end[-1])))
 
3729
  while (end > source_name && (isspace(end[-1]) ||
 
3730
                               iscntrl(end[-1])))
3633
3731
    end--;
3634
3732
  end[0]=0;
3635
 
  internal::unpack_filename(source_name,source_name);
 
3733
 
3636
3734
  /* open file name */
3637
3735
  if (!(sql_file = fopen(source_name, "r")))
3638
3736
  {
3639
3737
    char buff[FN_REFLEN+60];
3640
 
    sprintf(buff,"Failed to open file '%s', error: %d", source_name,errno);
 
3738
    sprintf(buff, _("Failed to open file '%s', error: %d"), source_name,errno);
3641
3739
    return put_info(buff, INFO_ERROR, 0 ,0);
3642
3740
  }
3643
3741
 
3645
3743
  if (line_buff == NULL)
3646
3744
  {
3647
3745
    fclose(sql_file);
3648
 
    return put_info("Can't initialize LineBuffer", INFO_ERROR, 0, 0);
 
3746
    return put_info(_("Can't initialize LineBuffer"), INFO_ERROR, 0, 0);
3649
3747
  }
3650
3748
 
3651
3749
  /* Save old status */
3653
3751
  memset(&status, 0, sizeof(status));
3654
3752
 
3655
3753
  // Run in batch mode
3656
 
  status.batch=old_status.batch;
3657
 
  status.line_buff=line_buff;
3658
 
  status.file_name=source_name;
 
3754
  status.setBatch(old_status.getBatch());
 
3755
  status.setLineBuff(line_buff);
 
3756
  status.setFileName(source_name);
3659
3757
  // Empty command buffer
3660
3758
  assert(glob_buffer!=NULL);
3661
3759
  glob_buffer->clear();
3663
3761
  // Continue as before
3664
3762
  status=old_status;
3665
3763
  fclose(sql_file);
3666
 
  delete status.line_buff;
3667
 
  line_buff= status.line_buff= 0;
 
3764
  delete status.getLineBuff();
 
3765
  line_buff=0;
 
3766
  status.setLineBuff(0);
3668
3767
  return error;
3669
3768
}
3670
3769
 
3680
3779
 
3681
3780
  if (!tmp || !*tmp)
3682
3781
  {
3683
 
    put_info("DELIMITER must be followed by a 'delimiter' character or string",
 
3782
    put_info(_("DELIMITER must be followed by a 'delimiter' character or string"),
3684
3783
             INFO_ERROR, 0, 0);
3685
3784
    return 0;
3686
3785
  }
3688
3787
  {
3689
3788
    if (strstr(tmp, "\\"))
3690
3789
    {
3691
 
      put_info("DELIMITER cannot contain a backslash character",
 
3790
      put_info(_("DELIMITER cannot contain a backslash character"),
3692
3791
               INFO_ERROR, 0, 0);
3693
3792
      return 0;
3694
3793
    }
3713
3812
  tmp= get_arg(buff, 0);
3714
3813
  if (!tmp || !*tmp)
3715
3814
  {
3716
 
    put_info("USE must be followed by a database name", INFO_ERROR, 0, 0);
 
3815
    put_info(_("USE must be followed by a database name"), INFO_ERROR, 0, 0);
3717
3816
    return 0;
3718
3817
  }
3719
3818
  /*
3723
3822
  */
3724
3823
  get_current_db();
3725
3824
 
3726
 
  if (!current_db || strcmp(current_db,tmp))
 
3825
  if (current_db.empty() || strcmp(current_db.c_str(),tmp))
3727
3826
  {
3728
3827
    if (one_database)
3729
3828
    {
3775
3874
      else
3776
3875
        drizzle_result_free(&result);
3777
3876
    }
3778
 
    free(current_db);
3779
 
    current_db= strdup(tmp);
 
3877
    current_db.erase();
 
3878
    current_db.assign(tmp);
3780
3879
    if (select_db > 1)
3781
3880
      build_completion_hash(opt_rehash, 1);
3782
3881
  }
3783
3882
 
3784
 
  put_info("Database changed",INFO_INFO, 0, 0);
 
3883
  put_info(_("Database changed"),INFO_INFO, 0, 0);
3785
3884
  return 0;
3786
3885
}
3787
3886
 
3789
3888
com_warnings(string *, const char *)
3790
3889
{
3791
3890
  show_warnings = 1;
3792
 
  put_info("Show warnings enabled.",INFO_INFO, 0, 0);
 
3891
  put_info(_("Show warnings enabled."),INFO_INFO, 0, 0);
3793
3892
  return 0;
3794
3893
}
3795
3894
 
3797
3896
com_nowarnings(string *, const char *)
3798
3897
{
3799
3898
  show_warnings = 0;
3800
 
  put_info("Show warnings disabled.",INFO_INFO, 0, 0);
 
3899
  put_info(_("Show warnings disabled."),INFO_INFO, 0, 0);
3801
3900
  return 0;
3802
3901
}
3803
3902
 
3827
3926
  else
3828
3927
  {
3829
3928
    /* skip leading white spaces */
3830
 
    while (my_isspace(charset_info, *ptr))
 
3929
    while (isspace(*ptr))
3831
3930
      ptr++;
3832
3931
    if (*ptr == '\\') // short command was used
3833
3932
      ptr+= 2;
3834
3933
    else
3835
 
      while (*ptr &&!my_isspace(charset_info, *ptr)) // skip command
 
3934
      while (*ptr &&!isspace(*ptr)) // skip command
3836
3935
        ptr++;
3837
3936
  }
3838
3937
  if (!*ptr)
3839
3938
    return NULL;
3840
 
  while (my_isspace(charset_info, *ptr))
 
3939
  while (isspace(*ptr))
3841
3940
    ptr++;
3842
3941
  if (*ptr == '\'' || *ptr == '\"' || *ptr == '`')
3843
3942
  {
3864
3963
 
3865
3964
 
3866
3965
static int
3867
 
sql_connect(char *host,char *database,char *user,char *password,
 
3966
sql_connect(const string &host, const string &database, const string &user, const string &password,
3868
3967
                 uint32_t silent)
3869
3968
{
3870
3969
  drizzle_return_t ret;
3871
 
 
3872
3970
  if (connected)
3873
3971
  {
3874
3972
    connected= 0;
3876
3974
    drizzle_free(&drizzle);
3877
3975
  }
3878
3976
  drizzle_create(&drizzle);
3879
 
  if (drizzle_con_add_tcp(&drizzle, &con, host, opt_drizzle_port, user,
3880
 
                          password, database, opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
 
3977
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(),
 
3978
    opt_drizzle_port, (char *)user.c_str(),
 
3979
    (char *)password.c_str(), (char *)database.c_str(),
 
3980
    use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
3881
3981
  {
3882
3982
    (void) put_error(&con, NULL);
3883
3983
    (void) fflush(stdout);
3933
4033
  drizzle_return_t ret;
3934
4034
 
3935
4035
  tee_puts("--------------", stdout);
3936
 
  usage(1);          /* Print version */
 
4036
  printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
 
4037
         drizzle_version(), VERSION,
 
4038
         HOST_VENDOR, HOST_OS, HOST_CPU,
 
4039
         rl_library_version);
 
4040
 
3937
4041
  if (connected)
3938
4042
  {
3939
 
    tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",drizzle_con_thread_id(&con));
 
4043
    tee_fprintf(stdout, _("\nConnection id:\t\t%lu\n"),drizzle_con_thread_id(&con));
3940
4044
    /*
3941
4045
      Don't remove "limit 1",
3942
4046
      it is protection againts SQL_SELECT_LIMIT=0
3948
4052
      drizzle_row_t cur=drizzle_row_next(&result);
3949
4053
      if (cur)
3950
4054
      {
3951
 
        tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
3952
 
        tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
 
4055
        tee_fprintf(stdout, _("Current database:\t%s\n"), cur[0] ? cur[0] : "");
 
4056
        tee_fprintf(stdout, _("Current user:\t\t%s\n"), cur[1]);
3953
4057
      }
3954
4058
      drizzle_result_free(&result);
3955
4059
    }
3956
4060
    else if (ret == DRIZZLE_RETURN_ERROR_CODE)
3957
4061
      drizzle_result_free(&result);
3958
 
    tee_puts("SSL:\t\t\tNot in use", stdout);
 
4062
    tee_puts(_("SSL:\t\t\tNot in use"), stdout);
3959
4063
  }
3960
4064
  else
3961
4065
  {
3962
4066
    vidattr(A_BOLD);
3963
 
    tee_fprintf(stdout, "\nNo connection\n");
 
4067
    tee_fprintf(stdout, _("\nNo connection\n"));
3964
4068
    vidattr(A_NORMAL);
3965
4069
    return 0;
3966
4070
  }
3967
4071
  if (skip_updates)
3968
4072
  {
3969
4073
    vidattr(A_BOLD);
3970
 
    tee_fprintf(stdout, "\nAll updates ignored to this database\n");
 
4074
    tee_fprintf(stdout, _("\nAll updates ignored to this database\n"));
3971
4075
    vidattr(A_NORMAL);
3972
4076
  }
3973
 
  tee_fprintf(stdout, "Current pager:\t\t%s\n", pager);
3974
 
  tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile : "");
3975
 
  tee_fprintf(stdout, "Using delimiter:\t%s\n", delimiter);
3976
 
  tee_fprintf(stdout, "Server version:\t\t%s\n", server_version_string(&con));
3977
 
  tee_fprintf(stdout, "Protocol version:\t%d\n", drizzle_con_protocol_version(&con));
3978
 
  tee_fprintf(stdout, "Connection:\t\t%s\n", drizzle_con_host(&con));
 
4077
  tee_fprintf(stdout, _("Current pager:\t\t%s\n"), pager.c_str());
 
4078
  tee_fprintf(stdout, _("Using outfile:\t\t'%s'\n"), opt_outfile ? outfile.c_str() : "");
 
4079
  tee_fprintf(stdout, _("Using delimiter:\t%s\n"), delimiter);
 
4080
  tee_fprintf(stdout, _("Server version:\t\t%s\n"), server_version_string(&con));
 
4081
  tee_fprintf(stdout, _("Protocol:\t\t%s\n"), opt_protocol.c_str());
 
4082
  tee_fprintf(stdout, _("Protocol version:\t%d\n"), drizzle_con_protocol_version(&con));
 
4083
  tee_fprintf(stdout, _("Connection:\t\t%s\n"), drizzle_con_host(&con));
3979
4084
/* XXX need to save this from result
3980
4085
  if ((id= drizzleclient_insert_id(&drizzle)))
3981
4086
    tee_fprintf(stdout, "Insert id:\t\t%s\n", internal::llstr(id, buff));
3982
4087
*/
3983
4088
 
3984
 
  if (strcmp(drizzle_con_uds(&con), ""))
3985
 
    tee_fprintf(stdout, "UNIX socket:\t\t%s\n", drizzle_con_uds(&con));
 
4089
  if (drizzle_con_uds(&con))
 
4090
    tee_fprintf(stdout, _("UNIX socket:\t\t%s\n"), drizzle_con_uds(&con));
3986
4091
  else
3987
 
    tee_fprintf(stdout, "TCP port:\t\t%d\n", drizzle_con_port(&con));
 
4092
    tee_fprintf(stdout, _("TCP port:\t\t%d\n"), drizzle_con_port(&con));
3988
4093
 
3989
4094
  if (safe_updates)
3990
4095
  {
3991
4096
    vidattr(A_BOLD);
3992
 
    tee_fprintf(stdout, "\nNote that you are running in safe_update_mode:\n");
 
4097
    tee_fprintf(stdout, _("\nNote that you are running in safe_update_mode:\n"));
3993
4098
    vidattr(A_NORMAL);
3994
 
    tee_fprintf(stdout, "\
 
4099
    tee_fprintf(stdout, _("\
3995
4100
UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\
3996
4101
(One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n \
3997
4102
SELECT has an automatic 'LIMIT %lu' if LIMIT is not used.\n             \
3998
 
Max number of examined row combination in a join is set to: %lu\n\n",
 
4103
Max number of examined row combination in a join is set to: %lu\n\n"),
3999
4104
                select_limit, max_join_size);
4000
4105
  }
4001
4106
  tee_puts("--------------\n", stdout);
4048
4153
  FILE *file= (info_type == INFO_ERROR ? stderr : stdout);
4049
4154
  static int inited=0;
4050
4155
 
4051
 
  if (status.batch)
 
4156
  if (status.getBatch())
4052
4157
  {
4053
4158
    if (info_type == INFO_ERROR)
4054
4159
    {
4055
4160
      (void) fflush(file);
4056
 
      fprintf(file,"ERROR");
 
4161
      fprintf(file,_("ERROR"));
4057
4162
      if (error)
4058
4163
      {
4059
4164
        if (sqlstate)
4061
4166
        else
4062
4167
          (void) fprintf(file," %d",error);
4063
4168
      }
4064
 
      if (status.query_start_line && line_numbers)
 
4169
      if (status.getQueryStartLine() && line_numbers)
4065
4170
      {
4066
 
        (void) fprintf(file," at line %"PRIu32,status.query_start_line);
4067
 
        if (status.file_name)
4068
 
          (void) fprintf(file," in file: '%s'", status.file_name);
 
4171
        (void) fprintf(file," at line %"PRIu32,status.getQueryStartLine());
 
4172
        if (status.getFileName())
 
4173
          (void) fprintf(file," in file: '%s'", status.getFileName());
4069
4174
      }
4070
4175
      (void) fprintf(file,": %s\n",str);
4071
4176
      (void) fflush(file);
4096
4201
      if (error)
4097
4202
      {
4098
4203
        if (sqlstate)
4099
 
          (void) tee_fprintf(file, "ERROR %d (%s): ", error, sqlstate);
 
4204
          (void) tee_fprintf(file, _("ERROR %d (%s): "), error, sqlstate);
4100
4205
        else
4101
 
          (void) tee_fprintf(file, "ERROR %d: ", error);
 
4206
          (void) tee_fprintf(file, _("ERROR %d: "), error);
4102
4207
      }
4103
4208
      else
4104
 
        tee_puts("ERROR: ", file);
 
4209
        tee_puts(_("ERROR: "), file);
4105
4210
    }
4106
4211
    else
4107
4212
      vidattr(A_BOLD);
4140
4245
{
4141
4246
  const char *start=  buffer->c_str();
4142
4247
  const char *end= start + (buffer->length());
4143
 
  while (start < end && !my_isgraph(charset_info,end[-1]))
 
4248
  while (start < end && !isgraph(end[-1]))
4144
4249
    end--;
4145
4250
  uint32_t pos_to_truncate= (end-start);
4146
4251
  if (buffer->length() > pos_to_truncate)
4234
4339
    tmp_buff_str << tmp;
4235
4340
 
4236
4341
    if (tmp > 1)
4237
 
      tmp_buff_str << " hours ";
 
4342
      tmp_buff_str << _(" hours ");
4238
4343
    else
4239
 
      tmp_buff_str << " hour ";
 
4344
      tmp_buff_str << _(" hour ");
4240
4345
  }
4241
4346
  if (sec >= 60.0)
4242
4347
  {
4243
4348
    tmp=(uint32_t) floor(sec/60.0);
4244
4349
    sec-=60.0*tmp;
4245
 
    tmp_buff_str << tmp << " min ";
 
4350
    tmp_buff_str << tmp << _(" min ");
4246
4351
  }
4247
4352
  if (part_second)
4248
4353
    tmp_buff_str.precision(2);
4249
4354
  else
4250
4355
    tmp_buff_str.precision(0);
4251
 
  tmp_buff_str << sec << " sec";
 
4356
  tmp_buff_str << sec << _(" sec");
4252
4357
  strcpy(buff, tmp_buff_str.str().c_str());
4253
4358
}
4254
4359
 
4279
4384
  struct tm *t = localtime(&lclock);
4280
4385
 
4281
4386
  /* parse thru the settings for the prompt */
4282
 
  for (char *c= current_prompt; *c; (void)*c++)
 
4387
  string::iterator c= current_prompt.begin();
 
4388
  while (c != current_prompt.end())
4283
4389
  {
4284
4390
    if (*c != PROMPT_CHAR)
4285
4391
    {
4286
 
      processed_prompt->append(c, 1);
 
4392
      processed_prompt->push_back(*c);
4287
4393
    }
4288
4394
    else
4289
4395
    {
4294
4400
      switch (*++c) {
4295
4401
      case '\0':
4296
4402
        // stop it from going beyond if ends with %
4297
 
        c--;
 
4403
        --c;
4298
4404
        break;
4299
4405
      case 'c':
4300
4406
        add_int_to_prompt(++prompt_counter);
4306
4412
          processed_prompt->append("not_connected");
4307
4413
        break;
4308
4414
      case 'd':
4309
 
        processed_prompt->append(current_db ? current_db : "(none)");
 
4415
        processed_prompt->append(not current_db.empty() ? current_db : "(none)");
4310
4416
        break;
4311
4417
      case 'h':
4312
4418
      {
4313
 
        const char *prompt;
4314
 
        prompt= connected ? drizzle_con_host(&con) : "not_connected";
 
4419
        const char *prompt= connected ? drizzle_con_host(&con) : "not_connected";
4315
4420
        if (strstr(prompt, "Localhost"))
4316
4421
          processed_prompt->append("localhost");
4317
4422
        else
4330
4435
          break;
4331
4436
        }
4332
4437
 
4333
 
        if (strcmp(drizzle_con_uds(&con), ""))
 
4438
        if (drizzle_con_uds(&con))
4334
4439
        {
4335
4440
          const char *pos=strrchr(drizzle_con_uds(&con),'/');
4336
4441
          processed_prompt->append(pos ? pos+1 : drizzle_con_uds(&con));
4343
4448
        if (!full_username)
4344
4449
          init_username();
4345
4450
        processed_prompt->append(full_username ? full_username :
4346
 
                                 (current_user ?  current_user : "(unknown)"));
 
4451
                                 (!current_user.empty() ?  current_user : "(unknown)"));
4347
4452
        break;
4348
4453
      case 'u':
4349
4454
        if (!full_username)
4350
4455
          init_username();
4351
4456
        processed_prompt->append(part_username ? part_username :
4352
 
                                 (current_user ?  current_user : "(unknown)"));
 
4457
                                 (!current_user.empty() ?  current_user : _("(unknown)")));
4353
4458
        break;
4354
4459
      case PROMPT_CHAR:
4355
4460
        {
4431
4536
        processed_prompt->append(delimiter_str);
4432
4537
        break;
4433
4538
      default:
4434
 
        processed_prompt->append(c, 1);
 
4539
        processed_prompt->push_back(*c);
4435
4540
      }
4436
4541
    }
 
4542
    ++c;
4437
4543
  }
4438
4544
  return processed_prompt->c_str();
4439
4545
}
4468
4574
{
4469
4575
  const char *ptr=strchr(line, ' ');
4470
4576
  if (ptr == NULL)
4471
 
    tee_fprintf(stdout, "Returning to default PROMPT of %s\n",
 
4577
    tee_fprintf(stdout, _("Returning to default PROMPT of %s\n"),
4472
4578
                default_prompt);
4473
4579
  prompt_counter = 0;
4474
4580
  char * tmpptr= strdup(ptr ? ptr+1 : default_prompt);
4475
4581
  if (tmpptr == NULL)
4476
 
    tee_fprintf(stdout, "Memory allocation error. Not changing prompt\n");
 
4582
    tee_fprintf(stdout, _("Memory allocation error. Not changing prompt\n"));
4477
4583
  else
4478
4584
  {
4479
 
    free(current_prompt);
 
4585
    current_prompt.erase();
4480
4586
    current_prompt= tmpptr;
4481
 
    tee_fprintf(stdout, "PROMPT set to '%s'\n", current_prompt);
 
4587
    tee_fprintf(stdout, _("PROMPT set to '%s'\n"), current_prompt.c_str());
4482
4588
  }
4483
4589
  return 0;
4484
4590
}