Skip to content

Commit

Permalink
fix function substr with 3 arguments bug (#1296) (#1301)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-srebot authored Dec 23, 2020
1 parent d17cc30 commit 7ba30ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbms/src/Functions/FunctionsString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ class FunctionSubstringUTF8 : public IFunction
}


if (start == 0 || length == 0) {
if (start == 0 || (!implicit_length && length == 0)) {
block.getByPosition(result).column = DataTypeString().createColumnConst(column_string->size(), toField(String("")));
return;
}
Expand Down
23 changes: 23 additions & 0 deletions tests/fullstack-test/expr/agg_pushdown.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
mysql> drop table if exists test.t
mysql> create table test.t (c varchar(64))
mysql> alter table test.t set tiflash replica 1

func> wait_table test t

mysql> insert into test.t values ('ABC'), ('DEF'), ('')
mysql> insert into test.t select * from test.t;
mysql> insert into test.t select * from test.t;
mysql> insert into test.t select * from test.t;
mysql> insert into test.t select * from test.t;
mysql> insert into test.t select * from test.t;
mysql> insert into test.t select * from test.t;

mysql> set @@tidb_isolation_read_engines='tiflash'
mysql> select substr(c, 2), count(1) from test.t group by substr(c, 2) order by substr(c, 2)
+--------------+----------+
| substr(c, 2) | count(1) |
+--------------+----------+
| | 64 |
| BC | 64 |
| EF | 64 |
+--------------+----------+

0 comments on commit 7ba30ab

Please sign in to comment.