~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Monty Taylor
  • Date: 2010-07-19 05:06:59 UTC
  • mto: (1662.1.2 rollup)
  • mto: This revision was merged to the branch mainline in revision 1663.
  • Revision ID: mordred@inaugust.com-20100719050659-if3thz0k66m1jkaf
Backed out two bits that snuck in to the merge.

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
5
4
 *  Copyright (C) 2008 MySQL
6
5
 *
7
6
 *  This program is free software; you can redistribute it and/or modify
39
38
 
40
39
#include "client/get_password.h"
41
40
 
42
 
#include "boost/date_time/posix_time/posix_time.hpp"
 
41
#if TIME_WITH_SYS_TIME
 
42
# include <sys/time.h>
 
43
# include <time.h>
 
44
#else
 
45
# if HAVE_SYS_TIME_H
 
46
#  include <sys/time.h>
 
47
# else
 
48
#  include <time.h>
 
49
# endif
 
50
#endif
43
51
 
44
52
#include <cerrno>
45
53
#include <string>
52
60
#include <cassert>
53
61
#include <stdarg.h>
54
62
#include <math.h>
55
 
#include <memory>
56
63
#include "client/linebuffer.h"
57
64
#include <signal.h>
58
65
#include <sys/ioctl.h>
59
66
#include <drizzled/configmake.h>
60
67
#include "drizzled/utf8/utf8.h"
61
 
#include <cstdlib>
62
68
 
63
69
#if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H)
64
70
#include <curses.h>
150
156
#define vidattr(A) {}      // Can't get this to work
151
157
#endif
152
158
#include <boost/program_options.hpp>
153
 
#include <boost/scoped_ptr.hpp>
154
 
#include "drizzled/program_options/config_file.h"
155
159
 
156
160
using namespace std;
157
161
namespace po=boost::program_options;
158
 
namespace dpo=drizzled::program_options;
159
162
 
 
163
const string VER("14.14");
160
164
/* Don't try to make a nice table if the data is too big */
161
165
const uint32_t MAX_COLUMN_LENGTH= 1024;
162
166
 
171
175
 
172
176
  Status(int in_exit_status, 
173
177
         uint32_t in_query_start_line,
174
 
         char *in_file_name,
 
178
         char *in_file_name,
175
179
         LineBuffer *in_line_buff,
176
 
         bool in_batch,
177
 
         bool in_add_to_history)
 
180
         bool in_batch,
 
181
         bool in_add_to_history)
178
182
    :
179
183
    exit_status(in_exit_status),
180
184
    query_start_line(in_query_start_line),
184
188
    add_to_history(in_add_to_history)
185
189
    {}
186
190
 
187
 
  Status() :
188
 
    exit_status(0),
189
 
    query_start_line(0),
190
 
    file_name(NULL),
191
 
    line_buff(NULL),
192
 
    batch(false),        
193
 
    add_to_history(false)
194
 
  {}
 
191
  Status()
 
192
    :
 
193
    exit_status(),
 
194
    query_start_line(),
 
195
    file_name(),
 
196
    line_buff(),
 
197
    batch(),        
 
198
    add_to_history()
 
199
    {}
195
200
  
196
201
  int getExitStatus() const
