@Test public void testCreateAsSelectIOError() throws Exception { TestUtils.assertMemoryLeak(new TestUtils.LeakProneCode() { @Override public void run() { String sql = "create table y as (" + "select rnd_symbol(4,4,4,2) a from long_sequence(10000)" + "), cast(a as STRING)"; final FilesFacade ff = new FilesFacadeImpl() { int mapCount = 0; @Override public long getMapPageSize() { return getPageSize(); } @Override public long mmap(long fd, long len, long offset, int mode) { if (mapCount++ > 5) { return -1; } return super.mmap(fd, len, offset, mode); } }; final DefaultCairoConfiguration configuration = new DefaultCairoConfiguration(root) { @Override public FilesFacade getFilesFacade() { return ff; } }; try ( CairoEngine engine = new CairoEngine(configuration); SqlCompiler compiler = new SqlCompiler(engine) ) { try { compiler.compile(sql, sqlExecutionContext); Assert.fail(); } catch (SqlException e) { TestUtils.assertContains(e.getMessage(), "Could not create table. See log for details"); } engine.releaseAllReaders(); engine.releaseAllWriters(); Assert.assertEquals(0, engine.getBusyReaderCount()); Assert.assertEquals(0, engine.getBusyWriterCount()); } } }); }
@NotNull public CompiledQuery compile(@NotNull CharSequence query, @NotNull SqlExecutionContext executionContext) throws SqlException { clear(); lexer.of(query); final CharSequence tok = SqlUtil.fetchNext(lexer); if (tok == null) { throw SqlException.$(0, "empty query"); } final KeywordBasedExecutor executor = keywordBasedExecutors.get(tok); if (executor == null) { return compileUsingModel(executionContext); } return executor.execute(executionContext); }
SqlCompiler implements Closeable { @NotNull public CompiledQuery compile(@NotNull CharSequence query, @NotNull SqlExecutionContext executionContext) throws SqlException { clear(); lexer.of(query); final CharSequence tok = SqlUtil.fetchNext(lexer); if (tok == null) { throw SqlException.$(0, "empty query"); } final KeywordBasedExecutor executor = keywordBasedExecutors.get(tok); if (executor == null) { return compileUsingModel(executionContext); } return executor.execute(executionContext); } }
SqlCompiler implements Closeable { @NotNull public CompiledQuery compile(@NotNull CharSequence query, @NotNull SqlExecutionContext executionContext) throws SqlException { clear(); lexer.of(query); final CharSequence tok = SqlUtil.fetchNext(lexer); if (tok == null) { throw SqlException.$(0, "empty query"); } final KeywordBasedExecutor executor = keywordBasedExecutors.get(tok); if (executor == null) { return compileUsingModel(executionContext); } return executor.execute(executionContext); } SqlCompiler(CairoEngine engine);  SqlCompiler(CairoEngine engine, @Nullable MessageBus messageBus, @Nullable FunctionFactoryCache functionFactoryCache); }
SqlCompiler implements Closeable { @NotNull public CompiledQuery compile(@NotNull CharSequence query, @NotNull SqlExecutionContext executionContext) throws SqlException { clear(); lexer.of(query); final CharSequence tok = SqlUtil.fetchNext(lexer); if (tok == null) { throw SqlException.$(0, "empty query"); } final KeywordBasedExecutor executor = keywordBasedExecutors.get(tok); if (executor == null) { return compileUsingModel(executionContext); } return executor.execute(executionContext); } SqlCompiler(CairoEngine engine);  SqlCompiler(CairoEngine engine, @Nullable MessageBus messageBus, @Nullable FunctionFactoryCache functionFactoryCache); static void configureLexer(GenericLexer lexer); static boolean isAssignableFrom(int to, int from); @Override void close(); @NotNull CompiledQuery compile(@NotNull CharSequence query, @NotNull SqlExecutionContext executionContext); CairoEngine getEngine(); }
SqlCompiler implements Closeable { @NotNull public CompiledQuery compile(@NotNull CharSequence query, @NotNull SqlExecutionContext executionContext) throws SqlException { clear(); lexer.of(query); final CharSequence tok = SqlUtil.fetchNext(lexer); if (tok == null) { throw SqlException.$(0, "empty query"); } final KeywordBasedExecutor executor = keywordBasedExecutors.get(tok); if (executor == null) { return compileUsingModel(executionContext); } return executor.execute(executionContext); } SqlCompiler(CairoEngine engine);  SqlCompiler(CairoEngine engine, @Nullable MessageBus messageBus, @Nullable FunctionFactoryCache functionFactoryCache); static void configureLexer(GenericLexer lexer); static boolean isAssignableFrom(int to, int from); @Override void close(); @NotNull CompiledQuery compile(@NotNull CharSequence query, @NotNull SqlExecutionContext executionContext); CairoEngine getEngine(); static final ObjList<String> sqlControlSymbols; }