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

Function command_reindex

pg_documentdb/src/commands/create_indexes.c:701–738  ·  view source on GitHub ↗

* command_reindex is the implementation of the internal logic for * ApiSchema.re_index(). */

Source from the content-addressed store, hash-verified

699 * ApiSchema.re_index().
700 */
701void
702command_reindex(const CallStmt *callStmt,
703 ProcessUtilityContext context,
704 const ParamListInfo params,
705 DestReceiver *destReceiver)
706{
707 ThrowIfWriteCommandNotAllowed();
708
709 /* must name it as "fcinfo" to be able to use PG_ARG/PG_GETARG functions */
710 LOCAL_FCINFO(fcinfo, FUNC_MAX_ARGS);
711 InitFCInfoForCallStmt(fcinfo, callStmt, context, params);
712
713 if (PG_ARGISNULL(0))
714 {
715 ereport(ERROR, (errmsg("Database name must not be NULL value")));
716 }
717 Datum dbNameDatum = PG_GETARG_DATUM(0);
718
719 if (PG_ARGISNULL(1))
720 {
721 ereport(ERROR, (errmsg("collection name cannot be NULL")));
722 }
723 Datum collectionNameDatum = PG_GETARG_DATUM(1);
724
725 bool isTopLevel = (context == PROCESS_UTILITY_TOPLEVEL);
726
727 /*
728 * Reindex is oly supported outside a transaction block
729 */
730 if (IsInTransactionBlock(isTopLevel))
731 {
732 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_OPERATIONNOTSUPPORTEDINTRANSACTION),
733 errmsg("Cannot run 'reIndex' in a multi-document transaction.")));
734 }
735 ReIndexResult result = reindex_concurrently(dbNameDatum, collectionNameDatum);
736
737 SendReIndexResultToClientAsBson(fcinfo, &result, destReceiver);
738}
739
740
741/*

Callers

nothing calls this directly

Calls 4

InitFCInfoForCallStmtFunction · 0.85
reindex_concurrentlyFunction · 0.85

Tested by

no test coverage detected