diff --git a/java/yb-pgsql/pom.xml b/java/yb-pgsql/pom.xml
index 2d30dc10e25a..71f0e1bba1d8 100644
--- a/java/yb-pgsql/pom.xml
+++ b/java/yb-pgsql/pom.xml
@@ -28,8 +28,9 @@
test
- org.postgresql
- postgresql
+ com.yugabyte
+ jdbc-yugabytedb
+ 42.3.0
org.json
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/BasePgSQLTest.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/BasePgSQLTest.java
index 6a2871d8c8a6..6d03cb8ade38 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/BasePgSQLTest.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/BasePgSQLTest.java
@@ -29,11 +29,11 @@
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
-import org.postgresql.core.TransactionState;
-import org.postgresql.jdbc.PgArray;
-import org.postgresql.jdbc.PgConnection;
-import org.postgresql.util.PGobject;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.core.TransactionState;
+import com.yugabyte.jdbc.PgArray;
+import com.yugabyte.jdbc.PgConnection;
+import com.yugabyte.util.PGobject;
+import com.yugabyte.util.PSQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yb.client.IsInitDbDoneResponse;
@@ -266,7 +266,7 @@ public void initPostgresBefore() throws Exception {
return;
LOG.info("Loading PostgreSQL JDBC driver");
- Class.forName("org.postgresql.Driver");
+ Class.forName("com.yugabyte.Driver");
// Postgres bin directory.
pgBinDir = new File(TestUtils.getBuildRootDir(), "postgres/bin");
@@ -312,7 +312,7 @@ protected void resetSettings() {
startRedisProxy = false;
}
- static ConnectionBuilder getConnectionBuilder() {
+ protected ConnectionBuilder getConnectionBuilder() {
return new ConnectionBuilder(miniCluster);
}
@@ -1769,6 +1769,7 @@ public static class ConnectionBuilder implements Cloneable {
private static final int INITIAL_CONNECTION_DELAY_MS = 500;
private final MiniYBCluster miniCluster;
+ private boolean loadBalance;
private int tserverIndex = 0;
private String database = DEFAULT_PG_DATABASE;
@@ -1865,7 +1866,7 @@ Connection connect() throws Exception {
final InetSocketAddress postgresAddress = miniCluster.getPostgresContactPoints()
.get(tserverIndex);
String url = String.format(
- "jdbc:postgresql://%s:%d/%s",
+ "jdbc:yugabytedb://%s:%d/%s",
postgresAddress.getHostName(),
postgresAddress.getPort(),
database
@@ -1895,6 +1896,9 @@ Connection connect() throws Exception {
props.setProperty("loggerLevel", "TRACE");
}
+ boolean loadBalance = getLoadBalance();
+ String lbValue = loadBalance ? "true" : "false";
+ props.setProperty("load-balance", lbValue);
int delayMs = INITIAL_CONNECTION_DELAY_MS;
for (int attempt = 1; attempt <= MAX_CONNECTION_ATTEMPTS; ++attempt) {
Connection connection = null;
@@ -1950,5 +1954,13 @@ Connection connect() throws Exception {
}
throw new IllegalStateException("Should not be able to reach here");
}
+
+ public boolean getLoadBalance() {
+ return loadBalance;
+ }
+
+ public void setLoadBalance(boolean lb) {
+ loadBalance = lb;
+ }
}
}
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestBatchCopyFrom.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestBatchCopyFrom.java
index ef2f943c7381..6d8b2ff0ab17 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestBatchCopyFrom.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestBatchCopyFrom.java
@@ -27,8 +27,8 @@
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.postgresql.copy.CopyManager;
-import org.postgresql.core.BaseConnection;
+import com.yugabyte.copy.CopyManager;
+import com.yugabyte.core.BaseConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yb.client.TestUtils;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestConsistency.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestConsistency.java
index ddbca86d4595..64b1f53bd9a3 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestConsistency.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestConsistency.java
@@ -31,8 +31,8 @@
import org.apache.commons.lang3.time.StopWatch;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.postgresql.util.PSQLException;
-import org.postgresql.util.PSQLState;
+import com.yugabyte.util.PSQLException;
+import com.yugabyte.util.PSQLState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestLoadBalance.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestLoadBalance.java
index 05030dbc0799..c6be2da4f08f 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestLoadBalance.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestLoadBalance.java
@@ -14,6 +14,8 @@
package org.yb.pgsql;
import com.google.common.net.HostAndPort;
+import com.yugabyte.ysql.ClusterAwareLoadBalancer;
+import com.yugabyte.jdbc.PgConnection;
import org.yb.AssertionWrappers;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -22,15 +24,25 @@
import org.yb.minicluster.MiniYBDaemon;
import org.yb.util.YBTestRunnerNonTsanOnly;
+import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
@RunWith(value = YBTestRunnerNonTsanOnly.class)
public class TestLoadBalance extends BasePgSQLTest {
private static final Logger LOG = LoggerFactory.getLogger(TestPgEncryption.class);
+ @Override
+ public ConnectionBuilder getConnectionBuilder() {
+ ConnectionBuilder cb = new ConnectionBuilder(miniCluster);
+ cb.setLoadBalance(true);
+ return cb;
+ }
+
@Test
public void testYBServersFunction() throws Exception {
Statement st = connection.createStatement();
@@ -75,6 +87,82 @@ public void testYBServersFunction() throws Exception {
}
AssertionWrappers.assertEquals(
"expected servers started by minicluster", hostPortsDaemonMap.size(), cnt);
-
+ ClusterAwareLoadBalancer clb = ClusterAwareLoadBalancer.instance();
+ AssertionWrappers.assertNotNull(clb);
+ List connList = new ArrayList<>();
+ try {
+ Map hostToNumConnections = new HashMap<>();
+ for (int i = 0; i < 10; i++) {
+ Connection c = getConnectionBuilder().connect();
+ connList.add(c);
+ String host = ((PgConnection)c).getQueryExecutor().getHostSpec().getHost();
+ Integer numConns = 0;
+ if (hostToNumConnections.containsKey(host)) {
+ numConns = hostToNumConnections.get(host);
+ numConns += 1;
+ } else {
+ numConns = 1;
+ }
+ hostToNumConnections.put(host, numConns);
+ }
+ // Add the first connection host port too
+ String firstHost = ((PgConnection)connection).getQueryExecutor().getHostSpec().getHost();
+ Integer numConns = hostToNumConnections.get(firstHost);
+ hostToNumConnections.put(firstHost, numConns+1);
+ clb.printHostToConnMap();
+ AssertionWrappers.assertEquals(3, hostToNumConnections.size());
+ for (Map.Entry e : hostToNumConnections.entrySet()) {
+ AssertionWrappers.assertTrue(e.getValue() >= 3);
+ }
+ } finally {
+ for (Connection c : connList) c.close();
+ }
+ // Let's close the first connection as well, so that this connection does not interfere
+ // with the accounting done later in the test when multiple threads try to create the
+ // connections at the same time.
+ connection.close();
+ // Now let's test parallel connection attempts. Even then it should be properly balanced
+ class ConnectionRunnable implements Runnable {
+ volatile Connection conn;
+ volatile Exception ex;
+ @Override
+ public void run() {
+ try {
+ conn = getConnectionBuilder().connect();
+ } catch (Exception e) {
+ ex = e;
+ }
+ }
+ }
+ Thread[] threads = new Thread[10];
+ ConnectionRunnable[] runnables = new ConnectionRunnable[10];
+ for(int i=0; i< 10; i++) {
+ runnables[i] = new ConnectionRunnable();
+ threads[i] = new Thread(runnables[i]);
+ }
+ for(Thread t : threads) {
+ t.start();
+ }
+ for(Thread t : threads) {
+ t.join();
+ }
+ Map hostToNumConnections = new HashMap<>();
+ for (int i = 0; i < 10; i++) {
+ AssertionWrappers.assertNull(runnables[i].ex);
+ Connection c = runnables[i].conn;
+ String host = ((PgConnection)c).getQueryExecutor().getHostSpec().getHost();
+ Integer numConns;
+ if (hostToNumConnections.containsKey(host)) {
+ numConns = hostToNumConnections.get(host);
+ numConns += 1;
+ } else {
+ numConns = 1;
+ }
+ hostToNumConnections.put(host, numConns);
+ c.close();
+ }
+ for (Map.Entry e : hostToNumConnections.entrySet()) {
+ AssertionWrappers.assertTrue(e.getValue() >= 3);
+ }
}
}
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestOneOrTwoAdmins.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestOneOrTwoAdmins.java
index 6f1ea2ad2990..3e1e06a8819d 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestOneOrTwoAdmins.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestOneOrTwoAdmins.java
@@ -23,7 +23,7 @@
import java.sql.Statement;
import java.sql.SQLException;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import static org.yb.AssertionWrappers.*;
@RunWith(value=YBTestRunnerNonTsanOnly.class)
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgCacheConsistency.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgCacheConsistency.java
index ff188bf0932c..6da5e27dfcaa 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgCacheConsistency.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgCacheConsistency.java
@@ -17,7 +17,7 @@
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yb.minicluster.MiniYBCluster;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgDropDatabase.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgDropDatabase.java
index 6d29d2dd5d82..bed5a7995133 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgDropDatabase.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgDropDatabase.java
@@ -20,7 +20,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgExplicitLocks.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgExplicitLocks.java
index 7ba5b4add2ca..e014a528d33b 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgExplicitLocks.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgExplicitLocks.java
@@ -24,7 +24,7 @@
import java.sql.SQLException;
import java.sql.Statement;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import static org.yb.AssertionWrappers.*;
@RunWith(value=YBTestRunnerNonTsanOnly.class)
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMisc.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMisc.java
index d7bcf7ee235a..2fff1157a226 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMisc.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMisc.java
@@ -17,8 +17,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.postgresql.util.PSQLException;
-import org.postgresql.util.PSQLWarning;
+import com.yugabyte.util.PSQLException;
+import com.yugabyte.util.PSQLWarning;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yb.util.YBTestRunnerNonTsanOnly;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMultiTouchCacheUsage.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMultiTouchCacheUsage.java
index ab126d9e4401..4831f7333e4e 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMultiTouchCacheUsage.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgMultiTouchCacheUsage.java
@@ -20,7 +20,7 @@
import org.yb.util.YBTestRunnerNonTsanOnly;
import org.yb.client.YBClient;
import org.yb.minicluster.MiniYBDaemon;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import static org.yb.AssertionWrappers.*;
import java.net.MalformedURLException;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgRpcForwarding.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgRpcForwarding.java
index 683e62c2ed8c..c17cdaf84018 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgRpcForwarding.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgRpcForwarding.java
@@ -31,7 +31,7 @@
import com.google.common.net.HostAndPort;
import org.yb.minicluster.MiniYBDaemon;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import static org.yb.AssertionWrappers.*;
@RunWith(value=YBTestRunnerNonTsanOnly.class)
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgSequences.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgSequences.java
index 23501a95db2d..79ad688d62d4 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgSequences.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgSequences.java
@@ -146,7 +146,7 @@ public void testSequencesWithMaxValue() throws Exception {
assertEquals(i, rs.getInt("nextval"));
}
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (5)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -165,7 +165,7 @@ public void testSequenceWithMinValue() throws Exception {
@Test
public void testCreateInvalidSequenceWithMinValueAndNegativeIncrement() throws Exception {
try (Statement statement = connection.createStatement()) {
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("MINVALUE (10) must be less than MAXVALUE (-1)");
statement.execute("CREATE SEQUENCE s1 MINVALUE 10 INCREMENT -1");
}
@@ -181,7 +181,7 @@ public void testSequenceWithMinValueAndMaxValueAndNegativeIncrement() throws Exc
assertEquals(i, rs.getInt("nextval"));
}
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached minimum value of sequence \"s1\" (100)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -200,7 +200,7 @@ public void testSequenceWithMaxValueAndCache() throws Exception {
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (5)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -247,7 +247,7 @@ public void testDropWithDependingObjects() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE table t(k SERIAL)");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("cannot drop sequence t_k_seq because other objects depend on it");
statement.execute("DROP SEQUENCE t_k_seq");
@@ -263,7 +263,7 @@ public void testDropRestrictedWithDependingObjects() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE table t(k SERIAL)");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("cannot drop sequence t_k_seq because other objects depend on it");
statement.execute("DROP SEQUENCE t_k_seq RESTRICT");
@@ -325,7 +325,7 @@ public void testMaxInt64FailureInSequence() throws Exception {
assertTrue(rs.next());
assertEquals(9223372036854775807L, rs.getLong("nextval"));
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (9223372036854775807)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -344,7 +344,7 @@ public void testMaxInt64FailureInSequenceInDifferentSession() throws Exception {
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (9223372036854775807)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -365,7 +365,7 @@ public void testMaxInt64OverflowFailureInSequenceInDifferentSession() throws Exc
boolean exceptionOcurred = false;
try {
rs = statement.executeQuery("SELECT nextval('s1')");
- } catch (org.postgresql.util.PSQLException e) {
+ } catch (com.yugabyte.util.PSQLException e) {
assertTrue(e.getMessage().contains(
"reached maximum value of sequence \"s1\" (9223372036854775807)"));
exceptionOcurred = true;
@@ -377,7 +377,7 @@ public void testMaxInt64OverflowFailureInSequenceInDifferentSession() throws Exc
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (9223372036854775807)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -392,7 +392,7 @@ public void testMinInt64FailureInSequence() throws Exception {
assertTrue(rs.next());
assertEquals(-9223372036854775808L, rs.getLong("nextval"));
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached minimum value of sequence \"s1\" (-9223372036854775808)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -412,7 +412,7 @@ public void testMinInt64FailureInSequenceInDifferentSession() throws Exception {
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached minimum value of sequence \"s1\" (-9223372036854775808)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -434,7 +434,7 @@ public void testMinInt64OverflowFailureInSequenceInDifferentSession() throws Exc
boolean exceptionOcurred = false;
try {
rs = statement.executeQuery("SELECT nextval('s1')");
- } catch (org.postgresql.util.PSQLException e) {
+ } catch (com.yugabyte.util.PSQLException e) {
assertTrue(e.getMessage().contains(
"reached minimum value of sequence \"s1\" (-9223372036854775808)"));
exceptionOcurred = true;
@@ -446,7 +446,7 @@ public void testMinInt64OverflowFailureInSequenceInDifferentSession() throws Exc
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached minimum value of sequence \"s1\" (-9223372036854775808)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -456,7 +456,7 @@ public void testMinInt64OverflowFailureInSequenceInDifferentSession() throws Exc
public void testCurrvalFails() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE SEQUENCE s1");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("currval of sequence \"s1\" is not yet defined in this session");
statement.executeQuery("SELECT currval('s1')");
}
@@ -485,7 +485,7 @@ public void testCurrval() throws Exception {
public void testLastvalFails() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE SEQUENCE s1");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("lastval is not yet defined in this session");
statement.execute("SELECT lastval()");
}
@@ -503,7 +503,7 @@ public void testLastvalInAnotherSessionFails() throws Exception {
try (Connection connection2 = getConnectionBuilder().connect();
Statement statement = connection2.createStatement()) {
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("lastval is not yet defined in this session");
statement.execute("SELECT lastval()");
}
@@ -549,7 +549,7 @@ public void testNoCycle() throws Exception {
assertEquals(i, rs.getInt("nextval"));
}
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (2)");
statement.executeQuery("SELECT nextval('s1')");
}
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgSequencesWithCacheFlag.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgSequencesWithCacheFlag.java
index e4fc02005f53..7335c77abe6f 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgSequencesWithCacheFlag.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgSequencesWithCacheFlag.java
@@ -164,7 +164,7 @@ public void testSequencesWithMaxValue() throws Exception {
assertEquals(i, rs.getInt("nextval"));
}
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (5)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -183,7 +183,7 @@ public void testSequenceWithMinValue() throws Exception {
@Test
public void testCreateInvalidSequenceWithMinValueAndNegativeIncrement() throws Exception {
try (Statement statement = connection.createStatement()) {
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("MINVALUE (10) must be less than MAXVALUE (-1)");
statement.execute("CREATE SEQUENCE s1 MINVALUE 10 INCREMENT -1");
}
@@ -199,7 +199,7 @@ public void testSequenceWithMinValueAndMaxValueAndNegativeIncrement() throws Exc
assertEquals(i, rs.getInt("nextval"));
}
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached minimum value of sequence \"s1\" (100)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -218,7 +218,7 @@ public void testSequenceWithMaxValueAndCache() throws Exception {
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (5)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -265,7 +265,7 @@ public void testDropWithDependingObjects() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE table t(k SERIAL)");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("cannot drop sequence t_k_seq because other objects depend on it");
statement.execute("DROP SEQUENCE t_k_seq");
@@ -281,7 +281,7 @@ public void testDropRestrictedWithDependingObjects() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE table t(k SERIAL)");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("cannot drop sequence t_k_seq because other objects depend on it");
statement.execute("DROP SEQUENCE t_k_seq RESTRICT");
@@ -343,7 +343,7 @@ public void testMaxInt64FailureInSequence() throws Exception {
assertTrue(rs.next());
assertEquals(9223372036854775807L, rs.getLong("nextval"));
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (9223372036854775807)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -362,7 +362,7 @@ public void testMaxInt64FailureInSequenceInDifferentSession() throws Exception {
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (9223372036854775807)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -383,7 +383,7 @@ public void testMaxInt64OverflowFailureInSequenceInDifferentSession() throws Exc
boolean exceptionOcurred = false;
try {
rs = statement.executeQuery("SELECT nextval('s1')");
- } catch (org.postgresql.util.PSQLException e) {
+ } catch (com.yugabyte.util.PSQLException e) {
assertTrue(e.getMessage().contains(
"reached maximum value of sequence \"s1\" (9223372036854775807)"));
exceptionOcurred = true;
@@ -395,7 +395,7 @@ public void testMaxInt64OverflowFailureInSequenceInDifferentSession() throws Exc
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (9223372036854775807)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -410,7 +410,7 @@ public void testMinInt64FailureInSequence() throws Exception {
assertTrue(rs.next());
assertEquals(-9223372036854775808L, rs.getLong("nextval"));
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached minimum value of sequence \"s1\" (-9223372036854775808)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -430,7 +430,7 @@ public void testMinInt64FailureInSequenceInDifferentSession() throws Exception {
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached minimum value of sequence \"s1\" (-9223372036854775808)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -452,7 +452,7 @@ public void testMinInt64OverflowFailureInSequenceInDifferentSession() throws Exc
boolean exceptionOcurred = false;
try {
rs = statement.executeQuery("SELECT nextval('s1')");
- } catch (org.postgresql.util.PSQLException e) {
+ } catch (com.yugabyte.util.PSQLException e) {
assertTrue(e.getMessage().contains(
"reached minimum value of sequence \"s1\" (-9223372036854775808)"));
exceptionOcurred = true;
@@ -464,7 +464,7 @@ public void testMinInt64OverflowFailureInSequenceInDifferentSession() throws Exc
Statement statement = connection2.createStatement()) {
// Since the previous client already got all the available sequence numbers in its cache,
// we should get an error when we request another sequence number from another client.
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached minimum value of sequence \"s1\" (-9223372036854775808)");
statement.executeQuery("SELECT nextval('s1')");
}
@@ -474,7 +474,7 @@ public void testMinInt64OverflowFailureInSequenceInDifferentSession() throws Exc
public void testCurrvalFails() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE SEQUENCE s1");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("currval of sequence \"s1\" is not yet defined in this session");
statement.executeQuery("SELECT currval('s1')");
}
@@ -503,7 +503,7 @@ public void testCurrval() throws Exception {
public void testLastvalFails() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE SEQUENCE s1");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("lastval is not yet defined in this session");
statement.execute("SELECT lastval()");
}
@@ -521,7 +521,7 @@ public void testLastvalInAnotherSessionFails() throws Exception {
try (Connection connection2 = getConnectionBuilder().connect();
Statement statement = connection2.createStatement()) {
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("lastval is not yet defined in this session");
statement.execute("SELECT lastval()");
}
@@ -567,7 +567,7 @@ public void testNoCycle() throws Exception {
assertEquals(i, rs.getInt("nextval"));
}
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("reached maximum value of sequence \"s1\" (2)");
statement.executeQuery("SELECT nextval('s1')");
}
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTimeout.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTimeout.java
index cd48cad2e2ba..b2f6d9ba7547 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTimeout.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTimeout.java
@@ -24,7 +24,7 @@
import java.util.List;
import java.util.Map;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import static org.yb.AssertionWrappers.*;
@RunWith(value=YBTestRunnerNonTsanOnly.class)
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTransactions.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTransactions.java
index b9fe09776310..1ed7554e0ec2 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTransactions.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTransactions.java
@@ -15,9 +15,9 @@
import org.apache.commons.lang3.RandomUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.postgresql.core.TransactionState;
-import org.postgresql.util.PSQLException;
-import org.postgresql.util.PSQLState;
+import com.yugabyte.core.TransactionState;
+import com.yugabyte.util.PSQLException;
+import com.yugabyte.util.PSQLState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yb.minicluster.MiniYBClusterBuilder;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTransparentRestarts.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTransparentRestarts.java
index e5d510012963..526acac8a5d3 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTransparentRestarts.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgTransparentRestarts.java
@@ -37,8 +37,8 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.postgresql.util.PSQLException;
-import org.postgresql.util.PSQLState;
+import com.yugabyte.util.PSQLException;
+import com.yugabyte.util.PSQLState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgWrapper.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgWrapper.java
index 669f3e6b2a29..810c880dad8b 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgWrapper.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgWrapper.java
@@ -259,7 +259,7 @@ public void testNotNullConstraint() throws Exception {
try (Statement statement = connection.createStatement()) {
statement.execute(
"CREATE TABLE testnotnullconstraint (k int primary key, v1 text not null)");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("null value in column \"v1\" violates not-null constraint");
statement.execute("INSERT INTO testnotnullconstraint(k, v1) VALUES (1, null)");
}
@@ -271,7 +271,7 @@ public void testCheckConstraint() throws Exception {
statement.execute(
"CREATE TABLE testcheckconstraint (k int primary key, v1 int CHECK (v1 > 9));");
- thrown.expect(org.postgresql.util.PSQLException.class);
+ thrown.expect(com.yugabyte.util.PSQLException.class);
thrown.expectMessage("new row for relation \"testcheckconstraint\" violates check " +
"constraint \"testcheckconstraint_v1_check\"");
statement.execute("INSERT INTO testcheckconstraint(k, v1) VALUES (1, -1)");
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgWriteRestart.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgWriteRestart.java
index afd1464a2b0d..e99af69ec2bc 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgWriteRestart.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestPgWriteRestart.java
@@ -32,7 +32,7 @@
import java.util.Arrays;
import java.util.List;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import static org.yb.AssertionWrappers.*;
@RunWith(value=YBTestRunnerNonTsanOnly.class)
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestReadConsistency.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestReadConsistency.java
index 069ce38d4d54..c95595caab3a 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestReadConsistency.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestReadConsistency.java
@@ -15,7 +15,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import org.yb.util.YBTestRunnerNonTsanOnly;
import java.sql.Connection;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestTablespaceProperties.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestTablespaceProperties.java
index 890c79441aaa..6613bca7ceeb 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestTablespaceProperties.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestTablespaceProperties.java
@@ -32,7 +32,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.postgresql.util.PSQLException;
+import com.yugabyte.util.PSQLException;
import org.yb.client.LeaderStepDownResponse;
import org.yb.client.LocatedTablet;
import org.yb.client.YBClient;
diff --git a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestYsqlUpgrade.java b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestYsqlUpgrade.java
index 81792e7297ff..c851df502660 100644
--- a/java/yb-pgsql/src/test/java/org/yb/pgsql/TestYsqlUpgrade.java
+++ b/java/yb-pgsql/src/test/java/org/yb/pgsql/TestYsqlUpgrade.java
@@ -44,8 +44,8 @@
import org.junit.Test;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
-import org.postgresql.jdbc.PgArray;
-import org.postgresql.util.PGobject;
+import com.yugabyte.jdbc.PgArray;
+import com.yugabyte.util.PGobject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;