From 5b27b8807716fb9c78dff18672b7c7d2d3540912 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 4 Dec 2022 22:20:40 +0800 Subject: [PATCH] Fix missing head string in fingerprint of an unexpected CALL statement --- query/query.go | 2 +- query/query_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/query/query.go b/query/query.go index 576014d..c86cc79 100644 --- a/query/query.go +++ b/query/query.go @@ -687,7 +687,7 @@ func Fingerprint(q string) string { if Debug { fmt.Println("CALL sp_name") } - return "call " + q[cpFromOffset:qi] + return string(f[0:fi]) + q[cpFromOffset:qi] } else if sqlState != onDupeKeyUpdate && (((s == inSpace || s == moreValuesOrUnknown) && (prevWord == "value" || prevWord == "values" || prevWord == "in")) || wordIn(q[cpFromOffset:qi], "value", "values", "in")) { // VALUE(, VALUE (, VALUES(, VALUES (, IN(, or IN( // but not after ON DUPLICATE KEY UPDATE diff --git a/query/query_test.go b/query/query_test.go index 3fcbd31..206934e 100644 --- a/query/query_test.go +++ b/query/query_test.go @@ -663,3 +663,14 @@ func TestFingerprintWithNumberInDbName(t *testing.T) { query.Fingerprint(q), ) } + +func TestFingerprintUnexpected(t *testing.T) { + var q string + + q = "EXPLAIN CALL foo(1, 2, 3)" + assert.Equal( + t, + "explain call foo", + query.Fingerprint(q), + ) +}