Commit b5fb52dc authored by unknown's avatar unknown

Fix problem with strange printout of line numbers, detected on aix52, but...

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
parent bbec7eda
...@@ -165,7 +165,6 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0; ...@@ -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 view_protocol= 0, view_protocol_enabled= 0;
static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0; static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0;
static int parsing_disabled= 0; static int parsing_disabled= 0;
static uint start_lineno, *lineno;
const char *manager_user="root",*manager_host=0; const char *manager_user="root",*manager_host=0;
char *manager_pass=0; char *manager_pass=0;
int manager_port=MYSQL_MANAGER_PORT; int manager_port=MYSQL_MANAGER_PORT;
...@@ -180,13 +179,14 @@ typedef struct ...@@ -180,13 +179,14 @@ typedef struct
{ {
FILE* file; FILE* file;
const char *file_name; const char *file_name;
uint lineno; /* Current line in file */
} test_file; } test_file;
static test_file file_stack[MAX_INCLUDE_DEPTH]; static test_file file_stack[MAX_INCLUDE_DEPTH];
static test_file* cur_file; static test_file* cur_file;
static test_file* file_stack_end; 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 TMPDIR[FN_REFLEN];
static char delimiter[MAX_DELIMITER]= DEFAULT_DELIMITER; static char delimiter[MAX_DELIMITER]= DEFAULT_DELIMITER;
static uint delimiter_length= 1; static uint delimiter_length= 1;
...@@ -662,7 +662,7 @@ static void verbose_msg(const char *fmt, ...) ...@@ -662,7 +662,7 @@ static void verbose_msg(const char *fmt, ...)
va_start(args, fmt); va_start(args, fmt);
fprintf(stderr, "mysqltest: "); fprintf(stderr, "mysqltest: ");
if (start_lineno > 0) if (start_lineno != 0)
fprintf(stderr, "At line %u: ", start_lineno); fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
...@@ -900,7 +900,7 @@ int open_file(const char *name) ...@@ -900,7 +900,7 @@ int open_file(const char *name)
die("Could not open file %s", buff); die("Could not open file %s", buff);
} }
cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
*++lineno=1; cur_file->lineno=1;
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -2497,7 +2497,7 @@ int read_line(char *buf, int size) ...@@ -2497,7 +2497,7 @@ int read_line(char *buf, int size)
DBUG_ENTER("read_line"); DBUG_ENTER("read_line");
LINT_INIT(quote); LINT_INIT(quote);
start_lineno= *lineno; start_lineno= cur_file->lineno;
for (; p < buf_end ;) for (; p < buf_end ;)
{ {
no_save= 0; no_save= 0;
...@@ -2512,28 +2512,25 @@ int read_line(char *buf, int size) ...@@ -2512,28 +2512,25 @@ int read_line(char *buf, int size)
} }
my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR));
cur_file->file_name= 0; cur_file->file_name= 0;
lineno--;
start_lineno= *lineno;
if (cur_file == file_stack) if (cur_file == file_stack)
{ {
/* We're back at the first file, check if /* We're back at the first file, check if
all { have matching } all { have matching }
*/ */
if (cur_block != block_stack) if (cur_block != block_stack)
{
start_lineno= *(lineno+1);
die("Missing end of block"); die("Missing end of block");
}
DBUG_PRINT("info", ("end of file")); DBUG_PRINT("info", ("end of file"));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
cur_file--; cur_file--;
start_lineno= cur_file->lineno;
continue; continue;
} }
/* Line counting is independent of state */ /* Line counting is independent of state */
if (c == '\n') if (c == '\n')
(*lineno)++; cur_file->lineno++;
switch(state) { switch(state) {
case R_NORMAL: case R_NORMAL:
...@@ -2562,14 +2559,15 @@ int read_line(char *buf, int size) ...@@ -2562,14 +2559,15 @@ int read_line(char *buf, int size)
break; break;
case R_LINE_START: case R_LINE_START:
/* Only accept start of comment if this is the first line in query */ /* 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; state = R_COMMENT;
} }
else if (my_isspace(charset_info, c)) else if (my_isspace(charset_info, c))
{ {
if (c == '\n') if (c == '\n')
start_lineno= *lineno; /* Query hasn't started yet */ start_lineno= cur_file->lineno; /* Query hasn't started yet */
no_save= 1; no_save= 1;
} }
else if (c == '}') else if (c == '}')
...@@ -2895,6 +2893,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -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)))) my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0))))
die("Could not open %s: errno = %d", buff, errno); die("Could not open %s: errno = %d", buff, errno);
cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); cur_file->file_name= my_strdup(buff, MYF(MY_FAE));
cur_file->lineno= 1;
break; break;
} }
case 'm': case 'm':
...@@ -4291,7 +4290,7 @@ int main(int argc, char **argv) ...@@ -4291,7 +4290,7 @@ int main(int argc, char **argv)
memset(&master_pos, 0, sizeof(master_pos)); memset(&master_pos, 0, sizeof(master_pos));
file_stack_end= file_stack + MAX_INCLUDE_DEPTH - 1; file_stack_end= file_stack + MAX_INCLUDE_DEPTH - 1;
cur_file= file_stack; cur_file= file_stack;
lineno = lineno_stack;
my_init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES, my_init_dynamic_array(&q_lines, sizeof(struct st_query*), INIT_Q_LINES,
INIT_Q_LINES); INIT_Q_LINES);
...@@ -4313,8 +4312,8 @@ int main(int argc, char **argv) ...@@ -4313,8 +4312,8 @@ int main(int argc, char **argv)
{ {
cur_file->file= stdin; cur_file->file= stdin;
cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME)); cur_file->file_name= my_strdup("<stdin>", MYF(MY_WME));
cur_file->lineno= 1;
} }
*lineno=1;
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
if (manager_host) if (manager_host)
init_manager(); init_manager();
...@@ -4609,6 +4608,8 @@ int main(int argc, char **argv) ...@@ -4609,6 +4608,8 @@ int main(int argc, char **argv)
parser.current_line += current_line_inc; parser.current_line += current_line_inc;
} }
start_lineno= 0;
/* /*
The whole test has been executed _sucessfully_ The whole test has been executed _sucessfully_
Time to compare result or save it to record file Time to compare result or save it to record file
......
...@@ -149,7 +149,7 @@ hello ...@@ -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: End of line junk detected: "6" mysqltest: At line 1: End of line junk detected: "6"
mysqltest: At line 1: Missing delimiter 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 # Another comment
" "
mysqltest: At line 1: Extra delimiter ";" found mysqltest: At line 1: Extra delimiter ";" found
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment