~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/mysql.cc

Merged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#ifndef __GNU_LIBRARY__
36
36
#define __GNU_LIBRARY__               // Skip warnings in getopt.h
37
37
#endif
 
38
#include <readline/history.h>
38
39
#include "my_readline.h"
39
40
#include <signal.h>
40
41
#include <violite.h>
155
156
static char *full_username=0,*part_username=0,*default_prompt=0;
156
157
static int wait_time = 5;
157
158
static STATUS status;
158
 
static ulong select_limit,max_join_size,opt_connect_timeout=0;
 
159
static uint32_t select_limit;
 
160
static ulong max_join_size;
 
161
static ulong opt_connect_timeout= 0;
159
162
static char mysql_charsets_dir[FN_REFLEN+1];
160
163
static const char *xmlmeta[] = {
161
164
  "&", "&amp;",
995
998
static int         embedded_server_arg_count= 0;
996
999
static char       *embedded_server_args[MAX_SERVER_ARGS];
997
1000
static const char *embedded_server_groups[]=
998
 
{ "server", "embedded", "mysql_SERVER", 0 };
999
 
 
1000
 
/*
1001
 
 HIST_ENTRY is defined for libedit, but not for the real readline
1002
 
 Need to redefine it for real readline to find it
1003
 
*/
1004
 
#if !defined(HAVE_HIST_ENTRY)
1005
 
typedef struct _hist_entry {
1006
 
  const char      *line;
1007
 
  const char      *data;
1008
 
} HIST_ENTRY; 
1009
 
#endif
1010
 
 
1011
 
extern "C" int add_history(const char *command); /* From readline directory */
1012
 
extern "C" int read_history(const char *command);
1013
 
extern "C" int write_history(const char *command);
1014
 
extern "C" HIST_ENTRY *history_get(int num);
 
1001
{ "server", "mysql_SERVER", 0 };
 
1002
 
1015
1003
extern "C" int history_length;
1016
1004
static int not_in_history(const char *line);
1017
1005
static void initialize_readline (char *name);
1136
1124
  put_info("Welcome to the Drizzle client..  Commands end with ; or \\g.",
1137
1125
           INFO_INFO);
1138
1126
  sprintf((char*) glob_buffer.ptr(),
1139
 
          "Your Drizzle connection id is %lu\nServer version: %s\n",
 
1127
          "Your Drizzle connection id is %u\nServer version: %s\n",
1140
1128
          mysql_thread_id(&mysql), server_version_string(&mysql));
1141
1129
  put_info((char*) glob_buffer.ptr(),INFO_INFO);
1142
1130
 
1256
1244
    goto err;
1257
1245
 
1258
1246
  /* kill_buffer is always big enough because max length of %lu is 15 */
1259
 
  sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
 
1247
  sprintf(kill_buffer, "KILL /*!50000 QUERY */ %u", mysql_thread_id(&mysql));
1260
1248
  mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
1261
1249
  mysql_close(kill_mysql);
1262
1250
  tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
2231
2219
static void initialize_readline (char *name)
2232
2220
{
2233
2221
  /* Allow conditional parsing of the ~/.inputrc file. */
2234
 
  rl_readline_name = name;
 
2222
  rl_readline_name= name;
2235
2223
 
2236
2224
  /* Tell the completer that we want a crack first. */
2237
2225
  rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion;
3112
3100
  {
3113
3101
    if (interrupted_query)
3114
3102
      break;
3115
 
    ulong *lengths= mysql_fetch_lengths(result);
 
3103
    uint32_t *lengths= mysql_fetch_lengths(result);
3116
3104
    (void) tee_fputs("| ", PAGER);
3117
3105
    mysql_field_seek(result, 0);
3118
3106
    for (uint off= 0; off < mysql_num_fields(result); off++)
3273
3261
  {
3274
3262
    if (interrupted_query)
3275
3263
      break;
3276
 
    ulong *lengths=mysql_fetch_lengths(result);
 
3264
    uint32_t *lengths= mysql_fetch_lengths(result);
3277
3265
    (void) tee_fputs("<TR>", PAGER);
3278
 
    for (uint i=0; i < mysql_num_fields(result); i++)
 
3266
    for (uint32_t i= 0; i < mysql_num_fields(result); i++)
3279
3267
    {
3280
3268
      (void) tee_fputs("<TD>", PAGER);
3281
3269
      safe_put_field(cur[i],lengths[i]);
3305
3293
  {
3306
3294
    if (interrupted_query)
3307
3295
      break;
3308
 
    ulong *lengths=mysql_fetch_lengths(result);
 
3296
    uint32_t *lengths= mysql_fetch_lengths(result);
3309
3297
    (void) tee_fputs("\n  <row>\n", PAGER);
3310
3298
    for (uint i=0; i < mysql_num_fields(result); i++)
3311
3299
    {
3474
3462
{
3475
3463
  MYSQL_ROW     cur;
3476
3464
  MYSQL_FIELD   *field;
3477
 
  ulong         *lengths;
 
3465
  uint32_t              *lengths;
3478
3466
 
3479
3467
  if (opt_silent < 2 && column_names)
3480
3468
  {
3489
3477
  }
3490
3478
  while ((cur = mysql_fetch_row(result)))
3491
3479
  {
3492
 
    lengths=mysql_fetch_lengths(result);
 
3480
    lengths= mysql_fetch_lengths(result);
3493
3481
    safe_put_field(cur[0],lengths[0]);
3494
3482
    for (uint off=1 ; off < mysql_num_fields(result); off++)
3495
3483
    {
3767
3755
 
3768
3756
  if (connected)
3769
3757
  {
3770
 
    sprintf(buff,"Connection id:    %lu",mysql_thread_id(&mysql));
 
3758
    sprintf(buff,"Connection id:    %u",mysql_thread_id(&mysql));
3771
3759
    put_info(buff,INFO_INFO);
3772
3760
    sprintf(buff,"Current database: %.128s\n",
3773
3761
            current_db ? current_db : "*** NONE ***");
4041
4029
  {
4042
4030
    char init_command[100];
4043
4031
    sprintf(init_command,
4044
 
            "SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%lu,SQL_MAX_JOIN_SIZE=%lu",
4045
 
            select_limit,max_join_size);
 
4032
            "SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%u,SQL_MAX_JOIN_SIZE=%u",
 
4033
            select_limit, max_join_size);
4046
4034
    mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command);
4047
4035
  }
4048
4036
  if (default_charset_used)
4280
4268
      }
4281
4269
      if (status.query_start_line && line_numbers)
4282
4270
      {
4283
 
        (void) fprintf(file," at line %lu",status.query_start_line);
 
4271
        (void) fprintf(file," at line %u",status.query_start_line);
4284
4272
        if (status.file_name)
4285
4273
          (void) fprintf(file," in file: '%s'", status.file_name);
4286
4274
      }