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

database/sql : Unsigned integer for affected rows and last insert id #49311

Closed
Naidile-P-N opened this issue Nov 3, 2021 · 4 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@Naidile-P-N
Copy link

RowsAffected() (int64, error)

Affected rows are always positive and usually the auto increment ID is preferred to be positive, so can we have new unsigned fields for these two props in the result

Issue for similar change in go-sql-driver/mysql : go-sql-driver/mysql#1278

@Naidile-P-N Naidile-P-N changed the title Unsigned integer for affected rows and last insert id Proposal : Unsigned integer for affected rows and last insert id Nov 3, 2021
@Naidile-P-N Naidile-P-N changed the title Proposal : Unsigned integer for affected rows and last insert id Unsigned integer for affected rows and last insert id Nov 3, 2021
@Naidile-P-N Naidile-P-N changed the title Unsigned integer for affected rows and last insert id database/sql : Unsigned integer for affected rows and last insert id Nov 3, 2021
@Naidile-P-N
Copy link
Author

Would like to contribute if accepted

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 3, 2021
@thanm
Copy link
Contributor

thanm commented Nov 3, 2021

Thanks for raising this issue.

Use of unsigned would seem to make sense as you point out, but unless I am misreading the code, making such a change would wind up breaking the Go compatibility guarantee, set out in https://golang.org/doc/go1compat.

@bradfitz @kardianos

@Naidile-P-N
Copy link
Author

@thanm Yes. Updating existing fields wouldn't be feasible, we may introduce new properties though.

@ianlancetaylor
Copy link
Contributor

In general Go prefers to use signed integers for numeric values, even if those values can never be negative.

This is because computer arithmetic, as compared to ordinary arithmetic, always has strange behaviors at some point. For signed types the strange behavior is at very large or very small values. For unsigned types the strange behavior is at zero. In practice numbers close to 0 are much much more common than numbers that are very large or very small. So it's better to use signed types.

Closing because we can't make this change in any case, as it would break the compatibility guidelines.

@golang golang locked and limited conversation to collaborators Nov 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants