ODBC 3.7 Visual Studio Analyzer Events

ODBC 3.70 will fire both stock and custom events to Visual Studio™ Analyzer to provide the client with performance and debugging information about the ODBC 3.7 layer. All Visual Studio Analyzer outbound events will be fired at the top-level interface so that developers will get as accurate a picture as possible regarding time spent in ODBC components vs. ADO and OLE DB components.

Registration

Visual Studio Analyzer provides a COM method, ISystemDebugEventFire::IsActive, to let an event source find out if there is any event collector listening. This minimizes the overhead to an “if” checking and a function call. However, to call method IsActive, CoInitialize and CoCreateInstance are called first. Some ODBC applications do not use OLE, and in order not to slow the load of ODBC to these applications, Visual Studio Analyzer Events can be enabled/disabled from within the ODBC Administrator. That way OLE and Visual Studio Analyzer are initialized when ODBC is loaded only if it has been enabled.

Visual Studio Analyzer requires any Visual Studio Analyzer Event source to register when the source is set up. There are two ways to register the ODBC Visual Studio Analyzer Event source. One is to call ISystemDebugEventInstall::RegisterSource, RegisterStockEvent, and RegisterCustomEvent, etc. in SQLInstallDriverManager. Another approach is for the user to enable/disable Visual Studio Analyzer Event in the ODBC Control Panel. The first approach has the benefit of only registering once on a machine. However, the setups of some programs are already very complicated and those applications may not find it necessary to view Visual Studio Analyzer events. Therefore, by using the ODBC Administrator, registration is deferred until a user enables Visual Studio Analyzer.

Categories

ODBC will fire the events in following categories:

DEBUG_EVENT_CATEGORY_STARTSTOP,

DEBUG_EVENT_CATEGORY_CALLRETURN,

DEBUG_EVENT_CATEGORY_QUERYRESULT,

DEBUG_EVENT_CATEGORY_TRANSACTION

In addition to the stock categories provided by Visual Studio Analyzer, ODBC 3.7 will add the following:

DEBUG_EVENT_CATEGORY_CONNECTION

ODBC 3.7 Visual Studio Analyzer Events by Handle

No Handle

Category Type Event Fired When
startstop Generic STRART When ODBC32.DLL is loaded
startstop Generic STOP When ODBC32.DLL is unloaded

Connection

Category Type Event Fired When
transaction Generic start SQLSetConnectAttr(…SQL_ATTR_ENLIST_IN_DTC)
transaction Generic start Any function call on an HDBC (or hstmt under this HDBC) after a call to SQLEndTran when SQL_ATTR_AUTOCOMMIT is set to SQL_AUTOCOMMIT_OFF. The overhead might be too high. We may want to fire the event after SQLEndTran returns from the driver.
transaction Generic commit SQLEndTran(…SQL_COMMIT)
transaction Generic rollback SQLEndTran(…SQL_ROLLBACK)
callreturn Outbound Enter At the entrance of SQLConnect/SQLDriverConnect
callreturn Inbound Leave_Normal (Exception) At the exit of SQLConnect/SQLDriverConnect if succeeds (or fails)
connection Outbound Open Before call driver’s SQLConnect/SQLDriverConnect
connection Inbound Open After driver’s SQLConnect/SQLDriverConnect returns
callreturn Outbound Enter At the entrace of SQLDisconnect
Callreturn Inbound Leave_Normal (Exception) At the exit of SQLDisconnect if succeeds (or fails)
Connection Outbound Close Before call driver’s SQLDisconnect
connection Inbound close After return from driver’s SQLDisconnect

Statement

Category Type Event Fired When
queryresult outbound Querysend Before the call of driver’s SQLExecute/SQLExecDirect
queryresult inbound Queryresult After driver’s SQLExecute/SQLExecDirect return
callreturn outbound Enter At enter of  SQLPrepare, SQLExecute, SQLExecDirect, SQLFetch, SQLExtendedFetch, SQLFetchScroll, SQLMoreResults, SQLGetData, SQLCancel, SQLTables, SQLColumns, SQLProcedures, SQLGetTypeInfo, SQLProcedureColumns, SQLSpecialColumns, SQLTablePrivileges, SQLSetPos, SQLPutData, SQLBulkOperations, SQLSpecialColumns, SQLColumnPrivileges, SQLForeignKeys, SQLStatistics
callreturn inbound Leave_Normal (or exception) At exit of SQLPrepare, SQLExecute, SQLExecDirect, SQLFetch, SQLExtendedFetch, SQLFetchScroll, SQLMoreResults, SQLGetData, SQLCancel, SQLTables, SQLColumns, SQLProcedures, SQLGetTypeInfo, SQLProcedureColumns, SQLSpecialColumns, SQLTablePrivileges, SQLSetPos, SQLPutData, SQLBulkOperations, SQLSpecialColumns, SQLColumnPrivileges, SQLForeignKeys, SQLStatistics

Visual Studio Analyzer Events Fired by ODBC 3.7

Event Type Args (prgKeys)

query_result inbound BSTR SQLText,

VARIANT_BOOL fAsync

query_send outbound BSTR SQLText

VARIANT_BOOL fAsync

call enter outbound the input arguments
return_normal inbound the output arguments
return_exception inbound HRESULT hrException
connection_open* outbound BSTR ConnectString,

BSTR UserId,

BSTR Password

connection_close* outbound

* indicates a custom event