| 1279 | } |
| 1280 | |
| 1281 | void InterpreterCreateQuery::setEngine(ASTCreateQuery & create) const |
| 1282 | { |
| 1283 | if (create.as_table_function) |
| 1284 | { |
| 1285 | if (getContext()->getSettingsRef()[Setting::restore_replace_external_table_functions_to_null]) |
| 1286 | { |
| 1287 | const auto & factory = TableFunctionFactory::instance(); |
| 1288 | |
| 1289 | auto properties = factory.tryGetProperties(create.as_table_function->as<ASTFunction>()->name); |
| 1290 | if (properties && properties->allow_readonly) |
| 1291 | return; |
| 1292 | if (!create.storage) |
| 1293 | { |
| 1294 | auto storage_ast = make_intrusive<ASTStorage>(); |
| 1295 | create.set(create.storage, storage_ast); |
| 1296 | } |
| 1297 | else |
| 1298 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Storage should not be created yet, it's a bug."); |
| 1299 | create.reset(create.as_table_function); |
| 1300 | setNullTableEngine(*create.storage); |
| 1301 | } |
| 1302 | return; |
| 1303 | } |
| 1304 | |
| 1305 | if (create.is_dictionary && getContext()->getSettingsRef()[Setting::restore_replace_external_dictionary_source_to_null]) |
| 1306 | setNullDictionarySourceIfExternal(create); |
| 1307 | |
| 1308 | if (create.is_dictionary || create.is_ordinary_view || create.is_window_view) |
| 1309 | return; |
| 1310 | |
| 1311 | if (create.isTemporary()) |
| 1312 | { |
| 1313 | /// Some part of storage definition is specified, but ENGINE is not: just set the one from default_temporary_table_engine setting. |
| 1314 | |
| 1315 | if (!create.cluster.empty()) |
| 1316 | throw Exception(ErrorCodes::INCORRECT_QUERY, "Temporary tables cannot be created with ON CLUSTER clause"); |
| 1317 | |
| 1318 | if (!create.storage) |
| 1319 | { |
| 1320 | auto storage_ast = make_intrusive<ASTStorage>(); |
| 1321 | create.set(create.storage, storage_ast); |
| 1322 | } |
| 1323 | |
| 1324 | if (!create.storage->engine) |
| 1325 | setDefaultTableEngine(*create.storage, getContext()->getSettingsRef()[Setting::default_temporary_table_engine].value); |
| 1326 | |
| 1327 | checkTemporaryTableEngineName(create.storage->engine->name); |
| 1328 | return; |
| 1329 | } |
| 1330 | |
| 1331 | if (create.is_materialized_view) |
| 1332 | { |
| 1333 | /// A materialized view with an external target doesn't need a table engine. |
| 1334 | if (create.is_materialized_view_with_external_target()) |
| 1335 | return; |
| 1336 | |
| 1337 | if (auto * to_engine = create.getTargetInnerEngine(ViewTarget::To)) |
| 1338 | { |
nothing calls this directly
no test coverage detected