Comment : Charset=windows-1252
Comment : test cases for managing tuple constraints

Comment : define the attributes used in the test
Request : assert attribute,attribute(tuple(attributename(int1)typename(int))tuple(attributename(int2)typename(int))tuple(attributename(int3)typename(int))tuple(attributename(int4)typename(int))tuple(attributename(ii1)typename(intinterval))tuple(attributename(ii2)typename(intinterval)))
Reply   : 

Comment : define the logical design of the relvars used in the test
Request : cmd(assert relvar,relvar(tuple(relvarname(dbmtc1)relvarpredicate(integers int1, int2, int3, int4.))tuple(relvarname(dbmtc2)relvarpredicate(integers  int1, int2 and intervals ii1, ii2.))))cmd(assert relvarattribute,relvarattribute(tuple(relvarname(dbmtc1)attributename(int1))tuple(relvarname(dbmtc1)attributename(int2))tuple(relvarname(dbmtc1)attributename(int3))tuple(relvarname(dbmtc1)attributename(int4))tuple(relvarname(dbmtc2)attributename(int1))tuple(relvarname(dbmtc2)attributename(int2))tuple(relvarname(dbmtc2)attributename(ii1))tuple(relvarname(dbmtc2)attributename(ii2))))
Reply   : 

Comment : define the storage resources used in the test
Request : cmd(assert dbmsfile,dbmsfile(tuple(filename(dbmtc.spdb)pagesize(8192))))cmd(assert storagespace,storagespace(tuple(filename(dbmtc.spdb)extentscount(2)pagecount(20)storagespaceid(1))tuple(filename(dbmtc.spdb)extentscount(2)pagecount(20)storagespaceid(2))))cmd(assert dataspace,dataspace(tuple(filename(dbmtc.spdb)storagespaceid(1)gapcompressionthreshold(5)maximumgaps(9))))cmd(assert multihashingindexspace,multihashingindexspace(tuple(filename(dbmtc.spdb)storagespaceid(2)gapcompressionthreshold(5)maximumgaps(9))))
Reply   : 

Comment : define the physical design of the relvars used in the test
Request : cmd(assert recordtype,recordtype(tuple(filename(dbmtc.spdb)storagespaceid(1)recordtypename(r_dbmtc1)indexname(l_r_dbmtc1)relvarname(dbmtc1))tuple(filename(dbmtc.spdb)storagespaceid(1)recordtypename(r_dbmtc2)indexname(l_r_dbmtc2)relvarname(dbmtc2))))cmd(assert index,index(tuple(filename(dbmtc.spdb)storagespaceid(2)recordtypename(r_dbmtc1)relvarname(dbmtc1)indexname(l_r_dbmtc1))tuple(filename(dbmtc.spdb)storagespaceid(2)recordtypename(r_dbmtc2)relvarname(dbmtc2)indexname(l_r_dbmtc2))))cmd(assert recordattribute,recordattribute(tuple(recordtypename(r_dbmtc1)relvarname(dbmtc1)attributename(int1)ordinal(10))tuple(recordtypename(r_dbmtc1)relvarname(dbmtc1)attributename(int2)ordinal(20))tuple(recordtypename(r_dbmtc1)relvarname(dbmtc1)attributename(int3)ordinal(30))tuple(recordtypename(r_dbmtc1)relvarname(dbmtc1)attributename(int4)ordinal(40))tuple(recordtypename(r_dbmtc2)relvarname(dbmtc2)attributename(int1)ordinal(10))tuple(recordtypename(r_dbmtc2)relvarname(dbmtc2)attributename(int2)ordinal(20))tuple(recordtypename(r_dbmtc2)relvarname(dbmtc2)attributename(ii1)ordinal(30))tuple(recordtypename(r_dbmtc2)relvarname(dbmtc2)attributename(ii2)ordinal(40))))cmd(assert indexcomponent,indexcomponent(tuple(relvarname(dbmtc1)indexname(l_r_dbmtc1)ordinal(10)sp_expression(int1))tuple(relvarname(dbmtc2)indexname(l_r_dbmtc2)ordinal(10)sp_expression(int2))))
Reply   : 

Request : delete dbmtc1,dbmtc1
Reply   : 
Request : delete dbmtc2,dbmtc2
Reply   : 

Request : commit
Reply   : 

Comment : tuple constraint to the effect that int1 must be > int2
Request : add tupleconstraint,tupleconstraint(tuple(errorcode(185001)relvarname(dbmtc1)sp_expression(gt\(int1,int2\))))
Reply   : 

