1 /*----------------------------------------------------------------------------- 2 File: sqlspi.h 3 4 Contents: This is the header for driver writers to support new ODBC 5 features. Application writers should not include 6 this header file 7 Please include <sql.h> and <sqlext.h> before including this 8 file 9 10 Based on the sqlspi.h provided by Microsoft 11 12 -----------------------------------------------------------------------------*/ 13 14 #ifndef __SQLSPI__ 15 #define __SQLSPI__ 16 17 #ifdef __cplusplus 18 extern "C" { // Assume C declarations for C++ 19 #endif // End of __cplusplus 20 21 /* SQL_SPI is just a marker for "Service Provider Interface", otherwise it is the same as API 22 Application should not call functions that are marked as SQL_SPI directly */ 23 #define SQL_SPI SQL_API 24 25 /*-------------------- ODBC Connection Info Handle -----------------------------*/ 26 /* handle for storing connection information for ODBC driver connection pooling */ 27 #define SQL_HANDLE_DBC_INFO_TOKEN 6 // Handle type, used in SQLAllocHandle 28 typedef SQLHANDLE SQLHDBC_INFO_TOKEN; 29 30 /*-------------------- ODBC Pool ID for driver-aware pooling -----------------------------*/ 31 typedef SQLULEN POOLID; 32 typedef DWORD* TRANSID; 33 34 /*-------------------- Driver-aware Connection Pooling --------------------------*/ 35 /* We define a few scores with special meaning */ 36 /* But driver can return any score between 0 and 100 */ 37 typedef DWORD SQLConnPoolRating; 38 #define SQL_CONN_POOL_RATING_BEST 100 /* the best of the rating */ 39 #define SQL_CONN_POOL_RATING_GOOD_ENOUGH 99 /* the rating is good enough and we can stop rating */ 40 #define SQL_CONN_POOL_RATING_USELESS 0 /* the candidate connection must not be reused for the current request */ 41 42 /* SQLSetConnectAttr */ 43 #define SQL_ATTR_DBC_INFO_TOKEN 118 /* reset the pooled connection in case it is not a perfect match */ 44 45 /* Set connection attributes into DBC info token */ 46 SQLRETURN SQL_SPI SQLSetConnectAttrForDbcInfoW( 47 SQLHDBC_INFO_TOKEN hDbcInfoToken, 48 SQLINTEGER Attribute, 49 SQLPOINTER Value, 50 SQLINTEGER StringLength); 51 52 /* Set connection information for SQLDriverConnect */ 53 SQLRETURN SQL_SPI SQLSetDriverConnectInfoW( 54 SQLHDBC_INFO_TOKEN hDbcInfoToken, 55 SQLWCHAR *szConnStrIn, 56 SQLSMALLINT cchConnStrIn); 57 58 /* Set connection information for SQLConnect */ 59 SQLRETURN SQL_SPI SQLSetConnectInfoW 60 ( 61 SQLHDBC_INFO_TOKEN hDbcInfoToken, 62 SQLWCHAR *szDSN, 63 SQLSMALLINT cchDSN, 64 SQLWCHAR *szUID, 65 SQLSMALLINT cchUID, 66 SQLWCHAR *szAuthStr, 67 SQLSMALLINT cchAuthStr 68 ); 69 70 /* Get the pool ID for the token */ 71 SQLRETURN SQL_SPI SQLGetPoolID( 72 SQLHDBC_INFO_TOKEN hDbcInfoToken, 73 POOLID* pPoolID); 74 75 /* Return how close hCandidateConnection matches with hRequest */ 76 /* *pRating must be between SQL_CONN_POOL_RATING_USELESS and SQL_CONN_POOL_RATING_BEST (inclusively) */ 77 /* If return value is not SQL_SUCCESS or *pRating > SQL_CONN_POOL_RATING_BEST, the candidate */ 78 /* connection will not be used any more in any other connection request */ 79 /* If fRequiresTransactionEnlistment is TRUE, transId represents the DTC transaction ID that */ 80 /* should be enlisted to (transId == 0 means unenlistment). Otherwise, transId should be ignored */ 81 SQLRETURN SQL_SPI SQLRateConnection( 82 SQLHDBC_INFO_TOKEN hRequest, 83 SQLHDBC hCandidateConnection, 84 BOOL fRequiresTransactionEnlistment, 85 TRANSID transId, 86 SQLConnPoolRating *pRating); 87 88 /* Create a physical connection */ 89 /* If application is calling SQLDriverConnect, szConnStrOut is non-NULL at input. */ 90 /* Otherwise, it will be set to NULL */ 91 SQLRETURN SQL_SPI SQLPoolConnectW( 92 SQLHDBC hdbc, 93 SQLHDBC_INFO_TOKEN hDbcInfoToken, 94 SQLWCHAR *szConnStrOut, 95 SQLSMALLINT cchConnStrOutMax, 96 SQLSMALLINT *pcchConnStrOut); 97 98 /* Clean up a pool Id that was timed out */ 99 /*/ poolID [in]: the pool ID (under EnvironmentHandle) to be cleaned */ 100 SQLRETURN SQL_SPI SQLCleanupConnectionPoolID( 101 SQLHENV EnvironmentHandle, 102 POOLID poolID); 103 104 /*-----------------------------------------------------------------------------*/ 105 /* functions for ANSI drivers */ 106 107 /* Set connection attributes into DBC info token */ 108 SQLRETURN SQL_SPI SQLSetConnectAttrForDbcInfoA( 109 SQLHDBC_INFO_TOKEN hDbcInfoToken, 110 SQLINTEGER Attribute, 111 SQLPOINTER Value, 112 SQLINTEGER StringLength); 113 114 /* Set connection information for SQLDriverConnect */ 115 SQLRETURN SQL_SPI SQLSetDriverConnectInfoA( 116 SQLHDBC_INFO_TOKEN hDbcInfoToken, 117 SQLCHAR *szConnStrIn, 118 SQLSMALLINT cchConnStrIn); 119 120 /* Set connection information for SQLConnect */ 121 SQLRETURN SQL_SPI SQLSetConnectInfoA 122 ( 123 SQLHDBC_INFO_TOKEN hDbcInfoToken, 124 SQLCHAR *szDSN, 125 SQLSMALLINT cchDSN, 126 SQLCHAR *szUID, 127 SQLSMALLINT cchUID, 128 SQLCHAR *szAuthStr, 129 SQLSMALLINT cchAuthStr 130 ); 131 132 /* Create a physical connection */ 133 /* If application is calling SQLDriverConnect, szConnStrOut is non-NULL at input. */ 134 /* Otherwise, it will be set to NULL */ 135 SQLRETURN SQL_SPI SQLPoolConnectA( 136 SQLHDBC hdbc, 137 SQLHDBC_INFO_TOKEN hDbcInfoToken, 138 SQLCHAR *szConnStrOut, 139 SQLSMALLINT cchConnStrOutMax, 140 SQLSMALLINT *pcchConnStrOut); 141 142 /*-----------------------------------------------------------------------------*/ 143 /* Unicode mapping */ 144 /* Define SQL_NOUNICODEMAP to disable the mapping */ 145 #if (!defined(SQL_NOUNICODEMAP) && defined(UNICODE)) 146 #define SQLSetConnectAttrForDbcInfo SQLSetConnectAttrForDbcInfoW 147 #define SQLSetDriverConnectInfo SQLSetDriverConnectInfoW 148 #define SQLSetConnectInfo SQLSetConnectInfoW 149 #define SQLPoolConnect SQLPoolConnectW 150 #else 151 #define SQLSetConnectAttrForDbcInfo SQLSetConnectAttrForDbcInfoA 152 #define SQLSetDriverConnectInfo SQLSetDriverConnectInfoA 153 #define SQLSetConnectInfo SQLSetConnectInfoA 154 #define SQLPoolConnect SQLPoolConnectA 155 #endif 156 /*------------------------------------------------------------------------------*/ 157 158 /*-------------------- Async Notification --------------------------*/ 159 #if (ODBCVER >= 0x0380) 160 #define SQL_ATTR_ASYNC_DBC_NOTIFICATION_CALLBACK 120 161 #define SQL_ATTR_ASYNC_DBC_NOTIFICATION_CONTEXT 121 162 163 #define SQL_ATTR_ASYNC_STMT_NOTIFICATION_CALLBACK 30 164 #define SQL_ATTR_ASYNC_STMT_NOTIFICATION_CONTEXT 31 165 166 typedef SQLRETURN (SQL_API *SQL_ASYNC_NOTIFICATION_CALLBACK)(SQLPOINTER pContext, BOOL fLast); 167 #endif /* ODBCVER >= 0x0380 */ 168 169 170 #ifdef __cplusplus 171 } // End of extern "C" { 172 #endif 173 #endif 174