Skip to content

ODBC: SYS COLUMNS column types alignment #35376

@bpintea

Description

@bpintea

SYS COLUMNS maps on the ODBC catalog function SQLColumns(). This function prepares a table for the application to subsequently fetch. The table definition is given within the spec.

Current SYS COLUMNS implementation is aligned with the spec with the exception of the following columns, that are all returned as integer, while the application expects them as "Smallint" (i.e. SQL SHORT): DATA_TYPE, DECIMAL_DIGITS , NUM_PREC_RADIX, NULLABLE, SQL_DATA_TYPE, SQL_DATETIME_SUB.

This misalignment is problematic for the applications that:

  • don't specify a particular type for the driver to convert the result to, but leave it to "default" (meaning "whatever type is in the DB"), but who also
  • provide a buffer for the result which is aligned to the standard.

For example: when fetching DATA_TYPE value, the application provides a two byte buffer (to accommodate the SHORT). Leaving the conversion to "default", the driver would then try to access a four byte buffer, corresponding to DB's INTEGER, which eventually leads to a failure.

Now, this application behavior is not really correct (and the spec advises against using "default" data type, but this is too late for 2.x applications). However, this problem can be mitigated if we aligned our types with the spec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions