Skip to content

Commit 3250686

Browse files
committed
MDEV-33281 Fix mysql-test-run to correctly handle hints
After commit 408a637 for MDEV-29344 the mysql-test framework started to misinterpret slash/star sequences for statements looking like this: SELECT /* BNL(t1) */* FROM t1, t2 where there is no space after closing `*/` and the following `*`. This commit fixes that misinterpretation
1 parent 2ea910d commit 3250686

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

client/mysqltest.cc

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6807,7 +6807,7 @@ int read_line()
68076807
my_bool have_slash= FALSE;
68086808

68096809
enum {R_NORMAL, R_Q, R_SLASH_IN_Q,
6810-
R_COMMENT, R_LINE_START, R_CSTYLE_COMMENT} state= R_LINE_START;
6810+
R_COMMENT, R_LINE_START, R_CSTYLE_COMMENT, R_HINT} state= R_LINE_START;
68116811
DBUG_ENTER("read_line");
68126812

68136813
*p= 0;
@@ -6864,8 +6864,10 @@ int read_line()
68646864
p--;
68656865
}
68666866

6867+
bool drop_last_char= false;
68676868
switch(state) {
68686869
case R_NORMAL:
6870+
case R_HINT:
68696871
if (end_of_query(c))
68706872
{
68716873
*p= 0;
@@ -6899,16 +6901,29 @@ int read_line()
68996901
state= R_CSTYLE_COMMENT;
69006902
break;
69016903
}
6904+
else if (c == '/' && last_char == '*') // Closing sequence `*/`
6905+
{
6906+
state= R_NORMAL;
6907+
// The hint is finished, and we don't want to interpret the current slash
6908+
// as an opener for a next hint or a C-style comment like it can happen
6909+
// for a statement like `SELECT /*+ BNL(t1) */* FROM t1` where there is
6910+
//no space between `*/` and `*`. So discard the current slash
6911+
drop_last_char= true;
6912+
}
69026913
have_slash= is_escape_char(c, last_quote);
69036914
break;
69046915

69056916
case R_CSTYLE_COMMENT:
6906-
if (c == '!')
6907-
// Got the hint introducer '/*!'. Switch to normal processing of
6908-
// next following characters
6909-
state= R_NORMAL;
6917+
if (c == '!' || c == '+')
6918+
{
6919+
// Got hint introducer '/*!' or '/*+'
6920+
state= R_HINT;
6921+
}
69106922
else if (c == '/' && last_char == '*')
6923+
{
69116924
state= R_NORMAL;
6925+
drop_last_char= true; // See comment for `drop_last_char` above
6926+
}
69126927
break;
69136928

69146929
case R_COMMENT:
@@ -6988,7 +7003,15 @@ int read_line()
69887003

69897004
}
69907005

6991-
last_char= c;
7006+
if (!drop_last_char)
7007+
{
7008+
last_char= c;
7009+
}
7010+
else
7011+
{
7012+
last_char= 0;
7013+
drop_last_char= false;
7014+
}
69927015

69937016
if (!skip_char)
69947017
{

0 commit comments

Comments
 (0)