197
202
  {
281
286
  connected= false, opt_raw_data= false, unbuffered= false,
282
287
  output_tables= false, opt_rehash= true, skip_updates= false,
283
288
  safe_updates= false, one_database= false,
284
 
  opt_shutdown= false, opt_ping= false,
 
289
  opt_compress= false, opt_shutdown= false, opt_ping= false,
285
290
  vertical= false, line_numbers= true, column_names= true,
286
291
  opt_nopager= true, opt_outfile= false, named_cmds= false,
287
292
  opt_nobeep= false, opt_reconnect= true,
289
294
  default_pager_set= false, opt_sigint_ignore= false,
290
295
  auto_vertical_output= false,
291
296
  show_warnings= false, executing_query= false, interrupted_query= false,
292
 
  use_drizzle_protocol= false, opt_local_infile;
 
297
  opt_mysql= false, opt_local_infile;
293
298
static uint32_t show_progress_size= 0;
294
299
static bool column_types_flag;
295
300
static bool preserve_comments= false;
314
319
  current_user,
315
320
  opt_verbose,
316
321
  current_password,
317
 
  opt_password,
318
 
  opt_protocol;
319
 
 
320
 
static const char* get_day_name(int day_of_week)
321
 
{
322
 
  switch(day_of_week)
323
 
  {
324
 
  case 0:
325
 
    return _("Sun");
326
 
  case 1:
327
 
    return _("Mon");
328
 
  case 2:
329
 
    return _("Tue");
330
 
  case 3:
331
 
    return _("Wed");
332
 
  case 4:
333
 
    return _("Thu");
334
 
  case 5:
335
 
    return _("Fri");
336
 
  case 6:
337
 
    return _("Sat");
338
 
  }
339
 
 
340
 
  return NULL;
341
 
}
342
 
 
343
 
static const char* get_month_name(int month)
344
 
{
345
 
  switch(month)
346
 
  {
347
 
  case 0:
348
 
    return _("Jan");
349
 
  case 1:
350
 
    return _("Feb");
351
 
  case 2:
352
 
    return _("Mar");
353
 
  case 3:
354
 
    return _("Apr");
355
 
  case 4:
356
 
    return _("May");
357
 
  case 5:
358
 
    return _("Jun");
359
 
  case 6:
360
 
    return _("Jul");
361
 
  case 7:
362
 
    return _("Aug");
363
 
  case 8:
364
 
    return _("Sep");
365
 
  case 9:
366
 
    return _("Oct");
367
 
  case 10:
368
 
    return _("Nov");
369
 
  case 11:
370
 
    return _("Dec");
371
 
  }
372
 
 
373
 
  return NULL;
374
 
}
375
 
 
 
322
  opt_password;
 
323
// TODO: Need to i18n these
 
324
static const char *day_names[]= {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
 
325
static const char *month_names[]= {"Jan","Feb","Mar","Apr","May","Jun","Jul",
 
326
                                  "Aug","Sep","Oct","Nov","Dec"};
376
327
/* @TODO: Remove this */
377
328
#define FN_REFLEN 512
378
329
 
385
336
static uint32_t delimiter_length= 1;
386
337
unsigned short terminal_width= 80;
387
338
 
388
 
int drizzleclient_real_query_for_lazy(const char *buf, size_t length,
 
339
int drizzleclient_real_query_for_lazy(const char *buf, int length,
389
340
                                      drizzle_result_st *result,
390
341
                                      uint32_t *error_code);
391
342
int drizzleclient_store_result_for_lazy(drizzle_result_st *result);
404
355
  com_help(string *str,const char*), com_clear(string *str,const char*),
405
356
  com_connect(string *str,const char*), com_status(string *str,const char*),
406
357
  com_use(string *str,const char*), com_source(string *str, const char*),
407
 
  com_shutdown(string *str,const char*),
408
358
  com_rehash(string *str, const char*), com_tee(string *str, const char*),
409
359
  com_notee(string *str, const char*),
410
360
  com_prompt(string *str, const char*), com_delimiter(string *str, const char*),
412
362
  com_nopager(string *str, const char*), com_pager(string *str, const char*);
413
363
 
414
364
static int read_and_execute(bool interactive);
415
 
static int sql_connect(const string &host, const string &database, const string &user, const string &password);
 
365
static int sql_connect(const string &host, const string &database, const string &user, const string &password,
 
366
                       uint32_t silent);
416
367
static const char *server_version_string(drizzle_con_st *con);
417
368
static int put_info(const char *str,INFO_TYPE info,uint32_t error,
418
369
                    const char *sql_state);
534
485
  Commands( "tee",    'T', com_tee,    1,
535
486
    N_("Set outfile [to_outfile]. Append everything into given outfile.") ),
536
487
  Commands( "use",    'u', com_use,    1,
537
 
    N_("Use another schema. Takes schema name as argument.") ),
538
 
  Commands( "shutdown",    'u', com_shutdown,    1,
539
 
    N_("Shutdown the instance you are connected too.") ),
 
488
    N_("Use another database. Takes database name as argument.") ),
540
489
  Commands( "warnings", 'W', com_warnings,  0,
541
490
    N_("Show warnings after every statement.") ),
542
491
  Commands( "nowarning", 'w', com_nowarnings, 0,
572
521
  Commands( "AUTO_INCREMENT", 0, 0, 0, ""),
573
522
  Commands( "AVG", 0, 0, 0, ""),
574
523
  Commands( "AVG_ROW_LENGTH", 0, 0, 0, ""),
 
524
  Commands( "BACKUP", 0, 0, 0, ""),
 
525
  Commands( "BDB", 0, 0, 0, ""),
575
526
  Commands( "BEFORE", 0, 0, 0, ""),
576
527
  Commands( "BEGIN", 0, 0, 0, ""),
 
528
  Commands( "BERKELEYDB", 0, 0, 0, ""),
577
529
  Commands( "BETWEEN", 0, 0, 0, ""),
578
530
  Commands( "BIGINT", 0, 0, 0, ""),
579
531
  Commands( "BINARY", 0, 0, 0, ""),
 
532
  Commands( "BINLOG", 0, 0, 0, ""),
580
533
  Commands( "BIT", 0, 0, 0, ""),
581
534
  Commands( "BLOB", 0, 0, 0, ""),
582
535
  Commands( "BOOL", 0, 0, 0, ""),
595
548
  Commands( "CHANGED", 0, 0, 0, ""),
596
549
  Commands( "CHAR", 0, 0, 0, ""),
597
550
  Commands( "CHARACTER", 0, 0, 0, ""),
 
551
  Commands( "CHARSET", 0, 0, 0, ""),
598
552
  Commands( "CHECK", 0, 0, 0, ""),
599
553
  Commands( "CHECKSUM", 0, 0, 0, ""),
 
554
  Commands( "CIPHER", 0, 0, 0, ""),
600
555
  Commands( "CLIENT", 0, 0, 0, ""),
601
556
  Commands( "CLOSE", 0, 0, 0, ""),
 
557
  Commands( "CODE", 0, 0, 0, ""),
602
558
  Commands( "COLLATE", 0, 0, 0, ""),
603
559
  Commands( "COLLATION", 0, 0, 0, ""),
604
560
  Commands( "COLUMN", 0, 0, 0, ""),
640
596
  Commands( "DEFAULT", 0, 0, 0, ""),
641
597
  Commands( "DEFINER", 0, 0, 0, ""),
642
598
  Commands( "DELAYED", 0, 0, 0, ""),
 
599
  Commands( "DELAY_KEY_WRITE", 0, 0, 0, ""),
643
600
  Commands( "DELETE", 0, 0, 0, ""),
644
601
  Commands( "DESC", 0, 0, 0, ""),
645
602
  Commands( "DESCRIBE", 0, 0, 0, ""),
 
603
  Commands( "DES_KEY_FILE", 0, 0, 0, ""),
646
604
  Commands( "DETERMINISTIC", 0, 0, 0, ""),
 
605
  Commands( "DIRECTORY", 0, 0, 0, ""),
647
606
  Commands( "DISABLE", 0, 0, 0, ""),
648
607
  Commands( "DISCARD", 0, 0, 0, ""),
649
608
  Commands( "DISTINCT", 0, 0, 0, ""),
650
609
  Commands( "DISTINCTROW", 0, 0, 0, ""),
651
610
  Commands( "DIV", 0, 0, 0, ""),
 
611
  Commands( "DO", 0, 0, 0, ""),
652
612
  Commands( "DOUBLE", 0, 0, 0, ""),
653
613
  Commands( "DROP", 0, 0, 0, ""),
 
614
  Commands( "DUAL", 0, 0, 0, ""),
654
615
  Commands( "DUMPFILE", 0, 0, 0, ""),
655
616
  Commands( "DUPLICATE", 0, 0, 0, ""),
656
617
  Commands( "DYNAMIC", 0, 0, 0, ""),
666
627
  Commands( "ERRORS", 0, 0, 0, ""),
667
628
  Commands( "ESCAPE", 0, 0, 0, ""),
668
629
  Commands( "ESCAPED", 0, 0, 0, ""),
 
630
  Commands( "EVENTS", 0, 0, 0, ""),
 
631
  Commands( "EXECUTE", 0, 0, 0, ""),
669
632
  Commands( "EXISTS", 0, 0, 0, ""),
670
633
  Commands( "EXIT", 0, 0, 0, ""),
 
634
  Commands( "EXPANSION", 0, 0, 0, ""),
671
635
  Commands( "EXPLAIN", 0, 0, 0, ""),
672
636
  Commands( "EXTENDED", 0, 0, 0, ""),
673
637
  Commands( "FALSE", 0, 0, 0, ""),
688
652
  Commands( "FRAC_SECOND", 0, 0, 0, ""),
689
653
  Commands( "FROM", 0, 0, 0, ""),
690
654
  Commands( "FULL", 0, 0, 0, ""),
 
655
  Commands( "FULLTEXT", 0, 0, 0, ""),
691
656
  Commands( "FUNCTION", 0, 0, 0, ""),
692
657
  Commands( "GLOBAL", 0, 0, 0, ""),
693
658
  Commands( "GRANT", 0, 0, 0, ""),
755
720
  Commands( "LOCKS", 0, 0, 0, ""),
756
721
  Commands( "LOGS", 0, 0, 0, ""),
757
722
  Commands( "LONG", 0, 0, 0, ""),
 
723
  Commands( "LONGTEXT", 0, 0, 0, ""),
758
724
  Commands( "LOOP", 0, 0, 0, ""),
 
725
  Commands( "LOW_PRIORITY", 0, 0, 0, ""),
 
726
  Commands( "MASTER", 0, 0, 0, ""),
 
727
  Commands( "MASTER_CONNECT_RETRY", 0, 0, 0, ""),
 
728
  Commands( "MASTER_HOST", 0, 0, 0, ""),
 
729
  Commands( "MASTER_LOG_FILE", 0, 0, 0, ""),
 
730
  Commands( "MASTER_LOG_POS", 0, 0, 0, ""),
 
731
  Commands( "MASTER_PASSWORD", 0, 0, 0, ""),
 
732
  Commands( "MASTER_PORT", 0, 0, 0, ""),
 
733
  Commands( "MASTER_SERVER_ID", 0, 0, 0, ""),
 
734
  Commands( "MASTER_SSL", 0, 0, 0, ""),
 
735
  Commands( "MASTER_SSL_CA", 0, 0, 0, ""),
 
736
  Commands( "MASTER_SSL_CAPATH", 0, 0, 0, ""),
 
737
  Commands( "MASTER_SSL_CERT", 0, 0, 0, ""),
 
738
  Commands( "MASTER_SSL_CIPHER", 0, 0, 0, ""),
 
739
  Commands( "MASTER_SSL_KEY", 0, 0, 0, ""),
 
740
  Commands( "MASTER_USER", 0, 0, 0, ""),
759
741
  Commands( "MATCH", 0, 0, 0, ""),
760
742
  Commands( "MAX_CONNECTIONS_PER_HOUR", 0, 0, 0, ""),
761
743
  Commands( "MAX_QUERIES_PER_HOUR", 0, 0, 0, ""),
763
745
  Commands( "MAX_UPDATES_PER_HOUR", 0, 0, 0, ""),
764
746
  Commands( "MAX_USER_CONNECTIONS", 0, 0, 0, ""),
765
747
  Commands( "MEDIUM", 0, 0, 0, ""),
 
748
  Commands( "MEDIUMTEXT", 0, 0, 0, ""),
766
749
  Commands( "MERGE", 0, 0, 0, ""),
767
750
  Commands( "MICROSECOND", 0, 0, 0, ""),
 
751
  Commands( "MIDDLEINT", 0, 0, 0, ""),
768
752
  Commands( "MIGRATE", 0, 0, 0, ""),
769
753
  Commands( "MINUTE", 0, 0, 0, ""),
770
754
  Commands( "MINUTE_MICROSECOND", 0, 0, 0, ""),
783
767
  Commands( "NAMES", 0, 0, 0, ""),
784
768
  Commands( "NATIONAL", 0, 0, 0, ""),
785
769
  Commands( "NATURAL", 0, 0, 0, ""),
 
770
  Commands( "NDB", 0, 0, 0, ""),
 
771
  Commands( "NDBCLUSTER", 0, 0, 0, ""),
786
772
  Commands( "NCHAR", 0, 0, 0, ""),
787
773
  Commands( "NEW", 0, 0, 0, ""),
788
774
  Commands( "NEXT", 0, 0, 0, ""),
789
775
  Commands( "NO", 0, 0, 0, ""),
790
776
  Commands( "NONE", 0, 0, 0, ""),
791
777
  Commands( "NOT", 0, 0, 0, ""),
 
778
  Commands( "NO_WRITE_TO_BINLOG", 0, 0, 0, ""),
792
779
  Commands( "NULL", 0, 0, 0, ""),
793
780
  Commands( "NUMERIC", 0, 0, 0, ""),
794
781
  Commands( "NVARCHAR", 0, 0, 0, ""),
795
782
  Commands( "OFFSET", 0, 0, 0, ""),
 
783
  Commands( "OLD_PASSWORD", 0, 0, 0, ""),
796
784
  Commands( "ON", 0, 0, 0, ""),
797
785
  Commands( "ONE", 0, 0, 0, ""),
798
786
  Commands( "ONE_SHOT", 0, 0, 0, ""),
809
797
  Commands( "PARTIAL", 0, 0, 0, ""),
810
798
  Commands( "PASSWORD", 0, 0, 0, ""),
811
799
  Commands( "PHASE", 0, 0, 0, ""),
 
800
  Commands( "POINT", 0, 0, 0, ""),
 
801
  Commands( "POLYGON", 0, 0, 0, ""),
812
802
  Commands( "PRECISION", 0, 0, 0, ""),
813
803
  Commands( "PREPARE", 0, 0, 0, ""),
814
804
  Commands( "PREV", 0, 0, 0, ""),
828
818
  Commands( "REDUNDANT", 0, 0, 0, ""),
829
819
  Commands( "REFERENCES", 0, 0, 0, ""),
830
820
  Commands( "REGEXP", 0, 0, 0, ""),
 
821
  Commands( "RELAY_LOG_FILE", 0, 0, 0, ""),
 
822
  Commands( "RELAY_LOG_POS", 0, 0, 0, ""),
 
823
  Commands( "RELAY_THREAD", 0, 0, 0, ""),
831
824
  Commands( "RELEASE", 0, 0, 0, ""),
832
825
  Commands( "RELOAD", 0, 0, 0, ""),
833
826
  Commands( "RENAME", 0, 0, 0, ""),
834
827
  Commands( "REPAIR", 0, 0, 0, ""),
835
828
  Commands( "REPEATABLE", 0, 0, 0, ""),
836
829
  Commands( "REPLACE", 0, 0, 0, ""),
 
830
  Commands( "REPLICATION", 0, 0, 0, ""),
837
831
  Commands( "REPEAT", 0, 0, 0, ""),
838
832
  Commands( "REQUIRE", 0, 0, 0, ""),
839
833
  Commands( "RESET", 0, 0, 0, ""),
872
866
  Commands( "SIMPLE", 0, 0, 0, ""),
873
867
  Commands( "SLAVE", 0, 0, 0, ""),
874
868
  Commands( "SNAPSHOT", 0, 0, 0, ""),
 
869
  Commands( "SMALLINT", 0, 0, 0, ""),
875
870
  Commands( "SOME", 0, 0, 0, ""),
876
871
  Commands( "SONAME", 0, 0, 0, ""),
877
872
  Commands( "SOUNDS", 0, 0, 0, ""),
920
915
  Commands( "TIMESTAMP", 0, 0, 0, ""),
921
916
  Commands( "TIMESTAMPADD", 0, 0, 0, ""),
922
917
  Commands( "TIMESTAMPDIFF", 0, 0, 0, ""),
 
918
  Commands( "TINYTEXT", 0, 0, 0, ""),
923
919
  Commands( "TO", 0, 0, 0, ""),
924
920
  Commands( "TRAILING", 0, 0, 0, ""),
925
921
  Commands( "TRANSACTION", 0, 0, 0, ""),
 
922
  Commands( "TRIGGER", 0, 0, 0, ""),
 
923
  Commands( "TRIGGERS", 0, 0, 0, ""),
926
924
  Commands( "TRUE", 0, 0, 0, ""),
927
925
  Commands( "TRUNCATE", 0, 0, 0, ""),
928
926
  Commands( "TYPE", 0, 0, 0, ""),
935
933
  Commands( "UNIQUE", 0, 0, 0, ""),
936
934
  Commands( "UNKNOWN", 0, 0, 0, ""),
937
935
  Commands( "UNLOCK", 0, 0, 0, ""),
 
936
  Commands( "UNSIGNED", 0, 0, 0, ""),
938
937
  Commands( "UNTIL", 0, 0, 0, ""),
939
938
  Commands( "UPDATE", 0, 0, 0, ""),
940
939
  Commands( "UPGRADE", 0, 0, 0, ""),
942
941
  Commands( "USE", 0, 0, 0, ""),
943
942
  Commands( "USER", 0, 0, 0, ""),
944
943
  Commands( "USER_RESOURCES", 0, 0, 0, ""),
 
944
  Commands( "USE_FRM", 0, 0, 0, ""),
945
945
  Commands( "USING", 0, 0, 0, ""),
946
946
  Commands( "UTC_DATE", 0, 0, 0, ""),
947
947
  Commands( "UTC_TIMESTAMP", 0, 0, 0, ""),
961
961
  Commands( "WITH", 0, 0, 0, ""),
962
962
  Commands( "WORK", 0, 0, 0, ""),
963
963
  Commands( "WRITE", 0, 0, 0, ""),
 
964
  Commands( "X509", 0, 0, 0, ""),
964
965
  Commands( "XOR", 0, 0, 0, ""),
965
966
  Commands( "XA", 0, 0, 0, ""),
966
967
  Commands( "YEAR", 0, 0, 0, ""),
969
970
  Commands( "ABS", 0, 0, 0, ""),
970
971
  Commands( "ACOS", 0, 0, 0, ""),
971
972
  Commands( "ADDDATE", 0, 0, 0, ""),
 
973
  Commands( "AES_ENCRYPT", 0, 0, 0, ""),
 
974
  Commands( "AES_DECRYPT", 0, 0, 0, ""),
972
975
  Commands( "AREA", 0, 0, 0, ""),
973
976
  Commands( "ASIN", 0, 0, 0, ""),
974
977
  Commands( "ASBINARY", 0, 0, 0, ""),
975
978
  Commands( "ASTEXT", 0, 0, 0, ""),
 
979
  Commands( "ASWKB", 0, 0, 0, ""),
 
980
  Commands( "ASWKT", 0, 0, 0, ""),
976
981
  Commands( "ATAN", 0, 0, 0, ""),
977
982
  Commands( "ATAN2", 0, 0, 0, ""),
978
983
  Commands( "BENCHMARK", 0, 0, 0, ""),
1038
1043
  Commands( "GROUP_UNIQUE_USERS", 0, 0, 0, ""),
1039
1044
  Commands( "HEX", 0, 0, 0, ""),
1040
1045
  Commands( "IFNULL", 0, 0, 0, ""),
 
1046
  Commands( "INET_ATON", 0, 0, 0, ""),
 
1047
  Commands( "INET_NTOA", 0, 0, 0, ""),
1041
1048
  Commands( "INSTR", 0, 0, 0, ""),
1042
1049
  Commands( "INTERIORRINGN", 0, 0, 0, ""),
1043
1050
  Commands( "INTERSECTS", 0, 0, 0, ""),
1053
1060
  Commands( "LEAST", 0, 0, 0, ""),
1054
1061
  Commands( "LENGTH", 0, 0, 0, ""),
1055
1062
  Commands( "LN", 0, 0, 0, ""),
 
1063
  Commands( "LINEFROMTEXT", 0, 0, 0, ""),
 
1064
  Commands( "LINEFROMWKB", 0, 0, 0, ""),
 
1065
  Commands( "LINESTRINGFROMTEXT", 0, 0, 0, ""),
 
1066
  Commands( "LINESTRINGFROMWKB", 0, 0, 0, ""),
1056
1067
  Commands( "LOAD_FILE", 0, 0, 0, ""),
1057
1068
  Commands( "LOCATE", 0, 0, 0, ""),
1058
1069
  Commands( "LOG", 0, 0, 0, ""),
1075
1086
  Commands( "MD5", 0, 0, 0, ""),
1076
1087
  Commands( "MID", 0, 0, 0, ""),
1077
1088
  Commands( "MIN", 0, 0, 0, ""),
 
1089
  Commands( "MLINEFROMTEXT", 0, 0, 0, ""),
 
1090
  Commands( "MLINEFROMWKB", 0, 0, 0, ""),
 
1091
  Commands( "MPOINTFROMTEXT", 0, 0, 0, ""),
 
1092
  Commands( "MPOINTFROMWKB", 0, 0, 0, ""),
 
1093
  Commands( "MPOLYFROMTEXT", 0, 0, 0, ""),
 
1094
  Commands( "MPOLYFROMWKB", 0, 0, 0, ""),
1078
1095
  Commands( "MONTHNAME", 0, 0, 0, ""),
 
1096
  Commands( "MULTILINESTRINGFROMTEXT", 0, 0, 0, ""),
 
1097
  Commands( "MULTILINESTRINGFROMWKB", 0, 0, 0, ""),
 
1098
  Commands( "MULTIPOINTFROMTEXT", 0, 0, 0, ""),
 
1099
  Commands( "MULTIPOINTFROMWKB", 0, 0, 0, ""),
 
1100
  Commands( "MULTIPOLYGONFROMTEXT", 0, 0, 0, ""),
 
1101
  Commands( "MULTIPOLYGONFROMWKB", 0, 0, 0, ""),
1079
1102
  Commands( "NAME_CONST", 0, 0, 0, ""),
1080
1103
  Commands( "NOW", 0, 0, 0, ""),
1081
1104
  Commands( "NULLIF", 0, 0, 0, ""),
 
1105
  Commands( "NUMINTERIORRINGS", 0, 0, 0, ""),
1082
1106
  Commands( "NUMPOINTS", 0, 0, 0, ""),
1083
1107
  Commands( "OCTET_LENGTH", 0, 0, 0, ""),
1084
1108
  Commands( "OCT", 0, 0, 0, ""),
1087
1111
  Commands( "PERIOD_ADD", 0, 0, 0, ""),
1088
1112
  Commands( "PERIOD_DIFF", 0, 0, 0, ""),
1089
1113
  Commands( "PI", 0, 0, 0, ""),
 
1114
  Commands( "POINTFROMTEXT", 0, 0, 0, ""),
 
1115
  Commands( "POINTFROMWKB", 0, 0, 0, ""),
1090
1116
  Commands( "POINTN", 0, 0, 0, ""),
 
1117
  Commands( "POLYFROMTEXT", 0, 0, 0, ""),
 
1118
  Commands( "POLYFROMWKB", 0, 0, 0, ""),
 
1119
  Commands( "POLYGONFROMTEXT", 0, 0, 0, ""),
 
1120
  Commands( "POLYGONFROMWKB", 0, 0, 0, ""),
1091
1121
  Commands( "POSITION", 0, 0, 0, ""),
1092
1122
  Commands( "POW", 0, 0, 0, ""),
1093
1123
  Commands( "POWER", 0, 0, 0, ""),
1165
1195
static void print_tab_data(drizzle_result_st *result);
1166
1196
static void print_table_data_vertically(drizzle_result_st *result);
1167
1197
static void print_warnings(uint32_t error_code);
1168
 
static boost::posix_time::ptime start_timer(void);
1169
 
static void end_timer(boost::posix_time::ptime, string &buff);
1170
 
static void drizzle_end_timer(boost::posix_time::ptime, string &buff);
1171
 
static void nice_time(boost::posix_time::time_duration duration, string &buff);
 
1198
static uint32_t start_timer(void);
 
1199
static void end_timer(uint32_t start_time,char *buff);
 
1200
static void drizzle_end_timer(uint32_t start_time,char *buff);
 
1201
static void nice_time(double sec,char *buff,bool part_second);
1172
1202
extern "C" void drizzle_end(int sig);
1173
1203
extern "C" void handle_sigint(int sig);
1174
1204
#if defined(HAVE_TERMIOS_H) && defined(GWINSZ_IN_SYS_IOCTL)
1190
1220
 
1191
1221
  if (verbose)
1192
1222
  {
1193
 
    printf(_("shutting down drizzled"));
 
1223
    printf("shutting down drizzled");
1194
1224
    if (opt_drizzle_port > 0)
1195
 
      printf(_(" on port %d"), opt_drizzle_port);
 
1225
      printf(" on port %d", opt_drizzle_port);
1196
1226
    printf("... ");
1197
1227
  }
1198
1228
 
1201
1231
  {
1202
1232
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
1203
1233
    {
1204
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
 
1234
      fprintf(stderr, "shutdown failed; error: '%s'",
1205
1235
              drizzle_result_error(&result));
1206
1236
      drizzle_result_free(&result);
1207
1237
    }
1208
1238
    else
1209
1239
    {
1210
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
 
1240
      fprintf(stderr, "shutdown failed; error: '%s'",
1211
1241
              drizzle_con_error(&con));
1212
1242
    }
1213
1243
    return false;
1216
1246
  drizzle_result_free(&result);
1217
1247
 
1218
1248
  if (verbose)
1219
 
    printf(_("done\n"));
 
1249
    printf("done\n");
1220
1250
 
1221
1251
  return true;
1222
1252
}
1237
1267
  if (drizzle_ping(&con, &result, &ret) != NULL && ret == DRIZZLE_RETURN_OK)
1238
1268
  {
1239
1269
    if (opt_silent < 2)
1240
 
      printf(_("drizzled is alive\n"));
 
1270
      printf("drizzled is alive\n");
1241
1271
  }
1242
1272
  else
1243
1273
  {
1244
1274
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
1245
1275
    {
1246
 
      fprintf(stderr, _("ping failed; error: '%s'"),
 
1276
      fprintf(stderr, "ping failed; error: '%s'",
1247
1277
              drizzle_result_error(&result));
1248
1278
      drizzle_result_free(&result);
1249
1279
    }
1250
1280
    else
1251
1281
    {
1252
 
      fprintf(stderr, _("drizzled won't answer to ping, error: '%s'"),
 
1282
      fprintf(stderr, "drizzled won't answer to ping, error: '%s'",
1253
1283
              drizzle_con_error(&con));
1254
1284
    }
1255
1285
    return false;
1298
1328
  opt_connect_timeout= 0;
1299
1329
  if (in_connect_timeout > 3600*12)
1300
1330
  {
1301
 
    cout << _("Error: Invalid Value for connect_timeout"); 
 
1331
    cout<<N_("Error: Invalid Value for connect_timeout"); 
1302
1332
    exit(-1);
1303
1333
  }
1304
1334
  opt_connect_timeout= in_connect_timeout;
1307
1337
static void check_max_input_line(uint32_t in_max_input_line)
1308
1338
{
1309
1339
  opt_max_input_line= 0;
1310
 
  if (in_max_input_line < 4096 || in_max_input_line > (int64_t)2*1024L*1024L*1024L)
 
1340
  if (in_max_input_line<4096 || in_max_input_line>(int64_t)2*1024L*1024L*1024L)
1311
1341
  {
1312
 
    cout << _("Error: Invalid Value for max_input_line");
 
1342
    cout<<N_("Error: Invalid Value for max_input_line");
1313
1343
    exit(-1);
1314
1344
  }
1315
 
  opt_max_input_line= in_max_input_line - (in_max_input_line % 1024);
 
1345
  opt_max_input_line= in_max_input_line/1024;
 
1346
  opt_max_input_line*=1024;
1316
1347
}
1317
1348
 
1318
1349
int main(int argc,char *argv[])
1319
1350
{
1320
1351
try
1321
1352
{
1322
 
 
1323
1353
#if defined(ENABLE_NLS)
1324
1354
# if defined(HAVE_LOCALE_H)
1325
1355
  setlocale(LC_ALL, "");
1326
1356
# endif
1327
 
  bindtextdomain("drizzle7", LOCALEDIR);
1328
 
  textdomain("drizzle7");
 
1357
  bindtextdomain("drizzle", LOCALEDIR);
 
1358
  textdomain("drizzle");
1329
1359
#endif
1330
1360
 
1331
 
  po::options_description commandline_options(_("Options used only in command line"));
 
1361
  po::options_description commandline_options("Options used only in command line");
1332
1362
  commandline_options.add_options()
1333
 
  ("help,?",_("Displays this help and exit."))
1334
 
  ("batch,B",_("Don't use history file. Disable interactive behavior. (Enables --silent)"))
 
1363
  ("help,?",N_("Displays this help and exit."))
 
1364
  ("batch,B",N_("Don't use history file. Disable interactive behavior. (Enables --silent)"))
1335
1365
  ("column-type-info", po::value<bool>(&column_types_flag)->default_value(false)->zero_tokens(),
1336
 
  _("Display column type information."))
 
1366
  N_("Display column type information."))
1337
1367
  ("comments,c", po::value<bool>(&preserve_comments)->default_value(false)->zero_tokens(),
1338
 
  _("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"))
 
1368
  N_("Preserve comments. Send comments to the server. The default is --skip-comments (discard comments), enable with --comments"))
 
1369
  ("compress,C", po::value<bool>(&opt_compress)->default_value(false)->zero_tokens(),
 
1370
  N_("Use compression in server/client protocol."))  
1339
1371
  ("vertical,E", po::value<bool>(&vertical)->default_value(false)->zero_tokens(),
1340
 
  _("Print the output of a query (rows) vertically."))
 
1372
  N_("Print the output of a query (rows) vertically."))
1341
1373
  ("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
1342
 
  _("Continue even if we get an sql error."))
 
1374
  N_("Continue even if we get an sql error."))
1343
1375
  ("named-commands,G", po::value<bool>(&named_cmds)->default_value(false)->zero_tokens(),
1344
 
  _("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."))
 
1376
  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."))
 
1377
  ("no-named-commands,g",
 
1378
  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."))
 
1379
  ("ignore-spaces,i", N_("Ignore space after function names."))
1345
1380
  ("no-beep,b", po::value<bool>(&opt_nobeep)->default_value(false)->zero_tokens(),
1346
 
  _("Turn off beep on error."))
1347
 
  ("disable-line-numbers", _("Do not write line numbers for errors."))
1348
 
  ("disable-column-names", _("Do not write column names in results."))
 
1381
  N_("Turn off beep on error."))
 
1382
  ("line-numbers", po::value<bool>(&line_numbers)->default_value(true)->zero_tokens(),
 
1383
  N_("Write line numbers for errors."))
 
1384
  ("skip-line-numbers,L", 
 
1385
  N_("Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead."))
 
1386
  ("column-name", po::value<bool>(&column_names)->default_value(true)->zero_tokens(),
 
1387
  N_("Write column names in results."))
1349
1388
  ("skip-column-names,N", 
1350
 
  _("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."))
 
1389
  N_("Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead."))
1351
1390
  ("set-variable,O", po::value<string>(),
1352
 
  _("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."))
 
1391
  N_("Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value."))
1353
1392
  ("table,t", po::value<bool>(&output_tables)->default_value(false)->zero_tokens(),
1354
 
  _("Output in table format.")) 
1355
 
  ("safe-updates,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
1356
 
  _("Only allow UPDATE and DELETE that uses keys."))
1357
 
  ("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(false)->zero_tokens(),
1358
 
  _("Synonym for option --safe-updates, -U."))
 
1393
  N_("Output in table format.")) 
 
1394
  ("safe-updates,U", po::value<bool>(&safe_updates)->default_value(0)->zero_tokens(),
 
1395
  N_("Only allow UPDATE and DELETE that uses keys."))
 
1396
  ("i-am-a-dummy,U", po::value<bool>(&safe_updates)->default_value(0)->zero_tokens(),
 
1397
  N_("Synonym for option --safe-updates, -U."))
1359
1398
  ("verbose,v", po::value<string>(&opt_verbose)->default_value(""),
1360
 
  _("-v vvv implies that verbose= 3, Used to specify verbose"))
1361
 
  ("version,V", _("Output version information and exit."))
 
1399
  N_("-v vvv implies that verbose= 3, Used to specify verbose"))
 
