A system that facilitates checking the consistency of a user-defined data
type in relation to a database environment. The invention can employ a
user-defined type (UDT) storage format whereby values can be
self-describing, including the runtime type of the value. The invention
can take the type definition that is persisted in the metadata catalogs
as a streaming input and generate a type-specific state machine
thereafter. At every point in the checking process, the type-specific
state machine can be aware of the next data type that is to be
encountered in the check. Whenever an embedded UDT is encountered, the
current type-specific state machine can be suspended and saved. The
embedded UDT can be checked before proceeding. In this way, the complex
check can be effected using memory space proportional to the number of
levels in the UDT as opposed to the number of bytes in the object.