From 8b68d94d896cbbc39905d471e6e0a6624a4e864b Mon Sep 17 00:00:00 2001 From: qw4990 Date: Tue, 18 Jul 2023 21:16:56 +0800 Subject: [PATCH] fixpu --- expression/builtin_string.go | 3 +++ planner/core/plan_cache_test.go | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/expression/builtin_string.go b/expression/builtin_string.go index 2da271b8c1a9a..b575bb541ac4f 100644 --- a/expression/builtin_string.go +++ b/expression/builtin_string.go @@ -1718,6 +1718,9 @@ func (c *unhexFunctionClass) getFunction(ctx sessionctx.Context, args []Expressi default: return nil, errors.Errorf("Unhex invalid args, need int or string but get %s", argType) } + if argType.GetFlen() == types.UnspecifiedLength { + retFlen = types.UnspecifiedLength + } bf, err := newBaseBuiltinFuncWithTp(ctx, c.funcName, args, types.ETString, types.ETString) if err != nil { diff --git a/planner/core/plan_cache_test.go b/planner/core/plan_cache_test.go index d658374a24d6b..233378bf5e5fb 100644 --- a/planner/core/plan_cache_test.go +++ b/planner/core/plan_cache_test.go @@ -2367,6 +2367,19 @@ func TestIssue45253(t *testing.T) { tk.MustQuery(`SELECT c1 FROM t1 WHERE TO_BASE64('')`).Check(testkit.Rows()) } +func TestIssue45378(t *testing.T) { + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") + tk.MustExec(`set tidb_enable_non_prepared_plan_cache=1`) + tk.MustExec(`CREATE TABLE t1(c1 INT)`) + tk.MustExec(`INSERT INTO t1 VALUES (1)`) + + tk.MustQuery(`SELECT c1 FROM t1 WHERE UNHEX(2038330881)`).Check(testkit.Rows("1")) + tk.MustQuery(`SELECT c1 FROM t1 WHERE UNHEX(2038330881)`).Check(testkit.Rows("1")) + tk.MustQuery(`select @@last_plan_from_cache`).Check(testkit.Rows("1")) +} + func TestNonPreparedPlanCacheBuiltinFuncs(t *testing.T) { store := testkit.CreateMockStore(t) tk := testkit.NewTestKit(t, store)