1400
  ("version,V", N_("Output version information and exit."))
1362
1401
  ("secure-auth", po::value<bool>(&opt_secure_auth)->default_value(false)->zero_tokens(),
1363
 
  _("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"))
 
1402
  N_("Refuse client connecting to server if it uses old (pre-4.1.1) protocol"))
1364
1403
  ("show-warnings", po::value<bool>(&show_warnings)->default_value(false)->zero_tokens(),
1365
 
  _("Show warnings after every statement."))
 
1404
  N_("Show warnings after every statement."))
1366
1405
  ("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(0),
1367
 
  _("Number of lines before each import progress report."))
 
1406
  N_("Number of lines before each import progress report."))
1368
1407
  ("ping", po::value<bool>(&opt_ping)->default_value(false)->zero_tokens(),
1369
 
  _("Ping the server to check if it's alive."))
 
1408
  N_("Ping the server to check if it's alive."))
1370
1409
  ("no-defaults", po::value<bool>()->default_value(false)->zero_tokens(),
1371
 
  _("Configuration file defaults are not used if no-defaults is set"))
 
1410
  N_("Configuration file defaults are not used if no-defaults is set"))
1372
1411
  ;
1373
1412
 
1374
 
  po::options_description drizzle_options(_("Options specific to the drizzle client"));
 