Comment : should fail
Request : add dbmtc1,dbmtc1(tuple(int1(1)int2(1)int3(1)int4(1)))
Reply   : 201806116:185001:The violating tuple's meaning is 'Integers 1, 1, 1, 1.'.

Comment : should pass
Request : add dbmtc1,dbmtc1(tuple(int1(3)int2(1)int3(1)int4(1)))
Reply   : 

Request : commit
Reply   : 

Comment : delete the constraint back again
Request : delete tupleconstraint,tupleconstraint(tuple(errorcode(185001)relvarname(dbmtc1)sp_expression(gt\(int1,int2\))))
Reply   : 

Comment : add an opposite one, should fail on the existing tuple
Request : add tupleconstraint,tupleconstraint(tuple(errorcode(185001)relvarname(dbmtc1)sp_expression(gt\(int2,int1\))))
Reply   : 1497858657:107:A problem prevented a commit from completing successfully, exception type was be.SIRAPRISE.server.DeferredSystemActionException, exception message was Existing tuple TUPLE(INT2(1)INT1(3)INT4(1)INT3(1)) in relvar NAME(TCNSTR1A) violates 185001.

Request : commit
Reply   : 

Request : delete dbmtc1,dbmtc1
Reply   : 

Request : commit
Reply   : 

Comment : relvar now empty, adding the opposite constraint should now pass
Request : add tupleconstraint,tupleconstraint(tuple(errorcode(185001)relvarname(dbmtc1)sp_expression(gt\(int2,int1\))))
Reply   : 

Request : commit
Reply   : 

Comment : should fail
Request : add dbmtc1,dbmtc1(tuple(int1(1)int2(1)int3(1)int4(1)))
Reply   : 201806116:185001:The violating tuple's meaning is 'Integers 1, 1, 1, 1.'.

Comment : should pass
Request : add dbmtc1,dbmtc1(tuple(int1(1)int2(3)int3(1)int4(1)))
Reply   : 

Request : commit
Reply   : 

Comment : test cases with interval types (which are special due to the autopack), when these interval values originate from scalar operator invocations

