List:Internals« Previous MessageNext Message »
From:sasha Date:June 30 2001 7:08pm
Subject:bk commit into 4.0 tree
View as plain text  
Below is the list of changes that have just been committed into a
4.0 repository of sasha. When sasha does a push, they will be propogated to 
the main repository and within 24 hours after the push to the public repository. 
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet@stripped, 2001-06-30 13:08:35-06:00, sasha@stripped
  support for eval_result and let $var = `query` syntax in mysql-test
  fixes for rpl_log test to make it config-independent

  BitKeeper/etc/ignore
    1.74 01/06/30 13:08:33 sasha@stripped +1 -0
    Added mysql-test/r/rpl_log.eval to the ignore list

  client/mysqltest.c
    1.47 01/06/30 13:08:33 sasha@stripped +97 -33
    support for eval_result and let $var = `query` syntax

  mysql-test/Makefile.am
    1.17 01/06/30 13:08:33 sasha@stripped +2 -0
    import more variables into mysql-test-run

  mysql-test/mysql-test-run.sh
    1.85 01/06/30 13:08:33 sasha@stripped +7 -0
    if we got wrong result on eval_result test case, diff against the
    expanded result, not the template

  mysql-test/r/rpl_log.result
    1.5 01/06/30 13:08:33 sasha@stripped +7 -7
    change config-dependent parts of the result to dynamic variables

  mysql-test/t/rpl_log.test
    1.4 01/06/30 13:08:33 sasha@stripped +2 -1
    get server version from the server
    remove obsoleted replace hack to solve port problem - use eval_result
    instead

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	sasha
# Host:	mysql.sashanet.com
# Root:	/home/sasha/src/bk/mysql-4.0

--- 1.84/mysql-test/mysql-test-run.sh	Thu Jun 28 01:22:50 2001
+++ 1.85/mysql-test/mysql-test-run.sh	Sat Jun 30 13:08:33 2001
@@ -333,6 +333,13 @@
 {
   reject_file=r/$1.reject
   result_file=r/$1.result
+  eval_file=r/$1.eval
+  
+  if [ -f $eval_file ]
+  then
+    result_file=$eval_file
+  fi
+    
   if [ -x "$DIFF" ] && [ -f $reject_file ]
   then
     echo "Below are the diffs between actual and expected results:"

--- 1.46/client/mysqltest.c	Sun Jun 24 13:11:00 2001
+++ 1.47/client/mysqltest.c	Sat Jun 30 13:08:33 2001
@@ -164,7 +164,7 @@
 Q_DIRTY_CLOSE,      Q_REPLACE,
 Q_PING,             Q_EVAL,
 Q_RPL_PROBE,        Q_ENABLE_RPL_PARSE,
-Q_DISABLE_RPL_PARSE,
+Q_DISABLE_RPL_PARSE, Q_EVAL_RESULT,
 Q_UNKNOWN,                             /* Unknown command.   */
 Q_COMMENT,                             /* Comments, ignored. */
 Q_COMMENT_WITH_COMMAND
@@ -173,7 +173,7 @@
 /* this should really be called command */
 struct st_query
 {
-  char *query, *query_buf,*first_argument;
+  char *query, *query_buf,*first_argument,*end;
   int first_word_len;
   my_bool abort_on_error, require_file;
   uint expected_errno[MAX_EXPECTED_ERRORS];
@@ -195,7 +195,7 @@
   "dirty_close",      "replace_result",
   "ping",             "eval",
   "rpl_probe",        "enable_rpl_parse",
-  "disable_rpl_parse",
+  "disable_rpl_parse", "eval_result",
   0
 };
 
@@ -238,10 +238,12 @@
 static int initialize_replace_buffer(void);
 static void free_replace_buffer(void);
 static void do_eval(DYNAMIC_STRING* query_eval, const char* query);
+void str_to_file(const char* fname, char* str, int size);
 
 struct st_replace *glob_replace;
 static char *out_buff;
 static uint out_length;
+static int eval_result = 0;
 
 static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
 {
@@ -298,7 +300,7 @@
 {
   do
   {
-    if (*cur_file != stdin)
+    if (*cur_file != stdin && *cur_file)
       my_fclose(*cur_file,MYF(0));
   } while (cur_file-- != file_stack);
 }
@@ -393,25 +395,53 @@
 int dyn_string_cmp(DYNAMIC_STRING* ds, const char* fname)
 {
   MY_STAT stat_info;
-  char *tmp;
+  char *tmp, *res_ptr;
+  char eval_file[FN_REFLEN];
   int res;
+  uint res_len;
   int fd;
+  DYNAMIC_STRING res_ds;
   DBUG_ENTER("dyn_string_cmp");
 
   if (!my_stat(fname, &stat_info, MYF(MY_WME)))
     die(NullS);
-  if (stat_info.st_size != ds->length)
+  if (!eval_result && stat_info.st_size != ds->length)
     DBUG_RETURN(2);
-  if (!(tmp = (char*) my_malloc(ds->length, MYF(MY_WME))))
+  if (!(tmp = (char*) my_malloc(stat_info.st_size + 1, MYF(MY_WME))))
     die(NullS);
   if ((fd = my_open(fname, O_RDONLY, MYF(MY_WME))) < 0)
     die(NullS);
   if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP)))
     die(NullS);
