| 1246 | |
| 1247 | |
| 1248 | void |
| 1249 | UpdatePostgresIndexCore(uint64_t collectionId, int indexId, IndexMetadataUpdateOperation |
| 1250 | operation, bool value, bool ignoreMissingShards) |
| 1251 | { |
| 1252 | /* First get the OID of the index */ |
| 1253 | char postgresIndexName[NAMEDATALEN] = { 0 }; |
| 1254 | pg_sprintf(postgresIndexName, DOCUMENT_DATA_TABLE_INDEX_NAME_FORMAT, indexId); |
| 1255 | Oid indexOid = get_relname_relid(postgresIndexName, ApiDataNamespaceOid()); |
| 1256 | |
| 1257 | List *indexOidList = NIL; |
| 1258 | indexOidList = lappend_oid(indexOidList, indexOid); |
| 1259 | |
| 1260 | /* Add any additional shard OIDs needed for this */ |
| 1261 | indexOidList = list_concat(indexOidList, |
| 1262 | GetShardIndexOids(collectionId, indexOid, |
| 1263 | ignoreMissingShards)); |
| 1264 | |
| 1265 | switch (operation) |
| 1266 | { |
| 1267 | case INDEX_METADATA_UPDATE_OPERATION_HIDDEN: |
| 1268 | { |
| 1269 | UpdatePostgresIndexesForHide(indexOidList, value); |
| 1270 | break; |
| 1271 | } |
| 1272 | |
| 1273 | case INDEX_METADATA_UPDATE_OPERATION_PREPARE_UNIQUE: |
| 1274 | { |
| 1275 | UpdatePostgresIndexesForPrepareUnique(indexOidList, value); |
| 1276 | break; |
| 1277 | } |
| 1278 | |
| 1279 | case INDEX_METADATA_UPDATE_OPERATION_UNIQUE: |
| 1280 | { |
| 1281 | UpdatePostgresIndexesForUnique(indexOidList, value); |
| 1282 | break; |
| 1283 | } |
| 1284 | |
| 1285 | default: |
| 1286 | ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_INTERNALERROR), |
| 1287 | errmsg("unknown index metadata update operation: %d", |
| 1288 | operation))); |
| 1289 | } |
| 1290 | |
| 1291 | ListCell *cell; |
| 1292 | foreach(cell, indexOidList) |
| 1293 | { |
| 1294 | CacheInvalidateRelcacheByRelid(lfirst_oid(cell)); |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | |
| 1299 | static void |
no test coverage detected