Page **1** of **1**

### Incorrect comparison of nested relation

Posted: **Fri Feb 28, 2014 7:59 pm**

by **eregon**

I found some relation (with nested relations) to not be equal to itself!

Let's define a P# type:

Code: Select all

```
WITH (R := RELATION { SUPPLIES RELATION {PID P#}} {
TUPLE { SUPPLIES RELATION {
TUPLE {PID P#("P1")},
TUPLE {PID P#("P2")},
TUPLE {PID P#("P3")},
TUPLE {PID P#("P4")},
TUPLE {PID P#("P5")},
TUPLE {PID P#("P6")}
}},
TUPLE { SUPPLIES RELATION {
TUPLE {PID P#("P1")},
TUPLE {PID P#("P2")}
}},
TUPLE { SUPPLIES RELATION {
TUPLE {PID P#("P2")},
TUPLE {PID P#("P4")},
TUPLE {PID P#("P5")}
}}
}) : R = R
```

This always yields

*false* at me (OS X 10.8.5 Java 1.7.0_40-b43 Rel 1.0.10 Beta.

Changing some parts of it seems to make this bug disappear.

### Re: Incorrect comparison of nested relation

Posted: **Sun Mar 02, 2014 11:41 am**

by **Dave**

Thanks. This will be fixed in the next update.

### Re: Incorrect comparison of nested relation

Posted: **Tue Feb 24, 2015 1:59 pm**

by **layus**

The previous example seems fixed, but I found a case where a relation is not equal to a join with itself.

Code: Select all

```
TYPE S# POSSREP {SNUM CHAR};
TYPE P# POSSREP {PNUM CHAR};
```

Code: Select all

```
with (S := RELATION {SID S#, PID P#, QTY INTEGER} {
TUPLE {SID S#("S1"), PID P#("P1"), QTY 300},
TUPLE {SID S#("S1"), PID P#("P2"), QTY 200},
TUPLE {SID S#("S1"), PID P#("P3"), QTY 400},
TUPLE {SID S#("S1"), PID P#("P4"), QTY 200},
TUPLE {SID S#("S1"), PID P#("P5"), QTY 100},
TUPLE {SID S#("S1"), PID P#("P6"), QTY 100},
TUPLE {SID S#("S2"), PID P#("P1"), QTY 300},
TUPLE {SID S#("S2"), PID P#("P2"), QTY 400},
TUPLE {SID S#("S3"), PID P#("P2"), QTY 200},
TUPLE {SID S#("S4"), PID P#("P2"), QTY 200},
TUPLE {SID S#("S4"), PID P#("P4"), QTY 300},
TUPLE {SID S#("S4"), PID P#("P5"), QTY 400}
}) :
with (R := S {PID, SID} group {PID} AS PARTS):
R = R join R
```

### Re: Incorrect comparison of nested relation

Posted: **Tue Feb 24, 2015 2:01 pm**

by **Dave**

Thanks! I'll check it and should have it fixed in the next update.

### Re: Incorrect comparison of nested relation

Posted: **Tue Feb 24, 2015 5:27 pm**

by **Dave**

The problem appears to be related to using the result of GROUP as the input to JOIN. The following produces an incorrect result:

Code: Select all

```
RELATION {
TUPLE {SID 1, PID 1},
TUPLE {SID 4, PID 5}
} GROUP {PID} AS PARTS
JOIN
RELATION {
TUPLE {SID 1, PID 1},
TUPLE {SID 4, PID 5}
} GROUP {PID} AS PARTS
```

Indeed, the output of GROUP appears to break other operators. The following produces an incorrect result:

Code: Select all

```
RELATION {
TUPLE {SID 1, PID 1},
TUPLE {SID 4, PID 5}
} GROUP {PID} AS PARTS
UNION
RELATION {
TUPLE {SID 1,
PARTS RELATION {
TUPLE {PID 1}
}
},
TUPLE {SID 4,
PARTS RELATION {
TUPLE {PID 5}
}
}
}
```

### Re: Incorrect comparison of nested relation

Posted: **Mon Mar 09, 2015 10:14 am**

by **layus**

Nice ! you found a very small tester.

Were you able to find the source of the problem ?

When should I expect the next update ?

### Re: Incorrect comparison of nested relation

Posted: **Mon Mar 09, 2015 3:32 pm**

by **Dave**

layus wrote:Nice ! you found a very small tester.

Were you able to find the source of the problem ?

When should I expect the next update ?

I haven't had a chance to debug it yet, but the next update should be out in several weeks.