Menu
Simba Technologies
Simba Technologies

SimbaEngine X SDK 10.1.3
Developing Drivers for Data Stores Without SQL

Concurrency Support

Some ODBC functions can be run concurrently on statements that share the same connection, while other functions block.

For example, the ODBC catalog function SQLTables cannot be run concurrently. Suppose a thread is executing SQLTables on a statement, while another thread attempts to execute a function on another statement that shares the same connection. The second thread blocks until SQLTables on the first thread is finished.

This section explains the concurrency behaviour for the different ODBC functions, and explains how to change the behaviour from concurrent to blocking.

ODBC Functions that Support Concurrency

By default, the following ODBC functions support concurrency:

  • SQLPrepare
  • SQLCloseCursor
  • SQLFreeStmt
  • SQLMoreResults
  • SQLAllocHandle
  • SQLFreeHandle

These functions can be executed concurrently, even if the statements that are executing them share the same connection. For example, suppose a statement is executing a function on a connection. If you pass that connection handle to SQLAllocHandle(), the SQLAllocHandle() function is executed concurrently and does not block.

Similarly, suppose two statements, Statement1 and Statement2, are using the same connection. Statement1 is already executing. You can call SQLFreeHandle() on Statement2 and it will not block.

Overriding the Default Behaviour

If you want these functions to block by default, you can change the default behaviour by setting a driver property.

To set ODBC functions to block:

  • In your IDriver implementation, set the DSI_DRIVER_ALLOW_INCREASED_ODBC_STATEMENT_CONCURRENCY property to false:

    SetProperty(DSI_DRIVER_ALLOW_INCREASED_ODBC_STATEMENT_CONCURRENCY, AttributeData::MakeNewUInt32AttributeData(DSI_AIOSC_FALSE));

ODBC Functions that Do Not Support Concurrency

The following ODBC functions do not support concurrency:

  • SQLExecute
  • SQLExecDirect
  • All catalog functions.