Skip to content

Commit

Permalink
Discarded count should always be 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffery-Wasty committed Jan 5, 2024
1 parent 62fc6d8 commit 9bb0f3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
Expand Up @@ -592,6 +592,11 @@ private void setTypeDefinition(DTV dtv) {
param.typeDefinition = SSType.DECIMAL.toString() + "(" + valueLength + "," + scale + ")";
}
} else {
if (inScale == null) {
// If inscale is null, null has been passed to a bigDecimal column. This will corrupt the
// destination, so we block it.
param.typeDefinition = null;
}
if (con.getCalcBigDecimalPrecision() && dtv.getJavaType() == JavaType.BIGDECIMAL
&& null != dtv.getSetterValue()) {
String[] plainValueArray = ((BigDecimal) dtv.getSetterValue()).abs().toPlainString()
Expand Down
Expand Up @@ -299,6 +299,8 @@ public void testBatchedUnprepare() throws SQLException {
if (prevDiscardActionCount > con.getServerPreparedStatementDiscardThreshold()) {
prevDiscardActionCount = 0;
}

assertSame(1, con.getDiscardedServerPreparedStatementCount());
}

// Skipped for now due to unexpected failures. Not functional so not critical.
Expand Down Expand Up @@ -398,7 +400,10 @@ public void testStatementPoolingEviction() throws SQLException {
}

// If we use it, now discard queue should be "full".
if (0 != testNo)
// At any point, con.getDiscardedPreparedStatementCount will always be 1 (i.e. the last eviction).
if (0 == testNo)
assertSame(1, con.getDiscardedServerPreparedStatementCount());
else
assertSame(0, con.getDiscardedServerPreparedStatementCount());

// Adding one more statement should cause one more pooled statement to be invalidated and
Expand Down

0 comments on commit 9bb0f3e

Please sign in to comment.