MCPcopy Create free account
hub / github.com/documentdb/documentdb / UpdatePostgresIndexCore

Function UpdatePostgresIndexCore

pg_documentdb/src/commands/coll_mod.c:1248–1296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1246
1247
1248void
1249UpdatePostgresIndexCore(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
1299static void

Callers 3

UpdatePostgresIndexFunction · 0.85

Calls 6

ApiDataNamespaceOidFunction · 0.85
GetShardIndexOidsFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected