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

Fix #5439 bug PrettySpace format #5560

Merged
merged 3 commits into from Jun 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions dbms/src/Formats/PrettySpaceBlockOutputStream.cpp
Expand Up @@ -7,7 +7,6 @@
namespace DB
{


void PrettySpaceBlockOutputStream::write(const Block & block)
{
UInt64 max_rows = format_settings.pretty.max_rows;
Expand All @@ -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.
Copy link
Contributor Author

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).

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is really important.

Copy link
Contributor Author

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?

Copy link
Contributor Author

@stavrolia stavrolia Jun 8, 2019

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?

Copy link
Member

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.

if (terminal_width > 80)
for (size_t i = 0; i < columns; ++i)
if (max_widths[i] > terminal_width / 2)
max_widths[i] = terminal_width / 2;

/// Names
for (size_t i = 0; i < columns; ++i)
{
Expand Down
1 change: 1 addition & 0 deletions dbms/tests/performance/select_format.xml
Expand Up @@ -40,6 +40,7 @@
<value>PrettyCompact</value>
<value>PrettyCompactMonoBlock</value>
<value>PrettyNoEscapes</value>
<value>PrettySpace</value>
<value>RowBinary</value>
<value>Native</value>
<value>XML</value>
Expand Down