Program: 80129
Project: 80129
Buggy source:
/** 
 * 1. basic testing 2. correct auto commit logic 3. correct holdability (JDBC 3)
 */
public void testDynamicResultSets() throws SQLException {
  Connection conn=getConnection();
  Connection conn2=openDefaultConnection();
  Statement s=createStatement();
  assertStatementError("String_Node_Str",s,"String_Node_Str");
  s.execute("String_Node_Str");
  String[] sysaliasDefinition={"String_Node_Str"};
  String[] dbMetadataDefinition={"String_Node_Str"};
  String[] columnDefinition={"String_Node_Str"};
  checkMatchingProcedures(conn,"String_Node_Str",sysaliasDefinition,dbMetadataDefinition,columnDefinition);
  assertCallError("String_Node_Str",conn,"String_Node_Str");
  assertCallError("String_Node_Str",conn,"String_Node_Str");
  CallableStatement drs1=conn.prepareCall("String_Node_Str");
  drs1.setInt(1,3);
  drs1.execute();
  ResultSet rs=drs1.getResultSet();
  String[][] drsResult={{"String_Node_Str","String_Node_Str"}};
  JDBC.assertFullResultSet(rs,drsResult);
  drs1.close();
  s.execute("String_Node_Str");
  sysaliasDefinition=new String[]{"String_Node_Str"};
  dbMetadataDefinition=new String[]{"String_Node_Str"};
  columnDefinition=new String[]{"String_Node_Str","String_Node_Str"};
  checkMatchingProcedures(conn,"String_Node_Str",sysaliasDefinition,dbMetadataDefinition,columnDefinition);
  CallableStatement drs2;
  drs2=conn.prepareCall("String_Node_Str");
  drs2.setInt(1,2);
  drs2.setInt(2,6);
  drs2.execute();
  rs=drs2.getResultSet();
  String[][] drs2Results={{"String_Node_Str","String_Node_Str"}};
  JDBC.assertFullResultSet(rs,drs2Results);
  assertTrue(drs2.getMoreResults());
  drs2Results=new String[][]{{"String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str"}};
  rs=drs2.getResultSet();
  JDBC.assertFullResultSet(rs,drs2Results);
  drs2.setInt(1,2);
  drs2.setInt(2,99);
  assertTrue(drs2.execute());
  rs=drs2.getResultSet();
  drs2Results=new String[][]{{"String_Node_Str","String_Node_Str"}};
  JDBC.assertFullResultSet(rs,drs2Results);
  assertFalse(drs2.getMoreResults());
  drs2.setInt(1,2);
  drs2.setInt(2,199);
  assertFalse(drs2.execute());
  assertFalse(drs2.getMoreResults());
  drs2.setInt(1,2);
  drs2.setInt(2,299);
  assertTrue(drs2.execute());
  drs2Results=new String[][]{{"String_Node_Str","String_Node_Str"}};
  rs=drs2.getResultSet();
  JDBC.assertFullResultSet(rs,drs2Results);
  assertTrue(drs2.getMoreResults());
  rs=drs2.getResultSet();
  JDBC.assertEmpty(rs);
  drs2.setInt(1,2);
  drs2.setInt(2,2);
  drs2.execute();
  ResultSet lastResultSet=null;
  int pass=1;
  do {
    if (lastResultSet != null) {
      try {
        lastResultSet.next();
        fail("String_Node_Str");
      }
 catch (      SQLException sqle) {
        assertSQLState("String_Node_Str",sqle);
      }
    }
    lastResultSet=drs2.getResultSet();
    if ((pass == 1) || (pass == 2))     assertNotNull("String_Node_Str" + pass,lastResultSet);
 else     if (pass == 3)     assertNull(lastResultSet);
    pass++;
  }
 while (drs2.getMoreResults() || lastResultSet != null);
  checkCommitWithMultipleResultSets(drs2,conn2,"String_Node_Str");
  checkCommitWithMultipleResultSets(drs2,conn2,"String_Node_Str");
  checkCommitWithMultipleResultSets(drs2,conn2,"String_Node_Str");
  drs2.close();
  drs2=conn.prepareCall("String_Node_Str");
  drs2.setInt(1,2);
  drs2.setInt(2,6);
  drs2.execute();
  rs=drs2.getResultSet();
  String[][] expectedRows={{"String_Node_Str","String_Node_Str"}};
  JDBC.assertFullResultSet(rs,expectedRows);
  drs2.close();
  s.execute("String_Node_Str");
  assertCallError("String_Node_Str",conn,"String_Node_Str");
  s.execute("String_Node_Str");
  s.execute("String_Node_Str");
  assertCallError("String_Node_Str",conn,"String_Node_Str");
  s.execute("String_Node_Str");
  s.execute("String_Node_Str");
  CallableStatement zadrs=conn.prepareCall("String_Node_Str");
  zadrs.execute();
  if (usingEmbedded())   assertEquals(0,zadrs.getUpdateCount());
 else   assertEquals(-1,zadrs.getUpdateCount());
  zadrs.close();
  s.execute("String_Node_Str");
  s.execute("String_Node_Str");
  CallableStatement toomany=conn.prepareCall("String_Node_Str");
  toomany.setInt(1,2);
  toomany.setInt(2,6);
  toomany.execute();
  SQLWarning warn=toomany.getWarnings();
  if (usingEmbedded())   assertEquals("String_Node_Str",warn.getSQLState());
  rs=toomany.getResultSet();
  JDBC.assertFullResultSet(rs,new String[][]{{"String_Node_Str","String_Node_Str"}});
  toomany.setInt(1,2);
  toomany.setInt(2,99);
  toomany.execute();
  rs=toomany.getResultSet();
  JDBC.assertFullResultSet(rs,new String[][]{{"String_Node_Str","String_Node_Str"}});
  toomany.close();
  s.execute("String_Node_Str");
  s.close();
  conn2.close();
}

