Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix substring wrong result bug (#9603) #9619

Open
wants to merge 4 commits into
base: release-7.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbms/src/Functions/FunctionsString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ struct SubstringUTF8Impl
res_data[res_offset] = 0;
++res_offset;
res_offsets[column_index] = res_offset;
prev_offset = offsets[column_index];
return;
}
start = start_offsets.size() - original_start_abs + 1;
Expand Down
24 changes: 24 additions & 0 deletions tests/fullstack-test/expr/substring_utf8.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,27 @@ a
1

mysql> drop table if exists test.t

mysql> drop table if exists test.t1
mysql> create table test.t1 (c1 int, c2 int)
mysql> insert into test.t1 (c1, c2) values (-82 , -4), ( 1 , 4)
mysql> alter table test.t1 set tiflash replica 1
func> wait_table test t1

mysql> set tidb_allow_mpp=1; set tidb_enforce_mpp=1; set tidb_isolation_read_engines='tiflash'; select c2, substring('abc', c2) as b FROM test.t1 order by 1, 2
+------+------+
| c2 | b |
+------+------+
| -4 | |
| 4 | |
+------+------+

mysql> set session tidb_isolation_read_engines='tiflash'; set tidb_allow_mpp=0; select c2, substring('abc', c2) as b FROM test.t1 order by 1, 2
+------+------+
| c2 | b |
+------+------+
| -4 | |
| 4 | |
+------+------+

mysql> drop table if exists test.t1