Determine internal representation

The internal representation of an opaque data type is a C data structure that holds the information that the opaque type needs.

The internal representation of an opaque type that is stored in a database is called its server internal representation. Inside this internal C structure, use the platform-independent DataBlade® API data types (such as mi_integer and mi_real) to improve the portability of the opaque data type.
Tip: The internal representation of an opaque data type is a binary format that might not match the external binary format surfaced to the client.
For example, the following code fragment shows the circle_t data structure, which holds the values for the circle opaque data type.
Figure 1. Internal representation of the circle opaque data type
typedef struct 
   {
   mi_double_precision    x;
   mi_double_precision    y;
   } point_t;

typedef struct
   {
   point_t                center;
   mi_double_precision    radius;
   } circle_t;

The CREATE OPAQUE TYPE statement uniquely names the opaque data type. It is recommended that you develop a unique prefix for the name of an opaque data type. If your DataBlade® module uses a prefix, such as USR, you can begin the names of opaque types with this prefix. For example, you might use the prefix USR on all database objects that your DataBlade® module creates. The preceding circle_t opaque type can be named USR_circle_t to ensure that it does not conflict with opaque types that other DataBlade® modules might create.

You register the opaque data type with the CREATE OPAQUE TYPE statement, which stores information about the opaque type in the sysxtdtypes system catalog table. When you register an opaque data type, you provide the following information about the internal representation of an opaque type:
  • The final size of the new opaque data type
  • How the opaque data type is aligned in memory
  • How the opaque data type is passed in an MI_DATUM structure