Error messages

The database server cannot validate specifications for features that the access method adds. If the access method includes a feature that the database server cannot detect, the access method must explicitly handle syntax errors in requests for that feature. To handle errors that the database server cannot detect, call the DataBlade® API mi_db_error_raise() function.

The following example shows you how an access method might avoid an unexpected exit due to a user error that the database server cannot detect. The CREATE INDEX statement in this example specifies configuration parameters.
CREATE INDEX fuzzy ON text(keywords)
   USING search_text(searchmode='string', wildcard='yes');
The access method should notify a user if a statement specifies an invalid parameter. To determine the parameters that a CREATE INDEX statement specifies, the access method calls the accessor function mi_tab_amparam(). To notify a user of an invalid parameter, the access method raises an exception, as the following example shows:
key_word = mi_tab_amparam (tableDesc);
if (strcmp (key_word, "searchmode") == 0)
{
           ...
}
else if (strcmp (key_word, "wildcard") == 0)
{
           ...
}
else
{
                    mi_db_error_raise (connection, MI_EXCEPTION,
                       "Invalid keyword in the USING clause.");
                    /* NOT REACHED */
}
The uppercase MI_EXCEPTION alerts the database server that an exception has occurred but does not necessarily halt execution. In contrast, the following call, which also raises an exception, assumes that a callback function exists for MI_Exception:
mi_db_error_raise( connection, MI_Exception, "Invalid...");

If the function that calls mi_db_error_raise() did not register a callback function for MI_Exception (upper and lowercase), execution aborts after the Invalid... error message appears.

The database server cannot always determine that the access method does not support a feature that a user specifies. The access method can test for the presence of specifications and either provide the feature or raise an exception for those features that it cannot provide.

For example, the database server does not know if the access method can handle lock types, isolation levels, referential constraints, or fragmentation that an SQL statement specifies. To retrieve the settings for mode, isolation level, and lock, the access method calls the following accessor functions:
mi_tab_mode()
The input and output mode (read-only, read and write, write only, and log transactions)
mi_tab_isolevel()
The isolation level
mi_scan_locktype()
The lock type for the scan
mi_scan_isolevel()
The isolation level in force