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

Make types.StrictFlags more strict #47829

Closed
Tracked by #47355
lcwangchao opened this issue Oct 20, 2023 · 0 comments · Fixed by #47842
Closed
Tracked by #47355

Make types.StrictFlags more strict #47829

lcwangchao opened this issue Oct 20, 2023 · 0 comments · Fixed by #47842
Assignees
Labels
sig/sql-infra SIG: SQL Infra type/enhancement The issue or PR belongs to an enhancement.

Comments

@lcwangchao
Copy link
Collaborator

lcwangchao commented Oct 20, 2023

types.StrictFlags is not "strict" in the strict sense beacuse of flag FlagClipNegativeToZero

The flag FlagClipNegativeToZero is zero in types.StrictFlags. It means when converting an negative to unsigned, the cast will succeed without any error or warning.

For example, if we converting -1 to unsigned. The types.StrictFlags will cast it to the max int value. Only if we set FlagClipNegativeToZero to 1, it will be recognized as an overflow error.

It's better to remove FlagClipNegativeToZero and introduce a new flag FlagAllowNegativeToUnsigned to replace it. When FlagAllowNegativeToUnsigned is not set by default, converting a negative value to unsigned will return an overflow error, otherwise, the negative value will be casted to an relatives positive value

@lcwangchao lcwangchao self-assigned this Oct 20, 2023
@lcwangchao lcwangchao added type/enhancement The issue or PR belongs to an enhancement. sig/sql-infra SIG: SQL Infra labels Oct 20, 2023
ti-chi-bot bot pushed a commit that referenced this issue Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant