~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.cc

  • Committer: Brian Aker
  • Date: 2009-04-13 16:22:40 UTC
  • mfrom: (971.1.78 mordred)
  • Revision ID: brian@gaz-20090413162240-ugi3gvhofmcuglzl
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
#include <queue>
44
44
#include <map>
45
45
#include <string>
 
46
#include <sstream>
 
47
#include <iostream>
46
48
#include <vector>
47
49
 
48
50
#include PCRE_HEADER
1945
1947
                     ',');
1946
1948
 
1947
1949
  /* Convert row number to int */
1948
 
  if (!str2int(ds_row.c_str(), 10, (long) 0, (long) INT_MAX, &row_no))
 
1950
  row_no= atoi(ds_row.c_str());
 
1951
  
 
1952
  istringstream buff(ds_row);
 
1953
  if ((buff >> row_no).fail())
1949
1954
    die("Invalid row number: '%s'", ds_row.c_str());
1950
1955
 
1951
1956
  /* Remove any surrounding "'s from the query - if there is any */
2505
2510
                     ' ');
2506
2511
 
2507
2512
  /* Parse what mode to set */
 
2513
  istringstream buff(ds_mode);
2508
2514
  if (ds_mode.length() != 4 ||
2509
 
      str2int(ds_mode.c_str(), 8, 0, INT_MAX, &mode) == NULL)
 
2515
      (buff >> mode).fail())
2510
2516
    die("You must write a 4 digit octal number for mode");
2511
2517
 
2512
2518
  handle_command_error(command, chmod(ds_file.c_str(), mode));
3272
3278
 
3273
3279
static int do_sleep(struct st_command *command, bool real_sleep)
3274
3280
{
3275
 
  int error= 0;
 
3281
  bool error= false;
3276
3282
  char *p= command->first_argument;
3277
3283
  char *sleep_start, *sleep_end= command->end;
3278
3284
  double sleep_val;
3286
3292
  if (!my_isdigit(charset_info, *sleep_start))
3287
3293
    die("Invalid argument to %.*s \"%s\"", command->first_word_len,
3288
3294
        command->query,command->first_argument);
3289
 
  sleep_val= my_strtod(sleep_start, &sleep_end, &error);
 
3295
  string buff_str(sleep_start, sleep_end-sleep_start);
 
3296
  istringstream buff(buff_str);
 
3297
  error= (buff >> sleep_val).fail();
3290
3298
  if (error)
3291
3299
    die("Invalid argument to %.*s \"%s\"", command->first_word_len,
3292
3300
        command->query, command->first_argument);
3441
3449
      }
3442
3450
 
3443
3451
      /* Convert the sting to int */
3444
 
      if (!str2int(start, 10, (long) INT_MIN, (long) INT_MAX, &val))
 
3452
      istringstream buff(start);
 
3453
      if ((buff >> val).fail())
3445
3454
        die("Invalid argument to error: '%s'", command->first_argument);
3446
3455
 
3447
3456
      to->code.errnum= (uint32_t) val;
5007
5016
static void append_info(string *ds, uint64_t affected_rows,
5008
5017
                        const char *info)
5009
5018
{
5010
 
  char buf[40], buff2[21];
5011
 
  sprintf(buf,"affected rows: %s\n", llstr(affected_rows, buff2));
5012
 
  ds->append(buf);
 
5019
  ostringstream buf;
 
5020
  buf << "affected rows: " << affected_rows << endl;
 
5021
  ds->append(buf.str());
5013
5022
  if (info && strcmp(info, ""))
5014
5023
  {
5015
5024
    ds->append("info: ");
5555
5564
 
5556
5565
static void mark_progress(struct st_command*, int line)
5557
5566
{
5558
 
  char buf[32], *end;
5559
5567
  uint64_t timer= timer_now();
5560
5568
  if (!progress_start)
5561
5569
    progress_start= timer;
5562
5570
  timer-= progress_start;
5563
5571
 
 
5572
  ostringstream buf;
5564
5573
  /* Milliseconds since start */
5565
 
  end= int64_t2str(timer, buf, 10);
5566
 
  ds_progress.append(buf, (int)(end-buf));
5567
 
  ds_progress.append("\t", 1);
 
5574
  buf << timer << "\t";
5568
5575
 
5569
5576
  /* Parser line number */
5570
 
  end= int10_to_str(line, buf, 10);
5571
 
  ds_progress.append(buf, (int)(end-buf));
5572
 
  ds_progress.append("\t", 1);
 
5577
  buf << line << "\t";
5573
5578
 
5574
5579
  /* Filename */
5575
 
  ds_progress.append(cur_file->file_name);
5576
 
  ds_progress.append(":", 1);
 
5580
  buf << cur_file->file_name << ":";
5577
5581
 
5578
5582
  /* Line in file */
5579
 
  end= int10_to_str(cur_file->lineno, buf, 10);
5580
 
  ds_progress.append(buf, (int)(end-buf));
5581
 
 
5582
 
 
5583
 
  ds_progress.append("\n", 1);
 
5583
  buf << cur_file->lineno << endl;
 
5584
 
 
5585
  ds_progress.append(buf.str());
5584
5586
 
5585
5587
}
5586
5588
 
6060
6062
{
6061
6063
  if (timer_file)
6062
6064
  {
6063
 
    char buf[32], *end;
 
6065
    ostringstream buf;
6064
6066
    uint64_t timer= timer_now() - timer_start;
6065
 
    end= int64_t2str(timer, buf, 10);
6066
 
    str_to_file(timer_file,buf, (int) (end-buf));
 
6067
    buf << timer;
 
6068
    str_to_file(timer_file,buf.str().c_str(), buf.str().size() );
6067
6069
    /* Timer has been written to the file, don't use it anymore */
6068
6070
    timer_file= 0;
6069
6071
  }
7252
7254
/* Append uint32_t to ds, with optional replace */
7253
7255
void replace_append_uint(string *ds, uint32_t val)
7254
7256
{
7255
 
  char buff[22]; /* This should be enough for any int */
7256
 
  char *end= int64_t10_to_str(val, buff, 10);
7257
 
  replace_append_mem(ds, buff, end - buff);
 
7257
  ostringstream buff;
 
7258
  buff << val;
 
7259
  replace_append_mem(ds, buff.str().c_str(), buff.str().size());
7258
7260
 
7259
7261
}
7260
7262