in reply to Vagueness and patched strings
in thread Revision control in relational databases

If you do ever decide to try and implement a diff system (I have thought about this problem a lot myself), remember to think about how your system will handle two simultaneous updates to a piece of content. There could be a race condition in the system you've outlined where, as you are doing the SELECTing and diffing required to generate the new change entry, a new row is entered in changes, for example from an update begun just before yours, for the same id. Now your diff is totally wrong.

Also, I don't know about the latest versions of MySQL, but in my 3.x datestamp only is granular to the second level, and it is not inconceivable for a central piece of content on a busy site like a Wiki to get two changes entered within the same one-second window, so there would be no way to select which change to apply first because they both have the same timestamp. (Although this eventuality could be mitigated by designating PRIMARY KEY(id, timestamp) which should throw an error on simultaneous update)

Replies are listed 'Best First'.
Re^2: Vagueness and patched strings
by Your Mother (Archbishop) on Jul 22, 2004 at 09:10 UTC

    Good thoughts, and from others above. Thanks, as usual to all. I'm on MySQL 4.whatever but trying to keep things pretty generic just in case. The sad part is, the last place I worked did just what I want (within a Berkeley DB) and I wasn't interested in checking out the code at the time so I have no idea how it worked.

      Not sure if it will work, but you could try diff'ing the backups of your Mysql database. Since a Mysql database backup is simply the DML (read SQL commands) to recreate the database, this may work.

      Now this idea assumes that Mysql will create the DML in the same order every time, but it might be worth a shot.

      -Jim