~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Monty Taylor
  • Date: 2008-09-14 19:39:48 UTC
  • mfrom: (383.1.43 client-split)
  • Revision ID: monty@inaugust.com-20080914193948-ns2p0lts4qtsqx7n
Merged from client-split.

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
static char * opt_drizzle_unix_port=0;
168
168
static int connect_flag=CLIENT_INTERACTIVE;
169
169
static char *current_host,*current_db,*current_user=0,*opt_password=0,
170
 
  *delimiter_str= 0,* current_prompt= 0,
171
 
  *default_charset= (char*) DRIZZLE_DEFAULT_CHARSET_NAME;
 
170
  *delimiter_str= 0,* current_prompt= 0;
172
171
static char *histfile;
173
172
static char *histfile_tmp;
174
173
static string *glob_buffer;
216
215
  com_connect(string *str,const char*), com_status(string *str,const char*),
217
216
  com_use(string *str,const char*), com_source(string *str, const char*),
218
217
  com_rehash(string *str, const char*), com_tee(string *str, const char*),
219
 
  com_notee(string *str, const char*), com_charset(string *str,const char*),
 
218
  com_notee(string *str, const char*),
220
219
  com_prompt(string *str, const char*), com_delimiter(string *str, const char*),
221
220
  com_warnings(string *str, const char*), com_nowarnings(string *str, const char*),
222
221
  com_nopager(string *str, const char*), com_pager(string *str, const char*);
279
278
    N_("Set outfile [to_outfile]. Append everything into given outfile.") },
280
279
  { "use",    'u', com_use,    1,
281
280
    N_("Use another database. Takes database name as argument.") },
282
 
  { "charset",    'C', com_charset,    1,
283
 
    N_("Switch to another charset. Might be needed for processing binlog with multi-byte charsets.") },
284
281
  { "warnings", 'W', com_warnings,  0,
285
282
    N_("Show warnings after every statement.") },
286
283
  { "nowarning", 'w', com_nowarnings, 0,
1304
1301
  {"database", 'D', N_("Database to use."), (char**) &current_db,
1305
1302
   (char**) &current_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1306
1303
  {"default-character-set", OPT_DEFAULT_CHARSET,
1307
 
   N_("Set the default character set."), (char**) &default_charset,
1308
 
   (char**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
 
1304
   N_("(not used)"), 0,
 
1305
   0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1309
1306
  {"delimiter", OPT_DELIMITER, N_("Delimiter to be used."), (char**) &delimiter_str,
1310
1307
   (char**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1311
1308
  {"execute", 'e', N_("Execute command and quit. (Disables --force and history file)"), 0,
1645
1642
    connect_flag= 0; /* Not in interactive mode */
1646
1643
  }
1647
1644
 
1648
 
  if (strcmp(default_charset, charset_info->csname) &&
1649
 
      !(charset_info= get_charset_by_csname(default_charset,
1650
 
                                            MY_CS_PRIMARY, MYF(MY_WME))))
1651
 
    exit(1);
1652
1645
  if (argc > 1)
1653
1646
  {
1654
1647
    usage(0);
2635
2628
  return 0;
2636
2629
}
2637
2630
 
2638
 
static int
2639
 
com_charset(string *buffer __attribute__((unused)),
2640
 
            const char *line)
2641
 
{
2642
 
  char buff[256], *param;
2643
 
  const CHARSET_INFO * new_cs;
2644
 
  strmake(buff, line, sizeof(buff) - 1);
2645
 
  param= get_arg(buff, 0);
2646
 
  if (!param || !*param)
2647
 
  {
2648
 
    return put_info(_("Usage: \\C char_setname | charset charset_name"),
2649
 
                    INFO_ERROR, 0, 0);
2650
 
  }
2651
 
  new_cs= get_charset_by_csname(param, MY_CS_PRIMARY, MYF(MY_WME));
2652
 
  if (new_cs)
2653
 
  {
2654
 
    charset_info= new_cs;
2655
 
    drizzle_set_character_set(&drizzle, charset_info->csname);
2656
 
    default_charset= (char *)charset_info->csname;
2657
 
    default_charset_used= 1;
2658
 
    put_info(_("Charset changed"), INFO_INFO,0,0);
2659
 
  }
2660
 
  else put_info(_("Charset is not found"), INFO_INFO,0,0);
2661
 
  return 0;
2662
 
}
2663
2631
 
2664
2632
/*
2665
2633
  Execute command
3784
3752
            select_limit, max_join_size);
3785
3753
    drizzle_options(&drizzle, DRIZZLE_INIT_COMMAND, init_command);
3786
3754
  }
3787
 
  if (default_charset_used)
3788
 
    drizzle_options(&drizzle, DRIZZLE_SET_CHARSET_NAME, default_charset);
3789
3755
  if (!drizzle_connect(&drizzle, host, user, password,
3790
3756
                          database, opt_drizzle_port, opt_drizzle_unix_port,
3791
3757
                          connect_flag | CLIENT_MULTI_STATEMENTS))
3873
3839
    }
3874
3840
    drizzle_free_result(result);
3875
3841
  }
3876
 
  else
3877
 
  {
3878
 
    /* Probably pre-4.1 server */
3879
 
    tee_fprintf(stdout, "Client characterset:\t%s\n", charset_info->csname);
3880
 
    tee_fprintf(stdout, "Server characterset:\t%s\n", drizzle.charset->csname);
3881
 
  }
3882
3842
 
3883
3843
  if (strstr(drizzle_get_host_info(&drizzle),"TCP/IP") || ! drizzle.unix_socket)
3884
3844
    tee_fprintf(stdout, "TCP port:\t\t%d\n", drizzle.port);