use of io.questdb.griffin.SqlException in project questdb by bluestreak01.
the class MatchStrBindVariableTest method testConstant.
@Test
public void testConstant() throws Exception {
assertMemoryLeak(() -> {
try (RecordCursorFactory factory = compiler.compile("select x from long_sequence(1) where '1GQO2' ~ $1", sqlExecutionContext).getRecordCursorFactory()) {
bindVariableService.setStr(0, "GQO");
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
TestUtils.printCursor(cursor, factory.getMetadata(), true, sink, TestUtils.printer);
}
TestUtils.assertEquals("x\n" + "1\n", sink);
bindVariableService.setStr(0, "QTQ");
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
TestUtils.printCursor(cursor, factory.getMetadata(), true, sink, TestUtils.printer);
}
TestUtils.assertEquals("x\n", sink);
bindVariableService.setStr(0, null);
try {
factory.getCursor(sqlExecutionContext);
Assert.fail();
} catch (SqlException e) {
Assert.assertEquals(47, e.getPosition());
TestUtils.assertContains(e.getFlyweightMessage(), "NULL regex");
}
}
});
}
use of io.questdb.griffin.SqlException in project questdb by bluestreak01.
the class TelemetryTest method testTelemetryCanDeleteTableWhenDisabled.
@Test
public void testTelemetryCanDeleteTableWhenDisabled() throws Exception {
CairoConfiguration configuration = new DefaultCairoConfiguration(root) {
@Override
public TelemetryConfiguration getTelemetryConfiguration() {
return new DefaultTelemetryConfiguration() {
@Override
public boolean getEnabled() {
return false;
}
};
}
};
TestUtils.assertMemoryLeak(() -> {
try (CairoEngine engine = new CairoEngine(configuration);
SqlCompiler compiler = new SqlCompiler(engine, null);
TelemetryJob ignored = new TelemetryJob(engine);
SqlExecutionContext sqlExecutionContext = new SqlExecutionContextImpl(engine, 1)) {
try {
compiler.compile("drop table telemetry", sqlExecutionContext);
Assert.fail();
} catch (SqlException e) {
TestUtils.assertContains(e.getFlyweightMessage(), "table 'telemetry' does not exist");
}
}
});
}
Aggregations