Skip to content

Commit fb9d220

Browse files
authored
expression: enum/set could be invalid during evaluation (#49543)
close #49487
1 parent 9fad344 commit fb9d220

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

pkg/expression/chunk_executor.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
package expression
1616

1717
import (
18-
"github.com/pingcap/errors"
1918
"github.com/pingcap/tidb/pkg/parser/ast"
2019
"github.com/pingcap/tidb/pkg/parser/mysql"
2120
"github.com/pingcap/tidb/pkg/types"
2221
"github.com/pingcap/tidb/pkg/util/chunk"
22+
"github.com/pingcap/tidb/pkg/util/logutil"
23+
"go.uber.org/zap"
2324
)
2425

2526
// Vectorizable checks whether a list of expressions can employ vectorized execution.
@@ -181,7 +182,11 @@ func evalOneVec(ctx EvalContext, expr Expression, input *chunk.Chunk, output *ch
181182
} else {
182183
enum, err := types.ParseEnumName(ft.GetElems(), result.GetString(i), ft.GetCollate())
183184
if err != nil {
184-
return errors.Errorf("Wrong enum value parsed during evaluation")
185+
logutil.BgLogger().Debug("Wrong enum name parsed during evaluation",
186+
zap.String("The name to be parsed in the ENUM", result.GetString(i)),
187+
zap.Strings("The valid names in the ENUM", ft.GetElems()),
188+
zap.Error(err),
189+
)
185190
}
186191
buf.AppendEnum(enum)
187192
}
@@ -197,7 +202,11 @@ func evalOneVec(ctx EvalContext, expr Expression, input *chunk.Chunk, output *ch
197202
} else {
198203
set, err := types.ParseSetName(ft.GetElems(), result.GetString(i), ft.GetCollate())
199204
if err != nil {
200-
return errors.Errorf("Wrong set value parsed during evaluation")
205+
logutil.BgLogger().Debug("Wrong set name parsed during evaluation",
206+
zap.String("The name to be parsed in the SET", result.GetString(i)),
207+
zap.Strings("The valid names in the SET", ft.GetElems()),
208+
zap.Error(err),
209+
)
201210
}
202211
buf.AppendSet(set)
203212
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
drop table if exists t01;
2+
CREATE TABLE `t01` (
3+
`6524d87a` timestamp DEFAULT '2024-10-02 01:54:55',
4+
`744e4d52` int(11) NOT NULL DEFAULT '2023959529',
5+
`087de3b2` varchar(122) DEFAULT '36h0hvfpylz0f0iv9h0ownfcg3rehi4',
6+
`26cbbf2a` enum('l7i9','3sdz3','83','4','92p','4g','8y5rn','7gp','7','1','e') NOT NULL DEFAULT '4',
7+
PRIMARY KEY (`744e4d52`,`26cbbf2a`) /*T![clustered_index] CLUSTERED */
8+
) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_chinese_ci COMMENT='7ad99128'
9+
PARTITION BY HASH (`744e4d52`) PARTITIONS 9;
10+
insert ignore into t01 values ("2023-01-01 20:01:02", 123, 'abcd', '');
11+
select `t01`.`26cbbf2a` as r0 from `t01` where `t01`.`6524d87a` in ( '2010-05-25') or not( `t01`.`26cbbf2a` > '1' ) ;
12+
r0
13+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://github.com/pingcap/tidb/issues/49487
2+
drop table if exists t01;
3+
CREATE TABLE `t01` (
4+
`6524d87a` timestamp DEFAULT '2024-10-02 01:54:55',
5+
`744e4d52` int(11) NOT NULL DEFAULT '2023959529',
6+
`087de3b2` varchar(122) DEFAULT '36h0hvfpylz0f0iv9h0ownfcg3rehi4',
7+
`26cbbf2a` enum('l7i9','3sdz3','83','4','92p','4g','8y5rn','7gp','7','1','e') NOT NULL DEFAULT '4',
8+
PRIMARY KEY (`744e4d52`,`26cbbf2a`) /*T![clustered_index] CLUSTERED */
9+
) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE=gbk_chinese_ci COMMENT='7ad99128'
10+
PARTITION BY HASH (`744e4d52`) PARTITIONS 9;
11+
insert ignore into t01 values ("2023-01-01 20:01:02", 123, 'abcd', '');
12+
select `t01`.`26cbbf2a` as r0 from `t01` where `t01`.`6524d87a` in ( '2010-05-25') or not( `t01`.`26cbbf2a` > '1' ) ;

0 commit comments

Comments
 (0)