Fixed version (ground truth):
/** 
 * 1. basic testing 2. correct auto commit logic 3. correct holdability (JDBC 3)
 */
public void testDynamicResultSets() throws SQLException {
  Connection conn=getConnection();
  Connection conn2=openDefaultConnection();
  Statement s=createStatement();
  assertStatementError("String_Node_Str",s,"String_Node_Str");
  s.execute("String_Node_Str");
  String[] sysaliasDefinition={"String_Node_Str"};
  String[] dbMetadataDefinition={"String_Node_Str"};
  String[] columnDefinition={"String_Node_Str"};
  checkMatchingProcedures(conn,"String_Node_Str",sysaliasDefinition,dbMetadataDefinition,columnDefinition);
  assertCallError("String_Node_Str","String_Node_Str");
  assertCallError("String_Node_Str","String_Node_Str");
  CallableStatement drs1=prepareCall("String_Node_Str");
  drs1.setInt(1,3);
  drs1.execute();
  ResultSet rs=drs1.getResultSet();
  String[][] drsResult={{"String_Node_Str","String_Node_Str"}};
  JDBC.assertFullResultSet(rs,drsResult);
  drs1.close();
  s.execute("String_Node_Str");
  sysaliasDefinition=new String[]{"String_Node_Str"};
  dbMetadataDefinition=new String[]{"String_Node_Str"};
  columnDefinition=new String[]{"String_Node_Str","String_Node_Str"};
  checkMatchingProcedures(conn,"String_Node_Str",sysaliasDefinition,dbMetadataDefinition,columnDefinition);
  CallableStatement drs2;
  drs2=conn.prepareCall("String_Node_Str");
  drs2.setInt(1,2);
  drs2.setInt(2,6);
  drs2.execute();
  rs=drs2.getResultSet();
  String[][] drs2Results={{"String_Node_Str","String_Node_Str"}};
  JDBC.assertFullResultSet(rs,drs2Results);
  assertTrue(drs2.getMoreResults());
  drs2Results=new String[][]{{"String_Node_Str","String_Node_Str"},{"String_Node_Str","String_Node_Str"}};
  rs=drs2.getResultSet();
  JDBC.assertFullResultSet(rs,drs2Results);
  drs2.setInt(1,2);
  drs2.setInt(2,99);
  assertTrue(drs2.execute());
  rs=drs2.getResultSet();
  drs2Results=new String[][]{{"String_Node_Str","String_Node_Str"}};
  JDBC.assertFullResultSet(rs,drs2Results);
  assertFalse(drs2.getMoreResults());
  drs2.setInt(1,2);
  drs2.setInt(2,199);
  assertFalse(drs2.execute());
  assertFalse(drs2.getMoreResults());
  drs2.setInt(1,2);
  drs2.setInt(2,299);
  assertTrue(drs2.execute());
  drs2Results=new String[][]{{"String_Node_Str","String_Node_Str"}};
  rs=drs2.getResultSet();
  JDBC.assertFullResultSet(rs,drs2Results);
  assertTrue(drs2.getMoreResults());
  rs=drs2.getResultSet();
  JDBC.assertEmpty(rs);
  drs2.setInt(1,2);
  drs2.setInt(2,2);
  drs2.execute();
  ResultSet lastResultSet=null;
  int pass=1;
  do {
    if (lastResultSet != null) {
      try {
        lastResultSet.next();
        fail("String_Node_Str");
      }
 catch (      SQLException sqle) {
        assertSQLState("String_Node_Str",sqle);
      }
    }
    lastResultSet=drs2.getResultSet();
    if ((pass == 1) || (pass == 2))     assertNotNull("String_Node_Str" + pass,lastResultSet);
 else     if (pass == 3)     assertNull(lastResultSet);
    pass++;
  }
 while (drs2.getMoreResults() || lastResultSet != null);
  checkCommitWithMultipleResultSets(drs2,conn2,"String_Node_Str");
  checkCommitWithMultipleResultSets(drs2,conn2,"String_Node_Str");
  checkCommitWithMultipleResultSets(drs2,conn2,"String_Node_Str");
  drs2.close();
  drs2=conn.prepareCall("String_Node_Str");
  drs2.setInt(1,2);
  drs2.setInt(2,6);
  drs2.execute();
  rs=drs2.getResultSet();
  String[][] expectedRows={{"String_Node_Str","String_Node_Str"}};
  JDBC.assertFullResultSet(rs,expectedRows);
  drs2.close();
  s.execute("String_Node_Str");
  assertCallError("String_Node_Str","String_Node_Str");
  s.execute("String_Node_Str");
  s.execute("String_Node_Str");
  assertCallError("String_Node_Str","String_Node_Str");
  s.execute("String_Node_Str");
  s.execute("String_Node_Str");
  CallableStatement zadrs=conn.prepareCall("String_Node_Str");
  zadrs.execute();
  if (usingEmbedded())   assertEquals(0,zadrs.getUpdateCount());
 else   assertEquals(-1,zadrs.getUpdateCount());
  zadrs.close();
  s.execute("String_Node_Str");
  s.execute("String_Node_Str");
  CallableStatement toomany=conn.prepareCall("String_Node_Str");
  toomany.setInt(1,2);
  toomany.setInt(2,6);
  toomany.execute();
  SQLWarning warn=toomany.getWarnings();
  if (usingEmbedded())   assertEquals("String_Node_Str",warn.getSQLState());
  rs=toomany.getResultSet();
  JDBC.assertFullResultSet(rs,new String[][]{{"String_Node_Str","String_Node_Str"}});
  toomany.setInt(1,2);
  toomany.setInt(2,99);
  toomany.execute();
  rs=toomany.getResultSet();
  JDBC.assertFullResultSet(rs,new String[][]{{"String_Node_Str","String_Node_Str"}});
  toomany.close();
  s.execute("String_Node_Str");
  s.close();
  conn2.close();
}