This commit is contained in:
Ivan Lezhankin 2021-04-16 20:49:38 +03:00
parent bb1c2ae576
commit 7f43dddf0b
4 changed files with 13 additions and 12 deletions

View File

@ -40,6 +40,7 @@ InputStreamFromASTInsertQuery::InputStreamFromASTInsertQuery(
format = "Values";
}
/// NOTE: can't create an input-format with empty buffer here, because parallel input-format starts to read immediately.
res_stream = context->getInputFormat(format, input_buffer, header, context->getSettings().max_insert_block_size);
if (context->getSettingsRef().input_format_defaults_for_omitted_fields && ast_insert_query->table_id && !input_function)

View File

@ -13,7 +13,7 @@ class ReadBufferFromString : public ReadBufferFromMemory
public:
/// std::string or something similar
template <typename S>
ReadBufferFromString(const S & s) : ReadBufferFromMemory(s.data(), s.size()) {}
explicit ReadBufferFromString(const S & s) : ReadBufferFromMemory(s.data(), s.size()) {}
};
}

View File

@ -165,14 +165,22 @@ void assertEOF(ReadBuffer & buf);
[[noreturn]] void throwAtAssertionFailed(const char * s, ReadBuffer & buf);
inline bool checkChar(char c, ReadBuffer & buf)
{
char a;
if (!buf.peek(a) || a != c)
return false;
buf.ignore();
return true;
}
inline void assertChar(char symbol, ReadBuffer & buf)
{
if (buf.eof() || *buf.position() != symbol)
if (!checkChar(symbol, buf))
{
char err[2] = {symbol, '\0'};
throwAtAssertionFailed(err, buf);
}
++buf.position();
}
inline void assertString(const String & s, ReadBuffer & buf)
@ -186,14 +194,6 @@ inline bool checkString(const String & s, ReadBuffer & buf)
return checkString(s.c_str(), buf);
}
inline bool checkChar(char c, ReadBuffer & buf)
{
if (buf.eof() || *buf.position() != c)
return false;
++buf.position();
return true;
}
bool checkStringCaseInsensitive(const char * s, ReadBuffer & buf);
inline bool checkStringCaseInsensitive(const String & s, ReadBuffer & buf)
{

View File

@ -36,7 +36,7 @@ static void skipTSVRow(ReadBuffer & in, const size_t num_columns)
*/
static void checkForCarriageReturn(ReadBuffer & in)
{
if (in.position()[0] == '\r' || (in.position() != in.buffer().begin() && in.position()[-1] == '\r'))
if (!in.eof() && (in.position()[0] == '\r' || (in.position() != in.buffer().begin() && in.position()[-1] == '\r')))
throw Exception("\nYou have carriage return (\\r, 0x0D, ASCII 13) at end of first row."
"\nIt's like your input data has DOS/Windows style line separators, that are illegal in TabSeparated format."
" You must transform your file to Unix format."