| 57 | } |
| 58 | |
| 59 | static std::unique_ptr<TableFuncBindData> bindFunc(const main::ClientContext* context, |
| 60 | const TableFuncBindInput* input) { |
| 61 | std::vector<std::string> columnNames; |
| 62 | std::vector<LogicalType> columnTypes; |
| 63 | columnNames.emplace_back("id"); |
| 64 | columnTypes.emplace_back(LogicalType::UINT64()); |
| 65 | columnNames.emplace_back("name"); |
| 66 | columnTypes.emplace_back(LogicalType::STRING()); |
| 67 | columnNames.emplace_back("type"); |
| 68 | columnTypes.emplace_back(LogicalType::STRING()); |
| 69 | columnNames.emplace_back("database name"); |
| 70 | columnTypes.emplace_back(LogicalType::STRING()); |
| 71 | columnNames.emplace_back("comment"); |
| 72 | columnTypes.emplace_back(LogicalType::STRING()); |
| 73 | std::vector<TableInfo> tableInfos; |
| 74 | auto transaction = transaction::Transaction::Get(*context); |
| 75 | auto dbManager = main::DatabaseManager::Get(*context); |
| 76 | |
| 77 | // Show tables from the main database (local) - always show these separately from graphs |
| 78 | if (!context->hasDefaultDatabase()) { |
| 79 | auto catalog = context->getDatabase()->getCatalog(); |
| 80 | for (auto& entry : |
| 81 | catalog->getTableEntries(transaction, context->useInternalCatalogEntry())) { |
| 82 | std::string dbName = LOCAL_DB_NAME; |
| 83 | // For foreign-backed rel tables, use the foreign database name |
| 84 | if (entry->getType() == CatalogEntryType::REL_GROUP_ENTRY) { |
| 85 | auto relEntry = entry->constPtrCast<RelGroupCatalogEntry>(); |
| 86 | if (!relEntry->getForeignDatabaseName().empty()) { |
| 87 | dbName = relEntry->getForeignDatabaseName(); |
| 88 | } |
| 89 | } |
| 90 | // For shadow node tables, use shadow db name |
| 91 | if (entry->getType() == CatalogEntryType::NODE_TABLE_ENTRY) { |
| 92 | auto nodeEntry = entry->constPtrCast<NodeTableCatalogEntry>(); |
| 93 | if (!nodeEntry->getForeignDatabaseName().empty()) { |
| 94 | dbName = SHADOW_DB_NAME; |
| 95 | } |
| 96 | } |
| 97 | tableInfos.emplace_back(entry->getName(), entry->getTableID(), |
| 98 | TableTypeUtils::toString(entry->getTableType()), dbName, entry->getComment()); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // Show tables from all graphs |
| 103 | for (auto& graph : dbManager->getGraphs()) { |
| 104 | auto graphName = graph->getCatalogName(); |
| 105 | for (auto& entry : |
| 106 | graph->getTableEntries(transaction, context->useInternalCatalogEntry())) { |
| 107 | tableInfos.emplace_back(entry->getName(), entry->getTableID(), |
| 108 | TableTypeUtils::toString(entry->getTableType()), |
| 109 | std::format("{}(graph)", graphName), entry->getComment()); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | // Show tables from attached databases |
| 114 | for (auto attachedDatabase : dbManager->getAttachedDatabases()) { |
| 115 | auto databaseName = attachedDatabase->getDBName(); |
| 116 | auto databaseType = attachedDatabase->getDBType(); |
nothing calls this directly
no test coverage detected