~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to client/mysqltest.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-02-14 23:59:22 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20120214235922-cux5uek1e5l0hje9
Tags: 5.5.20-0ubuntu1
* New upstream release.
* d/mysql-server-5.5.mysql.upstart: Fix stop on to make sure mysql is
  fully stopped before shutdown commences. (LP: #688541) Also simplify
  start on as it is redundant.
* d/control: Depend on upstart version which has apparmor profile load
  script to prevent failure on upgrade from lucid to precise.
  (LP: #907465)
* d/apparmor-profile: need to allow /run since that is the true path
  of /var/run files. (LP: #917542)
* d/control: mysql-server-5.5 has files in it that used to be owned
  by libmysqlclient-dev, so it must break/replace it. (LP: #912487)
* d/rules, d/control: 5.5.20 Fixes segfault on tests with gcc 4.6,
  change compiler back to system default.
* d/rules: Turn off embedded libedit/readline.(Closes: #659566)

Show diffs side-by-side

added added

removed removed

Lines of Context:
502
502
 
503
503
char builtin_echo[FN_REFLEN];
504
504
 
 
505
struct st_replace_regex
 
506
{
 
507
DYNAMIC_ARRAY regex_arr; /* stores a list of st_regex subsitutions */
 
508
 
 
509
/*
 
510
Temporary storage areas for substitutions. To reduce unnessary copying
 
511
and memory freeing/allocation, we pre-allocate two buffers, and alternate
 
512
their use, one for input/one for output, the roles changing on the next
 
513
st_regex substition. At the end of substitutions  buf points to the
 
514
one containing the final result.
 
515
*/
 
516
char* buf;
 
517
char* even_buf;
 
518
char* odd_buf;
 
519
int even_buf_len;
 
520
int odd_buf_len;
 
521
};
 
522
 
 
523
struct st_replace_regex *glob_replace_regex= 0;
 
524
 
 
525
struct st_replace;
 
526
struct st_replace *glob_replace= 0;
 
527
void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds,
 
528
const char *from, int len);
 
529
 
505
530
static void cleanup_and_exit(int exit_code) __attribute__((noreturn));
506
531
 
507
532
void die(const char *fmt, ...)
531
556
 
532
557
void fix_win_paths(const char *val, int len);
533
558
const char *get_errname_from_code (uint error_code);
 
559
int multi_reg_replace(struct st_replace_regex* r,char* val);
534
560
 
535
561
#ifdef __WIN__
536
562
void free_tmp_sh_file();
2432
2458
      if (row[i])
2433
2459
      {
2434
2460
        /* Add column to tab separated string */
2435
 
        dynstr_append_mem(&result, row[i], lengths[i]);
 
2461
        char *val= row[i];
 
2462
        int len= lengths[i];
 
2463
        
 
2464
        if (glob_replace_regex)
 
2465
        {
 
2466
          /* Regex replace */
 
2467
          if (!multi_reg_replace(glob_replace_regex, (char*)val))
 
2468
          {
 
2469
            val= glob_replace_regex->buf;
 
2470
            len= strlen(val);
 
2471
          }
 
2472
        }
 
2473
        
 
2474
        if (glob_replace)
 
2475
          replace_strings_append(glob_replace, &result, val, len);
 
2476
        else
 
2477
          dynstr_append_mem(&result, val, len);
2436
2478
      }
2437
2479
      dynstr_append_mem(&result, "\t", 1);
2438
2480
    }
3344
3386
                     ' ');
3345
3387
 
3346
3388
  DBUG_PRINT("info", ("Copy %s to %s", ds_from_file.str, ds_to_file.str));
 
3389
  /* MY_HOLD_ORIGINAL_MODES prevents attempts to chown the file */
3347
3390
  error= (my_copy(ds_from_file.str, ds_to_file.str,
3348
 
                  MYF(MY_DONT_OVERWRITE_FILE)) != 0);
 
3391
                  MYF(MY_DONT_OVERWRITE_FILE | MY_HOLD_ORIGINAL_MODES)) != 0);
3349
3392
  handle_command_error(command, error);
3350
3393
  dynstr_free(&ds_from_file);
3351
3394
  dynstr_free(&ds_to_file);
4839
4882
  struct st_match_err *to= saved_expected_errors.err;
4840
4883
  char *p= command->first_argument;
4841
4884
  uint count= 0;
 
4885
  char *next;
4842
4886
 
4843
4887
  DBUG_ENTER("do_get_errcodes");
4844
4888
 
4858
4902
    while (*end && *end != ',' && *end != ' ')
4859
4903
      end++;
4860
4904
 
 
4905
    next=end;
 
4906
 
 
4907
    /* code to handle variables passed to mysqltest */
 
4908
     if( *p == '$')
 
4909
     {
 
4910
        const char* fin;
 
4911
        VAR *var = var_get(p,&fin,0,0);
 
4912
        p=var->str_val;
 
4913
        end=p+var->str_val_len;
 
4914
     }
 
