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

bug(frontend): pgwire binary format for interval overflows #8041

Closed
Tracked by #8213
kwannoel opened this issue Feb 20, 2023 · 6 comments · Fixed by #8501
Closed
Tracked by #8213

bug(frontend): pgwire binary format for interval overflows #8041

kwannoel opened this issue Feb 20, 2023 · 6 comments · Fixed by #8501
Labels
found-by-sqlsmith help wanted Issues that need help from contributors type/bug Something isn't working
Milestone

Comments

@kwannoel
Copy link
Contributor

kwannoel commented Feb 20, 2023

Describe the bug

No response

To Reproduce

Execute a query in extended mode, to force binary format to be returned:

SELECT ((-2147483648) * (INTERVAL '86400'));

Expected behavior

No panic, return interval.

Interim workaround can be to use checked_mul to avoid panic.
But proper fix needs to avoid error.

Additional context

out.put_i64(self.ms * 1000);

https://bulidkite-artifacts-bucket.s3.amazonaws.com/9eed51d0-eaaf-4ea3-95a2-2e9e557607f6/01865e72-d4b3-425e-b291-836a1daf317c/01865e73-2536-4397-af1c-c0f6b20b9033/risedev-logs/fuzzing-4.log

@kwannoel kwannoel added type/bug Something isn't working found-by-sqlsmith labels Feb 20, 2023
@github-actions github-actions bot added this to the release-0.1.18 milestone Feb 20, 2023
@jon-chuang
Copy link
Contributor

It's supposed to be a decimal type, is that correct?

@kwannoel
Copy link
Contributor Author

It's supposed to be a decimal type, is that correct?

Not sure, see: https://github.com/postgres/postgres/blob/517bf2d9107f0d45c5fea2e3904e8d3b10ce6bb2/src/backend/utils/adt/timestamp.c#L1014

@kwannoel kwannoel added the help wanted Issues that need help from contributors label Feb 20, 2023
@xiangjinwu
Copy link
Contributor

#4514
It should be an overflow error during *, rather than during to_sql. I think we can checked_mul here first.

@xiangjinwu
Copy link
Contributor

This has been fixed "automatically" by #8501, as binary formatting no longer requires any calculation, and the multiplication already handles the error reporting properly.

Before closing this issue as resolved, are there disabled test cases that we want to re-enable?

@kwannoel
Copy link
Contributor Author

kwannoel commented Mar 15, 2023

This has been fixed "automatically" by #8501, as binary formatting no longer requires any calculation, and the multiplication already handles the error reporting properly.

Before closing this issue as resolved, are there disabled test cases that we want to re-enable?

@kwannoel
Copy link
Contributor Author

kwannoel commented Mar 15, 2023

Currently sqlsmith does not test binary format at all, since I have changed it to use simple_query to avoid binary_format errors.

Will add it back eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
found-by-sqlsmith help wanted Issues that need help from contributors type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants