| 67 | |
| 68 | template <typename F> |
| 69 | static void addElementSafe(size_t num_elems, IColumn & column, F && impl) |
| 70 | { |
| 71 | /// We use the assumption that tuples of zero size do not exist. |
| 72 | size_t old_size = column.size(); |
| 73 | |
| 74 | try |
| 75 | { |
| 76 | impl(); |
| 77 | |
| 78 | // Check that all columns now have the same size. |
| 79 | size_t new_size = column.size(); |
| 80 | for (auto i : collections::range(1, num_elems)) |
| 81 | { |
| 82 | const auto & element_column = extractElementColumn(column, i); |
| 83 | if (element_column.size() != new_size) |
| 84 | { |
| 85 | // This is not a logical error because it may work with |
| 86 | // user-supplied data. |
| 87 | throw Exception(ErrorCodes::SIZES_OF_COLUMNS_IN_TUPLE_DOESNT_MATCH, |
| 88 | "Cannot read a tuple because not all elements are present"); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | catch (...) |
| 93 | { |
| 94 | for (const auto & i : collections::range(0, num_elems)) |
| 95 | { |
| 96 | auto & element_column = extractElementColumn(column, i); |
| 97 | if (element_column.size() > old_size) |
| 98 | element_column.popBack(1); |
| 99 | } |
| 100 | |
| 101 | throw; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | void SerializationTuple::deserializeBinary(IColumn & column, ReadBuffer & istr) const |
| 106 | { |
no test coverage detected