The mi_tab_setuserdata() accessor function
The mi_tab_setuserdata() function stores a pointer to user data in the table descriptor.
Syntax
void mi_tab_setuserdata(MI_AM_TABLE_DESC *tableDesc,
void *user_data)
- tableDesc
- Points to the table descriptor.
- user_data
- Points to a data structure that the access method creates.
Usage
The access method stores state information from one purpose function so that another purpose function can use it.
To save table-state information as user data:
- Call the appropriate DataBlade API memory-management function to allocate PER_STMT_EXEC or PER_STMT_PREP memory for the user-data structure.
- Populate the user-data structure with the state information.
- Call the mi_tab_setuserdata() function to store
the pointer that the memory-allocation function returns in the table
descriptor.
Pass the pointer as the user_data argument.
Typically, an access method performs the preceding procedure in the am_open purpose function and deallocates the user-data memory in the am_close purpose function. To have the table descriptor retain the pointer to the user data as long as the table remains open, specify a memory duration of PER_STMT_EXEC or PER_STMT_PREP as Memory-duration options and Persistent user data describe.
To retrieve the pointer from the table descriptor to access the table-state user data, call the mi_tab_userdata() function in any purpose function between am_open and am_close.
Return values
None