1413
  po::options_description drizzle_options("Options specific to the drizzle client");
1375
1414
  drizzle_options.add_options()
1376
 
  ("disable-auto-rehash,A",
1377
 
  _("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."))
 
1415
  ("auto-rehash", po::value<bool>(&opt_rehash)->default_value(true)->zero_tokens(),
 
1416
  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."))
 
1417
  ("no-auto-rehash,A",N_("No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of drizzle_st and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead."))
1378
1418
  ("auto-vertical-output", po::value<bool>(&auto_vertical_output)->default_value(false)->zero_tokens(),
1379
 
  _("Automatically switch to vertical output mode if the result is wider than the terminal width."))
 
1419
  N_("Automatically switch to vertical output mode if the result is wider than the terminal width."))
1380
1420
  ("database,D", po::value<string>(&current_db)->default_value(""),
1381
 
  _("Database to use."))
 
1421
  N_("Database to use."))
1382
1422
  ("default-character-set",po::value<string>(),
1383
 
  _("(not used)"))
 
1423
  N_("(not used)"))
1384
1424
  ("delimiter", po::value<string>(&delimiter_str)->default_value(";"),
1385
 
  _("Delimiter to be used."))
 
1425
  N_("Delimiter to be used."))
1386
1426
  ("execute,e", po::value<string>(),
1387
 
  _("Execute command and quit. (Disables --force and history file)"))
 
1427
  N_("Execute command and quit. (Disables --force and history file)"))
1388
1428
  ("local-infile", po::value<bool>(&opt_local_infile)->default_value(false)->zero_tokens(),
1389
 
  _("Enable LOAD DATA LOCAL INFILE."))
 
1429
  N_("Enable/disable LOAD DATA LOCAL INFILE."))
1390
1430
  ("unbuffered,n", po::value<bool>(&unbuffered)->default_value(false)->zero_tokens(),
1391
 
  _("Flush buffer after each query."))
 
1431
  N_("Flush buffer after each query."))
1392
1432
  ("sigint-ignore", po::value<bool>(&opt_sigint_ignore)->default_value(false)->zero_tokens(),
1393
 
  _("Ignore SIGINT (CTRL-C)"))
 
1433
  N_("Ignore SIGINT (CTRL-C)"))
1394
1434
  ("one-database,o", po::value<bool>(&one_database)->default_value(false)->zero_tokens(),
1395
 
  _("Only update the default database. This is useful for skipping updates to other database in the update log."))
 
1435
  N_("Only update the default database. This is useful for skipping updates to other database in the update log."))
1396
1436
  ("pager", po::value<string>(),
1397
 
  _("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."))
 
1437
  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."))
1398
1438
  ("disable-pager", po::value<bool>(&opt_nopager)->default_value(false)->zero_tokens(),
1399
 
  _("Disable pager and print to stdout. See interactive help (\\h) also."))
 
1439
  N_("Disable pager and print to stdout. See interactive help (\\h) also."))
1400
1440
  ("prompt", po::value<string>(&current_prompt)->default_value(""),  
1401
 
  _("Set the drizzle prompt to this value."))
 
1441
  N_("Set the drizzle prompt to this value."))
1402
1442
  ("quick,q", po::value<bool>(&quick)->default_value(false)->zero_tokens(),
1403
 
  _("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."))
 
1443
  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."))
1404
1444
  ("raw,r", po::value<bool>(&opt_raw_data)->default_value(false)->zero_tokens(),
1405
 
  _("Write fields without conversion. Used with --batch.")) 
1406
 
  ("disable-reconnect", _("Do not reconnect if the connection is lost."))
1407
 
  ("shutdown", po::value<bool>()->zero_tokens(),
1408
 
  _("Shutdown the server"))
1409
 
  ("silent,s", _("Be more silent. Print results with a tab as separator, each row on new line."))
 
1445
  N_("Write fields without conversion. Used with --batch.")) 
 
1446
  ("reconnect", po::value<bool>(&opt_reconnect)->default_value(true)->zero_tokens(),
 
1447
  N_("Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default."))
 
1448
  ("shutdown", po::value<bool>(&opt_shutdown)->default_value(false)->zero_tokens(),
 
1449
  N_("Shutdown the server"))
 
1450
  ("silent,s", N_("Be more silent. Print results with a tab as separator, each row on new line."))
1410
1451
  ("tee", po::value<string>(),
1411
 
  _("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."))
 
1452
  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."))
1412
1453
  ("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(), 
1413
 
  _("Disable outfile. See interactive help (\\h) also."))
1414
 
  ("connect-timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value),
1415
 
  _("Number of seconds before connection timeout."))
1416
 
  ("max-input-line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line),
1417
 
  _("Max length of input line"))
1418
 
  ("select-limit", po::value<uint32_t>(&select_limit)->default_value(1000L),
1419
 
  _("Automatic limit for SELECT when using --safe-updates"))
1420
 
  ("max-join-size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
1421
 
  _("Automatic limit for rows in a join when using --safe-updates"))
 
1454
  N_("Disable outfile. See interactive help (\\h) also."))
 
1455
  ("wait,w", N_("Wait and retry if connection is down."))
 
1456
  ("connect_timeout", po::value<uint32_t>(&opt_connect_timeout)->default_value(0)->notifier(&check_timeout_value),
 
1457
  N_("Number of seconds before connection timeout."))
 
1458
  ("max_input_line", po::value<uint32_t>(&opt_max_input_line)->default_value(16*1024L*1024L)->notifier(&check_max_input_line),
 
1459
  N_("Max length of input line"))
 
1460
  ("select_limit", po::value<uint32_t>(&select_limit)->default_value(1000L),
 
1461
  N_("Automatic limit for SELECT when using --safe-updates"))
 
1462
  ("max_join_size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
 
1463
  N_("Automatic limit for rows in a join when using --safe-updates"))
1422
1464
  ;
1423
1465
 
1424
 
  po::options_description client_options(_("Options specific to the client"));
 
1466
  po::options_description client_options("Options specific to the client");
1425
1467
  client_options.add_options()
 
1468
  ("mysql,m", po::value<bool>(&opt_mysql)->default_value(true)->zero_tokens(),
 
1469
  N_("Use MySQL Protocol."))
1426
1470
  ("host,h", po::value<string>(&current_host)->default_value("localhost"),
1427
 
  _("Connect to host"))
 
1471
  N_("Connect to host"))
1428
1472
  ("password,P", po::value<string>(&current_password)->default_value(PASSWORD_SENTINEL),
1429
 
  _("Password to use when connecting to server. If password is not given it's asked from the tty."))
 
1473
  N_("Password to use when connecting to server. If password is not given it's asked from the tty."))
1430
1474
  ("port,p", po::value<uint32_t>()->default_value(0),
1431
 
  _("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
1432
 
#ifdef DRIZZLE_ADMIN_TOOL
1433
 
  ("user,u", po::value<string>(&current_user)->default_value("root"),
1434
 
#else
 
1475
  N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
1435
1476
  ("user,u", po::value<string>(&current_user)->default_value(""),
1436
 
#endif
1437
 
  _("User for login if not current user."))
1438
 
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
1439
 
  _("The protocol of connection (mysql or drizzle)."))
 
1477
  N_("User for login if not current user."))
 
1478
  ("protocol",po::value<string>(),
 
1479
  N_("The protocol of connection (tcp,socket,pipe,memory)."))
1440
1480
  ;
1441
1481
 
1442
 
  po::options_description long_options(_("Allowed Options"));
 
1482
  po::options_description long_options("Allowed Options");
1443
1483
  long_options.add(commandline_options).add(drizzle_options).add(client_options);
1444
1484
 
1445
1485
  std::string system_config_dir_drizzle(SYSCONFDIR); 
1448
1488
  std::string system_config_dir_client(SYSCONFDIR); 
1449
1489
  system_config_dir_client.append("/drizzle/client.cnf");
1450
1490
 
1451
 
  std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
1452
 
 
1453
 
  if (user_config_dir.compare(0, 2, "~/") == 0)
1454
 
  {
1455
 
    char *homedir;
1456
 
    homedir= getenv("HOME");
1457
 
    if (homedir != NULL)
1458
 
      user_config_dir.replace(0, 1, homedir);
1459
 
  }
1460
 
 
1461
1491
  po::variables_map vm;
1462
1492
 
1463
1493
  po::positional_options_description p;
1464
1494
  p.add("database", 1);
1465
1495
 
1466
 
  // Disable allow_guessing
1467
 
  int style = po::command_line_style::default_style & ~po::command_line_style::allow_guessing;
1468
 
 
1469
1496
  po::store(po::command_line_parser(argc, argv).options(long_options).
1470
 
            style(style).positional(p).extra_parser(parse_password_arg).run(),
1471
 
            vm);
 
1497
            positional(p).extra_parser(parse_password_arg).run(), vm);
1472
1498
 
1473
1499
  if (! vm["no-defaults"].as<bool>())
