Skip to content

Commit 3feaf2c

Browse files
committed
Test case for Bug#31667405.
1 parent 819ef9a commit 3feaf2c

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/test/java/testsuite/x/devapi/TableSelectTest.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021, Oracle and/or its affiliates.
2+
* Copyright (c) 2015, 2022, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -1153,4 +1153,47 @@ private void assertTestPreparedStatementsResult(RowResult res, int expectedMin,
11531153
}
11541154
assertEquals(expectedMax, expectedMin - 1);
11551155
}
1156+
1157+
/**
1158+
* Tests server Bug#31667405, INCORRECT PREPARED STATEMENT OUTCOME WITH NUMERIC STRINGS IN JSON.
1159+
*/
1160+
@Test
1161+
public void testBug31667405() {
1162+
assumeTrue(mysqlVersionMeetsMinimum(ServerVersion.parseVersion("8.0.14")), "MySQL 8.0.14+ is required to run this test.");
1163+
1164+
try {
1165+
// Prepare test data.
1166+
sqlUpdate("DROP TABLE IF EXISTS testBug31667405");
1167+
sqlUpdate("CREATE TABLE testBug31667405 (doc JSON)");
1168+
sqlUpdate("INSERT INTO testBug31667405 VALUES ('{\"ord\":\"1\"}')");
1169+
1170+
SessionFactory sf = new SessionFactory();
1171+
Session testSession = sf.getSession(this.testProperties);
1172+
1173+
int sessionThreadId = getThreadId(testSession);
1174+
assertPreparedStatementsCount(sessionThreadId, 0, 1);
1175+
assertPreparedStatementsStatusCounts(testSession, 0, 0, 0);
1176+
1177+
Table testTbl = testSession.getDefaultSchema().getTable("testBug31667405");
1178+
1179+
// Initialize SelectStatement object.
1180+
SelectStatement testSelect2 = testTbl.select().where("$.ord == :n");
1181+
assertPreparedStatementsCountsAndId(testSession, 0, testSelect2, 0, -1);
1182+
assertPreparedStatementsStatusCounts(testSession, 0, 0, 0);
1183+
1184+
// A. Set binds: 1st execute -> non-prepared.
1185+
testSelect2.bind("n", "1").execute();
1186+
assertPreparedStatementsCountsAndId(testSession, 0, testSelect2, 0, -1);
1187+
assertPreparedStatementsStatusCounts(testSession, 0, 0, 0);
1188+
1189+
// B. Set binds reuse statement: 2nd execute -> prepare + execute.
1190+
RowResult res = testSelect2.bind("n", "1").execute();
1191+
assertEquals(1, res.count());
1192+
1193+
assertPreparedStatementsCountsAndId(testSession, 1, testSelect2, 1, 1);
1194+
assertPreparedStatementsStatusCounts(testSession, 1, 1, 0);
1195+
} finally {
1196+
sqlUpdate("DROP TABLE IF EXISTS testBug31667405");
1197+
}
1198+
}
11561199
}

0 commit comments

Comments
 (0)