mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Merge bk-internal:/home/bk/mysql-4.1/
into serg.mylan:/usr/home/serg/Abk/mysql-4.1 client/mysqldump.c: Auto merged
This commit is contained in:
commit
75a87de04c
4 changed files with 38 additions and 36 deletions
|
@ -29,6 +29,6 @@ typedef struct st_line_buffer
|
|||
} LINE_BUFFER;
|
||||
|
||||
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 void batch_readline_end(LINE_BUFFER *buffer);
|
||||
|
|
|
@ -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.",
|
||||
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"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,
|
||||
"Directory where character sets are.", (gptr*) &charsets_dir,
|
||||
(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[] =
|
|||
(gptr*) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"delimiter", OPT_DELIMITER, "Delimiter to be used.", (gptr*) &delimiter_str,
|
||||
(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},
|
||||
{"vertical", 'E', "Print the output of a query (rows) vertically.",
|
||||
(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[] =
|
|||
0, 0, 0},
|
||||
{"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},
|
||||
{"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},
|
||||
#ifdef HAVE_SMEM
|
||||
{"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)),
|
|||
case 'e':
|
||||
status.batch= 1;
|
||||
status.add_to_history= 0;
|
||||
batch_readline_end(status.line_buff); // If multiple -e
|
||||
if (!(status.line_buff= batch_readline_command(argument)))
|
||||
if (!status.line_buff)
|
||||
ignore_errors= 0; // do it for the first -e only
|
||||
if (!(status.line_buff= batch_readline_command(status.line_buff, argument)))
|
||||
return 1;
|
||||
ignore_errors= 0;
|
||||
break;
|
||||
case 'o':
|
||||
if (argument == disabled_my_option)
|
||||
|
@ -798,12 +798,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
verbose++;
|
||||
break;
|
||||
case 'B':
|
||||
if (!status.batch)
|
||||
{
|
||||
status.batch= 1;
|
||||
status.add_to_history= 0;
|
||||
opt_silent++; // more silent
|
||||
}
|
||||
status.batch= 1;
|
||||
status.add_to_history= 0;
|
||||
set_if_bigger(opt_silent,1); // more silent
|
||||
break;
|
||||
case 'W':
|
||||
#ifdef __WIN__
|
||||
|
@ -1108,11 +1105,8 @@ static bool add_line(String &buffer,char *line,char *in_string,
|
|||
}
|
||||
else
|
||||
{
|
||||
int error= com_go(&buffer, 0);
|
||||
if (error)
|
||||
{
|
||||
return error < 0 ? 0 : 1; // < 0 is not fatal
|
||||
}
|
||||
if (com_go(&buffer, 0) > 0) // < 0 is not fatal
|
||||
return 1;
|
||||
}
|
||||
buffer.length(0);
|
||||
out= line;
|
||||
|
|
|
@ -241,10 +241,10 @@ static struct my_option my_long_options[] =
|
|||
{"no-data", 'd', "No row information.", (gptr*) &dFlag, (gptr*) &dFlag, 0,
|
||||
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"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},
|
||||
{"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,
|
||||
0, 0, 0, 0, 0},
|
||||
{"set-variable", 'O',
|
||||
|
|
|
@ -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 *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;
|
||||
if (init_line_buffer(line_buff,fileno(file),IO_SIZE,max_size))
|
||||
{
|
||||
|
@ -67,11 +68,12 @@ 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=(LINE_BUFFER*) my_malloc(sizeof(*line_buff),MYF(MY_WME))))
|
||||
return 0;
|
||||
if (!line_buff)
|
||||
if (!(line_buff=(LINE_BUFFER*)
|
||||
my_malloc(sizeof(*line_buff),MYF(MY_WME | MY_ZEROFILL))))
|
||||
return 0;
|
||||
if (init_line_buffer_from_string(line_buff,str))
|
||||
{
|
||||
my_free((char*) line_buff,MYF(0));
|
||||
|
@ -88,7 +90,6 @@ LINE_BUFFER *batch_readline_command(my_string str)
|
|||
static bool
|
||||
init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer)
|
||||
{
|
||||
bzero((char*) buffer,sizeof(buffer[0]));
|
||||
buffer->file=file;
|
||||
buffer->bufread=size;
|
||||
buffer->max_size=max_buffer;
|
||||
|
@ -100,19 +101,26 @@ init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer)
|
|||
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)
|
||||
{
|
||||
uint length;
|
||||
bzero((char*) buffer,sizeof(buffer[0]));
|
||||
length=(uint) strlen(str);
|
||||
if (!(buffer->buffer=buffer->start_of_line=buffer->end_of_line=
|
||||
(char*)my_malloc(length+2,MYF(MY_FAE))))
|
||||
uint old_length=buffer->end - buffer->buffer;
|
||||
uint length= (uint) strlen(str);
|
||||
if (!(buffer->buffer= buffer->start_of_line= buffer->end_of_line=
|
||||
(char*)my_realloc(buffer->buffer, old_length+length+2,
|
||||
MYF(MY_FAE|MY_ALLOW_ZERO_PTR))))
|
||||
return 1;
|
||||
memcpy(buffer->buffer,str,length);
|
||||
buffer->buffer[length]='\n';
|
||||
buffer->buffer[length+1]=0;
|
||||
buffer->end=buffer->buffer+length+1;
|
||||
buffer->end= buffer->buffer + old_length;
|
||||
if (old_length)
|
||||
buffer->end[-1]=' ';
|
||||
memcpy(buffer->end, str, length);
|
||||
buffer->end[length]= '\n';
|
||||
buffer->end[length+1]= 0;
|
||||
buffer->end+= length+1;
|
||||
buffer->eof=1;
|
||||
buffer->max_size=1;
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue