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

Very edge case on sequences #2678

Closed
2 tasks done
PedroTadim opened this issue Nov 25, 2021 · 1 comment · Fixed by #2692
Closed
2 tasks done

Very edge case on sequences #2678

PedroTadim opened this issue Nov 25, 2021 · 1 comment · Fixed by #2692

Comments

@PedroTadim
Copy link
Contributor

What happens?

As promised, I will keep posting here the issues I find.
While testing a cleanup for sequences in MonetDB, I got an assertion about integer overflow in DuckDB. Basically I run over the int64 max value and it would be expectable to go back to the minimum value. I know this is an extreme case and you can close the issue if you don't find it relevant. If this should be fixed, we have to be careful to not introduce a new branch in the sequence values retrieval and possibly slow it down.

To Reproduce

create sequence ups7 INCREMENT BY 1 MINVALUE 9223372036854775800 MAXVALUE 9223372036854775807 CYCLE;
SELECT nextval('ups7') from generate_series(0,20);
src/function/scalar/sequence/nextval.cpp:47:17: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long int'

Environment (please complete the following information):

  • OS: Linux
  • DuckDB Version: Tip of master branch
  • DuckDB Client: shell

Before Submitting

  • Have you tried this on the latest master branch?
  • Python: pip install duckdb --upgrade --pre
  • R: install.packages("https://github.com/duckdb/duckdb/releases/download/master-builds/duckdb_r_src.tar.gz", repos = NULL)
  • Other Platforms: You can find binaries here or compile from source.
  • Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?
@Mytherin
Copy link
Collaborator

Thanks for the report! Indeed this is an edge case but undefined behavior should always be fixed.

Mytherin added a commit that referenced this issue Nov 30, 2021
Fix #2678: Fix undefined behavior for sequences close to INT64 min/INT64 max
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 a pull request may close this issue.

2 participants