2023-02-17 10:36:58 +00:00
|
|
|
#pragma once
|
|
|
|
#include "Access/ContextAccess.h"
|
|
|
|
#include "Interpreters/Context.h"
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
struct SecretHidingFormatSettings
|
|
|
|
{
|
|
|
|
// We can't store const Context& as there's a dangerous usage {.ctx = *getContext()}
|
|
|
|
// which is UB in case getContext()'s return ptr is the only one holding the object
|
|
|
|
const ContextPtr & ctx;
|
|
|
|
const IAST & query;
|
|
|
|
size_t max_length = 0;
|
|
|
|
bool one_line = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline String format(const SecretHidingFormatSettings & settings)
|
|
|
|
{
|
2023-04-28 12:42:23 +00:00
|
|
|
const bool show_secrets = settings.ctx->displaySecretsInShowAndSelect()
|
2023-04-28 13:39:38 +00:00
|
|
|
&& settings.ctx->getSettingsRef().format_display_secrets_in_show_and_select
|
2023-04-28 12:42:23 +00:00
|
|
|
&& settings.ctx->getAccess()->isGranted(AccessType::displaySecretsInShowAndSelect);
|
2023-02-17 10:36:58 +00:00
|
|
|
|
|
|
|
return settings.query.formatWithPossiblyHidingSensitiveData(settings.max_length, settings.one_line, show_secrets);
|
|
|
|
}
|
|
|
|
}
|