| 103 | } |
| 104 | |
| 105 | static std::unique_ptr<TableFuncBindData> bindFunc(const main::ClientContext* context, |
| 106 | const TableFuncBindInput* input) { |
| 107 | std::vector<IndexInfo> indexesInfo; |
| 108 | auto catalog = Catalog::Get(*context); |
| 109 | auto transaction = transaction::Transaction::Get(*context); |
| 110 | std::unordered_set<std::string> seenIndexes; |
| 111 | auto indexEntries = catalog->getIndexEntries(transaction); |
| 112 | for (auto indexEntry : indexEntries) { |
| 113 | auto tableEntry = catalog->getTableCatalogEntry(transaction, indexEntry->getTableID()); |
| 114 | auto tableName = tableEntry->getName(); |
| 115 | auto indexName = indexEntry->getIndexName(); |
| 116 | auto indexType = indexEntry->getIndexType(); |
| 117 | auto propertyNames = getPropertyNames(*tableEntry, indexEntry->getPropertyIDs()); |
| 118 | auto dependencyLoaded = indexEntry->isLoaded(); |
| 119 | std::string indexDefinition; |
| 120 | if (dependencyLoaded) { |
| 121 | auto& auxInfo = indexEntry->getAuxInfo(); |
| 122 | common::FileScanInfo exportFileInfo{}; |
| 123 | IndexToCypherInfo info{context, exportFileInfo}; |
| 124 | indexDefinition = auxInfo.toCypher(*indexEntry, info); |
| 125 | } |
| 126 | indexesInfo.emplace_back(std::move(tableName), std::move(indexName), std::move(indexType), |
| 127 | std::move(propertyNames), dependencyLoaded, std::move(indexDefinition)); |
| 128 | seenIndexes.insert(getSeenKey(indexEntry->getTableID(), indexEntry->getIndexName())); |
| 129 | } |
| 130 | |
| 131 | auto* storageManager = storage::StorageManager::Get(*context); |
| 132 | for (auto* tableEntry : |
| 133 | catalog->getNodeTableEntries(transaction, context->useInternalCatalogEntry())) { |
| 134 | const auto tableID = tableEntry->getTableID(); |
| 135 | const auto hasCatalogPKIndex = |
| 136 | catalog->containsIndex(transaction, tableID, tableEntry->getPrimaryKeyID()); |
| 137 | auto* nodeTable = storageManager->getTable(tableID)->ptrCast<storage::NodeTable>(); |
| 138 | for (auto& indexHolder : nodeTable->getIndexes()) { |
| 139 | const auto& storageIndexInfo = indexHolder.getIndexInfo(); |
| 140 | if (!storageIndexInfo.isPrimary || !storageIndexInfo.isBuiltin) { |
| 141 | continue; |
| 142 | } |
| 143 | if (seenIndexes.contains(getSeenKey(tableID, storageIndexInfo.name))) { |
| 144 | continue; |
| 145 | } |
| 146 | if (storageIndexInfo.isPrimary && hasCatalogPKIndex) { |
| 147 | continue; |
| 148 | } |
| 149 | if (!indexHolder.isLoaded()) { |
| 150 | continue; |
| 151 | } |
| 152 | indexesInfo.emplace_back(tableEntry->getName(), storageIndexInfo.name, |
| 153 | storageIndexInfo.indexType, |
| 154 | getPropertyNames(*tableEntry, storageIndexInfo.columnIDs), true, |
| 155 | "" /* indexDefinition */); |
| 156 | } |
| 157 | } |
| 158 | return std::make_unique<ShowIndexesBindData>(indexesInfo, bindColumns(*input), |
| 159 | indexesInfo.size()); |
| 160 | } |
| 161 | |
| 162 | function_set ShowIndexesFunction::getFunctionSet() { |
nothing calls this directly
no test coverage detected