A transition descriptor
The transition descriptor, MI_TRANSITION_DESC, stores information about a transition in the processing state of the database server. It holds information for all state-transition events.
The following state-transition events are held by the transition
descriptor. (The first six state-transition events are for the server
only)
- MI_EVENT_SAVEPOINT
- MI_EVENT_COMMIT_ABORT
- MI_EVENT_POST_XACT
- MI_EVENT_END_STMT
- MI_EVENT_END_XACT
- MI_EVENT_END_SESSION
- MI_Xact_State_Change
The milib.h header file defines the MI_TRANSITION_DESC structure.
When a state transition event occurs, the DataBlade®
API invokes
the appropriate callback. To this callback, the DataBlade®
API passes
an initialized transition descriptor as the third callback argument.
The transition descriptor contains the transition type that initiated
the state-transition event. To obtain the transition type from the
descriptor, use the mi_transition_type() function.
This function returns a value of type MI_TRANSITION_TYPE to
indicate the transition type of the event that occurred. For a list
of valid MI_TRANSITION_TYPE values, see Understanding state-transition events.
Important: The MI_TRANSITION_DESC structure
is an opaque structure to DataBlade®
API modules.
Do not access its internal fields directly. The internal structure
of MI_TRANSITION_DESC might change in future releases. Therefore,
to create portable code, always use the mi_transition_type() accessor
function to obtain the transition type from this structure.
The following code fragment uses the mi_transition_type() function
to determine which action to take when it receives a state-transition
event:
MI_TRANSITION_DESC *event_data;
MI_TRANSITION_TYPE trans_type;
mi_string s[30];
...
trans_type = mi_transition_type(event_data);
switch ( trans_type )
{
case MI_BEGIN: /* client LIBMI apps only */
s = "Transaction started.";
break;
case MI_NORMAL_END:
s = "Successful event";
break;
case MI_ABORT_END:
s = "Event failed and rolled back,";
break;
default:
s = "Unknown transition type";
break;
}
fprintf(stderr, "%s\n", s);