Check that position always advances

This commit is contained in:
Ivan Lezhankin 2021-02-04 17:46:46 +03:00
parent 3b52b04008
commit ee0ff755e2
4 changed files with 11 additions and 5 deletions

View File

@ -1719,7 +1719,7 @@ private:
}
// Remember where the data ended. We use this info later to determine
// where the next query begins.
parsed_insert_query->end = data_in.buffer().begin() + data_in.count();
parsed_insert_query->end = parsed_insert_query->data + data_in.count();
}
else if (!is_interactive)
{

View File

@ -1,4 +1,5 @@
#include <IO/LimitReadBuffer.h>
#include <Common/Exception.h>
@ -13,6 +14,8 @@ namespace ErrorCodes
bool LimitReadBuffer::nextImpl()
{
assert(position() >= in.position());
/// Let underlying buffer calculate read bytes in `next()` call.
in.position() = position();
@ -25,7 +28,10 @@ bool LimitReadBuffer::nextImpl()
}
if (!in.next())
{
working_buffer = in.buffer();
return false;
}
working_buffer = in.buffer();

View File

@ -58,9 +58,9 @@ public:
bytes += offset();
bool res = nextImpl();
if (!res)
working_buffer.resize(0);
pos = working_buffer.begin() + nextimpl_working_buffer_offset;
working_buffer = Buffer(pos, pos);
else
pos = working_buffer.begin() + nextimpl_working_buffer_offset;
nextimpl_working_buffer_offset = 0;
return res;
}

View File

@ -30,7 +30,7 @@ private:
const char * getName() const override { return "INSERT query"; }
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
public:
ParserInsertQuery(const char * end_) : end(end_) {}
explicit ParserInsertQuery(const char * end_) : end(end_) {}
};
/** Insert accepts an identifier and an asterisk with variants.