V: 3.007, OS: Windows 10
When I declare multiple keys it appears that only the first of the keys is enforced.
VAR foo REAL RELATION {a INTEGER, b INTEGER} KEY {a} KEY {b};
INSERT foo RELATION {TUPLE {a 1, b 1}};
INSERT foo RELATION {TUPLE {a 2, b 1}};
result:
a b
1 1
2 1
Key violation
Re: Key violation
Use D_INSERT:
D_INSERT foo RELATION {TUPLE {a 1, b 1}};
D_INSERT foo RELATION {TUPLE {a 2, b 1}};
ERROR: RS0232: Inserting tuple would violate uniqueness constraint of KEY {b}
stephen
D_INSERT foo RELATION {TUPLE {a 1, b 1}};
D_INSERT foo RELATION {TUPLE {a 2, b 1}};
ERROR: RS0232: Inserting tuple would violate uniqueness constraint of KEY {b}
stephen
Re: Key violation
Thanks, D_INSERT does work as an alternative workaround. I'm more interested in reporting the bug than in finding workarounds. I wonder what other operations might also be affected if constraints aren't being enforced correctly.
Re: Key violation
I've added this to my to-do list.
Note that KEY constraints are handled differently from other explicit constraints -- i.e., those declared with CONSTRAINT -- so a bug in KEY constraints does not imply a bug in CONSTRAINTs in general. Of course, there might be bugs in CONSTRAINTs in general; I can only state with certainty that they're not related to KEY constraints!
Notably (and perhaps annoyingly), INSERT correctly reports that it is not inserting a tuple, but does so anyway. E.g.:
var myvar5 real relation {x int, y int} key {x} key {y};
Ok.
insert myvar5 rel {tup {x 1, y 1}};
NOTICE: Inserted 1 tuple.
Ok.
insert myvar5 rel {tup {x 2, y 1}};
NOTICE: Inserted 0 tuples.
Ok.
myvar5
RELATION {x INTEGER, y INTEGER} {
TUPLE {x 1, y 1},
TUPLE {x 2, y 1}
}
Re: Key violation
I've corrected this for the forthcoming v3.008 update.
Re: Key violation
The version 3.008 update that fixes this bug is now available for download from http://reldb.org
Re: Key violation
That was fast work! It has fixed the problem for me. Thanks.