| 667 | |
| 668 | |
| 669 | static List * |
| 670 | CollectionIdGetIndexesCore(uint64 collectionId, bool excludeIdIndex, |
| 671 | bool enableNestedDistribution, bool includeIndexBuilds) |
| 672 | { |
| 673 | StringInfo cmdStr = makeStringInfo(); |
| 674 | appendStringInfo(cmdStr, |
| 675 | "SELECT array_agg(a.index_id), array_agg(a.index_spec), " |
| 676 | " array_agg(a.index_build_in_progress) FROM ("); |
| 677 | |
| 678 | appendStringInfo(cmdStr, " SELECT index_id, index_spec"); |
| 679 | if (includeIndexBuilds) |
| 680 | { |
| 681 | appendStringInfo(cmdStr, |
| 682 | ", %s.index_build_is_in_progress(index_id) AS index_build_in_progress", |
| 683 | ApiInternalSchemaName); |
| 684 | } |
| 685 | else |
| 686 | { |
| 687 | appendStringInfo(cmdStr, ", FALSE AS index_build_in_progress"); |
| 688 | } |
| 689 | |
| 690 | appendStringInfo(cmdStr, |
| 691 | " FROM %s.collection_indexes WHERE collection_id = " UINT64_FORMAT, |
| 692 | ApiCatalogSchemaName, collectionId); |
| 693 | |
| 694 | if (includeIndexBuilds) |
| 695 | { |
| 696 | appendStringInfo(cmdStr, |
| 697 | " AND (index_is_valid OR %s.index_build_is_in_progress(index_id))", |
| 698 | ApiInternalSchemaName); |
| 699 | } |
| 700 | else |
| 701 | { |
| 702 | appendStringInfo(cmdStr, " AND index_is_valid"); |
| 703 | } |
| 704 | |
| 705 | if (excludeIdIndex) |
| 706 | { |
| 707 | appendStringInfo(cmdStr, " AND (index_spec).index_name != %s", |
| 708 | quote_literal_cstr(ID_INDEX_NAME)); |
| 709 | } |
| 710 | |
| 711 | /* Closed the inner query */ |
| 712 | appendStringInfo(cmdStr, " ORDER BY index_id) a"); |
| 713 | |
| 714 | bool readOnly = true; |
| 715 | int numValues = 3; |
| 716 | bool isNull[3]; |
| 717 | Datum results[3]; |
| 718 | if (enableNestedDistribution) |
| 719 | { |
| 720 | int nArgs = 0; |
| 721 | Oid *argTypes = NULL; |
| 722 | Datum *argValues = NULL; |
| 723 | char *argNulls = NULL; |
| 724 | RunMultiValueQueryWithNestedDistribution(cmdStr->data, nArgs, argTypes, argValues, |
| 725 | argNulls, |
| 726 | readOnly, SPI_OK_SELECT, results, isNull, |
no test coverage detected