mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #53342 from ClickHouse/fix-context-has-expired
Fix "Context has expired" error in dictionaries
This commit is contained in:
commit
38ac027658
@ -62,14 +62,13 @@ namespace ErrorCodes
|
||||
*/
|
||||
|
||||
|
||||
class FunctionDictHelper : WithContext
|
||||
class FunctionDictHelper
|
||||
{
|
||||
public:
|
||||
explicit FunctionDictHelper(ContextPtr context_) : WithContext(context_) {}
|
||||
explicit FunctionDictHelper(ContextPtr context_) : current_context(context_) {}
|
||||
|
||||
std::shared_ptr<const IDictionary> getDictionary(const String & dictionary_name)
|
||||
{
|
||||
auto current_context = getContext();
|
||||
auto dict = current_context->getExternalDictionariesLoader().getDictionary(dictionary_name, current_context);
|
||||
|
||||
if (!access_checked)
|
||||
@ -132,10 +131,12 @@ public:
|
||||
|
||||
DictionaryStructure getDictionaryStructure(const String & dictionary_name) const
|
||||
{
|
||||
return getContext()->getExternalDictionariesLoader().getDictionaryStructure(dictionary_name, getContext());
|
||||
return current_context->getExternalDictionariesLoader().getDictionaryStructure(dictionary_name, current_context);
|
||||
}
|
||||
|
||||
private:
|
||||
ContextPtr current_context;
|
||||
|
||||
/// Access cannot be not granted, since in this case checkAccess() will throw and access_checked will not be updated.
|
||||
std::atomic<bool> access_checked = false;
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
0
|
23
tests/queries/0_stateless/02843_context_has_expired.sql
Normal file
23
tests/queries/0_stateless/02843_context_has_expired.sql
Normal file
@ -0,0 +1,23 @@
|
||||
DROP DICTIONARY IF EXISTS dict;
|
||||
DROP TABLE IF EXISTS source;
|
||||
|
||||
CREATE TABLE source
|
||||
(
|
||||
id UInt64,
|
||||
value String
|
||||
)
|
||||
ENGINE=Memory;
|
||||
|
||||
CREATE DICTIONARY dict
|
||||
(
|
||||
id UInt64,
|
||||
value String
|
||||
)
|
||||
PRIMARY KEY id
|
||||
SOURCE(CLICKHOUSE(TABLE 'source'))
|
||||
LAYOUT(DIRECT());
|
||||
|
||||
SELECT 1 IN (SELECT dictGet('dict', 'value', materialize('1')));
|
||||
|
||||
DROP DICTIONARY dict;
|
||||
DROP TABLE source;
|
Loading…
Reference in New Issue
Block a user