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

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

mloskot
Copy link
Member

@mloskot mloskot commented Jan 25, 2023

  • 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 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
Copy link
Contributor

@lexicalunit lexicalunit left a comment

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
break;
case SQL_C_LONG:
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). Warning

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
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
2 participants