-  res = (memcmp(tmp, ds->str, stat_info.st_size)) ?  1 : 0;
+  tmp[stat_info.st_size] = 0;
+  init_dynamic_string(&res_ds, "", 0, 65536);
+  if (eval_result)
+  {
+    do_eval(&res_ds, tmp);
+    res_ptr = res_ds.str;
+    if((res_len = res_ds.length) != ds->length)
+    {
+      res = 2;
+      goto err;
+    }
+  }
+  else
+  {
+    res_ptr = tmp;
+    res_len = stat_info.st_size;
+  }
+  
+  res = (memcmp(res_ptr, ds->str, res_len)) ?  1 : 0;
+  
+err:  
+  if(res && eval_result)
+     str_to_file(fn_format(eval_file, fname, "", ".eval",2), res_ptr,
+		  res_len);
+    
   my_free((gptr) tmp, MYF(0));
   my_close(fd, MYF(MY_WME));
-
+  dynstr_free(&res_ds);
+  
   DBUG_RETURN(res);
 }
 
@@ -508,7 +538,6 @@
 	    char* var_val_end)
 {
   int digit;
-  int val_len;
   VAR* v;
   if (*var_name++ != '$')
     {
@@ -523,21 +552,8 @@
     }
   else 
    v = var_reg + digit;
-  if (v->alloced_len < (val_len = (int)(var_val_end - var_val)+1))
-    {
-      v->alloced_len = (val_len < MIN_VAR_ALLOC) ? MIN_VAR_ALLOC : val_len;
-     if (!(v->str_val =
-	  v->str_val ? my_realloc(v->str_val, v->alloced_len,  MYF(MY_WME)) :
-	   my_malloc(v->alloced_len, MYF(MY_WME))))
-	 die("Out of memory");
-    }
-  val_len--;
-  memcpy(v->str_val, var_val, val_len);
-  v->str_val_len = val_len;
-  v->str_val[val_len] = 0;
-  v->int_val = atoi(v->str_val);
-  v->int_dirty=0;
-  return 0;
+  
+  return eval_expr(v, var_val, (const char**)&var_val_end);
 }
 
 int open_file(const char* name)
@@ -565,6 +581,35 @@
   return open_file(name);
 }
 
+int var_query_set(VAR* v, const char* p, const char** p_end)
+{
+  char* end = (char*)((p_end && *p_end) ? *p_end : p + strlen(p));
+  MYSQL_RES *res;
+  MYSQL_ROW row;
+  MYSQL* mysql = &cur_con->mysql;
+  LINT_INIT(res);
+  
+  while (end > p && *end != '`')
+    --end;
+  if (p == end)
+    die("Syntax error in query, missing '`'");
+  ++p;
+
+  if (mysql_real_query(mysql, p, (int)(end - p)) ||
+      !(res = mysql_store_result(mysql)))
+  {
+    *end = 0;
+    die("Error running query '%s': %s", p, mysql_error(mysql));
+  }
+
+  if ((row = mysql_fetch_row(res)) && row[0])
+    eval_expr(v, row[0], 0);
+  else
+    eval_expr(v, "", 0);
+
+  mysql_free_result(res);
+  return 0;
+}
 
 int eval_expr(VAR* v, const char* p, const char** p_end)
 {
@@ -577,10 +622,27 @@
 	  return 0;
 	}
     }
+  else if(*p == '`')
+  {
+    return var_query_set(v, p, p_end);
+  }
   else
     {
-      v->str_val = (char*)p;
-      v->str_val_len = (p_end && *p_end) ? (int) (*p_end - p) : (int) strlen(p);
+      int new_val_len = (p_end && *p_end) ?
+	 (int) (*p_end - p) : (int) strlen(p);
+      if (new_val_len + 1 >= v->alloced_len)
+      {
+        v->alloced_len = (new_val_len < MIN_VAR_ALLOC - 1) ?
+	  MIN_VAR_ALLOC : new_val_len + 1;
+	if (!(v->str_val =
+	      v->str_val ? my_realloc(v->str_val, v->alloced_len,
+				      MYF(MY_WME)) :
+	      my_malloc(v->alloced_len, MYF(MY_WME))))
+	  die("Out of memory");
+      }
+      v->str_val_len = new_val_len;
+      memcpy(v->str_val, p, new_val_len);
+      v->str_val[new_val_len] = 0;
       v->int_val=atoi(p);
       v->int_dirty=0;
       return 0;
@@ -724,9 +786,7 @@
   while(*p && isspace(*p))
     p++;
   var_val_start = p;
-  while(*p && !isspace(*p))
-    p++;
-  return var_set(var_name, var_name_end, var_val_start, p);
+  return var_set(var_name, var_name_end, var_val_start, q->end);
 }
 
 int do_rpl_probe(struct st_query* __attribute__((unused)) q)
@@ -1400,7 +1460,7 @@
   q->first_word_len = (uint) (p - q->query);
   while (*p && isspace(*p)) p++;
   q->first_argument=p;
-
+  q->end = strend(q->query);
   parser.read_lines++;
   return 0;
 }
@@ -1787,11 +1847,13 @@
   if(!val_len)
     val_len = strlen(val) ;
   val_alloc_len = val_len + 16; /* room to grow */
-  if(!(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) + val_alloc_len
+  if(!(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) 
 				 + name_len, MYF(MY_WME))))
     die("Out of memory");
   tmp_var->name = (char*)tmp_var + sizeof(*tmp_var);
-  tmp_var->str_val = tmp_var->name + name_len;
+  if(!(tmp_var->str_val = my_malloc(val_alloc_len, MYF(MY_WME))))
+    die("Out of memory");
+  
   memcpy(tmp_var->name, name, name_len);
   memcpy(tmp_var->str_val, val, val_len + 1);
   tmp_var->name_len = name_len;
@@ -1804,6 +1866,7 @@
 
 static void var_free(void* v)
 {
+  my_free(((VAR*)v)->str_val, MYF(MY_WME));
   my_free(v, MYF(MY_WME));
 }
 
@@ -1901,6 +1964,7 @@
       case Q_ECHO: do_echo(q); break;
       case Q_SYSTEM: do_system(q); break;
       case Q_LET: do_let(q); break;
+      case Q_EVAL_RESULT: eval_result = 1; break;	
       case Q_EVAL:
         if (q->query == q->query_buf)
 	  q->query += q->first_word_len;

--- 1.73/BitKeeper/etc/ignore	Fri Jun 29 09:55:20 2001
+++ 1.74/BitKeeper/etc/ignore	Sat Jun 30 13:08:33 2001
@@ -371,3 +371,4 @@
 .gdbinit
 .vimrc
 scripts/mysqld_safe
+mysql-test/r/rpl_log.eval

--- 1.16/mysql-test/Makefile.am	Sat Apr 21 08:12:59 2001
+++ 1.17/mysql-test/Makefile.am	Sat Jun 30 13:08:33 2001
@@ -59,6 +59,8 @@
 	  -e 's!@''libexecdir''@!$(libexecdir)!g' \
 	  -e 's!@''PERL''@!@PERL@!' \
 	  -e 's!@''VERSION''@!@VERSION@!' \
+	  -e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \
+	  -e 's!@''MYSQL_NO_DASH_VERSION''@!@MYSQL_NO_DASH_VERSION@!' \
 	  -e 's!@''MYSQL_SERVER_SUFFIX''@!@MYSQL_SERVER_SUFFIX@!' \
 	  $< > $@-t
 	@CHMOD@ +x $@-t

--- 1.4/mysql-test/r/rpl_log.result	Tue Jun 26 17:02:32 2001
+++ 1.5/mysql-test/r/rpl_log.result	Sat Jun 30 13:08:33 2001
@@ -1,11 +1,11 @@
 Log_name	Pos	Event_type	Server_id	Log_seq	Info
-master-bin.001	4	Start	1	1	Server ver: 4.0.0-debug-log, Binlog ver: 2
+master-bin.001	4	Start	1	1	Server ver: $VERSION, Binlog ver: 2
 master-bin.001	79	Query	1	2	use test; create table t1(n int not null auto_increment primary key)
 master-bin.001	172	Intvar	1	3	INSERT_ID=1
 master-bin.001	200	Query	1	4	use test; insert into t1 values (NULL)
 master-bin.001	263	Query	1	5	use test; drop table t1
 master-bin.001	311	Query	1	6	use test; create table t1 (word char(20) not null)