4915
 
4861
4916
    if (*p == 'S')
4862
4917
    {
4863
4918
      char *to_ptr= to->code.sqlstate;
4932
4987
      die("Too many errorcodes specified");
4933
4988
 
4934
4989
    /* Set pointer to the end of the last error code */
4935
 
    p= end;
 
4990
    p= next;
4936
4991
 
4937
4992
    /* Find next ',' */
4938
4993
    while (*p && *p != ',')
5364
5419
 
5365
5420
  var_set_errno(0);
5366
5421
  handle_no_error(command);
 
5422
  revert_properties();
5367
5423
  return 1; /* Connected */
5368
5424
}
5369
5425
 
7319
7375
 
7320
7376
  /* If we come here the query is both executed and read successfully */
7321
7377
  handle_no_error(command);
 
7378
  revert_properties();
7322
7379
 
7323
7380
end:
7324
7381
 
7514
7571
    die("query '%s' succeeded - should have failed with sqlstate %s...",
7515
7572
        command->query, command->expected_errors.err[0].code.sqlstate);
7516
7573
  }
7517
 
 
7518
 
  revert_properties();
7519
7574
  DBUG_VOID_RETURN;
7520
7575
}
7521
7576
 
7546
7601
  DBUG_ENTER("run_query_stmt");
7547
7602
  DBUG_PRINT("query", ("'%-.60s'", query));
7548
7603
 
7549
 
  /* Remember disable_result_log since handle_no_error() may reset it */
7550
 
  my_bool dis_res= disable_result_log;
7551
 
  
7552
7604
  /*
7553
7605
    Init a new stmt if it's not already one created for this connection
7554
7606
  */
7644
7696
 
7645
7697
  /* If we got here the statement was both executed and read successfully */
7646
7698
  handle_no_error(command);
7647
 
  if (!dis_res)
 
7699
  if (!disable_result_log)
7648
7700
  {
7649
7701
    /*
7650
7702
      Not all statements creates a result set. If there is one we can
7720
7772
    dynstr_free(&ds_prepare_warnings);
7721
7773
    dynstr_free(&ds_execute_warnings);
7722
7774
  }
7723
 
 
 
7775
  revert_properties();
7724
7776
 
7725
7777
  /* Close the statement if - no reconnect, need new prepare */
7726
7778
  if (mysql->reconnect)
9110
9162
  uint  array_allocs,max_count,length,max_length;
9111
9163
} POINTER_ARRAY;
9112
9164
 
9113
 
struct st_replace;
9114
9165
struct st_replace *init_replace(char * *from, char * *to, uint count,
9115
9166
                                char * word_end_chars);
9116
9167
int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name);
9117
 
void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds,
9118
 
                            const char *from, int len);
9119
9168
void free_pointer_array(POINTER_ARRAY *pa);
9120
9169
 
9121
 
struct st_replace *glob_replace;
9122
 
 
9123
9170
/*
9124
9171
  Get arguments for replace. The syntax is:
9125
9172
  replace from to [from to ...]
9263
9310
  int icase; /* true if the match is case insensitive */
9264
9311
};
9265
9312
 
9266
 
struct st_replace_regex
9267
 
{
9268
 
  DYNAMIC_ARRAY regex_arr; /* stores a list of st_regex subsitutions */
9269
 
 
9270
 
  /*
9271
 
    Temporary storage areas for substitutions. To reduce unnessary copying
9272
 
    and memory freeing/allocation, we pre-allocate two buffers, and alternate
9273
 
    their use, one for input/one for output, the roles changing on the next
9274
 
    st_regex substition. At the end of substitutions  buf points to the
9275
 
    one containing the final result.
9276
 
  */
9277
 
  char* buf;
9278
 
  char* even_buf;
9279
 
  char* odd_buf;
9280
 
  int even_buf_len;
9281
 
  int odd_buf_len;
9282
 
};
9283
 
 
9284
 
struct st_replace_regex *glob_replace_regex= 0;
9285
 
 
9286
9313
int reg_replace(char** buf_p, int* buf_len_p, char *pattern, char *replace,
9287
9314
                char *string, int icase);
9288
9315
 
9481
9508
{
9482
9509
  char *expr= command->first_argument;
9483
9510
  free_replace_regex();
9484
 
  if (!(glob_replace_regex=init_replace_regex(expr)))
 
9511
  /* Allow variable for the *entire* list of replacements */
 
9512
  if (*expr == '$') 
 
9513
  {
 
9514
    VAR *val= var_get(expr, NULL, 0, 1);
 
9515
    expr= val ? val->str_val : NULL;
 
9516
  }
 
9517
  if (expr && *expr && !(glob_replace_regex=init_replace_regex(expr)))
9485
9518
    die("Could not init replace_regex");
9486
9519
  command->last_argument= command->end;
9487
9520
}