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.2021 06/02/15 22:43:42 msvensson@neptunus.(none) +3 -0
Add possibility to have a negative expression in "if" and "while" in mysqltest
mysql-test/t/mysqltest.test
1.29 06/02/15 22:43:38 msvensson@neptunus.(none) +30 -1
Add test for if
Add test for while with ! expr
mysql-test/r/mysqltest.result
1.25 06/02/15 22:43:38 msvensson@neptunus.(none) +3 -0
Update test results
client/mysqltest.c
1.199 06/02/15 22:43:38 msvensson@neptunus.(none) +45 -4
Extend 'do_block' to be able to process a !<expression>.
Making it possible to do 'if(!$i)' and 'while(!$i)'
# 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/bug16795/my50-bug16795
--- 1.24/mysql-test/r/mysqltest.result 2006-01-11 11:06:20 +01:00
+++ 1.25/mysql-test/r/mysqltest.result 2006-02-15 22:43:38 +01:00
@@ -309,7 +309,10 @@
test2
test3
test4
+Counter is greater than 0, (counter=10)
+Counter is not 0, (counter=0)
1
+Testing while with not
mysqltest: In included file "./include/mysqltest_while.inc": At line 64: Nesting too
deeply
mysqltest: At line 1: missing '(' in while
mysqltest: At line 1: missing ')' in while
--- 1.28/mysql-test/t/mysqltest.test 2006-01-12 18:19:51 +01:00
+++ 1.29/mysql-test/t/mysqltest.test 2006-02-15 22:43:38 +01:00
@@ -742,6 +742,30 @@
--delimiter ;
echo test4;
+
+# ----------------------------------------------------------------------------
+# Test if
+# ----------------------------------------------------------------------------
+
+let $counter=10;
+if ($counter)
+{
+ echo Counter is greater than 0, (counter=10);
+}
+if (!$counter)
+{
+ echo Counter is not 0, (counter=10);
+}
+let $counter=0;
+if ($counter)
+{
+ echo Counter is greater than 0, (counter=0);
+}
+if (!$counter)
+{
+ echo Counter is not 0, (counter=0);
+}
+
# ----------------------------------------------------------------------------
# Test while, { and }
# ----------------------------------------------------------------------------
@@ -755,7 +779,12 @@
# One liner
#let $i=1;while ($i){echo $i;dec $i;}
-
+let $i=0;
+while (!$i)
+{
+ echo Testing while with not;
+ inc $i;
+}
# Exceed max nesting level
--error 1
--- 1.198/client/mysqltest.c 2006-02-02 11:45:30 +01:00
+++ 1.199/client/mysqltest.c 2006-02-15 22:43:38 +01:00
@@ -2362,12 +2362,41 @@
}
+/*
+ Process start of a "if" or "while" statement
+
+ SYNOPSIS
+ do_block()
+ cmd Type of block
+ q called command
+
+ DESCRIPTION
+ if ([!]<expr>)
+ {
+ <block statements>
+ }
+
+ while ([!]<expr>)
+ {
+ <block statements>
+ }
+
+ Evaluates the <expr> and if it evaluates to
+ greater than zero executes the following code block.
+ A '!' can be used before the <expr> to indicate it should
+ be executed if it evaluates to zero.
+
+ */
+
int do_block(enum block_cmd cmd, struct st_query* q)
{
char *p= q->first_argument;
const char *expr_start, *expr_end;
VAR v;
const char *cmd_name= (cmd == cmd_while ? "while" : "if");
+ my_bool not_expr= FALSE;
+ DBUG_ENTER("do_block");
+ DBUG_PRINT("enter", ("%s", cmd_name));
/* Check stack overflow */
if (cur_block == block_stack_end)
@@ -2388,8 +2417,16 @@
/* Parse and evaluate test expression */
expr_start= strchr(p, '(');
- if (!expr_start)
+ if (!expr_start++)
die("missing '(' in %s", cmd_name);
+
+ /* Check for !<expr> */
+ if (*expr_start == '!')
+ {
+ not_expr= TRUE;
+ expr_start++; /* Step past the '!' */
+ }
+ /* Find ending ')' */
expr_end= strrchr(expr_start, ')');
if (!expr_end)
die("missing ')' in %s", cmd_name);
@@ -2403,14 +2440,20 @@
die("Missing '{' after %s. Found \"%s\"", cmd_name, p);
var_init(&v,0,0,0,0);
- eval_expr(&v, ++expr_start, &expr_end);
+ eval_expr(&v, expr_start, &expr_end);
/* Define inner block */
cur_block++;
cur_block->cmd= cmd;
cur_block->ok= (v.int_val ? TRUE : FALSE);
+ if (not_expr)
+ cur_block->ok = !cur_block->ok;
+
+ DBUG_PRINT("info", ("OK: %d", cur_block->ok));
+
var_free(&v);
+ DBUG_VOID_RETURN;
return 0;
}
@@ -3046,8 +3089,6 @@
static void append_field(DYNAMIC_STRING *ds, uint col_idx, MYSQL_FIELD* field,
const char* val, ulonglong len, bool is_null)
{
-
- char buf[256];
if (col_idx < max_replace_column && replace_column[col_idx])
{
val= replace_column[col_idx];
| Thread |
|---|
| • bk commit into 5.0 tree (msvensson:1.2021) | msvensson | 15 Feb |