1474
1500
  {
1475
 
    std::string user_config_dir_drizzle(user_config_dir);
1476
 
    user_config_dir_drizzle.append("/drizzle/drizzle.cnf"); 
1477
 
 
1478
 
    std::string user_config_dir_client(user_config_dir);
1479
 
    user_config_dir_client.append("/drizzle/client.cnf");
1480
 
 
1481
 
    ifstream user_drizzle_ifs(user_config_dir_drizzle.c_str());
1482
 
    po::store(dpo::parse_config_file(user_drizzle_ifs, drizzle_options), vm);
1483
 
 
1484
 
    ifstream user_client_ifs(user_config_dir_client.c_str());
1485
 
    po::store(dpo::parse_config_file(user_client_ifs, client_options), vm);
1486
 
 
 
1501
    ifstream user_drizzle_ifs("~/.drizzle/drizzle.cnf");
 
1502
    po::store(parse_config_file(user_drizzle_ifs, drizzle_options), vm);
 
1503
 
1487
1504
    ifstream system_drizzle_ifs(system_config_dir_drizzle.c_str());
1488
 
    store(dpo::parse_config_file(system_drizzle_ifs, drizzle_options), vm);
 
1505
    store(parse_config_file(system_drizzle_ifs, drizzle_options), vm);
 
1506
 
 
1507
    ifstream user_client_ifs("~/.drizzle/client.cnf");
 
1508
    po::store(parse_config_file(user_client_ifs, client_options), vm);
1489
1509
 
1490
1510
    ifstream system_client_ifs(system_config_dir_client.c_str());
1491
 
    po::store(dpo::parse_config_file(system_client_ifs, client_options), vm);
 
1511
    po::store(parse_config_file(system_client_ifs, client_options), vm);
1492
1512
  }
1493
1513
 
1494
1514
  po::notify(vm);
1495
1515
 
1496
 
#ifdef DRIZZLE_ADMIN_TOOL
1497
 
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1498
 
                         getenv("DRIZZLE_PS1") :
1499
 
                         "drizzleadmin> ");
1500
 
#else
1501
1516
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1502
1517
                         getenv("DRIZZLE_PS1") :
1503
1518
                         "drizzle> ");
1504
 
#endif
1505
1519
  if (default_prompt == NULL)
1506
1520
  {
1507
1521
    fprintf(stderr, _("Memory allocation error while constructing initial "
1508
1522
                      "prompt. Aborting.\n"));
1509
1523
    exit(ENOMEM);
1510
1524
  }
1511
 
 
1512
 
  if (current_prompt.empty())
1513
 
    current_prompt= strdup(default_prompt);
1514
 
 
 
1525
  current_prompt= strdup(default_prompt);
1515
1526
  if (current_prompt.empty())
