Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#49543
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
winoros authored and ti-chi-bot committed Dec 18, 2023
1 parent 3ac58a9 commit e031962
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/expression/chunk_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/types"
"github.com/pingcap/tidb/pkg/util/chunk"
"github.com/pingcap/tidb/pkg/util/logutil"
"go.uber.org/zap"
)

// Vectorizable checks whether a list of expressions can employ vectorized execution.
Expand Down Expand Up @@ -179,7 +181,19 @@ func evalOneVec(ctx sessionctx.Context, expr Expression, input *chunk.Chunk, out
if result.IsNull(i) {
buf.AppendNull()
} else {
<<<<<<< HEAD
buf.AppendEnum(types.Enum{Value: 0, Name: result.GetString(i)})
=======
enum, err := types.ParseEnumName(ft.GetElems(), result.GetString(i), ft.GetCollate())
if err != nil {
logutil.BgLogger().Debug("Wrong enum name parsed during evaluation",
zap.String("The name to be parsed in the ENUM", result.GetString(i)),
zap.Strings("The valid names in the ENUM", ft.GetElems()),
zap.Error(err),
)
}
buf.AppendEnum(enum)
>>>>>>> fb9d2203b99 (expression: enum/set could be invalid during evaluation (#49543))
}
}
output.SetCol(colIdx, buf)
Expand All @@ -191,7 +205,19 @@ func evalOneVec(ctx sessionctx.Context, expr Expression, input *chunk.Chunk, out
if result.IsNull(i) {
buf.AppendNull()
} else {
<<<<<<< HEAD
buf.AppendSet(types.Set{Value: 0, Name: result.GetString(i)})
=======
set, err := types.ParseSetName(ft.GetElems(), result.GetString(i), ft.GetCollate())
if err != nil {
logutil.BgLogger().Debug("Wrong set name parsed during evaluation",
zap.String("The name to be parsed in the SET", result.GetString(i)),
zap.Strings("The valid names in the SET", ft.GetElems()),
zap.Error(err),
)
}
buf.AppendSet(set)
>>>>>>> fb9d2203b99 (expression: enum/set could be invalid during evaluation (#49543))
}
}
output.SetCol(colIdx, buf)
Expand Down
13 changes: 13 additions & 0 deletions tests/integrationtest/r/expression/enum_set.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
drop table if exists t01;
CREATE TABLE `t01` (
`6524d87a` timestamp DEFAULT '2024-10-02 01:54:55',
`744e4d52` int(11) NOT NULL DEFAULT '2023959529',
`087de3b2` varchar(122) DEFAULT '36h0hvfpylz0f0iv9h0ownfcg3rehi4',
`26cbbf2a` enum('l7i9','3sdz3','83','4','92p','4g','8y5rn','7gp','7','1','e') NOT NULL DEFAULT '4',
PRIMARY KEY (`744e4d52`,`26cbbf2a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_chinese_ci COMMENT='7ad99128'
PARTITION BY HASH (`744e4d52`) PARTITIONS 9;
insert ignore into t01 values ("2023-01-01 20:01:02", 123, 'abcd', '');
select `t01`.`26cbbf2a` as r0 from `t01` where `t01`.`6524d87a` in ( '2010-05-25') or not( `t01`.`26cbbf2a` > '1' ) ;
r0

12 changes: 12 additions & 0 deletions tests/integrationtest/t/expression/enum_set.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://github.com/pingcap/tidb/issues/49487
drop table if exists t01;
CREATE TABLE `t01` (
`6524d87a` timestamp DEFAULT '2024-10-02 01:54:55',
`744e4d52` int(11) NOT NULL DEFAULT '2023959529',
`087de3b2` varchar(122) DEFAULT '36h0hvfpylz0f0iv9h0ownfcg3rehi4',
`26cbbf2a` enum('l7i9','3sdz3','83','4','92p','4g','8y5rn','7gp','7','1','e') NOT NULL DEFAULT '4',
PRIMARY KEY (`744e4d52`,`26cbbf2a`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_chinese_ci COMMENT='7ad99128'
PARTITION BY HASH (`744e4d52`) PARTITIONS 9;
insert ignore into t01 values ("2023-01-01 20:01:02", 123, 'abcd', '');
select `t01`.`26cbbf2a` as r0 from `t01` where `t01`.`6524d87a` in ( '2010-05-25') or not( `t01`.`26cbbf2a` > '1' ) ;

0 comments on commit e031962

Please sign in to comment.