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
Fix #5439 bug PrettySpace format #5560
Conversation
@@ -26,12 +25,6 @@ void PrettySpaceBlockOutputStream::write(const Block & block) | |||
Widths name_widths; | |||
calculateWidths(block, widths, max_widths, name_widths, format_settings); | |||
|
|||
/// Do not align on too long values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block affects only appearance, but it breaks the invariant "max_width[i] >= widths[i][j] for each j for each i" that leads to infinite loop at https://github.com/yandex/ClickHouse/blob/master/dbms/src/Formats/PrettyBlockOutputStream.cpp#L202
Subtracting unsigned integers (size_t) is problematic because it can easily lead to overflow (but here it makes this bug visible).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I want to save this behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is really important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain in more details the behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or I can just change result cycling loop from "a < b - c" to "a + c < b" here https://github.com/yandex/ClickHouse/blob/master/dbms/src/Formats/PrettyBlockOutputStream.cpp#L202 . It would save the behavior without infinite loop. @alexey-milovidov is it good in your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we have this logic:
https://github.com/yandex/ClickHouse/blob/master/dbms/src/Formats/PrettyBlockOutputStream.cpp#L64
the code you deleted is really obsolete and can be deleted for sure.
@@ -64,14 +57,12 @@ void PrettySpaceBlockOutputStream::write(const Block & block) | |||
} | |||
} | |||
writeCString("\n\n", ostr); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Irrelevant change.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
For changelog. Remove if this is non-significant change.
Short description (up to few sentences):
Fix infinite loop in pretty space format