ODBC applications need to understand the structure of a data store in order to execute SQL queries against it. This information is provided using catalog functions. For example, an application might request a result set containing information about all the tables in the data store, or all the columns in a particular table. Each catalog function returns data as a result set.
Your custom ODBC driver uses metadata sources, provided by the SimbaEngine X SDK, to handle SQL catalog functions.
Of the 13
DSIMetadataSource sub-classes, there is only one that you need to modify to make a basic driver work. This section describes the other
metadata classes and under what circumstances you need to update them.
If the driver is using the SQL Engine, then the
CustomerDSIIDataEngine class has to derive from
DSIExtSqlDataEngine, and implement the following function:
const simba_wstring& in_escapeChar,
const simba_wstring& in_identifierQuoteChar,
bool in_filterAsIdentifier) = 0;
This function creates a new
DSIMetadataSource* which contains raw metadata. If the driver does not support a metadata table, then it should return an empty metadata source with no rows by returning a
The function takes the following parameters:
in_metadataTableID: Identifier to create the appropriate metadata table. For a list of the possible identifiers, refer to the table below. For complete details on each identifier, refer to DSIMetadataTableID.h in the API guide.
in_restrictions: Restrictions that may be applied to the metadata table. Map of DSIOutputMetadataColumnTag that identify columns in the result set, to the restriction that apply to those columns. For example, if the DSIOutputMetadataColumnTag identifies a catalog name, then the restriction specifies that the result set should only contain rows with the same catalog name as the restriction. For a complete list and details of DSIOutputMetadataColumnTag values, refer to DSIMetadataColumnIdentifierDefns.h in the API guide.
in_escapeChar: Escape character used in filtering.
in_identifierQuoteChar: Quote identifier, which is the quotation mark that this filter recognizes.
in_filterAsIdentifier: Indicates if string filters are treated as identifiers. This can be set through the connection attribute SQL_ATTR_METADATA_ID.
If the metadata table is supported by the driver, then a new class should be implemented by deriving from
Simba::DSI::DSIMetadataSource and implementing all the functions.
The driver is required to implement a class for DSI_TYPE_INFO_METADATA metadata table identifier, which is for catalog function SQLGetTypeInfo. This class should derive from pure abstract class called DSIExtTypeInfoMetaDataSource that has the following pure virtual function:
virtual Simba::SQLEngine::TypePrepared PrepareType(Simba::SQLEngine::SqlTypeInfo& io_typeInfo) = 0;
This function takes the specified SQL type information, modifies any fields that need to be changed to fit the data source, and indicates if that type is supported or not. For a sample implementation, refer to the Quickstart sample driver.
The SQLEngine also provides default implementation for the following metadata table identifiers:
If the driver chooses to use these default implementations, then the driver has to implement a class that derives from
Simba::SQLEngine::DSIExtMetadataHelper and implement all the functions. The two pure virtual functions
GetNextTable() are called by the default implementations to retrieve the next procedure and the next table, respectively. For a sample implementation of
MetadataHelper class, refer to the Quickstart sample driver.
Note: If the driver does not use the default implementations for the metadata table identifiers mentioned above, then the driver should implement its own class for the metadata table identifiers by deriving from Simba::DSI::DSIMetadataSource. The driver should create an empty metadata source with no rows by returning a DSIEmptyMetadataSource object for the metadata table identifiers that it does not support. For a sample implementation of DSIMetadataSource classes, refer to the sample driver.