Check for dict access on underlying dict rather than table

This is better for the table function because otherwise the database is
set to "_table_function" when checking access which is not the database
where the actual dict is.
This commit is contained in:
joelynch 2024-06-19 16:44:47 +02:00
parent e8d831ce90
commit cd9fd1880f
No known key found for this signature in database
2 changed files with 1 additions and 2 deletions

View File

@ -161,9 +161,9 @@ Pipe StorageDictionary::read(
const size_t max_block_size,
const size_t threads)
{
local_context->checkAccess(AccessType::dictGet, getStorageID());
auto registered_dictionary_name = location == Location::SameDatabaseAndNameAsDictionary ? getStorageID().getInternalDictionaryName() : dictionary_name;
auto dictionary = getContext()->getExternalDictionariesLoader().getDictionary(registered_dictionary_name, local_context);
local_context->checkAccess(AccessType::dictGet, dictionary->getDatabaseOrNoDatabaseTag(), dictionary->getDictionaryID().getTableName());
return dictionary->read(column_names, max_block_size, threads);
}

View File

@ -80,7 +80,6 @@ ColumnsDescription TableFunctionDictionary::getActualTableStructure(ContextPtr c
StoragePtr TableFunctionDictionary::executeImpl(
const ASTPtr &, ContextPtr context, const std::string & table_name, ColumnsDescription, bool is_insert_query) const
{
context->checkAccess(AccessType::dictGet, getDatabaseName(), table_name);
StorageID dict_id(getDatabaseName(), table_name);
auto dictionary_table_structure = getActualTableStructure(context, is_insert_query);