Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -800,9 +800,11 @@ private void testDeleteCount(boolean autoCommit, Integer limit) throws Exception
allowServerSideMutations);
try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
conn.createStatement().execute(ddl);
Statement stmt = conn.createStatement();
String sqlStr = "UPSERT INTO " + tableName + " (pk1, v1) VALUES (?,'value')";
PreparedStatement stmt = conn.prepareStatement(sqlStr);
for (int i = 0; i < numRecords ; i++) {
stmt.executeUpdate("UPSERT INTO " + tableName + " (pk1, v1) VALUES (" + i + ",'value')");
stmt.setInt(1, i);
stmt.executeUpdate();
}
conn.commit();
conn.setAutoCommit(autoCommit);
Expand DownExpand Up@@ -865,9 +867,11 @@ public void testDeleteShouldNotFailWhenTheRowsMoreThanMaxMutationSize() throws E
try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
conn.createStatement().execute(ddl);
conn.createStatement().execute(idx1);
Statement stmt = conn.createStatement();
PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + tableName + " VALUES (?, ?, 'value2')");
for(int i = 0; i < 20; i++) {
stmt.executeUpdate("UPSERT INTO " + tableName + " VALUES ("+i+",'value"+i+"', 'value2')");
stmt.setInt(1, i);
stmt.setString(2, "value"+i);
stmt.executeUpdate();
if (i % 10 == 0) {
conn.commit();
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,7 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.PreparedStatement;

import org.junit.Test;

Expand All@@ -35,8 +36,9 @@ public void testRepeatedDropTable() throws Exception {
final Statement stmt = conn.createStatement()) {
assertFalse(stmt.execute(String.format("CREATE TABLE %s(pk varchar not null primary key)", tableName)));
String dropTable = String.format("DROP TABLE IF EXISTS %s", tableName);
PreparedStatement pstmt = conn.prepareStatement(dropTable);
for (int i = 0; i < 5; i++) {
assertFalse(stmt.execute(dropTable));
assertFalse(pstmt.execute());
}
}
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -241,11 +241,9 @@ public void testRowCountWithNoAutoCommitOnUpsertSelect() throws Exception {
conn.createStatement().execute(
"UPSERT INTO " + tableName + " VALUES (NEXT VALUE FOR "+ tableName + "_seq, 1)");
conn.commit();
PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + tableName + " SELECT NEXT VALUE FOR "+ tableName + "_seq, val FROM " + tableName);
for (int i=0; i<6; i++) {
Statement stmt = conn.createStatement();
int upsertCount = stmt.executeUpdate(
"UPSERT INTO " + tableName + " SELECT NEXT VALUE FOR "+ tableName + "_seq, val FROM "
+ tableName);
int upsertCount = stmt.executeUpdate();
conn.commit();
assertEquals((int)Math.pow(2, i), upsertCount);
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand DownExpand Up@@ -168,11 +169,14 @@ static String getRandomOrgId(int maxOrgId) {
private static void mutateRandomly(Connection conn, String tableName, int maxOrgId) {
try {

Statement stmt = conn.createStatement();
String sqlStr = "UPSERT INTO " + tableName + " VALUES(?, ?, ?, ?)";
PreparedStatement stmt = conn.prepareStatement(sqlStr);
for (int i = 0; i < 10000; i++) {
stmt.executeUpdate(
"UPSERT INTO " + tableName + " VALUES('" + getRandomOrgId(maxOrgId) + "'," + i
+ "," + (i + 1) + "," + (i + 2) + ")");
stmt.setString(1, getRandomOrgId(maxOrgId));
stmt.setInt(2, i);
stmt.setInt(3, i + 1);
stmt.setInt(4, i + 2);
stmt.executeUpdate();
}
conn.commit();
} catch (Exception e) {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
Expand DownExpand Up@@ -99,14 +100,16 @@ public void testUpsertSelectDoesntSeeUpsertedData() throws Exception {
props.setProperty(QueryServices.SCAN_RESULT_CHUNK_SIZE, Integer.toString(3));
Connection conn = getConnection(props);
conn.setAutoCommit(true);
conn.createStatement().execute("CREATE SEQUENCE "+seqName);
conn.createStatement().execute("CREATE TABLE " + fullTableName + "(pk INTEGER PRIMARY KEY, val INTEGER)"+tableDDLOptions);
conn.createStatement().execute("CREATE "+(localIndex? "LOCAL " : "")+"INDEX " + indexName + " ON " + fullTableName + "(val)");
Statement stmt = conn.createStatement();
stmt.execute("CREATE SEQUENCE "+seqName);
stmt.execute("CREATE TABLE " + fullTableName + "(pk INTEGER PRIMARY KEY, val INTEGER)"+tableDDLOptions);
stmt.execute("CREATE "+(localIndex? "LOCAL " : "")+"INDEX " + indexName + " ON " + fullTableName + "(val)");

conn.createStatement().execute("UPSERT INTO " + fullTableName + " VALUES (NEXT VALUE FOR " + seqName + ",1)");
stmt.execute("UPSERT INTO " + fullTableName + " VALUES (NEXT VALUE FOR " + seqName + ",1)");
String sqlStr = "UPSERT INTO " + fullTableName + " SELECT NEXT VALUE FOR " + seqName + ", val FROM " + fullTableName;
PreparedStatement pstmt = conn.prepareStatement(sqlStr);
for (int i=0; i<6; i++) {
Statement stmt = conn.createStatement();
int upsertCount = stmt.executeUpdate("UPSERT INTO " + fullTableName + " SELECT NEXT VALUE FOR " + seqName + ", val FROM " + fullTableName);
int upsertCount = pstmt.executeUpdate();
assertEquals((int)Math.pow(2, i), upsertCount);
}
conn.close();
Expand Down