Commit 772843ba authored by unknown's avatar unknown
Browse files

Bug #3131 mysqltest fails on $2=$1 assignment in test


client/mysqltest.c:
  Fix function var_copy to make it possible to assign one variable to another. 
  ex: let $1=$2
mysql-test/r/mysqltest.result:
  Update test result
mysql-test/t/mysqltest.test:
  Add test cases for variable to variable assignment
parent 50cc21ea
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -1151,12 +1151,20 @@ void var_copy(VAR* dest, VAR* src)
{
  dest->int_val= src->int_val;
  dest->int_dirty= src->int_dirty;

  /* Alloc/realloc data for str_val in dest */
  if (dest->alloced_len < src->alloced_len &&
      !(dest->str_val=my_realloc(dest->str_val,src->alloced_len+1,
				 MYF(MY_WME))))
      !(dest->str_val= dest->str_val
        ? my_realloc(dest->str_val, src->alloced_len, MYF(MY_WME))
        : my_malloc(src->alloced_len, MYF(MY_WME))))
    die("Out of memory");
  else
    dest->alloced_len= src->alloced_len;

  /* Copy str_val data to dest */
  dest->str_val_len= src->str_val_len;
  memcpy(dest->str_val,src->str_val,src->str_val_len+1);
  if (src->str_val_len)
    memcpy(dest->str_val, src->str_val, src->str_val_len);
}

int eval_expr(VAR* v, const char *p, const char** p_end)
+7 −0
Original line number Diff line number Diff line
@@ -206,6 +206,13 @@ source database
hej
hej 
hej
1


a long variable content
a long variable content
a long $where variable content

mysqltest: At line 1: Missing arguments to let
mysqltest: At line 1: Missing variable name in let
mysqltest: At line 1: Variable name in hi=hi does not start with '$'
+20 −0
Original line number Diff line number Diff line
@@ -473,6 +473,26 @@ echo $1;
let $1 = hej;
echo $1;

let $1=1;
let $2=$1;
echo $2;
let $5=$6;
echo $5;
echo $6;

let $where=a long variable content;
echo $where;

let $where2= $where;
echo $where2;

let $where3=a long $where variable content;
echo $where3;

let $novar1= $novar2;
echo $novar1;



# Test illegal uses of let