mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #43077 from evillique/query_parameters_inserts
Add support for interactive parameters in INSERT VALUES queries
This commit is contained in:
commit
82877d0824
@ -1628,6 +1628,14 @@ void ClientBase::processParsedSingleQuery(const String & full_query, const Strin
|
||||
global_context->applySettingChange(change);
|
||||
}
|
||||
global_context->resetSettingsToDefaultValue(set_query->default_settings);
|
||||
|
||||
/// Query parameters inside SET queries should be also saved on the client side
|
||||
/// to override their previous definitions set with --param_* arguments
|
||||
/// and for substitutions to work inside INSERT ... VALUES queries
|
||||
for (const auto & [name, value] : set_query->query_parameters)
|
||||
query_parameters.insert_or_assign(name, value);
|
||||
|
||||
global_context->addQueryParameters(set_query->query_parameters);
|
||||
}
|
||||
if (const auto * use_query = parsed_query->as<ASTUseQuery>())
|
||||
{
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,8 @@
|
||||
DROP TABLE IF EXISTS 02476_query_parameters_insert;
|
||||
CREATE TABLE 02476_query_parameters_insert (x Int32) ENGINE=MergeTree() ORDER BY tuple();
|
||||
|
||||
SET param_x = 1;
|
||||
INSERT INTO 02476_query_parameters_insert VALUES ({x: Int32});
|
||||
SELECT * FROM 02476_query_parameters_insert;
|
||||
|
||||
DROP TABLE 02476_query_parameters_insert;
|
Loading…
Reference in New Issue
Block a user