Define the statistics-collection function

When you declare your statistics-collection function, it must have the following C signature:
mi_statret *statcollect(udt_arg, num_rows, resolution,
      fparam_ptr)
   udt_type *udt_arg;
   mi_double_precision *num_rows;
   mi_double_precision *resolution;
   MI_FPARAM *fparam_ptr;
udt_arg
A pointer to the internal structure of the user-defined data type. The database server uses this argument to resolve the function and to pass in column values.
num_rows
A pointer to a floating-point value that indicates the number of rows that the database server must scan to gather the statistics.
resolution
A pointer to a floating-point value that is the resolution specified by the UPDATE STATISTICS statement. The resolution value specifies the bucket size for the distribution. However, you might choose to ignore this parameter if it does not make sense for your user-defined data type.
fparam_ptr
A pointer to the MI_FPARAM structure that holds the iterator-status constant for each iteration of the statcollect() function.
Tip: The statistics-collection function can have any name. It does not have to be named statcollect(). It is recommended that you include the name of your user-defined data type in the name of the statistics-collection function to help distinguish the function from the statistics-collection functions of other user-defined data type.
The following code fragment shows a C declaration of the statistics-collection function for the longlong opaque type:
Figure 1: Sample declaration of a statistics-collection function
mi_statret *statcollect_ll(ll_arg, num_rows, resolution, fparam_ptr)
   longlong_t *ll_arg;
   mi_double_precision *num_rows;
   mi_double_precision *resolution;
   MI_FPARAM *fparam_ptr;