Comment : Charset=windows-1252
Comment : test cases for management of attributes

Comment : define a user-implemented type, a variable-length constrained type and a fixed-length constrained type
Request : assert constrainedtype,constrainedtype(tuple(typename(splong)sp_expression( gt\(parameter\(v\(long\)\),long\(0\) \) )basetype(long)))
Reply   : 
Request : assert constrainedtype,constrainedtype(tuple(typename(shtring)sp_expression( gt\(int\(4800\),length\(parameter\(v\(string\)\)\) \) )basetype(string)))
Reply   : 

Comment : define attrs of these types - should fail on missing logical length declaration for one of them
Request : assert attribute,attribute(tuple(attributename(dbmatt_angle)typename(angle))tuple(attributename(dbmatt_splong)typename(splong))tuple(attributename(dbmatt_shtring)typename(shtring)))
Reply   : 201806116:72:Attribute DBMATT_SHTRING is of a variable-length type STRING, but a logical declaration is missing.

Comment : define attrs of these types - should fail on superfluous logical length declaration for one of them
Request : cmd(assert attribute,attribute(tuple(attributename(dbmatt_angle)typename(angle))tuple(attributename(dbmatt_splong)typename(splong))tuple(attributename(dbmatt_shtring)typename(shtring))))cmd(assert attributelogicallength,attributelogicallength(tuple(attributename(dbmatt_angle)logicallength(1))tuple(attributename(dbmatt_splong)logicallength(18))tuple(attributename(dbmatt_shtring)logicallength(5000))))
Reply   : 201806116:74:A logical-length is declared for attribute DBMATT_SPLONG, but that attribute is either not defined or else it is defined to be of a fixed-length type.

Comment : define attrs of these types - finally get it right
Request : cmd(assert attribute,attribute(tuple(attributename(dbmatt_angle)typename(angle))tuple(attributename(dbmatt_splong)typename(splong))tuple(attributename(dbmatt_shtring)typename(shtring))))cmd(assert attributelogicallength,attributelogicallength(tuple(attributename(dbmatt_shtring)logicallength(5000))))
Reply   : 

Comment : physical lengths should have appeared
Request : inquire join(attributephysicallength,relation(heading(attributename(name))body(tuple(attributename(dbmatt_shtring))tuple(attributename(dbmatt_splong))tuple(attributename(dbmatt_angle)))))
Reply   : RELATION(HEADING(PHYSICALLENGTH(INT)ATTRIBUTENAME(NAME))BODY(TUPLE(PHYSICALLENGTH(8)ATTRIBUTENAME(DBMATT_ANGLE))TUPLE(PHYSICALLENGTH(10004)ATTRIBUTENAME(DBMATT_SHTRING))TUPLE(PHYSICALLENGTH(8)ATTRIBUTENAME(DBMATT_SPLONG))))

Comment : try to force physical lengths onto SIRA_PRISE, should fail
Request : update attributephysicallength,restrict(attributephysicallength,eq(attributename,name(dbmatt_shtring))),(physicallength(5000))
Reply   : 201806116:108:The ATTRIBUTEPHYSICALLENGTH relvar is not user-updatable.

Comment : try to corrupt physical lengths, should fail
Request : delete attributephysicallength,restrict(attributephysicallength,eq(attributename,name(dbmatt_shtring)))
Reply   : 201806116:86:The server failed to derive the physical encoding size of attribute DBMATT_SHTRING of type SHTRING.  A type must be added before any attribute of that type is defined, preferably even in a separate prior assignment.  For attributes of variable-length types, a logical length is required to be specified.

Comment : delete FL attribute without logical deleting logical length - should pass
Request : unassert attribute,attribute(tuple(attributename(dbmatt_angle)typename(angle)))
Reply   : 

Comment : delete VL attribute without logical deleting logical length - should fail
Request : unassert attribute,attribute(tuple(attributename(dbmatt_shtring)typename(shtring)))
Reply   : 201806116:74:A logical-length is declared for attribute DBMATT_SHTRING, but that attribute is either not defined or else it is defined to be of a fixed-length type.

Comment : delete VL attribute including logical logical length - should succeed
Request : cmd(unassert attribute,attribute(tuple(attributename(dbmatt_shtring)typename(shtring))))cmd(unassert attributelogicallength,attributelogicallength(tuple(attributename(dbmatt_shtring)logicallength(5000))))
Reply   : 

Comment : physical lengths should have disappeared
Request : inquire join(attributephysicallength,relation(heading(attributename(name))body(tuple(attributename(dbmatt_shtring))tuple(attributename(dbmatt_splong))tuple(attributename(dbmatt_angle)))))
Reply   : RELATION(HEADING(PHYSICALLENGTH(INT)ATTRIBUTENAME(NAME))BODY(TUPLE(PHYSICALLENGTH(8)ATTRIBUTENAME(DBMATT_SPLONG))))

Comment : change attribute type to VL type without adding logical length - should fail
Request : update attribute,attribute(tuple(attributename(dbmatt_splong)typename(splong))),(typename(shtring))
Reply   : 201806116:72:Attribute DBMATT_SPLONG is of a variable-length type STRING, but a logical declaration is missing.

Comment : change attribute type to VL type while adding logical length - should pass
Request : cmd(update attribute,attribute(tuple(attributename(dbmatt_splong)typename(splong))),(typename(shtring)))cmd(add attributelogicallength,attributelogicallength(tuple(attributename(dbmatt_splong)logicallength(2500)))) 
Reply   : 

Comment : physical lengths should have been adapted
Request : inquire join(attributephysicallength,relation(heading(attributename(name))body(tuple(attributename(dbmatt_shtring))tuple(attributename(dbmatt_splong))tuple(attributename(dbmatt_angle)))))
Reply   : RELATION(HEADING(PHYSICALLENGTH(INT)ATTRIBUTENAME(NAME))BODY(TUPLE(PHYSICALLENGTH(5004)ATTRIBUTENAME(DBMATT_SPLONG))))

Comment : change back to FL type without removing logical length - should fail
Request : update attribute,attribute(tuple(attributename(dbmatt_splong)typename(shtring))),(typename(angle))
Reply   : 201806116:74:A logical-length is declared for attribute DBMATT_SPLONG, but that attribute is either not defined or else it is defined to be of a fixed-length type.

Comment : change back to FL type while removing logical length - should pass
Request : cmd(update attribute,attribute(tuple(attributename(dbmatt_splong)typename(shtring))),(typename(angleinterval)))cmd(delete attributelogicallength,attributelogicallength(tuple(attributename(dbmatt_splong)logicallength(2500)))) 
Reply   : 

Comment : physical lengths should have been adapted
Request : inquire join(attributephysicallength,relation(heading(attributename(name))body(tuple(attributename(dbmatt_shtring))tuple(attributename(dbmatt_splong))tuple(attributename(dbmatt_angle)))))
Reply   : RELATION(HEADING(PHYSICALLENGTH(INT)ATTRIBUTENAME(NAME))BODY(TUPLE(PHYSICALLENGTH(18)ATTRIBUTENAME(DBMATT_SPLONG))))

Comment : clean up
Request : unassert attribute,attribute(tuple(attributename(dbmatt_splong)typename(angleinterval)))
Reply   : 
Request : unassert constrainedtype,constrainedtype(tuple(typename(splong)sp_expression( gt\(parameter\(v\(long\)\),long\(0\) \) )basetype(long)))
Reply   : 
Request : unassert constrainedtype,constrainedtype(tuple(typename(shtring)sp_expression( gt\(int\(4800\),length\(parameter\(v\(string\)\)\) \) )basetype(string)))
Reply   : 

END
