Mask secrets in log

This commit is contained in:
kssenii 2022-11-21 22:30:20 +01:00
parent 894b654f93
commit 1073626f8e
3 changed files with 11 additions and 4 deletions

View File

@ -29,7 +29,10 @@ void ASTAlterNamedCollectionQuery::formatImpl(const IAST::FormatSettings & setti
first = false;
formatSettingName(change.name, settings.ostr);
settings.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value);
if (settings.show_secrets)
settings.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value);
else
settings.ostr << " = '[HIDDEN]'";
}
}
if (!delete_keys.empty())

View File

@ -32,7 +32,11 @@ void ASTCreateNamedCollectionQuery::formatImpl(const IAST::FormatSettings & sett
first = false;
formatSettingName(change.name, settings.ostr);
settings.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value);
if (settings.show_secrets)
settings.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value);
else
settings.ostr << " = '[HIDDEN]'";
}
}

View File

@ -25,7 +25,7 @@ namespace DB
namespace ErrorCodes
{
extern const int NAMED_COLLECTION_ALREADY_EXISTS;
extern const int NAMED_COLLECTION_DOESNT_EXISTS;
extern const int NAMED_COLLECTION_DOESNT_EXIST;
extern const int BAD_ARGUMENTS;
}
@ -269,7 +269,7 @@ public:
if (!removeIfExists(collection_name))
{
throw Exception(
ErrorCodes::NAMED_COLLECTION_DOESNT_EXISTS,
ErrorCodes::NAMED_COLLECTION_DOESNT_EXIST,
"Cannot remove collection `{}`, because it doesn't exist",
collection_name);
}