MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / executeInternal

Method executeInternal

src/processor/operator/simple/attach_database.cpp:31–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void AttachDatabase::executeInternal(ExecutionContext* context) {
32 auto client = context->clientContext;
33 auto databaseManager = main::DatabaseManager::Get(*client);
34 auto memoryManager = storage::MemoryManager::Get(*client);
35 if (common::StringUtils::getUpper(attachInfo.dbType) == common::ATTACHED_LBUG_DB_TYPE) {
36 auto db = std::make_unique<main::AttachedLbugDatabase>(attachInfo.dbPath,
37 attachInfo.dbAlias, common::ATTACHED_LBUG_DB_TYPE, client);
38 client->setDefaultDatabase(db.get());
39 databaseManager->registerAttachedDatabase(std::move(db));
40 client->addDBDirToFileSearchPath(attachInfo.dbPath);
41 appendMessage(attachMessage(), memoryManager);
42 return;
43 }
44 for (auto& storageExtension : client->getDatabase()->getStorageExtensions()) {
45 if (storageExtension->canHandleDB(attachInfo.dbType)) {
46 auto db = storageExtension->attach(attachInfo.dbAlias, attachInfo.dbPath, client,
47 attachInfo.options);
48 databaseManager->registerAttachedDatabase(std::move(db));
49 client->addDBDirToFileSearchPath(attachInfo.dbPath);
50 appendMessage(attachMessage(), memoryManager);
51 return;
52 }
53 }
54 auto errMsg =
55 std::format("No loaded extension can handle database type: {}.", attachInfo.dbType);
56 auto dbType = common::StringUtils::getLower(attachInfo.dbType);
57 if (dbType == "adbc" || dbType == "duckdb" || dbType == "postgres" || dbType == "sqlite") {
58 errMsg += std::format("\nDid you forget to load {} extension?\nYou can load it by: load "
59 "extension {};",
60 dbType, dbType);
61 }
62 throw common::RuntimeException{errMsg};
63}
64
65} // namespace processor
66} // namespace lbug

Callers

nothing calls this directly

Calls 9

attachMessageFunction · 0.85
canHandleDBMethod · 0.80
attachMethod · 0.80
setDefaultDatabaseMethod · 0.45
getMethod · 0.45
getStorageExtensionsMethod · 0.45
getDatabaseMethod · 0.45

Tested by

no test coverage detected