From bbec7eda631db68ef9b124c869193b2eceac24ec Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Jan 2006 00:24:57 +0100 Subject: [PATCH 1/4] Disable code for "let" to assign each column from query to it's own variable client/mysqltest.c: Disable "let" assign each column of query to own var mysql-test/r/mysqltest.result: Remove test results for disabled test mysql-test/t/mysqltest.test: Disable test for "let assigns each column of query to own var" --- client/mysqltest.c | 3 ++- mysql-test/r/mysqltest.result | 19 ------------------- mysql-test/t/mysqltest.test | 4 ++-- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index c31e8bc693b..a073df979f2 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1205,6 +1205,7 @@ int var_query_set(VAR* var, const char *query, const char** query_end) { if (row[0]) { +#ifdef NOT_YET /* Add to _ */ uint j; char var_col_name[MAX_VAR_NAME]; @@ -1218,7 +1219,7 @@ int var_query_set(VAR* var, const char *query, const char** query_end) } var_set(var_col_name, var_col_name + length, row[i], row[i] + lengths[i]); - +#endif /* Add column to tab separated string */ dynstr_append_mem(&result, row[i], lengths[i]); } diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 2657fb8a409..d0db0269a98 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -222,25 +222,6 @@ 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 does not start with '$' mysqltest: At line 1: Missing assignment operator in let -var1 -hi 1 hi there -hi -1 -hi there -var2 -2 - - -var2 again -2 - -2 - -var3 two columns with same name -1 2 3 -2 -2 -3 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 diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index ae28a66c685..ee309fbd7c9 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -543,7 +543,7 @@ echo $novar1; # Test to assign let from query # let $=``; # ---------------------------------------------------------------------------- - +--disable_parsing echo var1; let $var1= `select "hi" as "Col", 1 as "Column1", "hi there" as Col3`; echo $var1; @@ -574,7 +574,7 @@ echo $var3_var3; #echo failing query in let; #--error 1 #--exec echo "let $var2= `failing query;`" | $MYSQL_TEST 2>&1 - +--enable_parsing # ---------------------------------------------------------------------------- # Test source command # ---------------------------------------------------------------------------- From b5fb52dc4971354342126f3a018160366d09b30c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Jan 2006 11:06:26 +0100 Subject: [PATCH 2/4] Fix problem with strange printout of line numbers, detected on aix52, but existing on all platforms, just being masked by init of vars to zero. client/mysqltest.c: Remove lineno_stack, instead use the already existing file_stack and add a new variable lineno to keep track of what line in the file we are at. mysql-test/r/mysqltest.result: Correct test result, "At line 1" should be printed --- client/mysqltest.c | 31 ++++++++++++++++--------------- mysql-test/r/mysqltest.result | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index a073df979f2..31fd4992650 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -165,7 +165,6 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0; static my_bool view_protocol= 0, view_protocol_enabled= 0; static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0; static int parsing_disabled= 0; -static uint start_lineno, *lineno; const char *manager_user="root",*manager_host=0; char *manager_pass=0; int manager_port=MYSQL_MANAGER_PORT; @@ -180,13 +179,14 @@ typedef struct { FILE* file; const char *file_name; + uint lineno; /* Current line in file */ } test_file; static test_file file_stack[MAX_INCLUDE_DEPTH]; static test_file* cur_file; static test_file* file_stack_end; +uint start_lineno; /* Start line of query */ -static uint lineno_stack[MAX_INCLUDE_DEPTH]; static char TMPDIR[FN_REFLEN]; static char delimiter[MAX_DELIMITER]= DEFAULT_DELIMITER; static uint delimiter_length= 1; @@ -662,7 +662,7 @@ static void verbose_msg(const char *fmt, ...) va_start(args, fmt); fprintf(stderr, "mysqltest: "); - if (start_lineno > 0) + if (start_lineno != 0) fprintf(stderr, "At line %u: ", start_lineno); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); @@ -900,7 +900,7 @@ int open_file(const char *name) die("Could not open file %s", buff); } cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); - *++lineno=1; + cur_file->lineno=1; DBUG_RETURN(0); } @@ -2497,7 +2497,7 @@ int read_line(char *buf, int size) DBUG_ENTER("read_line"); LINT_INIT(quote); - start_lineno= *lineno; + start_lineno= cur_file->lineno; for (; p < buf_end ;) { no_save= 0; @@ -2512,28 +2512,25 @@ int read_line(char *buf, int size) } my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); cur_file->file_name= 0; - lineno--; - start_lineno= *lineno; if (cur_file == file_stack) { /* We're back at the first file, check if all { have matching } */ if (cur_block != block_stack) - { - start_lineno= *(lineno+1); die("Missing end of block"); - } + DBUG_PRINT("info", ("end of file")); DBUG_RETURN(1); } cur_file--; + start_lineno= cur_file->lineno; continue; } /* Line counting is independent of state */ if (c == '\n') - (*lineno)++; + cur_file->lineno++; switch(state) { case R_NORMAL: @@ -2562,14 +2559,15 @@ int read_line(char *buf, int size) break; case R_LINE_START: /* Only accept start of comment if this is the first line in query */ - if ((*lineno == start_lineno) && (c == '#' || c == '-' || parsing_disabled)) + if ((cur_file->lineno == start_lineno) && + (c == '#' || c == '-' || parsing_disabled)) { state = R_COMMENT; } else if (my_isspace(charset_info, c)) { if (c == '\n') - start_lineno= *lineno; /* Query hasn't started yet */ + start_lineno= cur_file->lineno; /* Query hasn't started yet */ no_save= 1; } else if (c == '}') @@ -2895,6 +2893,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0)))) die("Could not open %s: errno = %d", buff, errno); cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); + cur_file->lineno= 1; break; } case 'm': @@ -4291,7 +4290,7 @@ int main(int argc, char **argv) memset(&master_pos, 0, sizeof(master_pos)); file_stack_end= file_stack + MAX_INCLUDE_DEPTH - 1; cur_file= file_stack; - lineno = lineno_stack; + my_init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES, INIT_Q_LINES); @@ -4313,8 +4312,8 @@ int main(int argc, char **argv) { cur_file->file= stdin; cur_file->file_name= my_strdup("", MYF(MY_WME)); + cur_file->lineno= 1; } - *lineno=1; #ifndef EMBEDDED_LIBRARY if (manager_host) init_manager(); @@ -4609,6 +4608,8 @@ int main(int argc, char **argv) parser.current_line += current_line_inc; } + start_lineno= 0; + /* The whole test has been executed _sucessfully_ Time to compare result or save it to record file diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index d0db0269a98..067054510c2 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -149,7 +149,7 @@ hello mysqltest: At line 1: End of line junk detected: "6" mysqltest: At line 1: End of line junk detected: "6" mysqltest: At line 1: Missing delimiter -mysqltest: End of line junk detected: "sleep 7 +mysqltest: At line 1: End of line junk detected: "sleep 7 # Another comment " mysqltest: At line 1: Extra delimiter ";" found From c5451d02ad12a66b9be067be9db77e184651a12b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Jan 2006 11:07:17 +0100 Subject: [PATCH 3/4] Remove obsolete comment --- client/mysqltest.c | 1 - 1 file changed, 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 31fd4992650..552d8c4ee29 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2669,7 +2669,6 @@ int read_line(char *buf, int size) The advantage with this approach is to be able to execute commands terminated by new line '\n' regardless how many "delimiter" it contain. - If query starts with @ this will specify a file to .... */ static char read_query_buf[MAX_QUERY]; From 113290fe2f8846802edbe2688c72ca49f304091f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Jan 2006 11:10:58 +0100 Subject: [PATCH 4/4] Add comments that groups and describes the inits client/mysqltest.c: Add comments Group inits logically --- client/mysqltest.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 552d8c4ee29..6a2a7b072de 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -4280,25 +4280,30 @@ int main(int argc, char **argv) save_file[0]=0; TMPDIR[0]=0; + + /* Init cons */ memset(cons, 0, sizeof(cons)); cons_end = cons + MAX_CONS; next_con = cons + 1; cur_con = cons; + /* Init file stack */ memset(file_stack, 0, sizeof(file_stack)); - memset(&master_pos, 0, sizeof(master_pos)); file_stack_end= file_stack + MAX_INCLUDE_DEPTH - 1; cur_file= file_stack; - my_init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES, - INIT_Q_LINES); - + /* Init block stack */ memset(block_stack, 0, sizeof(block_stack)); block_stack_end= block_stack + BLOCK_STACK_DEPTH - 1; cur_block= block_stack; cur_block->ok= TRUE; /* Outer block should always be executed */ cur_block->cmd= cmd_none; + my_init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES, + INIT_Q_LINES); + + memset(&master_pos, 0, sizeof(master_pos)); + init_dynamic_string(&ds_res, "", 0, 65536); parse_args(argc, argv);