blob: 03c7177b54f46ab6aa1efefad546f9b9b3ca995d [file] [log] [blame]
4.7 User-defined types
A user-defined type is a schema object, identified by a <user-defined type name> . The definition of a userdefined type specifies a number of components, including in particular a list of attribute definitions. Although the attribute definitions are said to define the representation of the user-defined type, in fact they implicitly define certain functions (observers and mutators) that are part of the interface of the user-defined type; physical representations of user-defined type values are implementation-dependent.
The representation of a user-defined type is expressed either as a single data type (some predefined data type, called the source type), in which case the user-defined type is said to be a distinct type, or as a list of attribute definitions, in which case it is said to be a structured type.
The definition of a user-defined type may include a <method specification list> consisting of one or more <method specification> s. A <method specification> is either an <original method specification> or an <overriding method specification> . Each <original method specification> specifies the <method name> , the <specific method name> , the <SQL parameter declaration list> , the <returns data type> , the <result cast from type> (if any), whether the method is type-preserving, the <language clause> , the <parameter style> if the language is not SQL, whether STATIC or CONSTRUCTOR is specified, whether the method is deterministic, whether the method possibly modifies SQL data, possibly reads SQL data, possibly contains SQL, or does not possibly contain SQL, and whether the method should be evaluated as NULL whenever any argument is NULL, without actually invoking the method.
Each <overriding method specification> specifies the <method name> , the <specific method name> , the <SQL parameter declaration list> and the <returns data type> . For each <overriding method specification> , there shall be an <original method specification> with the same <method name> and <SQL parameter declaration list> in some proper supertype of the user-defined type. Every SQL-invoked method in a schema shall correspond to exactly one <original method specification> or <overriding method specification> associated with some user-defined type existing in that schema.
A method M that corresponds to an <original method specification> in the definition of a structured type T1 is an original method of T1. A method M that corresponds to an <overriding method specification> in the definition of T1 is an overriding method of T1.
A method M is a method of type T1 if one of the following holds:
- M is an original method of T1.
- M is an overriding method of T1.
- There is a proper supertype T2 of T1 such that M is an original or overriding method of T2 and such that there is no method M3 such that M3 has the same <method name> and <SQL parameter declaration list> as M and M3 is an original method or overriding method of a type T3 such that T2 is a proper supertype of T3 and T3 is a supertype of T1.
If T1 is a subtype of T2 and M1 is a method of T1 such that there exists a method M2 of T2 such that M1 and M2 have the same <method name> and the same unaugmented <SQL parameter declaration list> , then M1 is an inherited method of T1 from T2.
A user-defined type is described by a user-defined type descriptor. A user-defined type descriptor contains:
- The name of the user-defined type (<user-defined type name> ). This is the type designator of that type, used in type precedence lists (see Subclause 9.5, "Type precedence list determination").
- An indication of whether the user-defined type is a structured type or a distinct type.
- The ordering form for the user-defined type (EQUALS , FULL , or NONE ).
- The ordering category for the user-defined type (RELATIVE , MAP , or STATE ).
- A <specific routine designator> identifying the ordering function, depending on the ordering category.
- If the user-defined type is a direct subtype of another user-defined type, then the name of that user-defined type.
- If the representation is a predefined data type, then the descriptor of that type; otherwise the attribute descriptor of every originally-defined attribute and every inherited attribute of the user-defined type.
- An indication of whether the user-defined type is instantiable or not instantiable.
- An indication of whether the user-defined type is final or not final.
- The transform descriptor of the user-defined type.
- If the user-defined type is a structured type, then:
- Whether the referencing type of the structured type has a user-defined representation, a derived representation, or a system-defined representation.
- If user-defined representation is specified, then the type descriptor of the representation type of the referencing type of the structured type; otherwise, if derived representation is specified, then the list of attributes.
NOTE 15 - "user-defined representation", "derived representation", and "system-defined representation" of a reference type are defined in Subclause 4.9, "Reference types".
- If the <method specification list> is specified, then for each <method specification> contained in <method specification list> , a method specification descriptor that includes:
- The <method name>.
- The <specific method name>.
- The <SQL parameter declaration list> augmented to include the implicit first parameter with parameter name SELF.
- The <language name>.
- If the <language name> is not SQL, then the <parameter style>.
- The <returns data type>.
- The <result cast from type> , if any.
- An indication as to whether the <method specification> is an <original method specification> or an <overriding method specification> .
- If the <method specification> is an <original method specification> , then an indication of whether STATIC or CONSTRUCTOR is specified.
- An indication whether the method is deterministic.
- An indication whether the method possibly writes SQL data, possibly reads SQL data, possibly contains SQL, or does not possibly contain SQL.
- An indication whether the method should not be invoked if any argument is the null value, in which case the value of the method is the null value.
NOTE 16 - The characteristics of an <overriding method specification> other than the <method name> , <SQL parameter declaration list> , and <returns data type> are the same as the characteristics for the corresponding <original method specification> .