| 14 | namespace processor { |
| 15 | |
| 16 | void CreateTable::executeInternal(ExecutionContext* context) { |
| 17 | auto clientContext = context->clientContext; |
| 18 | auto catalog = Catalog::Get(*clientContext); |
| 19 | auto transaction = transaction::Transaction::Get(*clientContext); |
| 20 | auto memoryManager = storage::MemoryManager::Get(*clientContext); |
| 21 | // Check conflict |
| 22 | if (catalog->containsTable(transaction, info.tableName)) { |
| 23 | switch (info.onConflict) { |
| 24 | case ConflictAction::ON_CONFLICT_DO_NOTHING: { |
| 25 | appendMessage(std::format("Table {} already exists.", info.tableName), memoryManager); |
| 26 | return; |
| 27 | } |
| 28 | case ConflictAction::ON_CONFLICT_THROW: { |
| 29 | throw BinderException(info.tableName + " already exists in catalog."); |
| 30 | } |
| 31 | default: |
| 32 | UNREACHABLE_CODE; |
| 33 | } |
| 34 | } |
| 35 | // Create the table. |
| 36 | CatalogEntry* entry = nullptr; |
| 37 | switch (info.type) { |
| 38 | case CatalogEntryType::NODE_TABLE_ENTRY: |
| 39 | case CatalogEntryType::REL_GROUP_ENTRY: { |
| 40 | entry = catalog->createTableEntry(transaction, info); |
| 41 | } break; |
| 42 | default: |
| 43 | UNREACHABLE_CODE; |
| 44 | } |
| 45 | storage::StorageManager::Get(*clientContext) |
| 46 | ->createTable(entry->ptrCast<TableCatalogEntry>(), clientContext); |
| 47 | appendMessage(std::format("Table {} has been created.", info.tableName), memoryManager); |
| 48 | sharedState->tableCreated = true; |
| 49 | } |
| 50 | |
| 51 | } // namespace processor |
| 52 | } // namespace lbug |
nothing calls this directly
no test coverage detected