On 12 Jun 2017, at 2:48pm, Robert M. Münch <[email protected]> wrote:

> Hi, we want to use the Session extension to implement an UNDO system for our 
> application. We did some first steps using it and now a couple of questions 
> came up:
> 
> 1. Is it correct that schema changes are not tracked and can't be part of a 
> changeset? So any ALTER TABLE command needs to be taken care about separately?

Correct.  Changing the schema means that changesets are no longer valid.  You 
will either need to make a system which can handle both, or regard schema 
changes as points you cannot UNDO past.

> 2. Changes to the VIEW query are not tracked too? So, when a view query 
> changes, this is not part of the changeset.

VIEWs, like INDEXes, are part of the schema.  Changing a VIEW is changing the 
schema.

> 3. We are thinking about supporting UNDO not only for the current session but 
> for the live-time of a document. In this case we need to store the changeset 
> blob into the database as well.

But storing something in the database is changing the database !  You would get 
problems with recursion.  Instead, you would have to store the blobs in another 
database.

> 4. We haven't thought through all combinations but is the oder of UNDOs in a 
> changeset relevant? So if I have a changeset do I have to apply it strictly 
> in revers order in some cases to avoid constraint violations etc?

Absolutely.  Consider this sequence:

INSERT a row
DELETE that row

Now try to UNDO that sequence in the wrong order.  You end up with a row which 
wasn’t there.

I cannot comment on using sessions to do this but I can suggest an alternative 
which is compatible with more systems.  This is that for every SQL command you 
execute you provide one or more commands which would reverse the effect.  This 
can be slower in use, but it’s far more easy to debug when things go wrong, and 
it provides an excellent log in case you ever need to do forensic investigation 
on your database.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to