Comment : tuple constraint to the effect that [int1-int2[ doesn't overlap with [int3-int4[ ; should pass with current value
Request : add tupleconstraint,tupleconstraint(tuple(errorcode(185002)relvarname(dbmtc1)sp_expression(not\(overlaps\(intinterval\(begin\(int3\)end\(int4\)\),intinterval\(begin\(int1\)end\(int2\)\)\)\))))
Reply   : 

Request : commit
Reply   : 

Comment : should fail
Request : add dbmtc1,dbmtc1(tuple(int1(1)int2(7)int3(-1)int4(2)))
Reply   : 201806116:185002:The violating tuple's meaning is 'Integers 1, 7, -1, 2.'.

Comment : should pass
Request : add dbmtc1,dbmtc1(tuple(int1(1)int2(7)int3(-1)int4(1)))
Reply   : 

Request : commit
Reply   : 

Comment : now with the relvar that has interval-typed attributes

Comment : tuple constraint to the effect that length(ii1) = length(ii2)
Request : add tupleconstraint,tupleconstraint(tuple(errorcode(185003)relvarname(dbmtc2)sp_expression(eq\(length\(ii1\),length\(ii2\)\))))
Reply   : 

Request : commit
Reply   : 

Comment : should fail
Request : add dbmtc2,dbmtc2(tuple(int1(1)int2(7)ii1(begin(2)end(4))ii2(begin(1)end(4))))
Reply   : 201806116:185003:The violating tuple's meaning is 'Integers  1, 7 and intervals BEGIN(2)END(4), BEGIN(1)END(4).'.

Comment : should pass
Request : add dbmtc2,dbmtc2(tuple(int1(1)int2(7)ii1(begin(2)end(4))ii2(begin(1)end(3))))
Reply   : 

Comment : should fail
Request : add dbmtc2,dbmtc2(tuple(int1(1)int2(7)ii1(begin(4)end(6))ii2(begin(1)end(3))))
Reply   : 201806116:185003:The violating tuple's meaning is 'Integers  1, 7 and intervals BEGIN(2)END(6), BEGIN(1)END(3).'.

Comment : should pass
Request : assert dbmtc2,dbmtc2(tuple(int1(1)int2(7)ii1(begin(4)end(6))ii2(begin(1)end(5)))tuple(int1(1)int2(7)ii1(begin(2)end(4))ii2(begin(3)end(5))))
Reply   : 

Request : commit
Reply   : 

Request : delete dbmtc1,dbmtc1
Reply   : 
Request : delete dbmtc2,dbmtc2
Reply   : 

Request : commit
Reply   : 

Request : delete tupleconstraint,semijoin(tupleconstraint,relation(heading(errorcode(long))body(tuple(errorcode(185001))tuple(errorcode(185002))tuple(errorcode(185003)))))
Reply   : 

Request : commit
Reply   : 

Comment : remove the physical design of the relvars used in the test
Request : cmd(unassert recordtype,recordtype(tuple(filename(dbmtc.spdb)storagespaceid(1)recordtypename(r_dbmtc1)indexname(l_r_dbmtc1)relvarname(dbmtc1))tuple(filename(dbmtc.spdb)storagespaceid(1)recordtypename(r_dbmtc2)indexname(l_r_dbmtc2)relvarname(dbmtc2))))cmd(unassert index,index(tuple(filename(dbmtc.spdb)storagespaceid(2)recordtypename(r_dbmtc1)relvarname(dbmtc1)indexname(l_r_dbmtc1))tuple(filename(dbmtc.spdb)storagespaceid(2)recordtypename(r_dbmtc2)relvarname(dbmtc2)indexname(l_r_dbmtc2))))cmd(unassert recordattribute,recordattribute(tuple(recordtypename(r_dbmtc1)relvarname(dbmtc1)attributename(int1)ordinal(10))tuple(recordtypename(r_dbmtc1)relvarname(dbmtc1)attributename(int2)ordinal(20))tuple(recordtypename(r_dbmtc1)relvarname(dbmtc1)attributename(int3)ordinal(30))tuple(recordtypename(r_dbmtc1)relvarname(dbmtc1)attributename(int4)ordinal(40))tuple(recordtypename(r_dbmtc2)relvarname(dbmtc2)attributename(int1)ordinal(10))tuple(recordtypename(r_dbmtc2)relvarname(dbmtc2)attributename(int2)ordinal(20))tuple(recordtypename(r_dbmtc2)relvarname(dbmtc2)attributename(ii1)ordinal(30))tuple(recordtypename(r_dbmtc2)relvarname(dbmtc2)attributename(ii2)ordinal(40))))cmd(unassert indexcomponent,indexcomponent(tuple(relvarname(dbmtc1)indexname(l_r_dbmtc1)ordinal(10)sp_expression(int1))tuple(relvarname(dbmtc2)indexname(l_r_dbmtc2)ordinal(10)sp_expression(int2))))
Reply   : 

Comment : remove the storage resources used in the test
Request : cmd(unassert dbmsfile,dbmsfile(tuple(filename(dbmtc.spdb)pagesize(8192))))cmd(unassert storagespace,storagespace(tuple(filename(dbmtc.spdb)extentscount(2)pagecount(20)storagespaceid(1))tuple(filename(dbmtc.spdb)extentscount(2)pagecount(20)storagespaceid(2))))cmd(unassert dataspace,dataspace(tuple(filename(dbmtc.spdb)storagespaceid(1)gapcompressionthreshold(5)maximumgaps(9))))cmd(unassert multihashingindexspace,multihashingindexspace(tuple(filename(dbmtc.spdb)storagespaceid(2)gapcompressionthreshold(5)maximumgaps(9))))
Reply   : 

Comment : remove the logical design of the relvars used in the test
Request : cmd(unassert relvar,relvar(tuple(relvarname(dbmtc1)relvarpredicate(integers int1, int2, int3, int4.))tuple(relvarname(dbmtc2)relvarpredicate(integers  int1, int2 and intervals ii1, ii2.))))cmd(unassert relvarattribute,relvarattribute(tuple(relvarname(dbmtc1)attributename(int1))tuple(relvarname(dbmtc1)attributename(int2))tuple(relvarname(dbmtc1)attributename(int3))tuple(relvarname(dbmtc1)attributename(int4))tuple(relvarname(dbmtc2)attributename(int1))tuple(relvarname(dbmtc2)attributename(int2))tuple(relvarname(dbmtc2)attributename(ii1))tuple(relvarname(dbmtc2)attributename(ii2))))
Reply   : 

Comment : remove the attributes used in the test
Request : unassert attribute,semiminus(attribute(tuple(attributename(int1)typename(int))tuple(attributename(int2)typename(int))tuple(attributename(int3)typename(int))tuple(attributename(int4)typename(int))tuple(attributename(ii1)typename(intinterval))tuple(attributename(ii2)typename(intinterval))),relvarattribute)
Reply   : 
END
