From 3687290cbef35a8ebe7accb6dbb38406c2db6eca Mon Sep 17 00:00:00 2001 From: slayerjain Date: Tue, 9 Jun 2026 18:09:27 +0530 Subject: [PATCH] feat(tidb-stmt-cache): add /api/cross orphaned same-param-shape endpoint Adds GET /api/cross/{v}, which issues two DISTINCT prepared queries with an identical one-int parameter signature ("SELECT ? AS v" and "SELECT ? + 1000 AS w") inside a single request. When both PREPAREs predate the record window (orphaned mocks, expectedQuery==""), this exercises the matcher's parameter-aware orphaned-EXECUTE path: a param-only match must not serve query B's row for query A. a must echo v and b must be v+1000. Consumed by the keploy/keploy java_linux tidb-stmt-cache e2e job. Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: slayerjain --- .../tidbstmtcache/QueryController.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tidb-stmt-cache/src/main/java/com/example/tidbstmtcache/QueryController.java b/tidb-stmt-cache/src/main/java/com/example/tidbstmtcache/QueryController.java index 606cc8b9..68852dc8 100644 --- a/tidb-stmt-cache/src/main/java/com/example/tidbstmtcache/QueryController.java +++ b/tidb-stmt-cache/src/main/java/com/example/tidbstmtcache/QueryController.java @@ -86,4 +86,24 @@ public Map insertThenSelect(@PathVariable("v") int v) { out.put("readback", last); return out; } + + /** + * Two distinct prepared queries with an IDENTICAL parameter signature + * (one int) issued in the SAME request — exercises the orphaned-EXECUTE + * cross-query matcher path. + * + * When both PREPAREs predate the record window (orphaned mocks, + * expectedQuery==""), a param-only match must NOT serve query B's row for + * query A just because the bound parameter is equal. {@code a} must echo v + * and {@code b} must be v+1000. + */ + @GetMapping("/api/cross/{v}") + public Map cross(@PathVariable("v") int v) { + Integer a = jdbc.queryForObject("SELECT ? AS v", Integer.class, v); + Integer b = jdbc.queryForObject("SELECT ? + 1000 AS w", Integer.class, v); + Map out = new HashMap<>(); + out.put("a", a); + out.put("b", b); + return out; + } }