From 83a19e4e2fb0b01d063f341270b96adc770d298b Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Tue, 17 Aug 2021 07:03:07 -0700 Subject: [PATCH] Change prepareThreshold to 1 as default --- .../src/main/java/org/postgresql/PGProperty.java | 2 +- .../org/postgresql/test/jdbc2/PreparedStatementTest.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/jdbc-yugabytedb/src/main/java/org/postgresql/PGProperty.java b/jdbc-yugabytedb/src/main/java/org/postgresql/PGProperty.java index 63d49a3..fee9a18 100644 --- a/jdbc-yugabytedb/src/main/java/org/postgresql/PGProperty.java +++ b/jdbc-yugabytedb/src/main/java/org/postgresql/PGProperty.java @@ -91,7 +91,7 @@ public enum PGProperty { * Sets the default threshold for enabling server-side prepare. A value of {@code -1} stands for * forceBinary */ - PREPARE_THRESHOLD("prepareThreshold", "5", + PREPARE_THRESHOLD("prepareThreshold", "1", "Statement prepare threshold. A value of {@code -1} stands for forceBinary"), /** diff --git a/jdbc-yugabytedb/src/test/java/org/postgresql/test/jdbc2/PreparedStatementTest.java b/jdbc-yugabytedb/src/test/java/org/postgresql/test/jdbc2/PreparedStatementTest.java index 012e31f..45e037b 100644 --- a/jdbc-yugabytedb/src/test/java/org/postgresql/test/jdbc2/PreparedStatementTest.java +++ b/jdbc-yugabytedb/src/test/java/org/postgresql/test/jdbc2/PreparedStatementTest.java @@ -1319,7 +1319,7 @@ public void testStatementDescribe() throws SQLException { } @Test - public void testBatchWithPrepareThreshold5() throws SQLException { + public void testBatchWithPrepareThreshold1() throws SQLException { assumeBinaryModeRegular(); Assume.assumeTrue("simple protocol only does not support prepared statement requests", preferQueryMode != PreferQueryMode.SIMPLE); @@ -1331,7 +1331,7 @@ public void testBatchWithPrepareThreshold5() throws SQLException { // When using a prepareThreshold of 5, a batch update should use server-side prepare pstmt = con.prepareStatement("INSERT INTO batch_tab_threshold5 (id, val) VALUES (?,?)"); ((PgStatement) pstmt).setPrepareThreshold(5); - for (int p = 0; p < 5; p++) { + for (int p = 0; p < 1; p++) { for (int i = 0; i <= 5; i++) { pstmt.setLong(1, i); pstmt.setLong(2, i); @@ -1340,9 +1340,9 @@ public void testBatchWithPrepareThreshold5() throws SQLException { pstmt.executeBatch(); } pstmt.close(); - assertTrue("prepareThreshold=5, so the statement should be server-prepared", + assertTrue("prepareThreshold=1, so the statement should be server-prepared", ((PGStatement) pstmt).isUseServerPrepare()); - assertEquals("prepareThreshold=5, so the statement should be server-prepared", 1, + assertEquals("prepareThreshold=1, so the statement should be server-prepared", 1, getNumberOfServerPreparedStatements("INSERT INTO batch_tab_threshold5 (id, val) VALUES ($1,$2)")); }