@@ -259,6 +259,70 @@ func TestAnyValue(t *testing.T) {
259259 }
260260}
261261
262+ func TestAnyValueHybridStringEvalWithIntSig (t * testing.T ) {
263+ ctx := createContext (t )
264+ enumTp := types .NewFieldType (mysql .TypeEnum )
265+ enumTp .SetElems ([]string {"a" , "b" })
266+ enumTp .AddFlag (mysql .EnumSetAsIntFlag )
267+ setTp := types .NewFieldType (mysql .TypeSet )
268+ setTp .SetElems ([]string {"a" , "b" })
269+ setTp .AddFlag (mysql .EnumSetAsIntFlag )
270+ bitTp := types .NewFieldType (mysql .TypeBit )
271+
272+ tests := []struct {
273+ name string
274+ tp * types.FieldType
275+ appendFn func (* chunk.Chunk )
276+ expected string
277+ }{
278+ {
279+ name : "enum" ,
280+ tp : enumTp ,
281+ appendFn : func (chk * chunk.Chunk ) {
282+ chk .AppendEnum (0 , types.Enum {Name : "b" , Value : 2 })
283+ },
284+ expected : "b" ,
285+ },
286+ {
287+ name : "set" ,
288+ tp : setTp ,
289+ appendFn : func (chk * chunk.Chunk ) {
290+ chk .AppendSet (0 , types.Set {Name : "a,b" , Value : 3 })
291+ },
292+ expected : "a,b" ,
293+ },
294+ {
295+ name : "bit" ,
296+ tp : bitTp ,
297+ appendFn : func (chk * chunk.Chunk ) {
298+ chk .AppendBytes (0 , []byte {0x01 })
299+ },
300+ expected : "\x01 " ,
301+ },
302+ }
303+
304+ for _ , tt := range tests {
305+ t .Run (tt .name , func (t * testing.T ) {
306+ col := & Column {Index : 0 , RetType : tt .tp }
307+ f , err := funcs [ast .AnyValue ].getFunction (ctx , []Expression {col })
308+ require .NoError (t , err )
309+ require .IsType (t , & builtinIntAnyValueSig {}, f )
310+
311+ input := chunk .New ([]* types.FieldType {tt .tp }, 1 , 1 )
312+ tt .appendFn (input )
313+ got , isNull , err := f .evalString (ctx , input .GetRow (0 ))
314+ require .NoError (t , err )
315+ require .False (t , isNull )
316+ require .Equal (t , tt .expected , got )
317+
318+ result := chunk .NewColumn (types .NewFieldType (mysql .TypeString ), 1 )
319+ require .NoError (t , f .vecEvalString (ctx , input , result ))
320+ require .False (t , result .IsNull (0 ))
321+ require .Equal (t , tt .expected , result .GetString (0 ))
322+ })
323+ }
324+ }
325+
262326func TestIsIPv6 (t * testing.T ) {
263327 ctx := createContext (t )
264328 tests := []struct {
0 commit comments