//
// Verify that NULLS are allowed in non-NOT NULL columns
//
public void testInsertNulls_Nulls_Allowed() 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) {
// build the parameter list as described above
params[0] = "";
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 in to the ALLOW_NULLS table must succeed.
// Perform the inserts and execute selects, verifying the
// content of the select matches the parameters passed to
// insert
System.out.println("testNullsAllowed: " + k + " NULL type is " + m_types[k]);
try {
params[0] = "ALLOW_NULLS";
// We'll use the multi-partition insert for this test. Between
// this and testInsertNull_No_Nulls we should cover both
// cases in ticket 306
client.callProcedure("InsertMulti", params);
} catch (final ProcCallException e) {
e.printStackTrace();
fail();
} catch (final NoConnectionsException e) {
e.printStackTrace();
fail();
}
// verify that the row was inserted
try {
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());