mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Backport #70310 to 24.8: Fix context for startup scripts
This commit is contained in:
parent
cc54fd6021
commit
5a217c58ca
@ -609,7 +609,9 @@ void loadStartupScripts(const Poco::Util::AbstractConfiguration & config, Contex
|
||||
auto condition_write_buffer = WriteBufferFromOwnString();
|
||||
|
||||
LOG_DEBUG(log, "Checking startup query condition `{}`", condition);
|
||||
executeQuery(condition_read_buffer, condition_write_buffer, true, context, callback, QueryFlags{ .internal = true }, std::nullopt, {});
|
||||
auto startup_context = Context::createCopy(context);
|
||||
startup_context->makeQueryContext();
|
||||
executeQuery(condition_read_buffer, condition_write_buffer, true, startup_context, callback, QueryFlags{ .internal = true }, std::nullopt, {});
|
||||
|
||||
auto result = condition_write_buffer.str();
|
||||
|
||||
@ -629,7 +631,9 @@ void loadStartupScripts(const Poco::Util::AbstractConfiguration & config, Contex
|
||||
auto write_buffer = WriteBufferFromOwnString();
|
||||
|
||||
LOG_DEBUG(log, "Executing query `{}`", query);
|
||||
executeQuery(read_buffer, write_buffer, true, context, callback, QueryFlags{ .internal = true }, std::nullopt, {});
|
||||
auto startup_context = Context::createCopy(context);
|
||||
startup_context->makeQueryContext();
|
||||
executeQuery(read_buffer, write_buffer, true, startup_context, callback, QueryFlags{ .internal = true }, std::nullopt, {});
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
|
@ -13,5 +13,13 @@
|
||||
<scripts>
|
||||
<query>SELECT * FROM system.query_log LIMIT 1</query>
|
||||
</scripts>
|
||||
<scripts>
|
||||
<query>SELECT 1 SETTINGS skip_unavailable_shards = 1</query>
|
||||
<condition>SELECT 1;</condition>
|
||||
</scripts>
|
||||
<scripts>
|
||||
<query>SELECT 1 SETTINGS skip_unavailable_shards = 1</query>
|
||||
<condition>SELECT 1;</condition>
|
||||
</scripts>
|
||||
</startup_scripts>
|
||||
</clickhouse>
|
||||
|
@ -16,6 +16,12 @@ def test_startup_scripts():
|
||||
try:
|
||||
cluster.start()
|
||||
assert node.query("SHOW TABLES") == "TestTable\n"
|
||||
assert (
|
||||
node.query(
|
||||
"SELECT value, changed FROM system.settings WHERE name = 'skip_unavailable_shards'"
|
||||
)
|
||||
== "0\t0\n"
|
||||
)
|
||||
|
||||
finally:
|
||||
cluster.shutdown()
|
||||
|
Loading…
Reference in New Issue
Block a user