Commit 765ae6e8 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-19239 ERROR 1300 (HY000): Invalid utf8 character string in 10.3.13-MariaDB

A sequence of <digits>e<mbhead><mbtail>, e.g.:

  SELECT 123eXYzzz FROM t1;

was not scanned correctly (where XY is a multi-byte character).

The multi-byte head byte X was appended to 123e separately from
the multi-byte tail byte Y, so a pointer to "Yzzz" was passed
into scan_ident_start(), which failed on a bad multi-byte sequence.

After this change, scan_ident_start() gets a pointer to "XYzzz",
so it correctly sees the whole multi-byte character.
parent f4019f5b
......@@ -11300,5 +11300,73 @@ t1 CREATE TABLE `t1` (
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# MDEV-19239 ERROR 1300 (HY000): Invalid utf8 character string in 10.3.13-MariaDB
#
SET NAMES utf8;
SELECT
x.消息ID,
x.消息TITLE,
x.消息类型,
x.发送时间,
x.阅读时间,x.老师ID,
IF(x.四天内最近一次登录时间='2100-01-01 00:00:00','',x.四天内最近一次登录时间) 四天内最近一次登录时间
FROM (
SELECT
msg.*,
CASE
WHEN login.login_time BETWEEN msg.发送时间 AND DATE_ADD(msg.发送时间,INTERVAL 4 DAY)
THEN login.login_time
WHEN (login.login_time NOT BETWEEN msg.发送时间 AND DATE_ADD(msg.发送时间,INTERVAL 4 DAY)) AND login.login_time>0
THEN '2100-01-01 00:00:00' ELSE ''
END 四天内最近一次登录时间
FROM (
SELECT
me.id 消息ID,
me.title 消息TITLE,
CASE
WHEN me.type=1
THEN 'Interview Message'
WHEN me.type=2
THEN 'Orientation Message'
WHEN me.type=3
THEN 'Warning Message'
WHEN me.type=4
THEN 'Fail Message'
WHEN me.type=5
THEN 'FM Message'
WHEN me.type=6
THEN 'Training Message'
WHEN me.type=7
THEN 'TUrgent Message'
END 消息类型,
FROM_UNIXTIME(me.sending_time) 发送时间,
IF(tar.is_read=1,FROM_UNIXTIME(tar.read_time),'') 阅读时间,
tar.tid 老师ID
FROM ebk_message me
LEFT JOIN ebk_message_target tar
ON me.id=tar.msg_id
WHERE
FROM_UNIXTIME(me.sending_time,'%Y-%m-%d') BETWEEN 'start' AND 'end' AND me.status=1 AND tar.tid>0
GROUP BY
tar.tid,
me.sending_time,me.id) msg
LEFT JOIN (
SELECT tid,FROM_UNIXTIME(login_time) login_time
FROM ebk_teacher_login_log
WHERE FROM_UNIXTIME(login_time,'%Y-%m-%d') BETWEEN 'start' AND DATE_ADD('end',INTERVAL 4 DAY)
ORDER BY tid,FROM_UNIXTIME(login_time)) login
ON
msg.老师ID=login.tid
ORDER BY msg.消息ID,msg.发送时间,msg.老师ID,login_time) x
GROUP BY x.消息ID,x.发送时间,x.老师ID;
ERROR 42S02: Table 'test.ebk_message' doesn't exist
SET NAMES utf8;
CREATE TABLE t1 (x INT);
INSERT INTO t1 VALUES (1);
SELECT x AS 5天内最近一次登录时间 FROM t1;
5天内最近一次登录时间
1
DROP TABLE t1;
#
# End of 10.3 tests
#
......@@ -2180,6 +2180,81 @@ DROP TABLE t1;
SET sql_mode=DEFAULT;
--echo #
--echo # MDEV-19239 ERROR 1300 (HY000): Invalid utf8 character string in 10.3.13-MariaDB
--echo #
#
# Test that the following query does not fail on "Invalid utf8 character string"
#
SET NAMES utf8;
--error ER_NO_SUCH_TABLE
SELECT
x.消息ID,
x.消息TITLE,
x.消息类型,
x.发送时间,
x.阅读时间,x.老师ID,
IF(x.四天内最近一次登录时间='2100-01-01 00:00:00','',x.四天内最近一次登录时间) 四天内最近一次登录时间
FROM (
SELECT
msg.*,
CASE
WHEN login.login_time BETWEEN msg.发送时间 AND DATE_ADD(msg.发送时间,INTERVAL 4 DAY)
THEN login.login_time
WHEN (login.login_time NOT BETWEEN msg.发送时间 AND DATE_ADD(msg.发送时间,INTERVAL 4 DAY)) AND login.login_time>0
THEN '2100-01-01 00:00:00' ELSE ''
END 四天内最近一次登录时间
FROM (
SELECT
me.id 消息ID,
me.title 消息TITLE,
CASE
WHEN me.type=1
THEN 'Interview Message'
WHEN me.type=2
THEN 'Orientation Message'
WHEN me.type=3
THEN 'Warning Message'
WHEN me.type=4
THEN 'Fail Message'
WHEN me.type=5
THEN 'FM Message'
WHEN me.type=6
THEN 'Training Message'
WHEN me.type=7
THEN 'TUrgent Message'
END 消息类型,
FROM_UNIXTIME(me.sending_time) 发送时间,
IF(tar.is_read=1,FROM_UNIXTIME(tar.read_time),'') 阅读时间,
tar.tid 老师ID
FROM ebk_message me
LEFT JOIN ebk_message_target tar
ON me.id=tar.msg_id
WHERE
FROM_UNIXTIME(me.sending_time,'%Y-%m-%d') BETWEEN 'start' AND 'end' AND me.status=1 AND tar.tid>0
GROUP BY
tar.tid,
me.sending_time,me.id) msg
LEFT JOIN (
SELECT tid,FROM_UNIXTIME(login_time) login_time
FROM ebk_teacher_login_log
WHERE FROM_UNIXTIME(login_time,'%Y-%m-%d') BETWEEN 'start' AND DATE_ADD('end',INTERVAL 4 DAY)
ORDER BY tid,FROM_UNIXTIME(login_time)) login
ON
msg.老师ID=login.tid
ORDER BY msg.消息ID,msg.发送时间,msg.老师ID,login_time) x
GROUP BY x.消息ID,x.发送时间,x.老师ID;
SET NAMES utf8;
CREATE TABLE t1 (x INT);
INSERT INTO t1 VALUES (1);
SELECT x AS 5天内最近一次登录时间 FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #
......@@ -1587,9 +1587,27 @@ int Lex_input_stream::lex_one_token(YYSTYPE *yylval, THD *thd)
return(FLOAT_NUM);
}
}
/*
We've found:
- A sequence of digits
- Followed by 'e' or 'E'
- Followed by some byte XX which is not a known mantissa start,
and it's known to be a valid identifier part.
XX can be either a 8bit identifier character, or a multi-byte head.
*/
yyUnget();
return scan_ident_start(thd, &yylval->ident_cli);
}
// fall through
/*
We've found:
- A sequence of digits
- Followed by some character XX, which is neither 'e' nor 'E',
and it's known to be a valid identifier part.
XX can be a 8bit identifier character, or a multi-byte head.
*/
yyUnget();
return scan_ident_start(thd, &yylval->ident_cli);
case MY_LEX_IDENT_START: // We come here after '.'
return scan_ident_start(thd, &yylval->ident_cli);
......
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