1516
1527
  {
1517
1528
    fprintf(stderr, _("Memory allocation error while constructing initial "
1536
1547
  if (! isatty(0) || ! isatty(1))
1537
1548
  {
1538
1549
    status.setBatch(1); opt_silent=1;
 
1550
    ignore_errors=0;
1539
1551
  }
1540
1552
  else
1541
1553
    status.setAddToHistory(1);
1555
1567
      close(stdout_fileno_copy);             /* Clean up dup(). */
1556
1568
  }
1557
1569
 
1558
 
  /* Inverted Booleans */
1559
 
 
1560
 
  line_numbers= (vm.count("disable-line-numbers")) ? false : true;
1561
 
  column_names= (vm.count("disable-column-names")) ? false : true;
1562
 
  opt_rehash= (vm.count("disable-auto-rehash")) ? false : true;
1563
 
  opt_reconnect= (vm.count("disable-reconnect")) ? false : true;
1564
 
 
1565
 
  /* Don't rehash with --shutdown */
1566
 
  if (vm.count("shutdown"))
1567
 
  {
1568
 
    opt_rehash= false;
1569
 
    opt_shutdown= true;
1570
 
  }
1571
 
 
1572
1570
  if (vm.count("delimiter"))
1573
1571
  {
1574
1572
    /* Check that delimiter does not contain a backslash */
1645
1643
 
1646
1644
  if (one_database)
1647
1645
    skip_updates= true;
1648
 
 
1649
 
  if (vm.count("protocol"))
1650
 
  {
1651
 
    std::transform(opt_protocol.begin(), opt_protocol.end(), 
1652
 
      opt_protocol.begin(), ::tolower);
1653
 
 
1654
 
    if (not opt_protocol.compare("mysql"))
1655
 
      use_drizzle_protocol=false;
1656
 
    else if (not opt_protocol.compare("drizzle"))
1657
 
      use_drizzle_protocol=true;
1658
 
    else
1659
 
    {
1660
 
      cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
1661
 
      exit(-1);
1662
 
    }
1663
 
  }
1664
 
 
 
1646
  
1665
1647
  if (vm.count("port"))
1666
1648
  {
1667
1649
    opt_drizzle_port= vm["port"].as<uint32_t>();
1712
1694
  }
1713
1695
  if (vm.count("silent"))
1714
1696
  {
1715
 
    opt_silent= 2;
 
1697
    opt_silent++;
 
1698
  }
 
1699
  if (vm.count("version"))
 
1700
  {
 
1701
    printf(_("drizzle  Ver %s Distrib %s, for %s-%s (%s) using readline %s\n"),
 
1702
           VER.c_str(), drizzle_version(),
 
1703
           HOST_VENDOR, HOST_OS, HOST_CPU,
 
1704
           rl_library_version);
 
1705
 
 
1706
    exit(0);
1716
1707
  }
1717
1708
  
1718
 
  if (vm.count("help") || vm.count("version"))
 
1709
  if (vm.count("help"))
1719
1710
  {
1720
 
    printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
1721
 
           drizzle_version(), VERSION,
 
1711
    printf(_("drizzle  Ver %s Distrib %s, for %s-%s (%s) using readline %s\n"),
 
1712
           VER.c_str(), drizzle_version(),
1722
1713
           HOST_VENDOR, HOST_OS, HOST_CPU,
1723
1714
           rl_library_version);
1724
 
    if (vm.count("version"))
1725
 
      exit(0);
1726
1715
    printf(_("Copyright (C) 2008 Sun Microsystems\n"
1727
1716
           "This software comes with ABSOLUTELY NO WARRANTY. "
1728
1717
           "This is free software,\n"
1729
1718
           "and you are welcome to modify and redistribute it "
1730
1719
           "under the GPL license\n"));
1731
 
    printf(_("Usage: drizzle [OPTIONS] [schema]\n"));
1732
 
    cout << long_options;
 
1720
    printf(_("Usage: drizzle [OPTIONS] [database]\n"));
 
1721
    cout<<long_options;
1733
1722
    exit(0);
1734
1723
  }
1735
1724
 
1740
1729
  }
1741
1730
 
1742
1731
  memset(&drizzle, 0, sizeof(drizzle));
1743
 
  if (sql_connect(current_host, current_db, current_user, opt_password))
 
1732
  if (sql_connect(current_host, current_db, current_user, opt_password,opt_silent))
1744
1733
  {
1745
1734
    quick= 1;          // Avoid history
1746
1735
    status.setExitStatus(1);
1778
1767
  /* call the SIGWINCH handler to get the default term width */
1779
1768
  window_resize(0);
1780
1769
#endif
1781
 
  std::vector<char> output_buff;
1782
 
  output_buff.resize(512);
1783
 
 
1784
 
  snprintf(&output_buff[0], output_buff.size(), 
1785
 
           _("Welcome to the Drizzle client..  Commands end with %s or \\g."), 
1786
 
           delimiter);
1787
 
 
1788
 
  put_info(&output_buff[0], INFO_INFO, 0, 0);
 
1770
 
 
1771
  put_info(_("Welcome to the Drizzle client..  Commands end with ; or \\g."),
 
1772
           INFO_INFO,0,0);
1789
1773
 
1790
1774
  glob_buffer= new string();
1791
1775
  glob_buffer->reserve(512);
1792
1776
 
1793
 
  snprintf(&output_buff[0], output_buff.size(),
1794
 
          _("Your Drizzle connection id is %u\nConnection protocol: %s\nServer version: %s\n"),
 
1777
  char * output_buff= (char *)malloc(512);
 
1778
  memset(output_buff, '\0', 512);
 
1779
 
 
1780
  sprintf(output_buff,
 
1781
          _("Your Drizzle connection id is %u\nServer version: %s\n"),
1795
1782
          drizzle_con_thread_id(&con),
1796
 
          opt_protocol.c_str(),
1797
1783
          server_version_string(&con));
1798
 
  put_info(&output_buff[0], INFO_INFO, 0, 0);
1799
 
 
 
1784
  put_info(output_buff, INFO_INFO, 0, 0);
1800
1785
 
1801
1786
  initialize_readline((char *)current_prompt.c_str());
1802
1787
  if (!status.getBatch() && !quick)
1846
1831
 
1847
1832
  catch(exception &err)
1848
1833
  {
1849
 
    cerr << _("Error:") << err.what() << endl;
 
1834
  cerr<<"Error:"<<err.what()<<endl;
1850
1835
  }
1851
1836
  return(0);        // Keep compiler happy
1852
1837
}
1868
1853
 
1869
1854
  if (sig >= 0)
1870
1855
    put_info(sig ? _("Aborted") : _("Bye"), INFO_RESULT,0,0);
1871
 
  delete glob_buffer;
1872
 
  delete processed_prompt;
 
1856
  if (glob_buffer)
 
1857
    delete glob_buffer;
 
1858
  if (processed_prompt)
 
1859
    delete processed_prompt;
1873
1860
  opt_password.erase();
1874
1861
  free(histfile);
1875
1862
  free(histfile_tmp);
1893
1880
void handle_sigint(int sig)
1894
1881
{
1895
1882
  char kill_buffer[40];
1896
 
  boost::scoped_ptr<drizzle_con_st> kill_drizzle(new drizzle_con_st);
 
1883
  drizzle_con_st kill_drizzle;
1897
1884
  drizzle_result_st res;
1898
1885
  drizzle_return_t ret;
1899
1886
 
1902
1889
    goto err;
1903
1890
  }
1904
1891
 
1905
 
  if (drizzle_con_add_tcp(&drizzle, kill_drizzle.get(), current_host.c_str(),
1906
 
    opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL,
1907
 
    use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
 
1892
  if (drizzle_con_add_tcp(&drizzle, &kill_drizzle, current_host.c_str(),
 
1893
                          opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL,
 
1894
                          opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
1908
1895
  {
1909
1896
    goto err;
1910
1897
  }
1913
1900
  sprintf(kill_buffer, "KILL /*!50000 QUERY */ %u",
1914
1901
          drizzle_con_thread_id(&con));
1915
1902
 
1916
 
  if (drizzle_query_str(kill_drizzle.get(), &res, kill_buffer, &ret) != NULL)
 
1903
  if (drizzle_query_str(&kill_drizzle, &res, kill_buffer, &ret) != NULL)
1917
1904
    drizzle_result_free(&res);
1918
1905
 
1919
 
  drizzle_con_free(kill_drizzle.get());
 
1906
  drizzle_con_free(&kill_drizzle);
1920
1907
  tee_fprintf(stdout, _("Query aborted by Ctrl+C\n"));
1921
1908
 
1922
1909
  interrupted_query= 1;
2387
2374
  {
2388
2375
    *out++='\n';
2389
2376
    uint32_t length=(uint32_t) (out-line);
2390
 
    if ((buffer->length() + length) > opt_max_input_line)
2391
 
    {
2392
 
      status.setExitStatus(1);
2393
 
      put_info(_("Not found a delimiter within max_input_line of input"), INFO_ERROR, 0, 0);
2394
 
      return 1;
2395
 
    }
2396
2377
    if ((!*ml_comment || preserve_comments))
2397
2378
      buffer->append(line, length);
2398
2379
  }
2582
2563
  drizzle_return_t ret;
2583
2564
  drizzle_result_st databases,tables,fields;
2584
2565
  drizzle_row_t database_row,table_row;
 
2566
  drizzle_column_st *sql_field;
2585
2567
  string tmp_str, tmp_str_lower;
2586
 
  std::string query;
2587
2568
 
2588
2569
  if (status.getBatch() || quick || current_db.empty())
2589
2570
    return;      // We don't need completion in batches
2603
2584
  /* hash Drizzle functions (to be implemented) */
2604
2585
 
2605
2586
  /* hash all database names */
2606
 
  if (drizzle_query_str(&con, &databases, "select schema_name from information_schema.schemata", &ret) != NULL)
 
2587
  if (drizzle_query_str(&con, &databases, "show databases", &ret) != NULL)
2607
2588
  {
2608
2589
    if (ret == DRIZZLE_RETURN_OK)
2609
2590
    {
2623
2604
    drizzle_result_free(&databases);
2624
2605
  }
2625
2606
 
2626
 
  query= "select table_name, column_name from information_schema.columns where table_schema='";
2627
 
  query.append(current_db);
2628
 
  query.append("' order by table_name");
2629
 
  
2630
 
  if (drizzle_query(&con, &fields, query.c_str(), query.length(),
2631
 
                    &ret) != NULL)
 
2607
  /* hash all table names */
 
2608
  if (drizzle_query_str(&con, &tables, "show tables", &ret) != NULL)
2632
2609
  {
2633
 
    if (ret == DRIZZLE_RETURN_OK &&
2634
 
        drizzle_result_buffer(&fields) == DRIZZLE_RETURN_OK)
 
2610
    if (ret != DRIZZLE_RETURN_OK)
 
2611
    {
 
2612
      drizzle_result_free(&tables);
 
2613
      return;
 
2614
    }
 
2615
 
 
2616
    if (drizzle_result_buffer(&tables) != DRIZZLE_RETURN_OK)
 
2617
      put_info(drizzle_error(&drizzle),INFO_INFO,0,0);
 
2618
    else
2635
2619
    {
2636
2620
      if (drizzle_result_row_count(&tables) > 0 && !opt_silent && write_info)
2637
2621
      {
2641
2625
                      "You can turn off this feature to get a quicker "
2642
2626
                      "startup with -A\n\n"));
2643
2627
      }
2644
 
 
2645
 
      std::string table_name;
2646
 
      while ((table_row=drizzle_row_next(&fields)))
 
2628
      while ((table_row=drizzle_row_next(&tables)))
2647
2629
      {
2648
 
        if (table_name.compare(table_row[0]) != 0)
2649
 
        {
2650
 
          tmp_str= table_row[0];
2651
 
          tmp_str_lower= lower_string(tmp_str);
2652
 
          completion_map[tmp_str_lower]= tmp_str;
2653
 
          table_name= table_row[0];
2654
 
        }
2655
2630
        tmp_str= table_row[0];
2656
 
        tmp_str.append(".");
2657
 
        tmp_str.append(table_row[1]);
2658
 
        tmp_str_lower= lower_string(tmp_str);
2659
 
        completion_map[tmp_str_lower]= tmp_str;
2660
 
 
2661
 
        tmp_str= table_row[1];
2662
 
        tmp_str_lower= lower_string(tmp_str);
2663
 
        completion_map[tmp_str_lower]= tmp_str;
2664
 
      }
2665
 
    }
2666
 
  }
2667
 
  drizzle_result_free(&fields);
 
2631
        tmp_str_lower= lower_string(tmp_str);
 
2632
        completion_map[tmp_str_lower]= tmp_str;
 
2633
      }
 
2634
    }
 
2635
  }
 
2636
  else
 
2637
    return;
 
2638
 
 
2639
  /* hash all field names, both with the table prefix and without it */
 
2640
  if (drizzle_result_row_count(&tables) == 0)
 
2641
  {
 
2642
    drizzle_result_free(&tables);
 
2643
    return;
 
2644
  }
 
2645
 
 
2646
  drizzle_row_seek(&tables, 0);
 
2647
 
 
2648
  while ((table_row=drizzle_row_next(&tables)))
 
2649
  {
 
2650
    string query;
 
2651
 
 
2652
    query.append("show fields in '");
 
2653
    query.append(table_row[0]);
 
2654
    query.append("'");
 
2655
    
 
2656
    if (drizzle_query(&con, &fields, query.c_str(), query.length(),
 
2657
                      &ret) != NULL)
 
2658
    {
 
2659
      if (ret == DRIZZLE_RETURN_OK &&
 
2660
          drizzle_result_buffer(&fields) == DRIZZLE_RETURN_OK)
 
2661
      {
 
2662
        while ((sql_field=drizzle_column_next(&fields)))
 
2663
        {
 
2664
          tmp_str=table_row[0];
 
2665
          tmp_str.append(".");
 
2666
          tmp_str.append(drizzle_column_name(sql_field));
 
2667
          tmp_str_lower= lower_string(tmp_str);
 
2668
          completion_map[tmp_str_lower]= tmp_str;
 
2669
 
 
2670
          tmp_str=drizzle_column_name(sql_field);
 
2671
          tmp_str_lower= lower_string(tmp_str);
 
2672
          completion_map[tmp_str_lower]= tmp_str;
 
2673
        }
 
2674
      }
 
2675
      drizzle_result_free(&fields);
 
2676
    }
 
2677
  }
 
2678
  drizzle_result_free(&tables);
2668
2679
  completion_iter= completion_map.begin();
2669
2680
}
2670
2681
 
2710
2721
 The different commands
2711
2722
***************************************************************************/
2712
2723
 
2713
 
int drizzleclient_real_query_for_lazy(const char *buf, size_t length,
 
2724
int drizzleclient_real_query_for_lazy(const char *buf, int length,
2714
2725
                                      drizzle_result_st *result,
2715
2726
                                      uint32_t *error_code)
2716
2727
{
2749
2760
    return 0;
2750
2761
 
2751
2762
  if (drizzle_con_error(&con)[0])
2752
 
  {
2753
 
    int ret= put_error(&con, result);
2754
 
    drizzle_result_free(result);
2755
 
    return ret;
2756
 
  }
 
2763
    return put_error(&con, result);
2757
2764
  return 0;
2758
2765
}
2759
2766
 
2762
2769
{
2763
2770
  register int i, j;
2764
2771
  char buff[32], *end;
2765
 
  std::vector<char> output_buff;
2766
 
  output_buff.resize(512);
2767
2772
 
2768
2773
  put_info(_("List of all Drizzle commands:"), INFO_INFO,0,0);
2769
2774
  if (!named_cmds)
2770
 
  {
2771
 
    snprintf(&output_buff[0], output_buff.size(),
2772
 
             _("Note that all text commands must be first on line and end with '%s' or \\g"),
2773
 
             delimiter);
2774
 
    put_info(&output_buff[0], INFO_INFO, 0, 0);
2775
 
  }
 
2775
    put_info(_("Note that all text commands must be first on line and end with ';'"),INFO_INFO,0,0);
2776
2776
  for (i = 0; commands[i].getName(); i++)
2777
2777
  {
2778
2778
    end= strcpy(buff, commands[i].getName());
2809
2809
com_go(string *buffer, const char *)
2810
2810
{
2811
2811
  char          buff[200]; /* about 110 chars used so far */
 
2812
  char          time_buff[52+3+1]; /* time max + space&parens + NUL */
2812
2813
  drizzle_result_st result;
2813
2814
  drizzle_return_t ret;
2814
 
  uint32_t      warnings= 0;
2815
 
  boost::posix_time::ptime timer;
 
2815
  uint32_t      timer, warnings= 0;
2816
2816
  uint32_t      error= 0;
2817
2817
  uint32_t      error_code= 0;
2818
2818
  int           err= 0;
2881
2881
        goto end;
2882
2882
    }
2883
2883
 
2884
 
    string time_buff("");
2885
2884
    if (verbose >= 3 || !opt_silent)
2886
2885
      drizzle_end_timer(timer,time_buff);
 
2886
    else
 
2887
      time_buff[0]= '\0';
2887
2888
 
2888
2889
    /* Every branch must truncate  buff . */
2889
2890
    if (drizzle_result_column_count(&result) > 0)
2934
2935
      if (warnings != 1)
2935
2936
        *pos++= 's';
2936
2937
    }
2937
 
    strcpy(pos, time_buff.c_str());
 
2938
    strcpy(pos, time_buff);
2938
2939
    put_info(buff,INFO_RESULT,0,0);
2939
2940
    if (strcmp(drizzle_result_info(&result), ""))
2940
2941
      put_info(drizzle_result_info(&result),INFO_RESULT,0,0);
2987
2988
  {
2988
2989
    if (!(PAGER= popen(pager.c_str(), "w")))
2989
2990
    {
2990
 
      tee_fprintf(stdout,_( "popen() failed! defaulting PAGER to stdout!\n"));
 
2991
      tee_fprintf(stdout, "popen() failed! defaulting PAGER to stdout!\n");
2991
2992
      PAGER= stdout;
2992
2993
    }
2993
2994
  }
3009
3010
    end_tee();
3010
3011
  if (!(new_outfile= fopen(file_name, "a")))
3011
3012
  {
3012
 
    tee_fprintf(stdout, _("Error logging to file '%s'\n"), file_name);
 
3013
    tee_fprintf(stdout, "Error logging to file '%s'\n", file_name);
3013
3014
    return;
3014
3015
  }
3015
3016
  OUTFILE = new_outfile;
3016
3017
  outfile.assign(file_name);
3017
 
  tee_fprintf(stdout, _("Logging to file '%s'\n"), file_name);
 
3018
  tee_fprintf(stdout, "Logging to file '%s'\n", file_name);
3018
3019
  opt_outfile= 1;
3019
3020
 
3020
3021
  return;
3098
3099
 
3099
3100
  while ((field = drizzle_column_next(result)))
3100
3101
  {
3101
 
    tee_fprintf(PAGER, _("Field %3u:  `%s`\n"
 
3102
    tee_fprintf(PAGER, "Field %3u:  `%s`\n"
3102
3103
                "Catalog:    `%s`\n"
3103
 
                "Schema:     `%s`\n"
 
3104
                "Database:   `%s`\n"
3104
3105
                "Table:      `%s`\n"
3105
3106
                "Org_table:  `%s`\n"
3106
3107
                "Type:       UTF-8\n"
3108
3109
                "Length:     %lu\n"
3109
3110
                "Max_length: %lu\n"
3110
3111
                "Decimals:   %u\n"
3111
 
                "Flags:      %s\n\n"),
 
3112
                "Flags:      %s\n\n",
3112
3113
                ++i,
3113
3114
                drizzle_column_name(field), drizzle_column_catalog(field),
3114
3115
                drizzle_column_db(field), drizzle_column_table(field),
3127
3128
  drizzle_row_t cur;
3128
3129
  drizzle_return_t ret;
3129
3130
  drizzle_column_st *field;
3130
 
  std::vector<bool> num_flag;
 
3131
  bool *num_flag;
3131
3132
  string separator;
3132
3133
 
3133
3134
  separator.reserve(256);
3134
3135
 
3135
 
  num_flag.resize(drizzle_result_column_count(result));
 
3136
  num_flag=(bool*) malloc(sizeof(bool)*drizzle_result_column_count(result));
3136
3137
  if (column_types_flag)
3137
3138
  {
3138
3139
    print_field_types(result);
3273
3274
      drizzle_row_free(result, cur);
3274
3275
  }
3275
3276
  tee_puts(separator.c_str(), PAGER);
 
3277
  free(num_flag);
3276
3278
}
3277
3279
 
3278
3280
/**
3565
3567
  {
3566
3568
    if (outfile.empty())
3567
3569
    {
3568
 
      printf(_("No previous outfile available, you must give a filename!\n"));
 
3570
      printf("No previous outfile available, you must give a filename!\n");
3569
3571
      return 0;
3570
3572
    }
3571
3573
    else if (opt_outfile)
3572
3574
    {
3573
 
      tee_fprintf(stdout, _("Currently logging to file '%s'\n"), outfile.c_str());
 
3575
      tee_fprintf(stdout, "Currently logging to file '%s'\n", outfile.c_str());
3574
3576
      return 0;
3575
3577
    }
3576
3578
    else
3590
3592
  end[0]= 0;
3591
3593
  if (end == file_name)
3592
3594
  {
3593
 
    printf(_("No outfile specified!\n"));
 
3595
    printf("No outfile specified!\n");
3594
3596
    return 0;
3595
3597
  }
3596
3598
  init_tee(file_name);
3603
3605
{
3604
3606
  if (opt_outfile)
3605
3607
    end_tee();
3606
 
  tee_fprintf(stdout, _("Outfile disabled.\n"));
 
3608
  tee_fprintf(stdout, "Outfile disabled.\n");
3607
3609
  return 0;
3608
3610
}
3609
3611
 
3626
3628
  /* Skip the spaces between the command and the argument */
3627
3629
  while (param && isspace(*param))
3628
3630
    param++;
3629
 
  if (!param || (*param == '\0')) // if pager was not given, use the default
 
3631
  if (!param || !strlen(param)) // if pager was not given, use the default
3630
3632
  {
3631
3633
    if (!default_pager_set)
3632
3634
    {
3633
 
      tee_fprintf(stdout, _("Default pager wasn't set, using stdout.\n"));
 
3635
      tee_fprintf(stdout, "Default pager wasn't set, using stdout.\n");
3634
3636
      opt_nopager=1;
3635
3637
      pager.assign("stdout");
3636
3638
      PAGER= stdout;
3650
3652
    default_pager.assign(pager_name);
3651
3653
  }
3652
3654
  opt_nopager=0;
3653
 
  tee_fprintf(stdout, _("PAGER set to '%s'\n"), pager.c_str());
 
3655
  tee_fprintf(stdout, "PAGER set to '%s'\n", pager.c_str());
3654
3656
  return 0;
3655
3657
}
3656
3658
 
3661
3663
  pager.assign("stdout");
3662
3664
  opt_nopager=1;
3663
3665
  PAGER= stdout;
3664
 
  tee_fprintf(stdout, _("PAGER set to stdout\n"));
 
3666
  tee_fprintf(stdout, "PAGER set to stdout\n");
3665
3667
  return 0;
3666
3668
}
3667
3669
 
3739
3741
  }
3740
3742
  else
3741
3743
    opt_rehash= 0;
3742
 
  error=sql_connect(current_host, current_db, current_user, opt_password);
 
3744
  error=sql_connect(current_host, current_db, current_user, opt_password,0);
3743
3745
  opt_rehash= save_rehash;
3744
3746
 
3745
3747
  if (connected)
3746
3748
  {
3747
 
    sprintf(buff, _("Connection id:    %u"), drizzle_con_thread_id(&con));
 
3749
    sprintf(buff,"Connection id:    %u",drizzle_con_thread_id(&con));
3748
3750
    put_info(buff,INFO_INFO,0,0);
3749
 
    sprintf(buff, _("Current schema: %.128s\n"),
3750
 
            !current_db.empty() ? current_db.c_str() : _("*** NONE ***"));
 
3751
    sprintf(buff,"Current database: %.128s\n",
 
3752
            !current_db.empty() ? current_db.c_str() : "*** NONE ***");
3751
3753
    put_info(buff,INFO_INFO,0,0);
3752
3754
  }
3753
3755
  return error;
3767
3769
  while (isspace(*line))
3768
3770
    line++;
3769
3771
  if (!(param = strchr(line, ' ')))    // Skip command name
3770
 
    return put_info(_("Usage: \\. <filename> | source <filename>"),
 
3772
    return put_info("Usage: \\. <filename> | source <filename>",
3771
3773
                    INFO_ERROR, 0,0);
3772
3774
  while (isspace(*param))
3773
3775
    param++;
3782
3784
  if (!(sql_file = fopen(source_name, "r")))
3783
3785
  {
3784
3786
    char buff[FN_REFLEN+60];
3785
 
    sprintf(buff, _("Failed to open file '%s', error: %d"), source_name,errno);
 
3787
    sprintf(buff,"Failed to open file '%s', error: %d", source_name,errno);
3786
3788
    return put_info(buff, INFO_ERROR, 0 ,0);
3787
3789
  }
3788
3790
 
3790
3792
  if (line_buff == NULL)
3791
3793
  {
3792
3794
    fclose(sql_file);
3793
 
    return put_info(_("Can't initialize LineBuffer"), INFO_ERROR, 0, 0);
 
3795
    return put_info("Can't initialize LineBuffer", INFO_ERROR, 0, 0);
3794
3796
  }
3795
3797
 
3796
3798
  /* Save old status */
3826
3828
 
3827
3829
  if (!tmp || !*tmp)
3828
3830
  {
3829
 
    put_info(_("DELIMITER must be followed by a 'delimiter' character or string"),
 
3831
    put_info("DELIMITER must be followed by a 'delimiter' character or string",
3830
3832
             INFO_ERROR, 0, 0);
3831
3833
    return 0;
3832
3834
  }
3834
3836
  {
3835
3837
    if (strstr(tmp, "\\"))
3836
3838
    {
3837
 
      put_info(_("DELIMITER cannot contain a backslash character"),
 
3839
      put_info("DELIMITER cannot contain a backslash character",
3838
3840
               INFO_ERROR, 0, 0);
3839
3841
      return 0;
3840
3842
    }
3859
3861
  tmp= get_arg(buff, 0);
3860
3862
  if (!tmp || !*tmp)
3861
3863
  {
3862
 
    put_info(_("USE must be followed by a schema name"), INFO_ERROR, 0, 0);
 
3864
    put_info("USE must be followed by a database name", INFO_ERROR, 0, 0);
3863
3865
    return 0;
3864
3866
  }
3865
3867
  /*
3927
3929
      build_completion_hash(opt_rehash, 1);
3928
3930
  }
3929
3931
 
3930
 
  put_info(_("Schema changed"),INFO_INFO, 0, 0);
 
3932
  put_info("Database changed",INFO_INFO, 0, 0);
3931
3933
  return 0;
3932
3934
}
3933
3935
 
3934
 
static int com_shutdown(string *, const char *)
3935
 
{
3936
 
  drizzle_result_st result;
3937
 
  drizzle_return_t ret;
3938
 
 
3939
 
  if (verbose)
3940
 
  {
3941
 
    printf(_("shutting down drizzled"));
3942
 
    if (opt_drizzle_port > 0)
3943
 
      printf(_(" on port %d"), opt_drizzle_port);
3944
 
    printf("... ");
3945
 
  }
3946
 
 
3947
 
  if (drizzle_shutdown(&con, &result, DRIZZLE_SHUTDOWN_DEFAULT,
3948
 
                       &ret) == NULL || ret != DRIZZLE_RETURN_OK)
3949
 
  {
3950
 
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
3951
 
    {
3952
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
3953
 
              drizzle_result_error(&result));
3954
 
      drizzle_result_free(&result);
3955
 
    }
3956
 
    else
3957
 
    {
3958
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
3959
 
              drizzle_con_error(&con));
3960
 
    }
3961
 
    return false;
3962
 
  }
3963
 
 
3964
 
  drizzle_result_free(&result);
3965
 
 
3966
 
  if (verbose)
3967
 
    printf(_("done\n"));
3968
 
 
3969
 
  return false;
3970
 
}
3971
 
 
3972
3936
static int
3973
3937
com_warnings(string *, const char *)
3974
3938
{
3975
3939
  show_warnings = 1;
3976
 
  put_info(_("Show warnings enabled."),INFO_INFO, 0, 0);
 
3940
  put_info("Show warnings enabled.",INFO_INFO, 0, 0);
3977
3941
  return 0;
3978
3942
}
3979
3943
 
3981
3945
com_nowarnings(string *, const char *)
3982
3946
{
3983
3947
  show_warnings = 0;
3984
 
  put_info(_("Show warnings disabled."),INFO_INFO, 0, 0);
 
3948
  put_info("Show warnings disabled.",INFO_INFO, 0, 0);
3985
3949
  return 0;
3986
3950
}
3987
3951
 
4048
4012
 
4049
4013
 
4050
4014
static int
4051
 
sql_connect(const string &host, const string &database, const string &user, const string &password)
 
4015
sql_connect(const string &host, const string &database, const string &user, const string &password,
 
4016
                 uint32_t silent)
4052
4017
{
4053
4018
  drizzle_return_t ret;
4054
4019
  if (connected)
4058
4023
    drizzle_free(&drizzle);
4059
4024
  }
4060
4025
  drizzle_create(&drizzle);
4061
 
 
4062
 
#ifdef DRIZZLE_ADMIN_TOOL
4063
 
  drizzle_con_options_t options= (drizzle_con_options_t) (DRIZZLE_CON_ADMIN | (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL));
4064
 
#else
4065
 
  drizzle_con_options_t options= (drizzle_con_options_t) (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
4066
 
#endif
4067
 
 
4068
 
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(),
4069
 
    opt_drizzle_port, (char *)user.c_str(),
4070
 
    (char *)password.c_str(), (char *)database.c_str(),
4071
 
    options) == NULL)
 
4026
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(), opt_drizzle_port, (char *)user.c_str(),
 
4027
                          (char *)password.c_str(), (char *)database.c_str(), opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
4072
4028
  {
4073
4029
    (void) put_error(&con, NULL);
4074
4030
    (void) fflush(stdout);
4097
4053
*/
4098
4054
  if ((ret= drizzle_con_connect(&con)) != DRIZZLE_RETURN_OK)
4099
4055
  {
4100
 
 
4101
 
    if (opt_silent < 2)
 
4056
    if (!silent || (ret != DRIZZLE_RETURN_GETADDRINFO &&
 
4057
                    ret != DRIZZLE_RETURN_COULD_NOT_CONNECT))
4102
4058
    {
4103
4059
      (void) put_error(&con, NULL);
4104
4060
      (void) fflush(stdout);
4124
4080
  drizzle_return_t ret;
4125
4081
 
4126
4082
  tee_puts("--------------", stdout);
4127
 
  printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
4128
 
         drizzle_version(), VERSION,
4129
 
         HOST_VENDOR, HOST_OS, HOST_CPU,
4130
 
         rl_library_version);
 
4083
  printf(_("drizzle  Ver %s Distrib %s, for %s-%s (%s) using readline %s\n"),
 
4084
  VER.c_str(), drizzle_version(),
 
4085
  HOST_VENDOR, HOST_OS, HOST_CPU,
 
4086
  rl_library_version);          /* Print version */
 
4087
 
4131
4088
 
4132
4089
  if (connected)
4133
4090
  {
4134
 
    tee_fprintf(stdout, _("\nConnection id:\t\t%lu\n"),drizzle_con_thread_id(&con));
 
4091
    tee_fprintf(stdout, "\nConnection id:\t\t%lu\n",drizzle_con_thread_id(&con));
4135
4092
    /*
4136
4093
      Don't remove "limit 1",
4137
4094
      it is protection againts SQL_SELECT_LIMIT=0
4143
4100
      drizzle_row_t cur=drizzle_row_next(&result);
4144
4101
      if (cur)
4145
4102
      {
4146
 
        tee_fprintf(stdout, _("Current schema:\t%s\n"), cur[0] ? cur[0] : "");
4147
 
        tee_fprintf(stdout, _("Current user:\t\t%s\n"), cur[1]);
 
4103
        tee_fprintf(stdout, "Current database:\t%s\n", cur[0] ? cur[0] : "");
 
4104
        tee_fprintf(stdout, "Current user:\t\t%s\n", cur[1]);
4148
4105
      }
4149
4106
      drizzle_result_free(&result);
4150
4107
    }
4151
4108
    else if (ret == DRIZZLE_RETURN_ERROR_CODE)
4152
4109
      drizzle_result_free(&result);
4153
 
    tee_puts(_("SSL:\t\t\tNot in use"), stdout);
 
4110
    tee_puts("SSL:\t\t\tNot in use", stdout);
4154
4111
  }
4155
4112
  else
4156
4113
  {
4157
4114
    vidattr(A_BOLD);
4158
 
    tee_fprintf(stdout, _("\nNo connection\n"));
 
4115
    tee_fprintf(stdout, "\nNo connection\n");
4159
4116
    vidattr(A_NORMAL);
4160
4117
    return 0;
4161
4118
  }
4162
4119
  if (skip_updates)
4163
4120
  {
4164
4121
    vidattr(A_BOLD);
4165
 
    tee_fprintf(stdout, _("\nAll updates ignored to this schema\n"));
 
4122
    tee_fprintf(stdout, "\nAll updates ignored to this database\n");
4166
4123
    vidattr(A_NORMAL);
4167
4124
  }
4168
 
  tee_fprintf(stdout, _("Current pager:\t\t%s\n"), pager.c_str());
4169
 
  tee_fprintf(stdout, _("Using outfile:\t\t'%s'\n"), opt_outfile ? outfile.c_str() : "");
4170
 
  tee_fprintf(stdout, _("Using delimiter:\t%s\n"), delimiter);
4171
 
  tee_fprintf(stdout, _("Server version:\t\t%s\n"), server_version_string(&con));
4172
 
  tee_fprintf(stdout, _("Protocol:\t\t%s\n"), opt_protocol.c_str());
4173
 
  tee_fprintf(stdout, _("Protocol version:\t%d\n"), drizzle_con_protocol_version(&con));
4174
 
  tee_fprintf(stdout, _("Connection:\t\t%s\n"), drizzle_con_host(&con));
 
4125
  tee_fprintf(stdout, "Current pager:\t\t%s\n", pager.c_str());
 
4126
  tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile.c_str() : "");
 
4127
  tee_fprintf(stdout, "Using delimiter:\t%s\n", delimiter);
 
4128
  tee_fprintf(stdout, "Server version:\t\t%s\n", server_version_string(&con));
 
4129
  tee_fprintf(stdout, "Protocol version:\t%d\n", drizzle_con_protocol_version(&con));
 
4130
  tee_fprintf(stdout, "Connection:\t\t%s\n", drizzle_con_host(&con));
4175
4131
/* XXX need to save this from result
4176
4132
  if ((id= drizzleclient_insert_id(&drizzle)))
4177
4133
    tee_fprintf(stdout, "Insert id:\t\t%s\n", internal::llstr(id, buff));
4178
4134
*/
4179
4135
 
4180
4136
  if (drizzle_con_uds(&con))
4181
 
    tee_fprintf(stdout, _("UNIX socket:\t\t%s\n"), drizzle_con_uds(&con));
 
4137
    tee_fprintf(stdout, "UNIX socket:\t\t%s\n", drizzle_con_uds(&con));
4182
4138
  else
4183
 
    tee_fprintf(stdout, _("TCP port:\t\t%d\n"), drizzle_con_port(&con));
 
4139
    tee_fprintf(stdout, "TCP port:\t\t%d\n", drizzle_con_port(&con));
4184
4140
 
4185
4141
  if (safe_updates)
4186
4142
  {
4187
4143
    vidattr(A_BOLD);
4188
 
    tee_fprintf(stdout, _("\nNote that you are running in safe_update_mode:\n"));
 
4144
    tee_fprintf(stdout, "\nNote that you are running in safe_update_mode:\n");
4189
4145
    vidattr(A_NORMAL);
4190
 
    tee_fprintf(stdout, _("\
 
4146
    tee_fprintf(stdout, "\
4191
4147
UPDATEs and DELETEs that don't use a key in the WHERE clause are not allowed.\n\
4192
4148
(One can force an UPDATE/DELETE by adding LIMIT # at the end of the command.)\n \
4193
4149
SELECT has an automatic 'LIMIT %lu' if LIMIT is not used.\n             \
4194
 
Max number of examined row combination in a join is set to: %lu\n\n"),
 
4150
Max number of examined row combination in a join is set to: %lu\n\n",
4195
4151
                select_limit, max_join_size);
4196
4152
  }
4197
4153
  tee_puts("--------------\n", stdout);
4249
4205
    if (info_type == INFO_ERROR)
4250
4206
    {
4251
4207
      (void) fflush(file);
4252
 
      fprintf(file,_("ERROR"));
 
4208
      fprintf(file,"ERROR");
4253
4209
      if (error)
4254
4210
      {
4255
4211
        if (sqlstate)
4292
4248
      if (error)
4293
4249
      {
4294
4250
        if (sqlstate)
4295
 
          (void) tee_fprintf(file, _("ERROR %d (%s): "), error, sqlstate);
 
4251
          (void) tee_fprintf(file, "ERROR %d (%s): ", error, sqlstate);
4296
4252
        else
4297
 
          (void) tee_fprintf(file, _("ERROR %d: "), error);
 
4253
          (void) tee_fprintf(file, "ERROR %d: ", error);
4298
4254
      }
4299
4255
      else
4300
 
        tee_puts(_("ERROR: "), file);
 
4256
        tee_puts("ERROR: ", file);
4301
4257
    }
4302
4258
    else
4303
4259
      vidattr(A_BOLD);
4388
4344
}
4389
4345
 
4390
4346
#include <sys/times.h>
 
4347
#ifdef _SC_CLK_TCK        // For mit-pthreads
 
4348
#undef CLOCKS_PER_SEC
 
4349
#define CLOCKS_PER_SEC (sysconf(_SC_CLK_TCK))
 
4350
#endif
4391
4351
 
4392
 
static boost::posix_time::ptime start_timer(void)
 
4352
static uint32_t start_timer(void)
4393
4353
{
4394
 
  return boost::posix_time::microsec_clock::universal_time();
 
4354
  struct tms tms_tmp;
 
4355
  return times(&tms_tmp);
4395
4356
}
4396
4357
 
4397
 
static void nice_time(boost::posix_time::time_duration duration, string &buff)
 
4358
 
 
4359
/**
 
4360
   Write as many as 52+1 bytes to buff, in the form of a legible
 
4361
   duration of time.
 
4362
 
 
4363
   len("4294967296 days, 23 hours, 59 minutes, 60.00 seconds")  ->  52
 
4364
*/
 
4365
static void nice_time(double sec,char *buff,bool part_second)
4398
4366
{
 
4367
  uint32_t tmp;
4399
4368
  ostringstream tmp_buff_str;
4400
4369
 
4401
 
  if (duration.hours() > 0)
4402
 
  {
4403
 
    tmp_buff_str << duration.hours();
4404
 
    if (duration.hours() > 1)
4405
 
      tmp_buff_str << _(" hours ");
4406
 
    else
4407
 
      tmp_buff_str << _(" hour ");
4408
 
  }
4409
 
  if (duration.hours() > 0 || duration.minutes() > 0)
4410
 
  {
4411
 
    tmp_buff_str << duration.minutes() << _(" min ");
4412
 
  }
4413
 
 
4414
 
  tmp_buff_str.precision(duration.num_fractional_digits());
4415
 
 
4416
 
  double seconds= duration.fractional_seconds();
4417
 
 
4418
 
  seconds/= pow(10.0,duration.num_fractional_digits());
4419
 
 
4420
 
  seconds+= duration.seconds();
4421
 
  tmp_buff_str << seconds << _(" sec");
4422
 
 
4423
 
  buff.append(tmp_buff_str.str());
4424
 
}
4425
 
 
4426
 
static void end_timer(boost::posix_time::ptime start_time, string &buff)
4427
 
{
4428
 
  boost::posix_time::ptime end_time= start_timer();
4429
 
  boost::posix_time::time_period duration(start_time, end_time);
4430
 
 
4431
 
  nice_time(duration.length(), buff);
4432
 
}
4433
 
 
4434
 
 
4435
 
static void drizzle_end_timer(boost::posix_time::ptime start_time, string &buff)
4436
 
{
4437
 
  buff.append(" (");
4438
 
  end_timer(start_time,buff);
4439
 
  buff.append(")");
 
4370
  if (sec >= 3600.0*24)
 
4371
  {
 
4372
    tmp=(uint32_t) floor(sec/(3600.0*24));
 
4373
    sec-= 3600.0*24*tmp;
 
4374
    tmp_buff_str << tmp;
 
4375
 
 
4376
    if (tmp > 1)
 
4377
      tmp_buff_str << " days ";
 
4378
    else
 
4379
      tmp_buff_str << " day ";
 
4380
 
 
4381
  }
 
4382
  if (sec >= 3600.0)
 
4383
  {
 
4384
    tmp=(uint32_t) floor(sec/3600.0);
 
4385
    sec-=3600.0*tmp;
 
4386
    tmp_buff_str << tmp;
 
4387
 
 
4388
    if (tmp > 1)
 
4389
      tmp_buff_str << " hours ";
 
4390
    else
 
4391
      tmp_buff_str << " hour ";
 
4392
  }
 
4393
  if (sec >= 60.0)
 
4394
  {
 
4395
    tmp=(uint32_t) floor(sec/60.0);
 
4396
    sec-=60.0*tmp;
 
4397
    tmp_buff_str << tmp << " min ";
 
4398
  }
 
4399
  if (part_second)
 
4400
    tmp_buff_str.precision(2);
 
4401
  else
 
4402
    tmp_buff_str.precision(0);
 
4403
  tmp_buff_str << sec << " sec";
 
4404
  strcpy(buff, tmp_buff_str.str().c_str());
 
4405
}
 
4406
 
 
4407
 
 
4408
static void end_timer(uint32_t start_time,char *buff)
 
4409
{
 
4410
  nice_time((double) (start_timer() - start_time) /
 
4411
            CLOCKS_PER_SEC,buff,1);
 
4412
}
 
4413
 
 
4414
 
 
4415
static void drizzle_end_timer(uint32_t start_time,char *buff)
 
4416
{
 
4417
  buff[0]=' ';
 
4418
  buff[1]='(';
 
4419
  end_timer(start_time,buff+2);
 
4420
  strcpy(strchr(buff, '\0'),")");
4440
4421
}
4441
4422
 
4442
4423
static const char * construct_prompt()
4520
4501
        if (!full_username)
4521
4502
          init_username();
4522
4503
        processed_prompt->append(part_username ? part_username :
4523
 
                                 (!current_user.empty() ?  current_user : _("(unknown)")));
 
4504
                                 (!current_user.empty() ?  current_user : "(unknown)"));
4524
4505
        break;
4525
4506
      case PROMPT_CHAR:
4526
4507
        {
4575
4556
        add_int_to_prompt(t->tm_sec);
4576
4557
        break;
4577
4558
      case 'w':
4578
 
        processed_prompt->append(get_day_name(t->tm_wday));
 
4559
        processed_prompt->append(day_names[t->tm_wday]);
4579
4560
        break;
4580
4561
      case 'P':
4581
4562
        processed_prompt->append(t->tm_hour < 12 ? "am" : "pm");
4584
4565
        add_int_to_prompt(t->tm_mon+1);
4585
4566
        break;
4586
4567
      case 'O':
4587
 
        processed_prompt->append(get_month_name(t->tm_mon));
 
4568
        processed_prompt->append(month_names[t->tm_mon]);
4588
4569
        break;
4589
4570
      case '\'':
4590
4571
        processed_prompt->append("'");
4640
4621
{
4641
4622
  const char *ptr=strchr(line, ' ');
4642
4623
  if (ptr == NULL)
4643
 
    tee_fprintf(stdout, _("Returning to default PROMPT of %s\n"),
 
4624
    tee_fprintf(stdout, "Returning to default PROMPT of %s\n",
4644
4625
                default_prompt);
4645
4626
  prompt_counter = 0;
4646
4627
  char * tmpptr= strdup(ptr ? ptr+1 : default_prompt);
4647
4628
  if (tmpptr == NULL)
4648
 
    tee_fprintf(stdout, _("Memory allocation error. Not changing prompt\n"));
 
4629
    tee_fprintf(stdout, "Memory allocation error. Not changing prompt\n");
4649
4630
  else
4650
4631
  {
4651
4632
    current_prompt.erase();
4652
4633
    current_prompt= tmpptr;
4653
 
    tee_fprintf(stdout, _("PROMPT set to '%s'\n"), current_prompt.c_str());
 
4634
    tee_fprintf(stdout, "PROMPT set to '%s'\n", current_prompt.c_str());
4654
4635
  }
4655
4636
  return 0;
4656
4637
}