Comments - CHECK constraint introduced, when make it really useful?

4 years ago Jan-Hendrik Diederich
This comment has the status of 'removed' and can only be seen by you.

Simple Example which makes sure there are no entries inserted or updated which have overlapping time spans. Most important: This solution should be thread safe: CREATE TABLE Test ( startTime bigint(20), stopTime bigint(20), CONSTRAINT overlapping CHECK ( (SELECT COUNT(*) FROM Test r WHERE r.startTime < stopTime AND r.endTime > startTime LIMIT 1) = 0 ) ); Even more elegant would it be to put the CHECK content into a function. But I consider that to be a luxury.

And: According to JIRA Bug CHECK is even not working for UPDATE, only for INSERT. Although the documentation tells otherwise.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.