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

Function UpdatePostgresIndexesForHide

pg_documentdb/src/commands/coll_mod.c:1299–1334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1297
1298
1299static void
1300UpdatePostgresIndexesForHide(List *indexOids, bool hidden)
1301{
1302 ListCell *cell;
1303 foreach(cell, indexOids)
1304 {
1305 Oid currentIndexOid = lfirst_oid(cell);
1306 bool readOnly = false;
1307 int numArgs = 2;
1308 Datum args[2] = { BoolGetDatum(!hidden), ObjectIdGetDatum(currentIndexOid) };
1309 Oid argTypes[2] = { BOOLOID, OIDOID };
1310
1311
1312 /* all args are non-null */
1313 char *argNulls = NULL;
1314 bool resultIsNull;
1315
1316 /* Update pg_class to set the indisvalid which removes it from query but not writes */
1317 ExtensionExecuteQueryWithArgsViaSPI(
1318 "UPDATE pg_catalog.pg_index SET indisvalid = $1 WHERE indexrelid = $2 RETURNING indexrelid",
1319 numArgs,
1320 argTypes,
1321 args,
1322 argNulls,
1323 readOnly,
1324 SPI_OK_UPDATE_RETURNING,
1325 &resultIsNull);
1326
1327 if (resultIsNull)
1328 {
1329 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_INTERNALERROR),
1330 errmsg("failed to update hidden status for index oid %u",
1331 currentIndexOid)));
1332 }
1333 }
1334}
1335
1336
1337/* Given a list of indexOids it updates them and registers a bson exclusion constraint for the owning table in pg_constraint catalog.

Callers 1

UpdatePostgresIndexCoreFunction · 0.85

Calls 2

foreachFunction · 0.50

Tested by

no test coverage detected