Commit 3565cbc5 authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-4.1/

into serg.mylan:/usr/home/serg/Abk/mysql-4.1


client/mysqldump.c:
  Auto merged
parents 3ff2fcc9 0af74c23
...@@ -29,6 +29,6 @@ typedef struct st_line_buffer ...@@ -29,6 +29,6 @@ typedef struct st_line_buffer
} LINE_BUFFER; } LINE_BUFFER;
extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file); extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
extern LINE_BUFFER *batch_readline_command(my_string str); extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, my_string str);
extern char *batch_readline(LINE_BUFFER *buffer); extern char *batch_readline(LINE_BUFFER *buffer);
extern void batch_readline_end(LINE_BUFFER *buffer); extern void batch_readline_end(LINE_BUFFER *buffer);
...@@ -494,7 +494,7 @@ static struct my_option my_long_options[] = ...@@ -494,7 +494,7 @@ static struct my_option my_long_options[] =
"No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.", "No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"batch", 'B', {"batch", 'B',
"Print results with a tab as separator, each row on new line. Doesn't use history file.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, "Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"character-sets-dir", OPT_CHARSETS_DIR, {"character-sets-dir", OPT_CHARSETS_DIR,
"Directory where character sets are.", (gptr*) &charsets_dir, "Directory where character sets are.", (gptr*) &charsets_dir,
(gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
...@@ -515,7 +515,7 @@ static struct my_option my_long_options[] = ...@@ -515,7 +515,7 @@ static struct my_option my_long_options[] =
(gptr*) &current_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &current_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"delimiter", OPT_DELIMITER, "Delimiter to be used.", (gptr*) &delimiter_str, {"delimiter", OPT_DELIMITER, "Delimiter to be used.", (gptr*) &delimiter_str,
(gptr*) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"execute", 'e', "Execute command and quit. (Output like with --batch).", 0, {"execute", 'e', "Execute command and quit. (Disables --force and history file)", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"vertical", 'E', "Print the output of a query (rows) vertically.", {"vertical", 'E', "Print the output of a query (rows) vertically.",
(gptr*) &vertical, (gptr*) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, (gptr*) &vertical, (gptr*) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
...@@ -597,7 +597,7 @@ static struct my_option my_long_options[] = ...@@ -597,7 +597,7 @@ static struct my_option my_long_options[] =
0, 0, 0}, 0, 0, 0},
{"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.", {"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.",
(gptr*) &opt_reconnect, (gptr*) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, (gptr*) &opt_reconnect, (gptr*) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, {"silent", 's', "Be more silent. Print results with a tab as separator, each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0,
0, 0}, 0, 0},
#ifdef HAVE_SMEM #ifdef HAVE_SMEM
{"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME, {"shared_memory_base_name", OPT_SHARED_MEMORY_BASE_NAME,
...@@ -755,10 +755,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -755,10 +755,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case 'e': case 'e':
status.batch= 1; status.batch= 1;
status.add_to_history= 0; status.add_to_history= 0;
batch_readline_end(status.line_buff); // If multiple -e if (!status.line_buff)
if (!(status.line_buff= batch_readline_command(argument))) ignore_errors= 0; // do it for the first -e only
if (!(status.line_buff= batch_readline_command(status.line_buff, argument)))
return 1; return 1;
ignore_errors= 0;
break; break;
case 'o': case 'o':
if (argument == disabled_my_option) if (argument == disabled_my_option)
...@@ -798,12 +798,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -798,12 +798,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
verbose++; verbose++;
break; break;
case 'B': case 'B':
if (!status.batch)
{
status.batch= 1; status.batch= 1;
status.add_to_history= 0; status.add_to_history= 0;
opt_silent++; // more silent set_if_bigger(opt_silent,1); // more silent
}
break; break;
case 'W': case 'W':
#ifdef __WIN__ #ifdef __WIN__
...@@ -1108,11 +1105,8 @@ static bool add_line(String &buffer,char *line,char *in_string, ...@@ -1108,11 +1105,8 @@ static bool add_line(String &buffer,char *line,char *in_string,
} }
else else
{ {
int error= com_go(&buffer, 0); if (com_go(&buffer, 0) > 0) // < 0 is not fatal
if (error) return 1;
{
return error < 0 ? 0 : 1; // < 0 is not fatal
}
} }
buffer.length(0); buffer.length(0);
out= line; out= line;
......
...@@ -241,10 +241,10 @@ static struct my_option my_long_options[] = ...@@ -241,10 +241,10 @@ static struct my_option my_long_options[] =
{"no-data", 'd', "No row information.", (gptr*) &dFlag, (gptr*) &dFlag, 0, {"no-data", 'd', "No row information.", (gptr*) &dFlag, (gptr*) &dFlag, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"no-set-names", 'N', {"no-set-names", 'N',
"'SET NAMES charset_name' will not be put in the output. Deprecated, use --set-charset or --skip-set-charset to enable/disable charset settings instead", "Deprecated, use --set-charset or --skip-set-charset to enable/disable charset settings instead",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"set-charset", OPT_SET_CHARSET, {"set-charset", OPT_SET_CHARSET,
"'SET NAMES charset_name' will be put in the output", "'SET CHARACTER_SET_CLIENT=default_character_set' will be put in the output",
(gptr*) &opt_set_charset, (gptr*) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1, (gptr*) &opt_set_charset, (gptr*) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1,
0, 0, 0, 0, 0}, 0, 0, 0, 0, 0},
{"set-variable", 'O', {"set-variable", 'O',
......
...@@ -31,7 +31,8 @@ static char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length); ...@@ -31,7 +31,8 @@ static char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length);
LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
{ {
LINE_BUFFER *line_buff; LINE_BUFFER *line_buff;
if (!(line_buff=(LINE_BUFFER*) my_malloc(sizeof(*line_buff),MYF(MY_WME)))) if (!(line_buff=(LINE_BUFFER*)
my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
return 0; return 0;
if (init_line_buffer(line_buff,fileno(file),IO_SIZE,max_size)) if (init_line_buffer(line_buff,fileno(file),IO_SIZE,max_size))
{ {
...@@ -67,10 +68,11 @@ void batch_readline_end(LINE_BUFFER *line_buff) ...@@ -67,10 +68,11 @@ void batch_readline_end(LINE_BUFFER *line_buff)
} }
LINE_BUFFER *batch_readline_command(my_string str) LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, my_string str)
{ {
LINE_BUFFER *line_buff; if (!line_buff)
if (!(line_buff=(LINE_BUFFER*) my_malloc(sizeof(*line_buff),MYF(MY_WME)))) if (!(line_buff=(LINE_BUFFER*)
my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
return 0; return 0;
if (init_line_buffer_from_string(line_buff,str)) if (init_line_buffer_from_string(line_buff,str))
{ {
...@@ -88,7 +90,6 @@ LINE_BUFFER *batch_readline_command(my_string str) ...@@ -88,7 +90,6 @@ LINE_BUFFER *batch_readline_command(my_string str)
static bool static bool
init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer) init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer)
{ {
bzero((char*) buffer,sizeof(buffer[0]));
buffer->file=file; buffer->file=file;
buffer->bufread=size; buffer->bufread=size;
buffer->max_size=max_buffer; buffer->max_size=max_buffer;
...@@ -100,19 +101,26 @@ init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer) ...@@ -100,19 +101,26 @@ init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer)
return 0; return 0;
} }
/*
init_line_buffer_from_string can be called on the same buffer
several times. the resulting buffer will contain a
concatenation of all strings separated by spaces
*/
static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str) static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str)
{ {
uint length; uint old_length=buffer->end - buffer->buffer;
bzero((char*) buffer,sizeof(buffer[0])); uint length= (uint) strlen(str);
length=(uint) strlen(str); if (!(buffer->buffer= buffer->start_of_line= buffer->end_of_line=
if (!(buffer->buffer=buffer->start_of_line=buffer->end_of_line= (char*)my_realloc(buffer->buffer, old_length+length+2,
(char*)my_malloc(length+2,MYF(MY_FAE)))) MYF(MY_FAE|MY_ALLOW_ZERO_PTR))))
return 1; return 1;
memcpy(buffer->buffer,str,length); buffer->end= buffer->buffer + old_length;
buffer->buffer[length]='\n'; if (old_length)
buffer->buffer[length+1]=0; buffer->end[-1]=' ';
buffer->end=buffer->buffer+length+1; memcpy(buffer->end, str, length);
buffer->end[length]= '\n';
buffer->end[length+1]= 0;
buffer->end+= length+1;
buffer->eof=1; buffer->eof=1;
buffer->max_size=1; buffer->max_size=1;
return 0; return 0;
......
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