MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:msvensson Date:February 10 2006 11:11am
Subject:bk commit into 5.0 tree (msvensson:1.2020) BUG#17280
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson does a push these changes will
be propagated 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://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2020 06/02/10 12:11:16 msvensson@neptunus.(none) +3 -0
  Bug#17280 mysqltest, --echo sometimes does not expand $variables
   - Evaluate all variables in the text before printing it to result file

  mysql-test/t/mysqltest.test
    1.29 06/02/10 12:11:11 msvensson@neptunus.(none) +13 -0
    Add more advanced tests for echo of strings with several variables 
    and/or text plus variables. Also test that variables can be escaped

  mysql-test/r/mysqltest.result
    1.25 06/02/10 12:11:11 msvensson@neptunus.(none) +17 -2
    Update results for echo

  client/mysqltest.c
    1.197 06/02/10 12:11:10 msvensson@neptunus.(none) +15 -13
    Update echo command to vvaluate all variables in the string before printing, allow
    for variable names to be escaped using \

# 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:	msvensson
# Host:	neptunus.(none)
# Root:	/home/msvensson/mysql/bug17280/my50-bug17280

--- 1.24/mysql-test/r/mysqltest.result	2006-01-11 11:06:20 +01:00
+++ 1.25/mysql-test/r/mysqltest.result	2006-02-10 12:11:11 +01:00
@@ -201,8 +201,14 @@
 - world''s most
 -- popular open
 # source database
-'$message'
-"$message"
+'# MySQL: The
+- world''s most
+-- popular open
+# source database'
+"# MySQL: The
+- world''s most
+-- popular open
+# source database"
 hej
 hej 
 hej
@@ -222,6 +228,15 @@
 mysqltest: At line 1: Missing variable name in let
 mysqltest: At line 1: Variable name in =hi does not start with '$'
 mysqltest: At line 1: Missing assignment operator in let
+# Execute: --echo # <whatever> success: $success
+# <whatever> success: 1
+# Execute: echo # <whatever> success: $success ;
+# <whatever> success: 1 
+# The next two variants work fine and expand the content of $success
+# Execute: --echo $success
+1
+# Execute: echo $success ;
+1 
 mysqltest: At line 1: Missing file name in source
 mysqltest: At line 1: Could not open file ./non_existingFile
 mysqltest: In included file "./var/tmp/recursive.sql": At line 1: Source directives are nesting too deep

--- 1.28/mysql-test/t/mysqltest.test	2006-01-12 18:19:51 +01:00
+++ 1.29/mysql-test/t/mysqltest.test	2006-02-10 12:11:11 +01:00
@@ -539,6 +539,19 @@
 --error 1
 --exec echo "let hi;" | $MYSQL_TEST  2>&1
 
+# More advanced test for bug#17280
+let $success= 1;
+--echo # Execute: --echo # <whatever> success: \$success
+--echo # <whatever> success: $success
+--echo # Execute: echo # <whatever> success: \$success ;
+echo # <whatever> success: $success ;
+
+--echo # The next two variants work fine and expand the content of \$success
+--echo # Execute: --echo \$success
+--echo $success
+--echo # Execute: echo \$success ;
+echo $success ;
+
 # ----------------------------------------------------------------------------
 # Test to assign let from query
 # let $<var_name>=`<query>`;

--- 1.196/client/mysqltest.c	2006-01-11 11:10:53 +01:00
+++ 1.197/client/mysqltest.c	2006-02-10 12:11:10 +01:00
@@ -1384,38 +1384,40 @@
 
 /*
   Print the content between echo and <delimiter> to result file.
-  If content is a variable, the variable value will be retrieved
+  Evaluate all variables in the string before printing, allow
+  for variable names to be escaped using \
 
   SYNOPSIS
     do_echo()
     q  called command
 
   DESCRIPTION
-    Usage 1:
     echo text
     Print the text after echo until end of command to result file
 
-    Usage 2:
     echo $<var_name>
     Print the content of the variable <var_name> to result file
 
+    echo Some text $<var_name>
+    Print "Some text" plus the content of the variable <var_name> to
+    result file
+
+    echo Some text \$<var_name>
+    Print "Some text" plus $<var_name> to result file
 */
 
-int do_echo(struct st_query *q)
+int do_echo(struct st_query *command)
 {
-  char *p= q->first_argument;
-  DYNAMIC_STRING *ds;
-  VAR v;
-  var_init(&v,0,0,0,0);
+  DYNAMIC_STRING *ds, ds_echo;
 
   ds= &ds_res;
 
-  eval_expr(&v, p, 0); /* NULL terminated */
-  if (v.str_val_len)
-    dynstr_append_mem(ds, v.str_val, v.str_val_len);
+  init_dynamic_string(&ds_echo, "", 256, 256);
+  do_eval(&ds_echo, command->first_argument);
+  dynstr_append_mem(ds, ds_echo.str, ds_echo.length);
   dynstr_append_mem(ds, "\n", 1);
-  var_free(&v);
-  q->last_argument= q->end;
+  dynstr_free(&ds_echo);
+  command->last_argument= command->end;
   return 0;
 }
 
Thread
bk commit into 5.0 tree (msvensson:1.2020) BUG#17280msvensson10 Feb