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

Function CallDeleteWorker

pg_documentdb/src/commands/delete.c:1020–1083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1018
1019
1020static pgbson *
1021CallDeleteWorker(MongoCollection *collection,
1022 pgbson *serializedDeleteSpec,
1023 int64 shardKeyHash,
1024 text *transactionId,
1025 pgbsonsequence *sequence)
1026{
1027 int argCount = 6;
1028 Datum argValues[6];
1029
1030 /* whitespace means not null, n means null */
1031 char argNulls[6] = { ' ', ' ', ' ', ' ', 'n', 'n' };
1032 Oid argTypes[6] = { INT8OID, INT8OID, REGCLASSOID, BYTEAOID, BYTEAOID, TEXTOID };
1033
1034 const char *updateQuery = FormatSqlQuery(
1035 "SELECT %s.delete_worker($1, $2, $3, $4::%s.bson, $5::%s.bsonsequence, $6) FROM %s.documents_"
1036 UINT64_FORMAT " WHERE shard_key_value = %ld",
1037 DocumentDBApiInternalSchemaName, CoreSchemaNameV2, CoreSchemaNameV2,
1038 ApiDataSchemaName, collection->collectionId,
1039 shardKeyHash);
1040
1041 argValues[0] = UInt64GetDatum(collection->collectionId);
1042
1043 /* p_shard_key_value */
1044 argValues[1] = Int64GetDatum(shardKeyHash);
1045
1046 /* p_shard_oid */
1047 argValues[2] = ObjectIdGetDatum(InvalidOid);
1048
1049 argValues[3] = PointerGetDatum(serializedDeleteSpec);
1050
1051 if (sequence != NULL)
1052 {
1053 argValues[4] = PointerGetDatum(sequence);
1054 argNulls[4] = ' ';
1055 }
1056
1057 if (transactionId != NULL)
1058 {
1059 argValues[5] = PointerGetDatum(transactionId);
1060 argNulls[5] = ' ';
1061 }
1062
1063 bool readOnly = false;
1064
1065 Datum resultDatum[1] = { 0 };
1066 bool isNulls[1] = { false };
1067 int numResults = 1;
1068
1069 /* forceDelegation assumes nested distribution */
1070 RunMultiValueQueryWithNestedDistribution(updateQuery, argCount, argTypes, argValues,
1071 argNulls,
1072 readOnly, SPI_OK_SELECT, resultDatum,
1073 isNulls, numResults);
1074
1075 if (isNulls[0])
1076 {
1077 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_INTERNALERROR),

Callers 2

CallDeleteOneFunction · 0.85

Calls 2

FormatSqlQueryFunction · 0.85

Tested by

no test coverage detected