use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestFixedSQLSuite method subTestENG5637_VarcharVarbinaryErrorMessage.
private void subTestENG5637_VarcharVarbinaryErrorMessage() throws IOException, ProcCallException {
System.out.println("STARTING testing error message......");
if (isHSQL()) {
return;
}
Client client = getClient();
// Test Varchar
// Test AdHoc
String var1 = "Voltdb is a great database product";
try {
client.callProcedure("@AdHoc", "Insert into VARLENGTH (id, var1) VALUES (2,'" + var1 + "')");
fail();
} catch (Exception ex) {
assertTrue(ex.getMessage().contains("Value (" + var1 + ") is too wide for a constant varchar value of size 10"));
}
try {
client.callProcedure("@AdHoc", "Insert into VARLENGTH (id, var1) VALUES (2,'" + var1 + "' || 'abc')");
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains("Value (" + var1 + "abc) is too wide for a constant varchar value of size 10"));
}
// Test inlined varchar with stored procedure
try {
client.callProcedure("VARLENGTH.insert", 1, var1, null, null, null);
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains(String.format("The size %d of the value '%s' exceeds the size of the VARCHAR(%d) column.", var1.length(), var1, 10)));
}
// Test non-inlined varchar with stored procedure and threshold
String var2 = "Voltdb is great | Voltdb is great " + "| Voltdb is great | Voltdb is great| Voltdb is great | Voltdb is great" + "| Voltdb is great | Voltdb is great| Voltdb is great | Voltdb is great";
try {
client.callProcedure("VARLENGTH.insert", 2, null, var2, null, null);
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains(String.format("The size %d of the value '%s...' exceeds the size of the VARCHAR(%d) column.", 174, var2.substring(0, VARCHAR_VARBINARY_THRESHOLD), 80)));
}
// Test non-inlined varchar with stored procedure
var2 = "Voltdb is great | Voltdb is great " + "| Voltdb is great | Voltdb is great| Voltdb is great";
try {
client.callProcedure("VARLENGTH.insert", 21, null, var2, null, null);
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains(String.format("The size %d of the value '%s' exceeds the size of the VARCHAR(%d) column.", 86, var2, 80)));
}
// Test update
client.callProcedure("VARLENGTH.insert", 1, "voltdb", null, null, null);
try {
client.callProcedure("VARLENGTH.update", 1, var1, null, null, null, 1);
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains(String.format("The size %d of the value '%s' exceeds the size of the VARCHAR(%d) column.", var1.length(), var1, 10)));
}
// Test varbinary
// Test AdHoc
String bin1 = "1111111111111111111111000000";
try {
client.callProcedure("@AdHoc", "Insert into VARLENGTH (id, bin1) VALUES (6,'" + bin1 + "')");
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains("Value (" + bin1 + ") is too wide for a constant varbinary value of size 10"));
}
// Test inlined varchar with stored procedure
try {
client.callProcedure("VARLENGTH.insert", 7, null, null, bin1, null);
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains(String.format("The size %d of the value exceeds the size of the VARBINARY(%d) column.", bin1.length() / 2, 10)));
}
// Test non-inlined varchar with stored procedure
String bin2 = "111111111111111111111100000011111111111111111111110000001111111111111111111111000000" + "111111111111111111111100000011111111111111111111110000001111111111111111111111000000" + "111111111111111111111100000011111111111111111111110000001111111111111111111111000000";
try {
client.callProcedure("VARLENGTH.insert", 2, null, null, null, bin2);
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains(String.format("The size %d of the value exceeds the size of the VARBINARY(%d) column.", bin2.length() / 2, 80)));
}
// Test update
client.callProcedure("VARLENGTH.insert", 7, null, null, "1010", null);
try {
client.callProcedure("VARLENGTH.update", 7, null, null, bin1, null, 7);
fail();
} catch (Exception ex) {
//* enable for debugging */ System.out.println(ex.getMessage());
assertTrue(ex.getMessage().contains(String.format("The size %d of the value exceeds the size of the VARBINARY(%d) column.", bin1.length() / 2, 10)));
}
truncateTable(client, "VARLENGTH");
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestFixedSQLSuite method subTestTicketEng993.
// RE-ENABLE ONCE ENG-490 IS FIXED
// private void subTestTicketEng490() throws IOException, ProcCallException {
// Client client = getClient();
//
// VoltTable[] results = client.callProcedure("Eng490Select").getResults();
// assertEquals(1, results.length);
//
// String query = "SELECT A.ASSET_ID, A.OBJECT_DETAIL_ID, OD.OBJECT_DETAIL_ID " +
// "FROM ASSET A, OBJECT_DETAIL OD WHERE A.OBJECT_DETAIL_ID = OD.OBJECT_DETAIL_ID;";
// results = client.callProcedure("@AdHoc", query).getResults();
// assertEquals(1, results.length);
// }
private void subTestTicketEng993() throws IOException, ProcCallException {
Client client = getClient();
// this tests some other mumbo jumbo as well like ENG-999 and ENG-1001
ClientResponse response = client.callProcedure("Eng993Insert", 5, 5.5);
assertTrue(response.getStatus() == ClientResponse.SUCCESS);
// Verify ENG-999 (Literal string 'NULL' round-trips as literal string
// and doesn't transform into a SQL NULL value)
response = client.callProcedure("@AdHoc", "select DESC from P1 where ID = 6");
VoltTable result = response.getResults()[0];
assertEquals("NULL", result.fetchRow(0).get(0, VoltType.STRING));
// Additional verification that inserts are not bothered by math that used to
// generate unexpectedly formatted temp tuples and garbled persistent tuples.
// ENG-5926
response = client.callProcedure("@AdHoc", "select * from P1");
result = response.getResults()[0];
result.advanceRow();
assertEquals(6, result.getLong(0));
assertEquals("NULL", result.getString(1));
result.getLong(2);
// Not sure what's up with HSQL failing to find null here.
if (!isHSQL()) {
assertTrue(result.wasNull());
}
assertEquals(6.5, result.getDouble(3));
// Further verify that inline varchar columns still properly handle potentially larger values
// even after the temp tuple formatting fix for ENG-5926.
response = client.callProcedure("Eng5926Insert", 5, "", 5.5);
assertTrue(response.getStatus() == ClientResponse.SUCCESS);
try {
response = client.callProcedure("Eng5926Insert", 7, "HOO", 7.5);
fail("Failed to throw ProcCallException for runtime varchar length exceeded.");
} catch (ProcCallException pce) {
}
response = client.callProcedure("@AdHoc", "select * from PWEE ORDER BY ID DESC");
result = response.getResults()[0];
result.advanceRow();
assertEquals(6, result.getLong(0));
assertEquals("WEE", result.getString(1));
result.getLong(2);
// Not sure what's up with HSQL failing to find null here.
if (!isHSQL()) {
assertTrue(result.wasNull());
}
assertEquals(6.5, result.getDouble(3));
// this is the actual bug
try {
client.callProcedure("@AdHoc", "insert into P1 (ID,DESC,NUM,RATIO) VALUES('?',?,?,?);");
fail();
} catch (Exception e) {
assertTrue(e.getMessage().contains("Incorrect number of parameters passed: expected 3, passed 0"));
}
// test that missing parameters don't work (ENG-1000)
try {
client.callProcedure("@AdHoc", "insert into P1 (ID,DESC,NUM,RATIO) VALUES(?,?,?,?);");
fail();
} catch (Exception e) {
assertTrue(e.getMessage().contains("Incorrect number of parameters passed: expected 4, passed 0"));
}
//VoltTable results = client.callProcedure("@AdHoc", "select * from P1;").getResults()[0];
//System.out.println(results.toJSONString());
truncateTables(client, new String[] { "P1", "PWEE" });
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestFailuresSuite method testMemoryOverload.
//
// Note: this test looks like it should be testing the 50MB buffer serialization
// limit between the EE and Java but watching it run, it really fails on max
// temp table serialization sizes. This needs more investigation.
//
public void testMemoryOverload() throws IOException, ProcCallException {
if (isHSQL() || isValgrind())
return;
final int STRLEN = 30000;
int totalBytes = 0;
// less than the 50*1024*1024 limit.
int expectedMaxSuccessBytes = 40000000;
int expectedRows = 0;
System.out.println("STARTING testMemoryOverload");
Client client = getClient();
String longStringPart = "volt!";
StringBuilder sb = new StringBuilder();
while (sb.length() < STRLEN) sb.append(longStringPart);
String longString = sb.toString();
assertEquals(STRLEN, longString.length());
VoltTable[] results = null;
while (totalBytes < expectedMaxSuccessBytes) {
results = client.callProcedure("InsertBigString", expectedRows++, longString).getResults();
assertEquals(1, results.length);
assertEquals(1, results[0].asScalarLong());
totalBytes += STRLEN;
}
results = client.callProcedure("WorkWithBigString", expectedRows++, longString).getResults();
assertEquals(1, results.length);
assertEquals(expectedRows, results[0].getRowCount());
totalBytes += STRLEN;
// 51MB exceeds the response buffer limit.
while (totalBytes < (50 * 1024 * 1024)) {
results = client.callProcedure("InsertBigString", expectedRows++, longString).getResults();
assertEquals(1, results.length);
assertEquals(1, results[0].asScalarLong());
totalBytes += STRLEN;
}
// Some tests are run with a different effective partition count on community builds,
// due to a k-factor downgrade, so allow for a possible per partition row count scale difference.
int kFactorScaleDown;
if (MiscUtils.isPro()) {
kFactorScaleDown = 1;
} else {
kFactorScaleDown = 2;
}
for (int ii = 0; ii < 4; ii++) {
results = client.callProcedure("SelectBigString", ii).getResults();
System.out.println(results[0].getRowCount());
long rowCount = results[0].getRowCount();
//With elastic hashing the numbers are a little fuzzy
if (!((rowCount > 800 && rowCount < 950) || (rowCount > 800 / kFactorScaleDown && rowCount < 950 / kFactorScaleDown))) {
System.out.println("Unexpected row count: " + rowCount);
}
assertTrue((rowCount > 800 && rowCount < 950) || (rowCount > 800 / kFactorScaleDown && rowCount < 950 / kFactorScaleDown));
}
//System.out.flush();
try {
results = client.callProcedure("WorkWithBigString", expectedRows++, longString).getResults();
fail();
} catch (ProcCallException e) {
// this should eventually happen
assertTrue(totalBytes > expectedMaxSuccessBytes);
return;
} catch (IOException e) {
fail(e.toString());
return;
}
fail();
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestFailuresSuite method testViolateUniqueness.
public void testViolateUniqueness() throws IOException {
System.out.println("STARTING testVU");
Client client = getClient();
VoltTable[] results = null;
try {
results = client.callProcedure("ViolateUniqueness", 1L, 1L, 1L).getResults();
System.out.println("testVU client response received");
assertEquals(results.length, 0);
} catch (ProcCallException e) {
try {
results = client.callProcedure("InsertNewOrder", 2L, 2L, 2L).getResults();
} catch (ProcCallException e1) {
fail(e1.toString());
} catch (IOException e1) {
fail(e1.toString());
}
System.out.println("second client response received");
assertEquals(1, results.length);
assertEquals(1, results[0].asScalarLong());
return;
} catch (IOException e) {
fail(e.toString());
return;
}
fail("testViolateUniqueness should return while catching ProcCallException");
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestFailuresSuite method testBadVarcharToAnyCompare.
// Subcase of ENG-800
public void testBadVarcharToAnyCompare() throws IOException {
System.out.println("STARTING testBadVarcharToAnyCompare");
Client client = getClient();
boolean threw = false;
try {
client.callProcedure("BadVarcharCompare", 1).getResults();
} catch (ProcCallException e) {
if (!isHSQL()) {
if ((e.getMessage().contains("SQL ERROR")) && (e.getMessage().contains("cannot be cast for comparison to type VARCHAR"))) {
threw = true;
} else {
e.printStackTrace();
}
} else {
threw = true;
}
}
assertTrue(threw);
}
Aggregations