mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
auto-merge
This commit is contained in:
@ -112,6 +112,8 @@ extern "C" {
|
||||
#define PROMPT_CHAR '\\'
|
||||
#define DEFAULT_DELIMITER ";"
|
||||
|
||||
#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L)
|
||||
|
||||
typedef struct st_status
|
||||
{
|
||||
int exit_status;
|
||||
@ -243,7 +245,7 @@ static COMMANDS commands[] = {
|
||||
{ "connect",'r', com_connect,1,
|
||||
"Reconnect to the server. Optional arguments are db and host." },
|
||||
{ "delimiter", 'd', com_delimiter, 1,
|
||||
"Set statement delimiter. NOTE: Takes the rest of the line as new delimiter." },
|
||||
"Set statement delimiter." },
|
||||
#ifdef USE_POPEN
|
||||
{ "edit", 'e', com_edit, 0, "Edit command with $EDITOR."},
|
||||
#endif
|
||||
@ -1035,7 +1037,7 @@ static void fix_history(String *final_command);
|
||||
|
||||
static COMMANDS *find_command(char *name,char cmd_name);
|
||||
static bool add_line(String &buffer,char *line,char *in_string,
|
||||
bool *ml_comment);
|
||||
bool *ml_comment, bool truncated);
|
||||
static void remove_cntrl(String &buffer);
|
||||
static void print_table_data(MYSQL_RES *result);
|
||||
static void print_table_data_html(MYSQL_RES *result);
|
||||
@ -1117,7 +1119,7 @@ int main(int argc,char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
if (status.batch && !status.line_buff &&
|
||||
!(status.line_buff=batch_readline_init(opt_max_allowed_packet+512,stdin)))
|
||||
!(status.line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, stdin)))
|
||||
{
|
||||
free_defaults(defaults_argv);
|
||||
my_end(0);
|
||||
@ -1197,7 +1199,7 @@ int main(int argc,char *argv[])
|
||||
#endif
|
||||
sprintf(buff, "%s",
|
||||
#ifndef NOT_YET
|
||||
"Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.\n");
|
||||
"Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n");
|
||||
#else
|
||||
"Type 'help [[%]function name[%]]' to get help on usage of function.\n");
|
||||
#endif
|
||||
@ -1226,7 +1228,7 @@ sig_handler mysql_sigint(int sig)
|
||||
goto err;
|
||||
/* kill_buffer is always big enough because max length of %lu is 15 */
|
||||
sprintf(kill_buffer, "KILL /*!50000 QUERY */ %lu", mysql_thread_id(&mysql));
|
||||
mysql_real_query(kill_mysql, kill_buffer, strlen(kill_buffer));
|
||||
mysql_real_query(kill_mysql, kill_buffer, (uint) strlen(kill_buffer));
|
||||
mysql_close(kill_mysql);
|
||||
tee_fprintf(stdout, "Query aborted by Ctrl+C\n");
|
||||
|
||||
@ -1766,13 +1768,14 @@ static int read_and_execute(bool interactive)
|
||||
ulong line_number=0;
|
||||
bool ml_comment= 0;
|
||||
COMMANDS *com;
|
||||
bool truncated= 0;
|
||||
status.exit_status=1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (!interactive)
|
||||
{
|
||||
line=batch_readline(status.line_buff);
|
||||
line=batch_readline(status.line_buff, &truncated);
|
||||
/*
|
||||
Skip UTF8 Byte Order Marker (BOM) 0xEFBBBF.
|
||||
Editors like "notepad" put this marker in
|
||||
@ -1891,7 +1894,7 @@ static int read_and_execute(bool interactive)
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
if (add_line(glob_buffer,line,&in_string,&ml_comment))
|
||||
if (add_line(glob_buffer,line,&in_string,&ml_comment, truncated))
|
||||
break;
|
||||
}
|
||||
/* if in batch mode, send last query even if it doesn't end with \g or go */
|
||||
@ -1977,7 +1980,7 @@ static COMMANDS *find_command(char *name,char cmd_char)
|
||||
|
||||
|
||||
static bool add_line(String &buffer,char *line,char *in_string,
|
||||
bool *ml_comment)
|
||||
bool *ml_comment, bool truncated)
|
||||
{
|
||||
uchar inchar;
|
||||
char buff[80], *pos, *out;
|
||||
@ -2222,8 +2225,23 @@ static bool add_line(String &buffer,char *line,char *in_string,
|
||||
}
|
||||
if (out != line || !buffer.is_empty())
|
||||
{
|
||||
*out++='\n';
|
||||
uint length=(uint) (out-line);
|
||||
|
||||
if (!truncated &&
|
||||
(length < 9 ||
|
||||
my_strnncoll (charset_info,
|
||||
(uchar *)line, 9, (const uchar *) "delimiter", 9)))
|
||||
{
|
||||
/*
|
||||
Don't add a new line in case there's a DELIMITER command to be
|
||||
added to the glob buffer (e.g. on processing a line like
|
||||
"<command>;DELIMITER <non-eof>") : similar to how a new line is
|
||||
not added in the case when the DELIMITER is the first command
|
||||
entered with an empty glob buffer.
|
||||
*/
|
||||
*out++='\n';
|
||||
length++;
|
||||
}
|
||||
if (buffer.length() + length >= buffer.alloced_length())
|
||||
buffer.realloc(buffer.length()+length+IO_SIZE);
|
||||
if ((!*ml_comment || preserve_comments) && buffer.append(line, length))
|
||||
@ -2832,7 +2850,7 @@ com_charset(String *buffer __attribute__((unused)), char *line)
|
||||
param= get_arg(buff, 0);
|
||||
if (!param || !*param)
|
||||
{
|
||||
return put_info("Usage: \\C char_setname | charset charset_name",
|
||||
return put_info("Usage: \\C charset_name | charset charset_name",
|
||||
INFO_ERROR, 0);
|
||||
}
|
||||
new_cs= get_charset_by_csname(param, MY_CS_PRIMARY, MYF(MY_WME));
|
||||
@ -3449,7 +3467,7 @@ static void print_warnings()
|
||||
|
||||
/* Get the warnings */
|
||||
query= "show warnings";
|
||||
mysql_real_query_for_lazy(query, strlen(query));
|
||||
mysql_real_query_for_lazy(query, (uint) strlen(query));
|
||||
mysql_store_result_for_lazy(&result);
|
||||
|
||||
/* Bail out when no warnings */
|
||||
@ -3872,7 +3890,7 @@ static int com_source(String *buffer, char *line)
|
||||
return put_info(buff, INFO_ERROR, 0);
|
||||
}
|
||||
|
||||
if (!(line_buff=batch_readline_init(opt_max_allowed_packet+512,sql_file)))
|
||||
if (!(line_buff= batch_readline_init(MAX_BATCH_BUFFER_SIZE, sql_file)))
|
||||
{
|
||||
my_fclose(sql_file,MYF(0));
|
||||
return put_info("Can't initialize batch_readline", INFO_ERROR, 0);
|
||||
@ -4329,7 +4347,8 @@ server_version_string(MYSQL *con)
|
||||
MYSQL_ROW cur = mysql_fetch_row(result);
|
||||
if (cur && cur[0])
|
||||
{
|
||||
bufp = strxnmov(bufp, sizeof buf - (bufp - buf), " ", cur[0], NullS);
|
||||
bufp = strxnmov(bufp, (uint) (sizeof buf - (bufp - buf)), " ", cur[0],
|
||||
NullS);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
|
Reference in New Issue
Block a user