* DeleteDocumentByTID performs a TID delete on a single shard. * * The TID must be obtained via SelectUpdateCandidate in the current transaction. */
| 3768 | * The TID must be obtained via SelectUpdateCandidate in the current transaction. |
| 3769 | */ |
| 3770 | static bool |
| 3771 | DeleteDocumentByTID(uint64 collectionId, int64 shardKeyHash, ItemPointer tid) |
| 3772 | { |
| 3773 | StringInfoData deleteQuery; |
| 3774 | int argCount = 2; |
| 3775 | Oid argTypes[2]; |
| 3776 | Datum argValues[2]; |
| 3777 | |
| 3778 | SPI_connect(); |
| 3779 | |
| 3780 | initStringInfo(&deleteQuery); |
| 3781 | appendStringInfo(&deleteQuery, |
| 3782 | "DELETE FROM %s.documents_" UINT64_FORMAT |
| 3783 | " WHERE ctid = $2 AND shard_key_value = $1", |
| 3784 | ApiDataSchemaName, collectionId); |
| 3785 | |
| 3786 | argTypes[0] = INT8OID; |
| 3787 | argValues[0] = Int64GetDatum(shardKeyHash); |
| 3788 | |
| 3789 | argTypes[1] = TIDOID; |
| 3790 | argValues[1] = ItemPointerGetDatum(tid); |
| 3791 | |
| 3792 | char *argNulls = NULL; |
| 3793 | bool readOnly = false; |
| 3794 | long maxTupleCount = 0; |
| 3795 | |
| 3796 | SPIPlanPtr plan = GetSPIQueryPlan(collectionId, QUERY_ID_DELETE_BY_TID, |
| 3797 | deleteQuery.data, argTypes, argCount); |
| 3798 | |
| 3799 | SPI_execute_plan(plan, argValues, argNulls, readOnly, maxTupleCount); |
| 3800 | |
| 3801 | Assert(SPI_processed == 1); |
| 3802 | |
| 3803 | SPI_finish(); |
| 3804 | |
| 3805 | return true; |
| 3806 | } |
| 3807 | |
| 3808 | |
| 3809 | /* |
no test coverage detected