mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
Fix segfault in formatRow function
This commit is contained in:
parent
901ebcede6
commit
62c5951dd7
@ -8,6 +8,7 @@
|
||||
#include <IO/WriteBufferFromVector.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Processors/Formats/IOutputFormat.h>
|
||||
#include <Processors/Formats/IRowOutputFormat.h>
|
||||
#include <base/map.h>
|
||||
|
||||
|
||||
@ -18,6 +19,7 @@ namespace ErrorCodes
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
|
||||
extern const int UNKNOWN_FORMAT;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -70,6 +72,11 @@ public:
|
||||
writeChar('\0', buffer);
|
||||
offsets[row] = buffer.count();
|
||||
});
|
||||
|
||||
/// This function make sense only for row output formats.
|
||||
if (!dynamic_cast<IRowOutputFormat *>(out.get()))
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Cannot turn rows into a {} format strings. {} function supports only row output formats", format_name, getName());
|
||||
|
||||
out->write(arg_columns);
|
||||
return col_str;
|
||||
}
|
||||
|
5
tests/queries/0_stateless/02113_format_row_bug.sql
Normal file
5
tests/queries/0_stateless/02113_format_row_bug.sql
Normal file
@ -0,0 +1,5 @@
|
||||
select formatRow('ORC', number, toDate(number)) from numbers(5); -- { serverError 36 }
|
||||
select formatRow('Parquet', number, toDate(number)) from numbers(5); -- { serverError 36 }
|
||||
select formatRow('Arrow', number, toDate(number)) from numbers(5); -- { serverError 36 }
|
||||
select formatRow('Native', number, toDate(number)) from numbers(5); -- { serverError 36 }
|
||||
|
Loading…
Reference in New Issue
Block a user