burrow icon indicating copy to clipboard operation
burrow copied to clipboard

[Vent] Support deletion of multiple rows

Open silasdavis opened this issue 5 years ago • 1 comments

Currently we only support deletion (logic here: https://github.com/hyperledger/burrow/blob/master/vent/service/rowbuilder.go#L46) of single rows by only accepting primary keys (and all parts of composite). This makes sense as as a safer behaviour.

However sometimes it is useful to delete multiple rows with a partial match on primary key (or indeed any key) as in the case of cleaning up orphaned rows in a link table.

We could provide a DeleteMode flag on the projection and/or we could decide to give meaning the the value of the delete marker field which can currently be anything (usually 0). Instead we could say DeletePrimary == 0 DeletePartialPrimary == 1 DeleteMultiple == 2 or something like that.

The latter is simpler to implement but we probably want the flag for safety. The fields in a delete projection are intended to match the primary keys (other keys are ignored). Currently it is an error if we do not have all primary keys set. Perhaps DeleteMode == "Primary" should be default like current behaviour and can be omitted, and DeleteMode == "Matching" will delete any rows that match.

silasdavis avatar Aug 26 '20 15:08 silasdavis

Come to think of it, it's not clear to me why we don't control deletion entirely from the projection spec, there's not really any need for the marker field.

I think this was introduced before we had access to the EventName in a projection filter. The event name is enough to convey deletion semantics in every usage I can think of (usually LogFooBlahDeletion).

silasdavis avatar Aug 26 '20 16:08 silasdavis