From d4e5cd2004c656180a353b0cf2d320669453d027 Mon Sep 17 00:00:00 2001 From: Alexey Arno Date: Wed, 24 Aug 2016 19:52:17 +0300 Subject: [PATCH] dbms: Fixed issues with INSERT. [#METR-19266] --- dbms/src/DataTypes/DataTypeNullable.cpp | 51 +++++++++++++++---------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/dbms/src/DataTypes/DataTypeNullable.cpp b/dbms/src/DataTypes/DataTypeNullable.cpp index 7e6c83e9f4e..a9bae32493b 100644 --- a/dbms/src/DataTypes/DataTypeNullable.cpp +++ b/dbms/src/DataTypes/DataTypeNullable.cpp @@ -17,11 +17,13 @@ namespace /// we use for the binary deserialization. They are used as follows: /// /// auto action = NullDeserializer::execute(col, istr); -/// if (action != Action::NONE) -/// { +/// +/// if (action == Action::NONE) /// eof +/// return; +/// else if (action == Action::ADD_ORDINARY) /// add an ordinary value /// ... deserialize the nested column ... -/// updateNullMap(col, action); -/// } +/// +/// updateNullMap(col, action); /// /// This two-step process is required because when we perform an INSERT query /// whose values are expressions, ValuesRowInputStream attempts to deserialize @@ -135,11 +137,13 @@ void DataTypeNullable::deserializeTextEscaped(IColumn & column, ReadBuffer & ist ColumnNullable & col = static_cast(column); auto action = NullDeserializer::execute(col, istr); - if (action != Action::NONE) - { + + if (action == Action::NONE) + return; + else if (action == Action::ADD_ORDINARY) nested_data_type->deserializeTextEscaped(*col.getNestedColumn(), istr); - updateNullMap(col, action); - } + + updateNullMap(col, action); } void DataTypeNullable::serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr) const @@ -157,11 +161,14 @@ void DataTypeNullable::deserializeTextQuoted(IColumn & column, ReadBuffer & istr ColumnNullable & col = static_cast(column); auto action = NullDeserializer::execute(col, istr); - if (action != Action::NONE) - { + + if (action == Action::NONE) + return; + else if (action == Action::ADD_ORDINARY) nested_data_type->deserializeTextQuoted(*col.getNestedColumn(), istr); - updateNullMap(col, action); - } + + updateNullMap(col, action); + } void DataTypeNullable::serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr) const @@ -179,11 +186,13 @@ void DataTypeNullable::deserializeTextCSV(IColumn & column, ReadBuffer & istr, c ColumnNullable & col = static_cast(column); auto action = NullDeserializer::execute(col, istr); - if (action != Action::NONE) - { + + if (action == Action::NONE) + return; + else if (action == Action::ADD_ORDINARY) nested_data_type->deserializeTextCSV(*col.getNestedColumn(), istr, delimiter); - updateNullMap(col, action); - } + + updateNullMap(col, action); } void DataTypeNullable::serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr) const @@ -211,11 +220,13 @@ void DataTypeNullable::deserializeTextJSON(IColumn & column, ReadBuffer & istr) ColumnNullable & col = static_cast(column); auto action = NullDeserializer::execute(col, istr); - if (action != Action::NONE) - { + + if (action == Action::NONE) + return; + else if (action == Action::ADD_ORDINARY) nested_data_type->deserializeTextJSON(*col.getNestedColumn(), istr); - updateNullMap(col, action); - } + + updateNullMap(col, action); } void DataTypeNullable::serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr) const