Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLBindCol doesn't allow a driver-specific C type binding. #132

Open
groprima opened this issue Feb 3, 2023 · 2 comments
Open

SQLBindCol doesn't allow a driver-specific C type binding. #132

groprima opened this issue Feb 3, 2023 · 2 comments

Comments

@groprima
Copy link

groprima commented Feb 3, 2023

The DB2 CLI ODBC defines several driver-specific SQL, C types and memory layouts for them. These types have been around for quite a while. With the current implementation in the SQLBindCol, they are rejected in the check_target_type(..). My understanding of the MS specs is that the validation only happens when ODBC is 3.8 and up. For the versions below 3.8 any value is accepted.

What do you think about that?

DB2 sqlcli.h:

/* SQL extended data types */
#define SQL_GRAPHIC -95
#define SQL_VARGRAPHIC -96
#define SQL_LONGVARGRAPHIC -97
#define SQL_BLOB -98
#define SQL_CLOB -99
#define SQL_DBCLOB -350
#define SQL_XML -370
#define SQL_CURSORHANDLE -380
#define SQL_DATALINK -400
#define SQL_USER_DEFINED_TYPE -450

/* C data type to SQL data type mapping */
#define SQL_C_DBCHAR SQL_DBCLOB
#define SQL_C_DECIMAL_IBM SQL_DECIMAL
#define SQL_C_DATALINK SQL_C_CHAR
#define SQL_C_PTR 2463
#define SQL_C_DECIMAL_OLEDB 2514
#define SQL_C_DECIMAL64 SQL_DECFLOAT
#define SQL_C_DECIMAL128 -361
#define SQL_C_TIMESTAMP_EXT -362
#define SQL_C_TYPE_TIMESTAMP_EXT SQL_C_TIMESTAMP_EXT
#define SQL_C_BINARYXML -363
#define SQL_C_TIMESTAMP_EXT_TZ -364
#define SQL_C_TYPE_TIMESTAMP_EXT_TZ SQL_C_TIMESTAMP_EXT_TZ
#define SQL_C_CURSORHANDLE -365

Microsoft:
https://learn.microsoft.com/en-us/sql/odbc/reference/develop-app/c-data-types-in-odbc?view=sql-server-ver16

C Data Type Extensibility
In ODBC 3.8, you can specify driver-specific C data types ........
..........
...........
A C data type is defined in the driver as follows:

The ODBC compliance level for an application, ODBC driver, and Driver Manager is 3.8 (or higher).

The data range of a driver-specific C type is between 0x4000 and 0x7FFF.

The driver defines the structure of the data corresponding to the C type. This can be done in the driver-specific SDK.

The driver manager will not validate a C type defined in the range of 0x4000 and 0x7FFF; the driver will perform the validation and any data type conversion. But if the data range of a C type passed to the driver manager is between 0x0000 and 0x3FFF or between 0x8000 and 0xFFFF, the driver manager will validate the C data type.

@lurcher
Copy link
Owner

lurcher commented Feb 3, 2023 via email

@TallTed
Copy link

TallTed commented Feb 6, 2023

It may be worth noting that ODBC 3.8 is a typo; this should actually read ODBC 3.80.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants