Search in sources :

Example 16 with SqlException

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");
            }
        }
    });
}
Also used : RecordCursorFactory(io.questdb.cairo.sql.RecordCursorFactory) RecordCursor(io.questdb.cairo.sql.RecordCursor) SqlException(io.questdb.griffin.SqlException) AbstractGriffinTest(io.questdb.griffin.AbstractGriffinTest) Test(org.junit.Test)

Example 17 with SqlException

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");
            }
        }
    });
}
Also used : SqlExecutionContextImpl(io.questdb.griffin.SqlExecutionContextImpl) SqlCompiler(io.questdb.griffin.SqlCompiler) SqlExecutionContext(io.questdb.griffin.SqlExecutionContext) SqlException(io.questdb.griffin.SqlException) DefaultCairoConfiguration(io.questdb.cairo.DefaultCairoConfiguration) CairoEngine(io.questdb.cairo.CairoEngine) DefaultCairoConfiguration(io.questdb.cairo.DefaultCairoConfiguration) CairoConfiguration(io.questdb.cairo.CairoConfiguration) Test(org.junit.Test) AbstractCairoTest(io.questdb.cairo.AbstractCairoTest)

Aggregations

SqlException (io.questdb.griffin.SqlException)17 SqlCompiler (io.questdb.griffin.SqlCompiler)9 SqlExecutionContext (io.questdb.griffin.SqlExecutionContext)9 Test (org.junit.Test)9 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)7 CairoConfiguration (io.questdb.cairo.CairoConfiguration)5 Function (io.questdb.cairo.sql.Function)5 SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)5 ColumnType (io.questdb.cairo.ColumnType)4 RecordCursor (io.questdb.cairo.sql.RecordCursor)4 RecordCursorFactory (io.questdb.cairo.sql.RecordCursorFactory)4 FunctionFactory (io.questdb.griffin.FunctionFactory)4 Constants (io.questdb.griffin.engine.functions.constants.Constants)4 Record (io.questdb.cairo.sql.Record)3 io.questdb.std (io.questdb.std)3 ObjList (io.questdb.std.ObjList)3 ExpressionNode (io.questdb.griffin.model.ExpressionNode)2 QueryColumn (io.questdb.griffin.model.QueryColumn)2 Runner (org.openjdk.jmh.runner.Runner)2 Options (org.openjdk.jmh.runner.options.Options)2