@@ -116,7 +116,7 @@ namespace
116116void  checkStoragesSupportTransactions (const  PlannerContextPtr & planner_context)
117117{
118118    const  auto  & query_context = planner_context->getQueryContext ();
119-     if  (query_context->getSettingsRef ().throw_on_unsupported_query_inside_transaction )
119+     if  (! query_context->getSettingsRef ().throw_on_unsupported_query_inside_transaction )
120120        return ;
121121
122122    if  (!query_context->getCurrentTransaction ())
@@ -130,13 +130,11 @@ void checkStoragesSupportTransactions(const PlannerContextPtr & planner_context)
130130        else  if  (auto  * table_function_node = table_expression->as <TableFunctionNode>())
131131            storage = table_function_node->getStorage ();
132132
133-         if  (storage->supportsTransactions ())
134-             continue ;
135- 
136-         throw  Exception (ErrorCodes::NOT_IMPLEMENTED,
137-             " Storage {} (table {}) does not support transactions"  ,
138-             storage->getName (),
139-             storage->getStorageID ().getNameForLogs ());
133+         if  (storage && !storage->supportsTransactions ())
134+             throw  Exception (ErrorCodes::NOT_IMPLEMENTED,
135+                 " Storage {} (table {}) does not support transactions"  ,
136+                 storage->getName (),
137+                 storage->getStorageID ().getNameForLogs ());
140138    }
141139}
142140
@@ -1334,9 +1332,9 @@ void Planner::buildPlanForQueryNode()
13341332        query_node.getHaving () = {};
13351333    }
13361334
1337-     checkStoragesSupportTransactions (planner_context);
13381335    collectSets (query_tree, *planner_context);
13391336    collectTableExpressionData (query_tree, planner_context);
1337+     checkStoragesSupportTransactions (planner_context);
13401338
13411339    if  (!select_query_options.only_analyze )
13421340        collectFiltersForAnalysis (query_tree, planner_context);
0 commit comments