From fc08a36c921da39d24989b5d5233cdb69e057275 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 22 Feb 2006 17:07:18 +0200 Subject: BUG#17265 Assertion failure in rpl_row_view01. To quote Timour review lines: The actual cause of the bug is that sql_base.cc:setup_wild() sets "select_lex->with_wild = 0" (in the end of the function) once it expands all wild-cards, and wild-card expansion is done during the prepare phase. During this phase we replace all "*" with the corresponding items, which for views happen to be references to references. When we do execute, select_lex->with_wild = 0, and all "*" are already replaced by the corresponding items, which in the case of views need to be dereferenced first. Fixed by refining the assert. Regression test for the bug is rpl_row_view01, as was reported. sql/item.cc: Refined asssert, suggested by Evgen, due to BUG#17265 prepared statement for select with ps-protocol does not hold the former. --- sql/item.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index fbdb217f5df..367452444d2 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5116,9 +5116,9 @@ bool Item_direct_view_ref::eq(const Item *item, bool binary_cmp) const if (item_ref->ref_type() == VIEW_REF) { Item *item_ref_ref= *(item_ref->ref); - DBUG_ASSERT((*ref)->type() == FIELD_ITEM && - (item_ref_ref->type() == FIELD_ITEM)); - return (*ref == item_ref_ref); + DBUG_ASSERT((*ref)->real_item()->type() == FIELD_ITEM && + (item_ref_ref->real_item()->type() == FIELD_ITEM)); + return ((*ref)->real_item() == item_ref_ref->real_item()); } } return FALSE; -- cgit v1.2.1 From 09eee68dbaa5cb2d74f2abc70979eec7f1e38e6c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Feb 2006 10:11:57 +0100 Subject: Add new parameter to do_eval so that only unescaped variables in input string is expanded and rest of string is left untouched. client/mysqltest.c: Add new parameter to 'do_eval' that will add any escape chars found in the input string to the output string. This is used in 'do_system' and in 'do_exec' where only unescaped variables will be expanded, rest of the string will be left untouched. mysql-test/r/mysqltest.result: Update test result mysql-test/t/mysqldump.test: Revert previous patch that added extra \\ in "exec" command mysql-test/t/mysqltest.test: Revert previous patch that added extra \\ in exec command --- client/mysqltest.c | 20 ++++++++++++++------ mysql-test/r/mysqltest.result | 2 +- mysql-test/t/mysqldump.test | 2 +- mysql-test/t/mysqltest.test | 26 +++++++++++++------------- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 6bf361c17aa..30cb1839c7a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -457,7 +457,8 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name); static void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds, const char *from, int len); void free_pointer_array(POINTER_ARRAY *pa); -static void do_eval(DYNAMIC_STRING *query_eval, const char *query); +static void do_eval(DYNAMIC_STRING *query_eval, const char *query, + my_bool pass_through_escape_chars); static void str_to_file(const char *fname, char *str, int size); #ifdef __WIN__ @@ -489,7 +490,8 @@ static void handle_error(const char *query, struct st_query *q, const char *err_sqlstate, DYNAMIC_STRING *ds); static void handle_no_error(struct st_query *q); -static void do_eval(DYNAMIC_STRING* query_eval, const char *query) +static void do_eval(DYNAMIC_STRING* query_eval, const char *query, + my_bool pass_through_escape_chars) { const char *p; register char c, next_c; @@ -524,6 +526,12 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char *query) { /* Set escaped only if next char is \ or $ */ escaped = 1; + + if (pass_through_escape_chars) + { + /* The escape char should be added to the output string. */ + dynstr_append_mem(query_eval, p, 1); + } } else dynstr_append_mem(query_eval, p, 1); @@ -713,7 +721,7 @@ static int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) init_dynamic_string(&res_ds, "", 0, 65536); if (eval_result) { - do_eval(&res_ds, tmp); + do_eval(&res_ds, tmp, FALSE); res_ptr = res_ds.str; if ((res_len = res_ds.length) != ds->length) { @@ -1085,7 +1093,7 @@ static void do_exec(struct st_query *query) init_dynamic_string(&ds_cmd, 0, strlen(cmd)+256, 256); /* Eval the command, thus replacing all environment variables */ - do_eval(&ds_cmd, cmd); + do_eval(&ds_cmd, cmd, TRUE); cmd= ds_cmd.str; DBUG_PRINT("info", ("Executing '%s' as '%s'", @@ -1379,7 +1387,7 @@ int do_system(struct st_query *command) init_dynamic_string(&ds_cmd, 0, strlen(command->first_argument) + 64, 256); /* Eval the system command, thus replacing all environment variables */ - do_eval(&ds_cmd, command->first_argument); + do_eval(&ds_cmd, command->first_argument, TRUE); DBUG_PRINT("info", ("running system command '%s' as '%s'", command->first_argument, ds_cmd.str)); @@ -3984,7 +3992,7 @@ static void run_query(MYSQL *mysql, struct st_query *command, int flags) if (command->type == Q_EVAL) { init_dynamic_string(&eval_query, "", 16384, 65536); - do_eval(&eval_query, command->query); + do_eval(&eval_query, command->query, FALSE); query = eval_query.str; query_len = eval_query.length; } diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 067054510c2..d2114280a84 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -218,7 +218,7 @@ mysqltest: At line 1: Missing variable name in let mysqltest: At line 1: Variable name in hi=hi does not start with '$' mysqltest: At line 1: Missing assignment operator in let mysqltest: At line 1: Missing assignment operator in let -mysqltest: At line 1: Missing arguments to let +mysqltest: At line 1: Missing assignment operator in let 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 diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index d5e48387203..0564ee9964c 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -647,7 +647,7 @@ select '------ Testing with illegal table names ------' as test_sequence ; --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\\t1" 2>&1 --error 6 ---exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\\\\\\t1" 2>&1 +--exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\\\\t1" 2>&1 --error 6 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "t\1" 2>&1 diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 50f8c02dbae..3726d6b8096 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -678,7 +678,7 @@ echo $i; --error 1 --exec echo "inc i;" | $MYSQL_TEST 2>&1 --error 1 ---exec echo "let \\\$i=100; inc \\\$i 1000; echo \\\$i;" | $MYSQL_TEST 2>&1 +--exec echo "let \$i=100; inc \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1 inc $i; inc $i; inc $i; --echo $i echo $i; @@ -706,7 +706,7 @@ echo $d; --error 1 --exec echo "dec i;" | $MYSQL_TEST 2>&1 --error 1 ---exec echo "let \\\$i=100; dec \\\$i 1000; echo \\\$i;" | $MYSQL_TEST 2>&1 +--exec echo "let \$i=100; dec \$i 1000; echo \$i;" | $MYSQL_TEST 2>&1 # ---------------------------------------------------------------------------- @@ -761,11 +761,11 @@ while ($i) --error 1 --exec echo "source include/mysqltest_while.inc;" | $MYSQL_TEST 2>&1 --error 1 ---exec echo "while \\\$i;" | $MYSQL_TEST 2>&1 +--exec echo "while \$i;" | $MYSQL_TEST 2>&1 --error 1 ---exec echo "while (\\\$i;" | $MYSQL_TEST 2>&1 +--exec echo "while (\$i;" | $MYSQL_TEST 2>&1 --error 1 ---exec echo "let \\\$i=1; while (\\\$i) dec \\\$i;" | $MYSQL_TEST 2>&1 +--exec echo "let \$i=1; while (\$i) dec \$i;" | $MYSQL_TEST 2>&1 --error 1 --exec echo "};" | $MYSQL_TEST 2>&1 --error 1 @@ -877,22 +877,22 @@ select "a" as col1, "c" as col2; --exec echo "connect (con1,localhost,root,,,,,SMTP POP);" | $MYSQL_TEST 2>&1 # Repeat connect/disconnect ---exec echo "let \\\$i=100;" > var/tmp/con.sql ---exec echo "while (\\\$i)" >> var/tmp/con.sql +--exec echo "let \$i=100;" > var/tmp/con.sql +--exec echo "while (\$i)" >> var/tmp/con.sql --exec echo "{" >> var/tmp/con.sql ---exec echo " connect (test_con1,localhost,root,,); " >> var/tmp/con.sql +--exec echo " connect (test_con1,localhost,root,,); " >> var/tmp/con.sql --exec echo " disconnect test_con1; " >> var/tmp/con.sql ---exec echo " dec \\\$i; " >> var/tmp/con.sql +--exec echo " dec \$i; " >> var/tmp/con.sql --exec echo "}" >> var/tmp/con.sql --exec echo "source var/tmp/con.sql; echo OK;" | $MYSQL_TEST 2>&1 # Repeat connect/disconnect, exceed max number of connections ---exec echo "let \\\$i=200;" > var/tmp/con.sql ---exec echo "while (\\\$i)" >> var/tmp/con.sql +--exec echo "let \$i=200;" > var/tmp/con.sql +--exec echo "while (\$i)" >> var/tmp/con.sql --exec echo "{" >> var/tmp/con.sql --exec echo " connect (test_con1,localhost,root,,); " >> var/tmp/con.sql --exec echo " disconnect test_con1; " >> var/tmp/con.sql ---exec echo " dec \\\$i; " >> var/tmp/con.sql +--exec echo " dec \$i; " >> var/tmp/con.sql --exec echo "}" >> var/tmp/con.sql --error 1 --exec echo "source var/tmp/con.sql;" | $MYSQL_TEST 2>&1 @@ -1001,7 +1001,7 @@ select "this will be executed"; # # Test that a test file that does not generate any output fails. # ---exec echo "let \\\$i= 1;" > $MYSQL_TEST_DIR/var/tmp/query.sql +--exec echo "let \$i= 1;" > $MYSQL_TEST_DIR/var/tmp/query.sql --error 1 --exec $MYSQL_TEST -x var/tmp/query.sql 2>&1 -- cgit v1.2.1 From b8a77b14a14e96b05fe10d7ce5deb41655126c14 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 23 Feb 2006 10:35:53 +0100 Subject: Merge fixup client/mysqltest.c: Fix after merge, do_eval has three args Remove extre return in do_block --- client/mysqltest.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 57d76a169a7..cc75aaed3a8 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1438,7 +1438,7 @@ int do_echo(struct st_query *command) ds= &ds_res; init_dynamic_string(&ds_echo, "", 256, 256); - do_eval(&ds_echo, command->first_argument); + do_eval(&ds_echo, command->first_argument, FALSE); dynstr_append_mem(ds, ds_echo.str, ds_echo.length); dynstr_append_mem(ds, "\n", 1); dynstr_free(&ds_echo); @@ -2468,7 +2468,6 @@ int do_block(enum block_cmd cmd, struct st_query* q) var_free(&v); DBUG_VOID_RETURN; - return 0; } -- cgit v1.2.1