Search in sources :

Example 76 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestShutdown method testShutdown.

public void testShutdown() throws Exception {
    final Client client = getClient();
    // sleep a little so that we have time for the IPC backend to actually be running
    // so it can screw us on empty results
    Thread.sleep(1000);
    boolean lostConnect = false;
    try {
        client.callProcedure("@Shutdown").getResults();
    } catch (ProcCallException pce) {
        lostConnect = pce.getMessage().contains("was lost before a response was received");
    }
    assertTrue(lostConnect);
    while (!((LocalCluster) getServerConfig()).areAllNonLocalProcessesDead()) {
        Thread.sleep(500);
    }
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 77 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestSubQueriesSuite method testLhsScalarInSubquery.

public void testLhsScalarInSubquery() throws Exception {
    Client client = getClient();
    loadData(false);
    String sql;
    // Non-correlated IN with a non-correlated select on the left side.
    sql = "select ID from R1 T1 " + "where (select ID from R2 T2 " + "       where ID = 5) " + "      IN " + "      (select ID from R2 T3 " + "       where T3.ID = 5) " + "order by ID;";
    validateTableOfLongs(client, sql, new long[][] { { 1 }, { 2 }, { 3 }, { 4 }, { 5 } });
    // Correlated IN with a non-correlated select on the left side.
    sql = "select ID from R1 T1 " + "where (select ID from R2 T2 " + "       where ID = 5) " + "      IN " + "      (select ID from R2 T3 " + "       where T3.ID > T1.ID) " + "order by ID;";
    validateTableOfLongs(client, sql, new long[][] { { 1 }, { 2 }, { 3 }, { 4 } });
    // Correlated IN with a correlated select on the left side.
    sql = "select ID from R1 T1 " + "where (select ID from R2 T2 " + "       where T2.ID = T1.ID) " + "      IN " + "      (select ID from R2 T3 " + "       where T3.ID <> 5 and T3.ID >= T1.ID) " + "order by ID;";
    validateTableOfLongs(client, sql, new long[][] { { 1 }, { 2 }, { 3 }, { 4 } });
    // Cardinality error
    try {
        sql = "select ID from R1 T1 " + "where (select ID from R2 T2" + "       where T2.ID <= T1.ID)" + "      IN " + "      (select ID from R2 T2" + "       where T2.ID <= T1.ID);";
        client.callProcedure("@AdHoc", sql);
        fail("Did not get the expected scalar subquery cardinality error");
    } catch (ProcCallException ex) {
        String errMsg = (isHSQL()) ? "cardinality violation" : "More than one row returned by a scalar/row subquery";
        assertTrue(ex.getMessage().contains(errMsg));
    }
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 78 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestSubQueriesSuite method subtestSelectScalarwithParentTable.

private void subtestSelectScalarwithParentTable(String tb, Client client) throws Exception {
    VoltTable vt;
    String sql;
    // Non-correlated
    sql = "select T1.ID, T1.DEPT," + "       (select ID from R2 " + "        where ID = 2) " + "from " + tb + " T1 " + "where T1.ID < 3 " + "order by T1.ID desc;";
    validateTableOfLongs(client, sql, new long[][] { { 2, 1, 2 }, { 1, 1, 2 } });
    // User-parameter-correlated
    vt = client.callProcedure("@AdHoc", "select T1.ID, T1.DEPT, " + "       (select ID from R2 " + "        where ID = ?) " + "from " + tb + " T1 " + "where T1.ID < 3 " + "order by T1.ID desc;", 2).getResults()[0];
    validateTableOfLongs(vt, new long[][] { { 2, 1, 2 }, { 1, 1, 2 } });
    // Correlated
    sql = "select T1.ID, T1.DEPT, " + "       (select ID from R2 " + "        where R2.ID = T1.ID and R2.WAGE = 50) " + "from " + tb + " T1 " + "where T1.ID > 3 " + "order by T1.ID desc;";
    validateTableOfLongs(client, sql, new long[][] { { 7, 2, Long.MIN_VALUE }, { 6, 2, Long.MIN_VALUE }, { 5, 2, 5 }, { 4, 2, Long.MIN_VALUE } });
    // Uncorreleted on simple seq scan
    sql = "select T1.DEPT, " + "       (select ID from R2 " + "        where R2.ID = 1) " + "from " + tb + " T1 " + "where T1.DEPT = 2;";
    validateTableOfLongs(client, sql, new long[][] { { 2, 1 }, { 2, 1 }, { 2, 1 }, { 2, 1 } });
    // check for cardinality error
    try {
        sql = "select T1.ID, T1.DEPT, " + "       (select ID from R2 " + "        where R2.ID < T1.ID) " + "from " + tb + " T1 " + "where T1.ID > 3 " + "order by T1.ID desc;";
        client.callProcedure("@AdHoc", sql);
        fail("Did not get expected cardinality error from :" + sql);
    } catch (ProcCallException ex) {
        String errMsg = (isHSQL()) ? "cardinality violation" : "More than one row returned by a scalar/row subquery";
        assertTrue(ex.getMessage().contains(errMsg));
    }
    // Hsqldb back end bug: ENG-8273 NPE
    if (!isHSQL()) {
        sql = "select T1.DEPT, count(*), " + "       (select max(dept) from R2 " + "        where R2.wage = T1.wage) " + "from " + tb + " T1 " + "group by dept, wage " + "order by dept, wage;";
        validateTableOfLongs(client, sql, new long[][] { { 1, 1, 2 }, { 1, 1, 1 }, { 1, 1, 1 }, { 2, 1, 2 }, { 2, 2, 2 }, { 2, 1, 2 } });
        sql = "select T1.DEPT, count(*), " + "       (select sum(dept) from R2" + "        where R2.wage > T1.dept * 10) " + "from " + tb + " T1 " + "group by dept " + "order by dept;";
        validateTableOfLongs(client, sql, new long[][] { { 1, 3, 8 }, { 2, 4, 7 } });
    }
}
Also used : VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 79 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestSQLTypesSuite method testUpdateToNull.

public void testUpdateToNull() throws IOException, ProcCallException {
    final Client client = this.getClient();
    final Object[] params = new Object[COLS + 2];
    for (int k = 0; k < COLS; ++k) {
        // build the parameter list as described above
        // Fill the row with non-null data and insert
        params[0] = "";
        params[1] = pkey.incrementAndGet();
        for (int i = 0; i < COLS; i++) {
            params[i + 2] = m_midValues[i];
            assert (params[i + 2] != null);
        }
        params[0] = "ALLOW_NULLS";
        client.callProcedure("Insert", params);
        for (int i = 0; i < COLS; i++) {
            params[i + 2] = (i == k) ? m_nullValues[i] : m_midValues[i];
            assert (params[i + 2] != null);
        }
        try {
            client.callProcedure("Update", params);
        } catch (final ProcCallException e) {
            e.printStackTrace();
            fail(e.getMessage());
        } catch (final NoConnectionsException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
        // verify that the row was updated
        final VoltTable[] result = client.callProcedure("Select", "ALLOW_NULLS", pkey.get()).getResults();
        final VoltTableRow row = result[0].fetchRow(0);
        for (int i = 0; i < COLS; ++i) {
            final Object obj = row.get(i + 1, m_types[i]);
            if (i == k) {
                assertTrue(row.wasNull());
            } else {
                assertTrue(comparisonHelper(obj, params[i + 2], m_types[i]));
            }
        }
    }
}
Also used : NoConnectionsException(org.voltdb.client.NoConnectionsException) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) VoltTableRow(org.voltdb.VoltTableRow) ProcCallException(org.voltdb.client.ProcCallException)

Example 80 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestSQLTypesSuite method testInsertNulls_No_Nulls.

//
// Verify that NULLS are rejected in in NOT NULL columns
//
public void testInsertNulls_No_Nulls() throws IOException {
    final Client client = this.getClient();
    // Insert a NULL value for each column. For the first
    // row, insert null in the first column, for the 5th row
    // in the 5 column, etc.
    final Object[] params = new Object[COLS + 2];
    for (int k = 0; k < COLS; ++k) {
        boolean caught = false;
        // build the parameter list as described above
        params[0] = "NO_NULLS";
        params[1] = pkey.incrementAndGet();
        for (int i = 0; i < COLS; i++) {
            params[i + 2] = (i == k) ? m_nullValues[i] : m_midValues[i];
            assert (params[i + 2] != null);
        }
        // Each insert into the NO_NULLS table must fail with a
        // constraint failure. Verify this.
        System.out.println("testNullsRejected: :" + k + " " + m_types[k]);
        try {
            client.callProcedure("Insert", params);
        } catch (final ProcCallException e) {
            if (e.getMessage().contains("CONSTRAINT VIOLATION"))
                caught = true;
            else {
                e.printStackTrace();
                fail();
            }
        } catch (final NoConnectionsException e) {
            e.printStackTrace();
            fail();
        }
        assertTrue(caught);
    }
}
Also used : NoConnectionsException(org.voltdb.client.NoConnectionsException) Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Aggregations

ProcCallException (org.voltdb.client.ProcCallException)240 Client (org.voltdb.client.Client)151 VoltTable (org.voltdb.VoltTable)120 ClientResponse (org.voltdb.client.ClientResponse)92 IOException (java.io.IOException)82 NoConnectionsException (org.voltdb.client.NoConnectionsException)55 Test (org.junit.Test)44 Configuration (org.voltdb.VoltDB.Configuration)41 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)36 File (java.io.File)21 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)19 VoltCompiler (org.voltdb.compiler.VoltCompiler)15 VoltDB (org.voltdb.VoltDB)10 VoltTableRow (org.voltdb.VoltTableRow)10 Timestamp (java.sql.Timestamp)5 TimestampType (org.voltdb.types.TimestampType)5 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 HashSet (java.util.HashSet)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3