Skip to content

fix: promote unsigned integers to double to prevent overflow - #413

Closed
philtran wants to merge 9 commits into
r-dbi:mainfrom
philtran:unsigned_int
Closed

philtran wants to merge 9 commits into
r-dbi:mainfrom
philtran:unsigned_int

Conversation

@philtran

Copy link
Copy Markdown

Attempt to fix #412 , #171 , #132

Adds is_unsigned parameter to variable_type_from_field_type, and for unsigned ints (MYSQL_TYPE_LONG), will promote to MY_DBL instead of MY_INT32

@philtran

Copy link
Copy Markdown
Author

@krlmlr Are you the best person to ask to look at/review this?

@krlmlr

krlmlr commented Nov 12, 2025

Copy link
Copy Markdown
Member

Thanks for the initiative and for your patience.

It's not clear to me that all users of the "unsigned" data type will want it to map to double, on the off chance that the values exceed 2^31-1. In other packages I've been exploring ways to configure handling of type conversion in an argument to dbConnect(). Let me think about how to standardize this; I'm also happy to review a proposal.

@krlmlr

krlmlr commented Nov 29, 2026

Copy link
Copy Markdown
Member

Thank you for your contribution.

I'd like to move away from the bigint argument altogether and return an ALTREP vector that can store data losslessly and coerce to whatever type the application requires. In #639, unsigned ints will be just returned as doubles. With ALTREP, this can then be coerced to an integer or a string without materializing the doubles.

@krlmlr krlmlr closed this Nov 29, 2026
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

Successfully merging this pull request may close these issues.

Large Unsigned ints Overflow issue revised Raise error if data type domain differs between R and database Overflow Issue - Large Unsigned Integers

2 participants