Skip to content

Commit

Permalink
expression: fix append to result twice when vecEval compress('') (#33523
Browse files Browse the repository at this point in the history
)

close #33397
  • Loading branch information
UBarney authored Mar 29, 2022
1 parent 5dbd394 commit 5a54d0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions expression/builtin_encryption_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ func (b *builtinCompressSig) vecEvalString(input *chunk.Chunk, result *chunk.Col
// According to doc: Empty strings are stored as empty strings.
if len(strBytes) == 0 {
result.AppendString("")
continue
}

compressed, err := deflate(strBytes)
Expand Down
13 changes: 13 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7078,3 +7078,16 @@ func TestIssue32488(t *testing.T) {
tk.MustQuery("select binary upper(a), lower(a) from t order by upper(a);").Check([][]interface{}{{"İ i"}, {"Ʞ ʞ"}})
tk.MustQuery("select distinct upper(a), lower(a) from t order by upper(a);").Check([][]interface{}{{"İ i"}, {"Ʞ ʞ"}})
}

func TestIssue33397(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a varchar(32)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;")
tk.MustExec("insert into t values(''), ('');")
tk.MustExec("set @@tidb_enable_vectorized_expression = true;")
result := tk.MustQuery("select compress(a) from t").Rows()
require.Equal(t, [][]interface{}{{""}, {""}}, result)
}

0 comments on commit 5a54d0d

Please sign in to comment.