mi_integer am_check(MI_AM_TABLE_DESC *tableDesc, mi_integer option)
A user, generally a system administrator or operator, runs the oncheck utility to verify physical data structures. The options that follow the oncheck command indicate the kind of checking to perform. The additional -y or -n option specifies that the user wants oncheck to repair any damage to an index. For information about oncheck options, refer to the IBM Informix: Administrator's Reference.
In response to an oncheck command, the database server calls the am_check purpose function, which checks the internal consistency of the index and returns a success or failure indicator. If appropriate, am_check can call the am_open and am_close purpose functions.
To determine the exact contents of the command line, pass the option argument to the following VII macros. Each macro returns a value of MI_TRUE if the option includes the particular -c or -p qualifier that the following table shows.
The am_check purpose function executes each macro that it needs until one of them returns MI_TRUE. For example, the following syntax tests for oncheck option -cD demonstrate:
if (MI_CHECK_EXTENTS(option) == MI_TRUE)
{
/* Check rows and smart-large-object metadata
* If problem exists, issue message. */
}
The access method can call accessor function mi_tab_spacetype() to determine whether the specified index resides in an sbspace or extspace. If the data resides in an sbspace, the am_check purpose function can duplicate the expected behavior of the oncheck utility. For information about the behavior for each oncheck option, refer to the IBM Informix: Administrator's Reference.
For an extspace, such as a file that the operating system manages, am_check performs tasks that correspond to the command-line option.
To provide detailed information about the state of the index, am_check can call the mi_tab_check_msg() function.
An access method can contain the logic to repair an index and execute additional macros to determine whether it should repair a problem that am_check detects. The following table shows the oncheck options that enable or disable repair and the am_check macro that detects each option.
| Option | Meaning | Macro |
|---|---|---|
| -y | Automatically repair any problem. | MI_CHECK_YES_TO_ALL |
| -n | Do not repair any problem. | MI_CHECK_NO_TO_ALL |
If a user does not specify -y or -n with an oncheck command, the database server displays a prompt that asks whether the user wants the index repaired. Similarly, when both MI_CHECK_YES_TO_ALL() and MI_CHECK_NO_TO_ALL() return MI_FALSE, am_check can call accessor function mi_tab_check_set_ask(), which causes the database server to ask if the user wants the index repaired. If the user answers yes or y, the database server adds -y to the option argument and executes am_check a second time.
If either the MI_CHECK_YES_TO_ALL() macro or mi_tab_check_is_recheck() accessor function returns MI_TRUE, am_check should attempt to repair an index.
MI_OK validates the index structure as error free.
MI_ERROR indicates the access method could not validate the index structure as error free.
See the descriptions of: