mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Do not crash if the row template file is empty.
This commit is contained in:
parent
ba7ab32098
commit
55be790199
@ -16,20 +16,10 @@ namespace ErrorCodes
|
|||||||
|
|
||||||
ParsedTemplateFormatString::ParsedTemplateFormatString(const FormatSchemaInfo & schema, const ColumnIdxGetter & idx_by_name)
|
ParsedTemplateFormatString::ParsedTemplateFormatString(const FormatSchemaInfo & schema, const ColumnIdxGetter & idx_by_name)
|
||||||
{
|
{
|
||||||
try
|
ReadBufferFromFile schema_file(schema.absoluteSchemaPath(), 4096);
|
||||||
{
|
String format_string;
|
||||||
ReadBufferFromFile schema_file(schema.absoluteSchemaPath(), 4096);
|
readStringUntilEOF(format_string, schema_file);
|
||||||
String format_string;
|
parse(format_string, idx_by_name);
|
||||||
readStringUntilEOF(format_string, schema_file);
|
|
||||||
parse(format_string, idx_by_name);
|
|
||||||
}
|
|
||||||
catch (DB::Exception & e)
|
|
||||||
{
|
|
||||||
if (e.code() != ErrorCodes::INVALID_TEMPLATE_FORMAT)
|
|
||||||
throwInvalidFormat(e.message(), columnsCount());
|
|
||||||
else
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -193,8 +183,11 @@ const char * ParsedTemplateFormatString::readMayBeQuotedColumnNameInto(const cha
|
|||||||
String ParsedTemplateFormatString::dump() const
|
String ParsedTemplateFormatString::dump() const
|
||||||
{
|
{
|
||||||
WriteBufferFromOwnString res;
|
WriteBufferFromOwnString res;
|
||||||
res << "Delimiter " << 0 << ": ";
|
res << "\nDelimiter " << 0 << ": ";
|
||||||
verbosePrintString(delimiters.front().c_str(), delimiters.front().c_str() + delimiters.front().size(), res);
|
if (delimiters.size() <= 1)
|
||||||
|
res << "<ERROR>";
|
||||||
|
else
|
||||||
|
verbosePrintString(delimiters[0].c_str(), delimiters[0].c_str() + delimiters[0].size(), res);
|
||||||
|
|
||||||
size_t num_columns = std::max(formats.size(), format_idx_to_column_idx.size());
|
size_t num_columns = std::max(formats.size(), format_idx_to_column_idx.size());
|
||||||
for (size_t i = 0; i < num_columns; ++i)
|
for (size_t i = 0; i < num_columns; ++i)
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
select 1 format Template settings format_template_row='01070_nonexistent_file.txt'; -- { clientError 107 }
|
||||||
|
select 1 format Template settings format_template_row='/dev/null'; -- { clientError 474 }
|
Loading…
Reference in New Issue
Block a user