Merge pull request #70081 from ClickHouse/backport/24.8/69985

Backport #69985 to 24.8: Fix parsing for definers
This commit is contained in:
robot-ch-test-poll4 2024-09-27 21:37:02 +02:00 committed by GitHub
commit ad92f57223
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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) 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); s_eq.ignore(pos, expected);
if (s_current_user.ignore(pos, expected)) if (s_current_user.ignore(pos, expected))

View File

@ -29,6 +29,7 @@ OK
100 100
100 100
OK OK
Syntax error
===== TestGrants ===== ===== TestGrants =====
OK OK
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} --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 =====" echo "===== TestGrants ====="
${CLICKHOUSE_CLIENT} --query "GRANT CREATE ON *.* TO $user1" ${CLICKHOUSE_CLIENT} --query "GRANT CREATE ON *.* TO $user1"
${CLICKHOUSE_CLIENT} --query "GRANT SELECT ON $db.test_table TO $user1, $user2" ${CLICKHOUSE_CLIENT} --query "GRANT SELECT ON $db.test_table TO $user1, $user2"