-master-bin.001	386	Load	1	7	use test; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 FIELDS TERMINATED BY '\t' ESCAPED BY '\\' LINES TERMINATED BY '\n' (word)
+master-bin.001	386	Load	1	7	use test; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 FIELDS TERMINATED BY '\\t' ESCAPED BY '\\\\' LINES TERMINATED BY '\\n' (word)
 master-bin.001	468	Query	1	8	use test; drop table t1
 Log_name	Pos	Event_type	Server_id	Log_seq	Info
 master-bin.001	79	Query	1	2	use test; create table t1(n int not null auto_increment primary key)
@@ -21,12 +21,12 @@
 master-bin.001	200	Query	1	4	use test; insert into t1 values (NULL)
 master-bin.001	263	Query	1	5	use test; drop table t1
 master-bin.001	311	Query	1	6	use test; create table t1 (word char(20) not null)
-master-bin.001	386	Load	1	7	use test; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 FIELDS TERMINATED BY '\t' ESCAPED BY '\\' LINES TERMINATED BY '\n' (word)
+master-bin.001	386	Load	1	7	use test; LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 FIELDS TERMINATED BY '\\t' ESCAPED BY '\\\\' LINES TERMINATED BY '\\n' (word)
 master-bin.001	468	Query	1	8	use test; drop table t1
 master-bin.001	516	Rotate	1	9	master-bin.002;pos=4
 master-bin.001	557	Stop	1	10	
 Log_name	Pos	Event_type	Server_id	Log_seq	Info
-master-bin.002	4	Start	1	1	Server ver: 4.0.0-debug-log, Binlog ver: 2
+master-bin.002	4	Start	1	1	Server ver: $VERSION, Binlog ver: 2
 master-bin.002	79	Query	1	2	use test; create table t1 (n int)
 master-bin.002	137	Query	1	3	use test; insert into t1 values (1)
 master-bin.002	197	Query	1	4	use test; drop table t1
@@ -38,7 +38,7 @@
 slave-bin.002
 Log_name	Pos	Event_type	Server_id	Log_seq	Info
 slave-bin.001	4	Start	2	1	Server ver: 4.0.0-debug-log, Binlog ver: 2
-slave-bin.001	79	Slave	2	2	host=127.0.0.1,port=9306,log=master-bin.001,pos=4
+slave-bin.001	79	Slave	2	2	host=127.0.0.1,port=$MASTER_MYPORT,log=master-bin.001,pos=4
 slave-bin.001	132	Query	1	2	use test; create table t1(n int not null auto_increment primary key)
 slave-bin.001	225	Intvar	1	3	INSERT_ID=1
 slave-bin.001	253	Query	1	4	use test; insert into t1 values (NULL)
@@ -49,9 +49,9 @@
 slave-bin.001	527	Stop	2	4	
 Log_name	Pos	Event_type	Server_id	Log_seq	Info
 slave-bin.002	4	Start	2	1	Server ver: 4.0.0-debug-log, Binlog ver: 2
-slave-bin.002	79	Slave	2	2	host=127.0.0.1,port=9306,log=master-bin.002,pos=4
+slave-bin.002	79	Slave	2	2	host=127.0.0.1,port=$MASTER_MYPORT,log=master-bin.002,pos=4
 slave-bin.002	132	Query	1	2	use test; create table t1 (n int)
 slave-bin.002	190	Query	1	3	use test; insert into t1 values (1)
 slave-bin.002	250	Query	1	4	use test; drop table t1
 Master_Host	Master_User	Master_Port	Connect_retry	Log_File	Pos	Slave_Running	Replicate_do_db	Replicate_ignore_db	Last_errno	Last_error	Skip_counter	Last_log_seq
-127.0.0.1	root	9999	1	master-bin.002	245	Yes			0		0	4
+127.0.0.1	root	$MASTER_MYPORT	1	master-bin.002	245	Yes			0		0	4

--- 1.3/mysql-test/t/rpl_log.test	Sat Jun 23 19:37:23 2001
+++ 1.4/mysql-test/t/rpl_log.test	Sat Jun 30 13:08:33 2001
@@ -1,4 +1,5 @@
 source include/master-slave.inc;
+eval_result; #result depends on some server specific params
 
 #clean up slave binlogs
 connection slave;
@@ -28,10 +29,10 @@
 show master logs;
 save_master_pos;
 connection slave;
+let $VERSION=`select version()`;
 slave start;
 sync_with_master;
 show master logs;
 show binlog events in 'slave-bin.001' from 4;
 show binlog events in 'slave-bin.002' from 4;
---replace_result 9306 9999 3334 9999 3335 9999
 show slave status;
Thread
bk commit into 4.0 treesasha30 Jun