ODBC 64-bit Windows and Linux Considerations
Identify header files and data types when using the ODBC driver in an IBM® i Access for Windows or IBM i Access for Linux environment.
- sql.h
- sqlext.h
- sqltypes.h
- sqlucode.h
There is one case, SQLExtendedFetch, that is handled differently in Linux than what is defined in sqlext.h. In sqlext.h, the definition for the pcrow parameter is defined as a SQLROWSETSIZE pointer. SQLROWSETSIZE is a 4 byte value in 64-bit Linux implementations. Despite this, the ODBC driver returns data for the pcrow pointer as an 8 byte (64-bit) value to be consistent with its 64-bit Windows ODBC implementation.
- In 64-bit Linux environments, the size of a long C/C++ type is 8 bytes. In other environments, including 64-bit Windows, the size of the long type is 4 bytes. Refer to the table below.
- In 32-bit environments, the size of a pointer is 4 bytes. In 64-bit environments, the size of a pointer is 8 bytes.
- Some of the ODBC APIs have parameters that are pointers. In some cases, these pointers are used to pass data of different sizes between the application and the driver. In 64-bit implementations, there are some changes where the size of data passed this way has changed from being 4 byte values to 8 byte values.
Some common C/C++ types and the size of each are listed in the table below.
C/C++ Type | Linux 64-bit | Windows 64-bit | Linux 32-bit | Windows 32-bit |
---|---|---|---|---|
int | 4 | 4 | 4 | 4 |
long | 8 | 4 | 4 | 4 |
long long | 8 | Not defined | 8 | Not defined |
LONG LONG | Not defined | 8 | Not defined | Not defined |
pointer size | 8 | 8 | 4 | 4 |
INT32 | Not defined 41 | 4 | Not defined 41 | 4 |
INT64 | Not defined 81 | 8 | Not defined 81 | 8 |
SQLSMALLINT | 2 | 2 | 2 | 2 |
SQLINTEGER | 4 | 4 | 4 | 4 |
SQLLEN | 8 | 8 | 4 | 4 |
SQLSETPOSIROW | 8 | 8 | 2 | 2 |
SQLROWCOUNT | 8 | Not defined | 4 | 4 |
SQLROWSETSIZE | 4 | Not defined | 4 | 4 |
SQLROWOFFSET | 8 | Not defined | 4 | 4 |
SQLPOINTER | 8 | 8 | 4 | 4 |
UINT_PTR | Not defined 81 | 8 | Not defined 41 | 4 |
DWORD | Not defined 41 | 4 | Not defined 41 | 4 |
SDWORD | Not defined 41 | 4 | Not defined 41 | 4 |
ULONG_PTR | Not defined 81 | 8 | Not defined 41 | 4 |
SQLHANDLE | 8 | 8 | 4 | 4 |
SQLHDESC | 8 | 8 | 4 | 4 |
Options for the ODBC APIs listed below result in different behavior by the 32-bit and 64-bit ODBC drivers for parameter pointer data. Generally, the 64-bit ODBC drivers treat parameter pointer data as 8 byte (64-bit) values, unless otherwise noted.
- SQLColAttribute
- SQL_DESC_DISPLAY_SIZE
- SQL_DESC_LENGTH
- SQL_DESC_OCTET_LENGTH
- SQL_DESC_COUNT
- SQLColAttributes
- SQL_COLUMN_DISPLAY_SIZE
- SQL_COLUMN_LENGTH
- SQL_COLUMN_COUNT
- SQLGetConnectAttr
- SQL_ATTR_QUIET_MODE
- SQLGetConnectOption (This is mapped to SQLGetConnectAttr by the ODBC driver manager.)
- SQL_ATTR_QUIET_MODE
- SQLGetDescField
- SQL_DESC_ARRAY_SIZE
- SQLGetDiagField
- SQL_DIAG_CURSOR_ROW_COUNT
- SQL_DIAG_ROW_COUNT
- SQL_DIAG_ROW_NUMBER
- SQLGetInfo (These are all handled by the ODBC driver manager.)
- SQL_DRIVER_HENV
- SQL_DRIVER_HDBC
- SQL_DRIVER_HLIB
- SQL_DRIVER_HSTMT
- SQL_DRIVER_HDESC
- SQLGetStmtAttr
- SQL_ATTR_APP_PARAM_DESC
- SQL_ATTR_APP_ROW_DESC
- SQL_ATTR_IMP_PARAM_DESC
- SQL_ATTR_IMP_ROW_DESC
- SQL_ATTR_MAX_LENGTH
- SQL_ATTR_MAX_ROWS
- SQL_ATTR_PARAM_BIND_OFFSET_PTR
- SQL_ATTR_ROW_ARRAY_SIZE
- SQL_ATTR_ROW_BIND_OFFSET_PTR
- SQL_ATTR_ROW_NUMBER
- SQL_ATTR_ROWS_FETCHED_PTR
- SQL_ATTR_KEYSET_SIZE
- SQLGetStmtOption (This is mapped to SQLGetStmtAttr by the ODBC driver manager.)
- SQL_MAX_LENGTH
- SQL_MAX_ROWS
- SQL_ROWSET_SIZE
- SQL_KEYSET_SIZE
- SQLSetConnectAttr
- SQL_ATTR_QUIET_MODE
- SQLSetConnectOption (This is mapped to SQLSetConnectAttr by the ODBC driver manager.)
- SQL_ATTR_QUIET_MODE
- SQLSetDescField
- SQL_DESC_ARRAY_SIZE
- SQLSetStmtAttr
- SQL_ATTR_APP_PARAM_DESC
- SQL_ATTR_APP_ROW_DESC
- SQL_ATTR_IMP_PARAM_DESC
- SQL_ATTR_IMP_ROW_DESC
- SQL_ATTR_MAX_LENGTH
- SQL_ATTR_MAX_ROWS
- SQL_ATTR_PARAM_BIND_OFFSET_PTR
- SQL_ATTR_ROW_ARRAY_SIZE
- SQL_ATTR_ROW_BIND_OFFSET_PTR
- SQL_ATTR_ROW_NUMBER
- SQL_ATTR_ROWS_FETCHED_PTR
- SQL_ATTR_KEYSET_SIZE
- SQLSetConnectAttr
- SQL_MAX_LENGTH
- SQL_MAX_ROWS
- SQL_ROWSET_SIZE
- SQL_KEYSET_SIZE