2020-08-08 18:55:14 +00:00
|
|
|
#include <Parsers/ASTSetQuery.h>
|
|
|
|
#include <Parsers/formatSettingName.h>
|
2020-08-20 02:01:40 +00:00
|
|
|
#include <Common/SipHash.h>
|
2021-06-14 04:13:35 +00:00
|
|
|
#include <Common/FieldVisitorHash.h>
|
|
|
|
#include <Common/FieldVisitorToString.h>
|
2020-11-09 16:05:40 +00:00
|
|
|
#include <IO/Operators.h>
|
2020-08-08 18:55:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-08-20 02:01:40 +00:00
|
|
|
|
|
|
|
void ASTSetQuery::updateTreeHashImpl(SipHash & hash_state) const
|
|
|
|
{
|
|
|
|
for (const auto & change : changes)
|
|
|
|
{
|
|
|
|
hash_state.update(change.name.size());
|
|
|
|
hash_state.update(change.name);
|
|
|
|
applyVisitor(FieldVisitorHash(hash_state), change.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-08 18:55:14 +00:00
|
|
|
void ASTSetQuery::formatImpl(const FormatSettings & format, FormatState &, FormatStateStacked) const
|
|
|
|
{
|
|
|
|
if (is_standalone)
|
|
|
|
format.ostr << (format.hilite ? hilite_keyword : "") << "SET " << (format.hilite ? hilite_none : "");
|
|
|
|
|
2022-09-25 23:34:07 +00:00
|
|
|
bool first = true;
|
|
|
|
|
2022-09-26 21:20:43 +00:00
|
|
|
for (const auto & change : changes)
|
2020-08-08 18:55:14 +00:00
|
|
|
{
|
2022-09-25 23:34:07 +00:00
|
|
|
if (!first)
|
2020-08-08 18:55:14 +00:00
|
|
|
format.ostr << ", ";
|
2022-09-25 23:34:07 +00:00
|
|
|
else
|
|
|
|
first = false;
|
2020-08-08 18:55:14 +00:00
|
|
|
|
2022-09-26 21:20:43 +00:00
|
|
|
formatSettingName(change.name, format.ostr);
|
2023-02-21 18:24:01 +00:00
|
|
|
CustomType custom;
|
|
|
|
if (!format.show_secrets && change.value.tryGet<CustomType>(custom) && custom.isSecret())
|
|
|
|
format.ostr << " = " << custom.toString(false);
|
|
|
|
else
|
|
|
|
format.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value);
|
2020-08-08 18:55:14 +00:00
|
|
|
}
|
2022-09-25 23:34:07 +00:00
|
|
|
|
2022-10-11 18:25:28 +00:00
|
|
|
for (const auto & setting_name : default_settings)
|
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
format.ostr << ", ";
|
|
|
|
else
|
|
|
|
first = false;
|
|
|
|
|
|
|
|
formatSettingName(setting_name, format.ostr);
|
|
|
|
format.ostr << " = DEFAULT";
|
|
|
|
}
|
|
|
|
|
2022-09-26 21:20:43 +00:00
|
|
|
for (const auto & [name, value] : query_parameters)
|
2022-09-25 23:34:07 +00:00
|
|
|
{
|
|
|
|
if (!first)
|
|
|
|
format.ostr << ", ";
|
|
|
|
else
|
|
|
|
first = false;
|
|
|
|
|
2022-09-26 21:20:43 +00:00
|
|
|
formatSettingName(QUERY_PARAMETER_NAME_PREFIX + name, format.ostr);
|
|
|
|
format.ostr << " = " << value;
|
2022-09-25 23:34:07 +00:00
|
|
|
}
|
2020-08-08 18:55:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|