Incorrect comparison of nested relation

This forum is to report technical problems with Rel.
Post Reply
eregon
Posts: 1
Joined: Fri Feb 28, 2014 7:51 pm

Incorrect comparison of nested relation

Post by eregon »

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

Let's define a P# type:

Code: Select all

TYPE P#     POSSREP {PNUM CHAR};

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.
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: Incorrect comparison of nested relation

Post by Dave »

Thanks. This will be fixed in the next update.
layus
Posts: 2
Joined: Tue Feb 24, 2015 1:52 pm

Re: Incorrect comparison of nested relation

Post 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
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: Incorrect comparison of nested relation

Post by Dave »

Thanks! I'll check it and should have it fixed in the next update.
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: Incorrect comparison of nested relation

Post 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}
              }
      }
}
layus
Posts: 2
Joined: Tue Feb 24, 2015 1:52 pm

Re: Incorrect comparison of nested relation

Post 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 ?
Dave
Site Admin
Posts: 372
Joined: Sun Nov 27, 2005 7:19 pm

Re: Incorrect comparison of nested relation

Post 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.
Post Reply