use of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream in project derby by apache.
the class BasicSetup method atestTriggersWithLOBcolumns.
// This test creates a table with LOB column and insets large data
// into that column. There is a trigger defined on this table
// but the trigger does not need access to the LOB column. In 10.8
// and prior releases, even though we don't need the LOB column to
// execute the trigger, we still read all the columns from the
// trigger table when the trigger fired. With 10.9, only the columns
// required by the firing triggers are read from the trigger table
// and hence for our test here, LOB column will not be materialized.
// In 10.8 and prior releases, the trigger defined in this test can
// run into OOM errors depending on how much heap is available to
// the upgrade test. But in 10.9 and higher, that won't happen
// because LOB is never read into memory for the trigger being
// used by this test.
public void atestTriggersWithLOBcolumns() throws Exception {
Statement s = createStatement();
ResultSet rs;
boolean modeDb2SqlOptional = oldAtLeast(10, 3);
final int lobsize = 50000 * 1024;
switch(getPhase()) {
case // create with old version
PH_CREATE:
s.execute("create table table1LOBtest (id int, status smallint, bl blob(2G))");
PreparedStatement ps = prepareStatement("insert into table1LOBtest values (?, 0, ?)");
ps.setInt(1, 1);
ps.setBinaryStream(2, new LoopingAlphabetStream(lobsize), lobsize);
ps.executeUpdate();
s.execute("create table table2LOBtest (id int, updates int default 0)");
ps = prepareStatement("insert into table2LOBtest (id) values (?)");
ps.setInt(1, 1);
ps.executeUpdate();
s.execute("create trigger trigger1 after update of status on table1LOBtest referencing " + "new as n_row for each row " + (modeDb2SqlOptional ? "" : "MODE DB2SQL ") + "update table2LOBtest set updates = updates + 1 where table2LOBtest.id = n_row.id");
break;
case PH_HARD_UPGRADE:
// OOM in 10.8 and prior
if ((getConnection().getMetaData().getDatabaseMajorVersion() >= 10) && (getConnection().getMetaData().getDatabaseMinorVersion() >= 9)) {
ps = prepareStatement("update table1LOBtest set status = 1 where id = 1");
ps.executeUpdate();
}
break;
}
}
Aggregations