Backport #69985 to 24.9: Fix parsing for definers

This commit is contained in:
robot-clickhouse 2024-09-27 18:09:42 +00:00
parent 4ed0de28c6
commit b68bf12d1a
3 changed files with 10 additions and 1 deletions

View File

@ -68,7 +68,7 @@ bool ParserSQLSecurity::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
while (true)
{
if (!definer && s_definer.ignore(pos, expected))
if (!definer && !is_definer_current_user && s_definer.ignore(pos, expected))
{
s_eq.ignore(pos, expected);
if (s_current_user.ignore(pos, expected))

View File

@ -29,6 +29,7 @@ OK
100
100
OK
Syntax error
===== TestGrants =====
OK
OK

View File

@ -208,6 +208,14 @@ ${CLICKHOUSE_CLIENT} --query "SELECT count() FROM destination2"
(( $(${CLICKHOUSE_CLIENT} --query "ALTER TABLE test_table MODIFY SQL SECURITY INVOKER" 2>&1 | grep -c "is not supported") >= 1 )) && echo "OK" || echo "UNEXPECTED"
(( $(${CLICKHOUSE_CLIENT} --user $user1 --query "
CREATE VIEW $db.test_view_broken
SQL SECURITY DEFINER
DEFINER CURRENT_USER
DEFINER $user2
AS SELECT * FROM $db.test_table;
" 2>&1 | grep -c "Syntax error") >= 1 )) && echo "Syntax error" || echo "UNEXPECTED"
echo "===== TestGrants ====="
${CLICKHOUSE_CLIENT} --query "GRANT CREATE ON *.* TO $user1"
${CLICKHOUSE_CLIENT} --query "GRANT SELECT ON $db.test_table TO $user1, $user2"