External unload representation
To handle opaque-type data in its external unload representation, the database server calls the import and export support functions of the opaque type. The external unload representation is the text version of the opaque-type data when it is in a copy file. Usually, the external unload and external representations of an opaque type are the same.
The database server stores the external unload representation of an opaque type in an mi_impexp structure. The mi_impexp structure is a varying-length structure that encapsulates the external unload representation. Its ability to store varying-length data enables it to handle any possible changes in the size of the opaque-type data when it is converted between its server internal and its external unload representations. For example, opaque data types that contain smart large objects might have a file name in their external unload representation rather than storing all the smart-large-object data in the copy file.
Opaque-type support function | Cast from | Cast to |
---|---|---|
Import | mi_impexp * | Server internal representation of the opaque data type |
Export | Server internal representation of the opaque data type | mi_impexp * |
For your opaque data type to accept an external representation in nondefault locales, you must internationalize the import and export support functions. For more information, see Internationalization of DataBlade API modules (GLS).
- Call the input function inside the import function.
The import functions for the circle opaque type (Figure 1) and the two_bytes opaque type (Figure 2) use this method.
- Omit the import function from the definition of the opaque type.
You must still create the implicit cast from the IMPBIN data type to the opaque data type with the CREATE CAST statement. However, instead of listing an import support function as the cast function, list the input support function. The database server would then automatically call the appropriate input support function to load the opaque type when it is in its external unload representation.