Open agentm opened 3 years ago
C.J. Date in "Database In Depth" around page 126 discusses his multiple assignment operator (the comma) and how is differs from deferred execution, allowing various whole statement optimizations to still apply while not requiring constraints deferred all the way to commit time. It's worth considering.
I assume the is no easy way to determine what constraints reference
a
, so that it can be somewhat automated or something.
A constraint is a RelationalExpr
data type. Maybe things like uniplate could find out what relvar it depends on.
Indeed, the current constraint optimizer uses such information to determine which constraint checks can be skipped (if the update expression mentions relvar x and the constraint does not, then the constraint can be skipped), so that part of the implementation is covered.
Is this issue about implementing deferred constraints or multiple assignment operator?
Ultimately, deferred constraints and the comma operator serve the same purpose. The advantage of the comma operator is that it doesn't actually defer constraint-checking. Date explains:
s:= ..., p:=...;
* First, all of the expressions on the right side are evaluated.
* Second, all of the constituent assignments are then executed in sequence as written [thus triggering the constraint checker].
...since multiple assignment is considered to be a single operation, no integrity checking is performed "in the middle of" any such assignment.
Unlike deferred constraints (often checked at commit-time), the comma operator allows the user to have more fine-grained control over specifically where constraint-checking happens. The comma operator could be implemented in Project:M36 without any special state (such as holding onto which constraints should be validated at commit-time).
Thanks! I did read page 126 but wasn't sure which direction Project:M36 would take. This would also allow for true 1:1 relationships between tables instead of 1:[0,1] at best without deferred constraints.
Indeed, the solution also appeals to me because it's a feature which doesn't exist in any other database and seems to be a slick solution to a common problem. SQL just doesn't have relational assignment or equality as concepts, but these are fundamental to the algebra.
Discussed in https://github.com/agentm/project-m36/discussions/307