Memory alignment

When the database server passes the data type to a UDR, it aligns opaque-type data on a specified byte boundary. Alignment requirements depend on the C definition of the opaque data type and on the system (hardware and compiler) on which the opaque data type is compiled.

You can specify the memory-alignment requirement for your opaque data type with the ALIGNMENT modifier of the CREATE OPAQUE TYPE statement. The following table summarizes valid alignment values.
ALIGNMENT value Meaning Purpose
1 Align structure on single-byte boundary. Structures that begin with 1-byte quantities
2 Align structure on 2-byte boundary. Structures that begin with 2-byte quantities such as mi_unsigned_smallint
4 Align structure on 4-byte boundary. Structures that begin with 4-byte quantities such as float or mi_unsigned_integer
8 Align structure on 8-byte boundary. Structures that contain members of the C double data type

Structures that begin with single-byte characters, char, can be aligned anywhere. Arrays of a data type should follow the same alignment restrictions as the data type itself.

For example, the following CREATE OPAQUE TYPE statement specifies a fixed-length opaque data type, called LongLong, of 18 bytes that must be aligned on a 1-byte boundary:
CREATE OPAQUE TYPE LongLong (INTERNALLENGTH=18, ALIGNMENT=1);

If you do not include the ALIGNMENT modifier in the CREATE OPAQUE TYPE statement, the default alignment is a 4-byte boundary.