2 ms·
> You do that and you're just trading one race condition for another. SELECT pk, sqlite, version FROM foo; -- later UPDATE foo SET sqlite='myblob',
by lloeki 14y ago
> You do that and you're just trading one race condition for another.
SELECT pk, sqlite, version FROM foo;
-- later
UPDATE foo SET sqlite='myblob', version=43 WHERE pk = whatever and version = 42;
-- if zero row update, there's a conflict
Those are not the race conditions you are looking for.
Terrible design though.
Purely a thought experiment but I'm wondering if a Postgres SQLite data type (similar to the JSON data type) could be workable.
- fusiongyro 14y agoIt's true. Hibernate even has special support for this ("row versioning") which I should have remembered. This isn't a race condition, but it is foisting more work on the developer that the database is already prepared to do (albeit in a different manner). The advantage to having a SQLite datatype would be that you could do the kinds of things you can do with the XML data type (extracting information in the outer layer for querying, indexing or simply ensuring validity) but you're still going to thrash the disk with every little change. And once you've committed to Postgres, you may as well use its own solution to this problem, schemas.