diff --git a/cql3/query_processor.hh b/cql3/query_processor.hh index 718830fcca..28a2c571e8 100644 --- a/cql3/query_processor.hh +++ b/cql3/query_processor.hh @@ -174,9 +174,7 @@ public: return *_wasm._instance_cache; } - wasm::alien_thread_runner& alien_runner() { - return *_wasm._alien_runner; - } + wasm::manager& wasm() { return _wasm; } statements::prepared_statement::checked_weak_ptr get_prepared(const std::optional& user, const prepared_cache_key_type& key) { if (user) { diff --git a/cql3/statements/create_function_statement.cc b/cql3/statements/create_function_statement.cc index 21fc98b08f..07812deead 100644 --- a/cql3/statements/create_function_statement.cc +++ b/cql3/statements/create_function_statement.cc @@ -51,7 +51,7 @@ seastar::future> create_function_statement::crea // FIXME: need better way to test wasm compilation without real_database() wasm::context ctx{qp.wasm_engine(), _name.name, qp.wasm_instance_cache(), db.get_config().wasm_udf_yield_fuel(), db.get_config().wasm_udf_total_fuel()}; try { - co_await wasm::precompile(qp.alien_runner(), ctx, arg_names, _body); + co_await qp.wasm().precompile(ctx, arg_names, _body); co_return ::make_shared(_name, _arg_types, std::move(arg_names), _body, _language, std::move(return_type), _called_on_null_input, std::move(ctx)); } catch (const wasm::exception& we) { diff --git a/db/schema_tables.cc b/db/schema_tables.cc index 4310e01106..1aaba1088f 100644 --- a/db/schema_tables.cc +++ b/db/schema_tables.cc @@ -1913,7 +1913,7 @@ static seastar::future> create_func(r row.get_nonnull("called_on_null_input"), std::move(ctx)); } else if (language == "wasm") { wasm::context ctx{qctx->qp().wasm_engine(), name.name, qctx->qp().wasm_instance_cache(), db.get_config().wasm_udf_yield_fuel(), db.get_config().wasm_udf_total_fuel()}; - co_await wasm::precompile(qctx->qp().alien_runner(), ctx, arg_names, body); + co_await qctx->qp().wasm().precompile(ctx, arg_names, body); co_return ::make_shared(std::move(name), std::move(arg_types), std::move(arg_names), std::move(body), language, std::move(return_type), row.get_nonnull("called_on_null_input"), std::move(ctx)); diff --git a/lang/wasm.cc b/lang/wasm.cc index 3297bef922..2799728136 100644 --- a/lang/wasm.cc +++ b/lang/wasm.cc @@ -239,6 +239,10 @@ struct from_val_visitor { } }; +seastar::future<> manager::precompile(context& ctx, const std::vector& arg_names, std::string script) { + return ::wasm::precompile(*_alien_runner, ctx, arg_names, std::move(script)); +} + seastar::future<> precompile(alien_thread_runner& alien_runner, context& ctx, const std::vector& arg_names, std::string script) { seastar::promise> done; alien_runner.submit(done, [&engine_ptr = ctx.engine_ptr, script = std::move(script)] { diff --git a/lang/wasm.hh b/lang/wasm.hh index c155b8d7bf..fd4fe7c01c 100644 --- a/lang/wasm.hh +++ b/lang/wasm.hh @@ -58,6 +58,7 @@ public: manager(const std::optional&); friend class cql3::query_processor; future<> stop(); + seastar::future<> precompile(context& ctx, const std::vector& arg_names, std::string script); }; struct context {