* CollectionIdGetIndexCount returns number of indexes that collection with * collectionId has. */
| 814 | * collectionId has. |
| 815 | */ |
| 816 | int |
| 817 | CollectionIdGetIndexCount(uint64 collectionId) |
| 818 | { |
| 819 | StringInfo cmdStr = makeStringInfo(); |
| 820 | appendStringInfo(cmdStr, |
| 821 | "SELECT COUNT(*) " |
| 822 | "FROM %s.collection_indexes " |
| 823 | "WHERE collection_id = " UINT64_FORMAT |
| 824 | " AND (index_is_valid OR %s.index_build_is_in_progress(index_id))", |
| 825 | ApiCatalogSchemaName, collectionId, ApiInternalSchemaName); |
| 826 | |
| 827 | bool isNull = true; |
| 828 | bool readOnly = true; |
| 829 | Datum resultDatum = ExtensionExecuteQueryViaSPI(cmdStr->data, readOnly, |
| 830 | SPI_OK_SELECT, &isNull); |
| 831 | Assert(!isNull); |
| 832 | |
| 833 | if (DatumGetInt64(resultDatum) > INT_MAX) |
| 834 | { |
| 835 | ereport(ERROR, (errmsg("found too many indexes in index metadata"))); |
| 836 | } |
| 837 | |
| 838 | return DatumGetInt64(resultDatum); |
| 839 | } |
| 840 | |
| 841 | |
| 842 | /* |
no test coverage detected