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

Function DeleteRetryRecord

pg_documentdb/src/commands/retryable_writes.c:174–305  ·  view source on GitHub ↗

* DeleteRetryRecordGetObjectId deletes a retry record and returns the object ID * that was stored in the record. */

Source from the content-addressed store, hash-verified

172 * that was stored in the record.
173 */
174bool
175DeleteRetryRecord(uint64 collectionId, int64 shardKeyValue,
176 text *transactionId, RetryableWriteResult *writeResult)
177{
178 StringInfoData query;
179 int spiStatus PG_USED_FOR_ASSERTS_ONLY = 0;
180 bool foundRetryRecord = false;
181
182 MemoryContext outerContext = CurrentMemoryContext;
183
184 SPI_connect();
185
186 if (UseLocalRetryTable())
187 {
188 const int argCount = 3;
189 Oid argTypes[3];
190 Datum argValues[3];
191
192 initStringInfo(&query);
193 appendStringInfo(&query,
194 "DELETE FROM %s.retryable_writes"
195 " WHERE collection_id = $1 AND shard_key_value = $2"
196 " AND transaction_id = $3"
197 " RETURNING object_id, rows_affected, result_document",
198 ApiDataSchemaName);
199
200 argTypes[0] = INT8OID;
201 argValues[0] = Int64GetDatum((int64) collectionId);
202
203 argTypes[1] = INT8OID;
204 argValues[1] = Int64GetDatum(shardKeyValue);
205
206 argTypes[2] = TEXTOID;
207 argValues[2] = PointerGetDatum(transactionId);
208
209 char *argNulls = NULL;
210 bool readOnly = false;
211 long maxTupleCount = 0;
212
213 SPIPlanPtr plan = GetSPIQueryPlan(collectionId,
214 QUERY_ID_GLOBAL_RETRY_RECORD_DELETE,
215 query.data, argTypes, argCount);
216
217 spiStatus = SPI_execute_plan(plan, argValues, argNulls, readOnly,
218 maxTupleCount);
219 Assert(spiStatus == SPI_OK_DELETE_RETURNING);
220 }
221 else
222 {
223 const int argCount = 2;
224 Oid argTypes[2];
225 Datum argValues[2];
226
227 initStringInfo(&query);
228 appendStringInfo(&query,
229 "DELETE FROM %s.retry_" UINT64_FORMAT
230 " WHERE shard_key_value = $1 AND transaction_id = $2"
231 " RETURNING object_id, rows_affected, result_document",

Callers 3

DeleteOneInternalCoreFunction · 0.85

Calls 3

UseLocalRetryTableFunction · 0.85
GetSPIQueryPlanFunction · 0.85

Tested by

no test coverage detected