Skip to content

Commit 58668ce

Browse files
pufitnikitamikhaylov
authored andcommitted
Fix context
1 parent 573abcf commit 58668ce

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Access/AccessControl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class AccessControl : public MultipleAccessStorage
173173
void setBcryptWorkfactor(int workfactor_);
174174
int getBcryptWorkfactor() const;
175175

176-
/// Compatability setting
176+
/// Compatibility setting
177177
void setEnableUserNameAccessType(bool enable_user_name_access_type_);
178178
bool isEnabledUserNameAccessType() const;
179179

src/Access/Common/AccessRightsElement.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,12 @@ void AccessRightsElement::formatColumnNames(WriteBuffer & buffer) const
142142

143143
void AccessRightsElement::formatONClause(WriteBuffer & buffer, bool hilite) const
144144
{
145-
const auto context = Context::getGlobalContextInstance();
146-
const auto & access_control = context->getAccessControl();
145+
auto is_enabled_user_name_access_type = true;
146+
if (const auto context = Context::getGlobalContextInstance())
147+
{
148+
const auto & access_control = context->getAccessControl();
149+
is_enabled_user_name_access_type = access_control.isEnabledUserNameAccessType();
150+
}
147151

148152
buffer << (hilite ? IAST::hilite_keyword : "") << "ON " << (hilite ? IAST::hilite_none : "");
149153
if (isGlobalWithParameter())
@@ -152,7 +156,7 @@ void AccessRightsElement::formatONClause(WriteBuffer & buffer, bool hilite) cons
152156
/// If `enable_user_name_access_type` is set to false, we will dump `GRANT CREATE USER ON *` as `GRANT CREATE USER ON *.*`.
153157
/// This will allow us to run old replicas in the same cluster.
154158
if (access_flags.getParameterType() == AccessFlags::USER_NAME
155-
&& !access_control.isEnabledUserNameAccessType())
159+
&& is_enabled_user_name_access_type)
156160
{
157161
if (!anyParameter())
158162
LOG_WARNING(getLogger("AccessRightsElement"),

0 commit comments

Comments
 (0)