~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

mergeĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
#include "client_priv.h"
37
37
#include <string>
38
 
#include CMATH_H
39
38
#include <algorithm>
40
39
#include <mystrings/m_ctype.h>
41
40
#include <stdarg.h>
116
115
 
117
116
#include <drizzled/gettext.h>
118
117
 
119
 
#if defined(CMATH_NAMESPACE)
120
 
  using namespace CMATH_NAMESPACE;
121
 
#endif
122
 
 
123
 
const char *VER= "14.14";
124
 
 
125
 
/* Don't try to make a nice table if the data is too big */
126
 
#define MAX_COLUMN_LENGTH       (uint32_t)1024
127
 
 
128
 
/* Buffer to hold 'version' and 'version_comment' */
129
 
#define MAX_SERVER_VERSION_LENGTH     128
130
118
 
131
119
void* sql_alloc(unsigned size);       // Don't use drizzled alloc for these
132
120
void sql_element_free(void *ptr);
137
125
#define vidattr(A) {}      // Can't get this to work
138
126
#endif
139
127
 
140
 
#ifdef FN_NO_CASE_SENCE
141
 
#define cmp_database(cs,A,B) my_strcasecmp((cs), (A), (B))
142
 
#else
143
 
#define cmp_database(cs,A,B) strcmp((A),(B))
144
 
#endif
145
 
 
146
128
#include "completion_hash.h"
147
129
 
148
130
using namespace std;
149
131
 
 
132
const string VER("14.14");
 
133
/* Don't try to make a nice table if the data is too big */
 
134
const uint32_t MAX_COLUMN_LENGTH= 1024;
 
135
 
 
136
/* Buffer to hold 'version' and 'version_comment' */
 
137
const int MAX_SERVER_VERSION_LENGTH= 128;
 
138
 
150
139
#define PROMPT_CHAR '\\'
151
140
#define DEFAULT_DELIMITER ";"
152
141
 
171
160
  connected= false, opt_raw_data= false, unbuffered= false,
172
161
  output_tables= false, opt_rehash= true, skip_updates= false,
173
162
  safe_updates= false, one_database= false,
174
 
  opt_compress= false, using_opt_local_infile= false,
 
163
  opt_compress= false,
175
164
  vertical= false, line_numbers= true, column_names= true,
176
165
  opt_nopager= true, opt_outfile= false, named_cmds= false,
177
166
  tty_password= false, opt_nobeep= false, opt_reconnect= true,
1455
1444
  const char* readline= "readline";
1456
1445
 
1457
1446
  printf(_("%s  Ver %s Distrib %s, for %s (%s) using %s %s\n"),
1458
 
         my_progname, VER, drizzleclient_get_client_info(),
 
1447
         my_progname, VER.c_str(), drizzleclient_get_client_info(),
1459
1448
         SYSTEM_TYPE, MACHINE_TYPE,
1460
1449
         readline, rl_library_version);
1461
1450
 
1505
1494
    delimiter_length= (uint32_t)strlen(delimiter);
1506
1495
    delimiter_str= delimiter;
1507
1496
    break;
1508
 
  case OPT_LOCAL_INFILE:
1509
 
    using_opt_local_infile= 1;
1510
 
    break;
1511
1497
  case OPT_TEE:
1512
1498
    if (argument == disabled_my_option)
1513
1499
    {
2748
2734
  FILE* new_outfile;
2749
2735
  if (opt_outfile)
2750
2736
    end_tee();
2751
 
  if (!(new_outfile= my_fopen(file_name, O_APPEND | O_WRONLY, MYF(MY_WME))))
 
2737
  if (!(new_outfile= fopen(file_name, "a")))
2752
2738
  {
2753
2739
    tee_fprintf(stdout, "Error logging to file '%s'\n", file_name);
2754
2740
    return;
2757
2743
  strncpy(outfile, file_name, FN_REFLEN-1);
2758
2744
  tee_fprintf(stdout, "Logging to file '%s'\n", file_name);
2759
2745
  opt_outfile= 1;
 
2746
 
2760
2747
  return;
2761
2748
}
2762
2749
 
2763
2750
 
2764
2751
static void end_tee()
2765
2752
{
2766
 
  my_fclose(OUTFILE, MYF(0));
 
2753
  fclose(OUTFILE);
2767
2754
  OUTFILE= 0;
2768
2755
  opt_outfile= 0;
2769
2756
  return;
3459
3446
  end[0]=0;
3460
3447
  unpack_filename(source_name,source_name);
3461
3448
  /* open file name */
3462
 
  if (!(sql_file = my_fopen(source_name, O_RDONLY,MYF(0))))
 
3449
  if (!(sql_file = fopen(source_name, "r")))
3463
3450
  {
3464
3451
    char buff[FN_REFLEN+60];
3465
3452
    sprintf(buff,"Failed to open file '%s', error: %d", source_name,errno);
3468
3455
 
3469
3456
  if (!(line_buff=batch_readline_init(opt_max_allowed_packet+512,sql_file)))
3470
3457
  {
3471
 
    my_fclose(sql_file,MYF(0));
 
3458
    fclose(sql_file);
3472
3459
    return put_info("Can't initialize batch_readline", INFO_ERROR, 0 ,0);
3473
3460
  }
3474
3461
 
3486
3473
  error= read_and_execute(false);
3487
3474
  // Continue as before
3488
3475
  status=old_status;
3489
 
  my_fclose(sql_file,MYF(0));
 
3476
  fclose(sql_file);
3490
3477
  batch_readline_end(line_buff);
3491
3478
  return error;
3492
3479
}
3544
3531
  */
3545
3532
  get_current_db();
3546
3533
 
3547
 
  if (!current_db || cmp_database(charset_info, current_db,tmp))
 
3534
  if (!current_db || strcmp(current_db,tmp))
3548
3535
  {
3549
3536
    if (one_database)
3550
3537
    {
3693
3680
    drizzleclient_options(&drizzle,DRIZZLE_OPT_COMPRESS,NULL);
3694
3681
  if (opt_secure_auth)
3695
3682
    drizzleclient_options(&drizzle, DRIZZLE_SECURE_AUTH, (char *) &opt_secure_auth);
3696
 
  if (using_opt_local_infile)
3697
 
    drizzleclient_options(&drizzle,DRIZZLE_OPT_LOCAL_INFILE, (char*) &opt_local_infile);
3698
3683
  if (safe_updates)
3699
3684
  {
3700
3685
    char init_command[100];