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

Function IndexIdGetIndexDetailsCore

pg_documentdb/src/metadata/index.c:296–339  ·  view source on GitHub ↗

* IndexIdGetIndexDetails searches for the given indexId and * returns an IndexDetails object if found or NULL if there is * no such index. */

Source from the content-addressed store, hash-verified

294 * no such index.
295 */
296static IndexDetails *
297IndexIdGetIndexDetailsCore(int indexId, bool includeCurrentTransactions)
298{
299 const char *cmdStr =
300 FormatSqlQuery(
301 "SELECT collection_id, index_spec, %s.index_build_is_in_progress(index_id)"
302 " FROM %s.collection_indexes WHERE index_id = $1",
303 ApiInternalSchemaName, ApiCatalogSchemaName);
304
305 int argCount = 1;
306 Oid argTypes[1];
307 Datum argValues[1];
308
309 argTypes[0] = INT4OID;
310 argValues[0] = Int32GetDatum(indexId);
311
312 /* all args are non-null */
313 char *argNulls = NULL;
314
315 /* readOnly only gives durably committed writes - for including current transactions
316 * readonly needs to be false.
317 */
318 bool readOnly = !includeCurrentTransactions;
319
320 int numValues = 3;
321 bool isNull[3];
322 Datum results[3];
323 ExtensionExecuteMultiValueQueryWithArgsViaSPI(cmdStr, argCount, argTypes,
324 argValues, argNulls, readOnly,
325 SPI_OK_SELECT, results, isNull,
326 numValues);
327 if (isNull[0] || isNull[1])
328 {
329 return NULL;
330 }
331
332 IndexDetails *indexDetails = palloc0(sizeof(IndexDetails));
333 indexDetails->indexId = indexId;
334 indexDetails->collectionId = DatumGetInt64(results[0]);
335 indexDetails->indexSpec = *DatumGetIndexSpec(results[1]);
336 indexDetails->isIndexBuildInProgress = DatumGetBool(results[2]);
337
338 return indexDetails;
339}
340
341
342IndexDetails *

Calls 3

FormatSqlQueryFunction · 0.85
DatumGetIndexSpecFunction · 0.85

Tested by

no test coverage detected