Skip to content

Improve mapping of SQL integer types to C corresponding types - #370

Open
mloskot wants to merge 14 commits into
nanodbc:mainfrom
mloskot:ml/fine-grain-numeric-types-mapping
Open

Improve mapping of SQL integer types to C corresponding types#370
mloskot wants to merge 14 commits into
nanodbc:mainfrom
mloskot:ml/fine-grain-numeric-types-mapping

Conversation

@mloskot

@mloskot mloskot commented Jan 25, 2023

Copy link
Copy Markdown
Member
  • Fine-grained mapping of SQL integer types to C corresponding types
  • Add reading of missing C data types for integers
  • Distinguish SQL_C_BIT data type for reading
  • Prefer mapping of SQL_C_* types to fixed-width integer types
  • Ensure SQL_C_SHORT and SQL_C_LONG are mapped to fixed-width variant types
  • Refine reading of SQL_C_TINYINT into int8_t instead of int16_t
  • Refine reading of SQL_C_BIT into int8_t
  • Make auto-binding of numeric columns signedness-aware

References

Closes #369

@mloskot mloskot self-assigned this Jan 25, 2023
@mloskot
mloskot requested a review from lexicalunit January 25, 2023 12:25
@mloskot mloskot changed the title ml/fine grain numeric types mapping Fine-grained mapping of SQL integer types to C corresponding types Jan 25, 2023
@mloskot mloskot changed the title Fine-grained mapping of SQL integer types to C corresponding types Improve mapping of SQL integer types to C corresponding types Jan 25, 2023
@mloskot mloskot added this to the 2.15+ milestone Jan 25, 2023
mloskot added a commit to Cadcorp/nanodbc that referenced this pull request Jan 25, 2023
Porting nanodbc#370

Fine-grained mapping of SQL integer types to C corresponding types
Add reading of missing C data types for integers
Distinguish SQL_C_BIT data type for reading
Prefer mapping of SQL_C_* types to fixed-width integer types
Ensure SQL_C_SHORT and SQL_C_LONG are mapped to fixed-width variant types
test: Catch up with improved integer types mapping
Refine reading of SQL_C_TINYINT into int8_t instead of int16_t
The int16_t may lead to numeric garbage for values at range boundaries.
tests: Refine SQLite tests for integer types
mloskot added a commit to Cadcorp/nanodbc that referenced this pull request Jan 26, 2023
Porting nanodbc#370

Fine-grained mapping of SQL integer types to C corresponding types
Add reading of missing C data types for integers
Distinguish SQL_C_BIT data type for reading
Prefer mapping of SQL_C_* types to fixed-width integer types
Ensure SQL_C_SHORT and SQL_C_LONG are mapped to fixed-width variant types
test: Catch up with improved integer types mapping
Refine reading of SQL_C_TINYINT into int8_t instead of int16_t
The int16_t may lead to numeric garbage for values at range boundaries.
tests: Refine SQLite tests for integer types
Fix size of output value read for SQL_C_BIT data
@mloskot
mloskot force-pushed the ml/fine-grain-numeric-types-mapping branch 2 times, most recently from e41d33a to 6b7c309 Compare February 4, 2023 14:01

@lexicalunit lexicalunit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mloskot
mloskot force-pushed the ml/fine-grain-numeric-types-mapping branch from 6b7c309 to 11430cf Compare August 2, 2023 20:17
Comment thread nanodbc/nanodbc.cpp
case SQL_C_SLONG:
result = *(ensure_pdata<int32_t>(column));
{
long d = *(ensure_pdata<int32_t>(column));

Check warning

Code scanning / PREfast

The variable 'd' does not change after construction, mark it as const (con.4).

The variable 'd' does not change after construction, mark it as const (con.4).
@mloskot
mloskot force-pushed the ml/fine-grain-numeric-types-mapping branch from 11430cf to 74cf4b5 Compare August 2, 2023 21:04
@mloskot
mloskot force-pushed the ml/fine-grain-numeric-types-mapping branch from 74cf4b5 to 3a86690 Compare August 2, 2023 21:07
@marlowa

marlowa commented Aug 6, 2026

Copy link
Copy Markdown

This work looks good. The work was done and approved over 3 years ago. Is it going to make it into a release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve auto_bind_columns to recognise fine-grained types

4 participants