Search in sources :

Example 6 with ReaderOutOfDateException

use of io.questdb.cairo.sql.ReaderOutOfDateException in project questdb by bluestreak01.

the class TruncateTest method testDropColumnWithCachedPlan.

private void testDropColumnWithCachedPlan() throws Exception {
    assertMemoryLeak(() -> {
        compiler.compile("create table y as (" + "select timestamp_sequence(0, 1000000000) timestamp," + " rnd_symbol('a','b',null) symbol1 " + " from long_sequence(10)" + ") timestamp (timestamp)", sqlExecutionContext);
        try (RecordCursorFactory factory = compiler.compile("select * from y", sqlExecutionContext).getRecordCursorFactory()) {
            try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
                sink.clear();
                TestUtils.printCursor(cursor, factory.getMetadata(), true, sink, printer);
            }
            compiler.compile("alter table y drop column symbol1", sqlExecutionContext);
            try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
                TestUtils.printCursor(cursor, factory.getMetadata(), true, sink, printer);
                Assert.fail();
            } catch (ReaderOutOfDateException e) {
                TestUtils.assertContains(e.getFlyweightMessage(), "cannot be used because table schema has changed [table='y']");
            }
        }
    });
}
Also used : RecordCursorFactory(io.questdb.cairo.sql.RecordCursorFactory) RecordCursor(io.questdb.cairo.sql.RecordCursor) ReaderOutOfDateException(io.questdb.cairo.sql.ReaderOutOfDateException)

Aggregations

ReaderOutOfDateException (io.questdb.cairo.sql.ReaderOutOfDateException)6 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)4 RecordCursor (io.questdb.cairo.sql.RecordCursor)3 Test (org.junit.Test)3 DataFrameCursor (io.questdb.cairo.sql.DataFrameCursor)2 Rnd (io.questdb.std.Rnd)2 CairoError (io.questdb.cairo.CairoError)1 CairoException (io.questdb.cairo.CairoException)1 EntryUnavailableException (io.questdb.cairo.EntryUnavailableException)1 DataFrame (io.questdb.cairo.sql.DataFrame)1 CompiledQuery (io.questdb.griffin.CompiledQuery)1 SqlCompiler (io.questdb.griffin.SqlCompiler)1 SqlExecutionContext (io.questdb.griffin.SqlExecutionContext)1 SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)1 BindVariableServiceImpl (io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl)1 PeerDisconnectedException (io.questdb.network.PeerDisconnectedException)1 PeerIsSlowToReadException (io.questdb.network.PeerIsSlowToReadException)1