Complex rel exp causes exception

This forum is to report technical problems with Rel.
Post Reply
HughDarwen
Posts: 121
Joined: Sat May 24, 2008 4:49 pm

Complex rel exp causes exception

Post by HughDarwen »

The following expression (a solution to one of the exercises set to my 2nd-year undergrads at Warwick) gave rise to an error:

WITH
( S RENAME ( S# AS SX ) ) AS RX ,
( S RENAME ( S# AS SY ) ) AS RY :

( ( RX JOIN RY ) WHERE
( ( SP WHERE S# = SX ) { P# } )
= ( ( SP WHERE S# = SY ) { P# } )
) { SX, SY } WHERE SX < SY

The error was:

RELATION {SX CHARACTER, SY CHARACTER} {ERROR: java.lang.ArrayIndexOutOfBoundsException: 4
java.lang.ArrayIndexOutOfBoundsException: 4
at ca.mb.armchair.rel3.vm.Context.tupleGetAttribute(Context.java:287)
at ca.mb.armchair.rel3.vm.instructions.tuple.OpTupleGetAttribute.execute(OpTupleGetAttribute.java:19)
at ca.mb.armchair.rel3.vm.Context.execute(Context.java:138)
at ca.mb.armchair.rel3.vm.Context.call(Context.java:144)
at ca.mb.armchair.rel3.values.RelTupleFilter.filter(RelTupleFilter.java:19)
at ca.mb.armchair.rel3.values.ValueRelation$12$1.hasNext(ValueRelation.java:509)
at ca.mb.armchair.rel3.values.ValueRelation$3$1.hasNext(ValueRelation.java:96)
at ca.mb.armchair.rel3.values.TupleIteratorUnique.hasNext(TupleIteratorUnique.java:25)
at ca.mb.armchair.rel3.values.TupleIteration.hasNext(TupleIteration.java:10)
at ca.mb.armchair.rel3.values.TupleIteration.run(TupleIteration.java:17)
at ca.mb.armchair.rel3.values.ValueRelation.buildCache(ValueRelation.java:585)
at ca.mb.armchair.rel3.values.ValueRelation.getCardinality(ValueRelation.java:644)
at ca.mb.armchair.rel3.values.ValueRelation.eq(ValueRelation.java:675)
at ca.mb.armchair.rel3.vm.Context.eq(Context.java:456)
at ca.mb.armchair.rel3.vm.instructions.core.OpEq.execute(OpEq.java:9)
at ca.mb.armchair.rel3.vm.Context.execute(Context.java:138)
at ca.mb.armchair.rel3.vm.Context.call(Context.java:144)
at ca.mb.armchair.rel3.values.RelTupleFilter.filter(RelTupleFilter.java:19)
at ca.mb.armchair.rel3.values.ValueRelation$12$1.hasNext(ValueRelation.java:509)
at ca.mb.armchair.rel3.values.ValueRelation$3$1.hasNext(ValueRelation.java:96)
at ca.mb.armchair.rel3.values.TupleIteratorUnique.hasNext(TupleIteratorUnique.java:25)
at ca.mb.armchair.rel3.values.ValueRelation$12$1.hasNext(ValueRelation.java:506)
at ca.mb.armchair.rel3.values.ValueRelation.toStream(ValueRelation.java:629)
at ca.mb.armchair.rel3.interpreter.Evaluation.toStream(Evaluation.java:18)
at ca.mb.armchair.rel3.client.stream.ClientLocalConnection.sendEvaluate(ClientLocalConnection.java:36)
at ca.mb.armchair.rel3.client.string.ClientLocal.sendEvaluate(ClientLocal.java:52)
at ca.mb.armchair.rel3.dbrowser.ui.PanelCommandline$34.doInBackground(PanelCommandline.java:1070)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

The values of S and SP are as in Date's Suppliers and Parts:

S := RELATION {S# CHARACTER, Sname CHARACTER, Status INTEGER, City CHARACTER} {
TUPLE {S# "S1", Sname "Smith", Status 20, City "London"},
TUPLE {S# "S2", Sname "Jones", Status 10, City "Paris"},
TUPLE {S# "S3", Sname "Blake", Status 30, City "Paris"},
TUPLE {S# "S4", Sname "Clark", Status 20, City "London"},
TUPLE {S# "S5", Sname "Adams", Status 30, City "Athens"}
};

SP := RELATION {S# CHARACTER, P# CHARACTER, Qty INTEGER} {
TUPLE {S# "S1", P# "P1", Qty 300},
TUPLE {S# "S1", P# "P2", Qty 200},
TUPLE {S# "S1", P# "P3", Qty 400},
TUPLE {S# "S1", P# "P4", Qty 200},
TUPLE {S# "S1", P# "P5", Qty 100},
TUPLE {S# "S1", P# "P6", Qty 100},
TUPLE {S# "S2", P# "P1", Qty 300},
TUPLE {S# "S2", P# "P2", Qty 400},
TUPLE {S# "S3", P# "P2", Qty 200},
TUPLE {S# "S4", P# "P2", Qty 200},
TUPLE {S# "S4", P# "P4", Qty 300},
TUPLE {S# "S4", P# "P5", Qty 400}
};

Sorry!
Hugh
Dave
Site Admin
Posts: 368
Joined: Sun Nov 27, 2005 7:19 pm

Re: Complex rel exp causes exception

Post by Dave »

In digging into this one, I've noticed the following also causes a similar exception:

Code: Select all

S WHERE ( ( SP WHERE S# = CITY ) = SP )
I should have this fixed in the next release.
Post Reply