MDEV-34860 Fix opt_hint_timeout.test for embedded; fix mariadb client
1. Disable opt_hint_timeout.test for embedded server. Make sure the test does not crash even when started for embedded server. Disable view-protocol since hints are not supported inside views. 2. Hints are designed to behave like regular /* ... */ comments: `SELECT /*+ " */ 1;` -- a valid SQL query However, the mysql client program waits for the closing doublequote character. Another problem is observed when there is no space character between closing `*/` of the hint and the following `*`: `SELECT /*+ some_hints(...) */* FROM t1;` In this case the client treats `/*` as a comment section opening and waits for the closing `*/` sequence. This commit fixes all of these issues
This commit is contained in:
parent
d2918e10fc
commit
0e088b5d7e
@ -236,6 +236,8 @@ static char **defaults_argv;
|
||||
enum enum_info_type { INFO_INFO,INFO_ERROR,INFO_RESULT};
|
||||
typedef enum enum_info_type INFO_TYPE;
|
||||
|
||||
enum ss_comment_type { SSC_NONE= 0, SSC_CONDITIONAL, SSC_HINT };
|
||||
|
||||
static MYSQL mysql; /* The connection */
|
||||
static my_bool ignore_errors=0,wait_flag=0,quick=0,
|
||||
connected=0,opt_raw_data=0,unbuffered=0,output_tables=0,
|
||||
@ -1159,7 +1161,8 @@ static void fix_history(String *final_command);
|
||||
|
||||
static COMMANDS *find_command(char *name);
|
||||
static COMMANDS *find_command(char cmd_name);
|
||||
static bool add_line(String &, char *, size_t line_length, char *, bool *, bool);
|
||||
static bool add_line(String &, char *, size_t line_length, char *,
|
||||
bool *, ss_comment_type *, bool);
|
||||
static void remove_cntrl(String &buffer);
|
||||
static void print_table_data(MYSQL_RES *result);
|
||||
static void print_table_data_html(MYSQL_RES *result);
|
||||
@ -2212,6 +2215,7 @@ static int read_and_execute(bool interactive)
|
||||
char in_string=0;
|
||||
ulong line_number=0;
|
||||
bool ml_comment= 0;
|
||||
ss_comment_type ss_comment= SSC_NONE;
|
||||
COMMANDS *com;
|
||||
size_t line_length= 0;
|
||||
status.exit_status=1;
|
||||
@ -2358,7 +2362,8 @@ static int read_and_execute(bool interactive)
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
if (add_line(glob_buffer, line, line_length, &in_string, &ml_comment,
|
||||
if (add_line(glob_buffer, line, line_length, &in_string,
|
||||
&ml_comment, &ss_comment,
|
||||
status.line_buff ? status.line_buff->truncated : 0))
|
||||
break;
|
||||
}
|
||||
@ -2527,13 +2532,13 @@ static COMMANDS *find_command(char *name)
|
||||
|
||||
|
||||
static bool add_line(String &buffer, char *line, size_t line_length,
|
||||
char *in_string, bool *ml_comment, bool truncated)
|
||||
char *in_string, bool *ml_comment,
|
||||
ss_comment_type *ss_comment, bool truncated)
|
||||
{
|
||||
uchar inchar;
|
||||
char buff[80], *pos, *out;
|
||||
COMMANDS *com;
|
||||
bool need_space= 0;
|
||||
bool ss_comment= 0;
|
||||
DBUG_ENTER("add_line");
|
||||
|
||||
if (!line[0] && buffer.is_empty())
|
||||
@ -2608,7 +2613,7 @@ static bool add_line(String &buffer, char *line, size_t line_length,
|
||||
DBUG_RETURN(1); // Quit
|
||||
if (com->takes_params)
|
||||
{
|
||||
if (ss_comment)
|
||||
if (*ss_comment != SSC_NONE)
|
||||
{
|
||||
/*
|
||||
If a client-side macro appears inside a server-side comment,
|
||||
@ -2642,7 +2647,8 @@ static bool add_line(String &buffer, char *line, size_t line_length,
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (!*ml_comment && !*in_string && is_prefix(pos, delimiter))
|
||||
else if (!*ml_comment && !*in_string && *ss_comment != SSC_HINT &&
|
||||
is_prefix(pos, delimiter))
|
||||
{
|
||||
// Found a statement. Continue parsing after the delimiter
|
||||
pos+= delimiter_length;
|
||||
@ -2731,9 +2737,8 @@ static bool add_line(String &buffer, char *line, size_t line_length,
|
||||
break;
|
||||
}
|
||||
else if (!*in_string && inchar == '/' && pos[1] == '*' &&
|
||||
!(pos[2] == '!' ||
|
||||
(pos[2] == 'M' && pos[3] == '!') ||
|
||||
pos[2] == '+'))
|
||||
pos[2] != '!' && !(pos[2] == 'M' && pos[3] == '!') &&
|
||||
pos[2] != '+' && *ss_comment != SSC_HINT)
|
||||
{
|
||||
if (preserve_comments)
|
||||
{
|
||||
@ -2749,7 +2754,8 @@ static bool add_line(String &buffer, char *line, size_t line_length,
|
||||
out=line;
|
||||
}
|
||||
}
|
||||
else if (*ml_comment && !ss_comment && inchar == '*' && *(pos + 1) == '/')
|
||||
else if (*ml_comment && *ss_comment == SSC_NONE &&
|
||||
inchar == '*' && *(pos + 1) == '/')
|
||||
{
|
||||
if (preserve_comments)
|
||||
{
|
||||
@ -2770,14 +2776,24 @@ static bool add_line(String &buffer, char *line, size_t line_length,
|
||||
}
|
||||
else
|
||||
{ // Add found char to buffer
|
||||
if (!*in_string && inchar == '/' && pos[1] == '*' &&
|
||||
(pos[2] == '!' || pos[2] == '+'))
|
||||
ss_comment= 1;
|
||||
else if (!*in_string && ss_comment && inchar == '*' && *(pos + 1) == '/')
|
||||
ss_comment= 0;
|
||||
if (!*in_string && inchar == '/' && pos[1] == '*')
|
||||
{
|
||||
if (pos[2] == '!')
|
||||
*ss_comment= SSC_CONDITIONAL;
|
||||
else if (pos[2] == '+')
|
||||
*ss_comment= SSC_HINT;
|
||||
}
|
||||
else if (!*in_string && *ss_comment != SSC_NONE &&
|
||||
inchar == '*' && *(pos + 1) == '/')
|
||||
{
|
||||
*ss_comment= SSC_NONE;
|
||||
*out++= *pos++; // copy '*'
|
||||
*out++= *pos; // copy '/'
|
||||
continue;
|
||||
}
|
||||
if (inchar == *in_string)
|
||||
*in_string= 0;
|
||||
else if (!*ml_comment && !*in_string &&
|
||||
else if (!*ml_comment && !*in_string && *ss_comment != SSC_HINT &&
|
||||
(inchar == '\'' || inchar == '"' || inchar == '`'))
|
||||
*in_string= (char) inchar;
|
||||
if (!*ml_comment || preserve_comments)
|
||||
|
@ -33,6 +33,14 @@ Trigger sql_mode SQL Original Statement character_set_client collation_connectio
|
||||
t1_bi CREATE DEFINER=`root`@`localhost` trigger t1_bi before insert on t1\nfor each row\nbegin\n\n\n\n \n declare b int;\n declare c float;\n\n \n \n\n \n set NEW.data := 12;\nend latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci --TIME--
|
||||
id data
|
||||
trig 12
|
||||
id data
|
||||
trig 12
|
||||
id data
|
||||
trig 12
|
||||
id data
|
||||
trig 12
|
||||
id data
|
||||
trig 12
|
||||
"Pass 2 : --enable-comments"
|
||||
1
|
||||
1
|
||||
@ -60,5 +68,13 @@ Trigger sql_mode SQL Original Statement character_set_client collation_connectio
|
||||
t1_bi CREATE DEFINER=`root`@`localhost` trigger t1_bi before insert on t1\nfor each row\nbegin\n# comment 1a\n-- comment 1b\n/*\n comment 1c\n*/\n -- declare some variables here\n declare b int;\n declare c float;\n\n -- do more stuff here\n -- commented nicely and so on\n\n -- famous last words ...\n set NEW.data := 12;\nend latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci --TIME--
|
||||
id data
|
||||
trig 12
|
||||
id data
|
||||
trig 12
|
||||
id data
|
||||
trig 12
|
||||
id data
|
||||
trig 12
|
||||
id data
|
||||
trig 12
|
||||
set global sql_mode=default;
|
||||
End of 5.0 tests
|
||||
|
@ -211,6 +211,18 @@ show create trigger t1_bi;
|
||||
insert into t1(id) value ("trig");
|
||||
select * from t1;
|
||||
|
||||
##============================================================================
|
||||
## Optimizer hints
|
||||
##============================================================================
|
||||
|
||||
select /*+ no_icp(t1)*/* from t1;
|
||||
select /*+ no_icp(t1) " ;,` */* from t1;
|
||||
select /*+ "some text" */* from t1;
|
||||
|
||||
select /* no_icp(t1)
|
||||
no_bka(t1)
|
||||
*/* from t1;
|
||||
|
||||
##============================================================================
|
||||
## Cleanup
|
||||
##============================================================================
|
||||
|
@ -1,6 +1,11 @@
|
||||
# Setting statement time-outs is not possible for the embedded server neither
|
||||
# by SET STATEMENT max_statement_time=X nor by /*+ MAX_EXECUTION_TIME(X)*/ hint.
|
||||
# That is why this test is disabled for the embedded server
|
||||
--source include/not_embedded.inc
|
||||
--source include/have_sequence.inc
|
||||
|
||||
--disable_view_protocol # Since optimizer hints are not supported inside views
|
||||
|
||||
--source include/have_sequence.inc
|
||||
--echo #
|
||||
--echo # MAX_EXECUTION_TIME hint testing
|
||||
--echo #
|
||||
|
@ -6064,7 +6064,9 @@ public:
|
||||
}
|
||||
void set_query_timer_force(ulonglong timeout_val)
|
||||
{
|
||||
#ifndef EMBEDDED_LIBRARY
|
||||
thr_timer_settime(&query_timer, timeout_val);
|
||||
#endif
|
||||
}
|
||||
void reset_query_timer()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user