| 152 | } |
| 153 | |
| 154 | void deserializeImpl( |
| 155 | IColumn & column, ReadBuffer & istr, const FormatSettings & settings, std::function<bool(ReadBuffer &)> check_end_of_value) |
| 156 | { |
| 157 | ColumnUInt8 * col = checkAndGetDeserializeColumnType(column); |
| 158 | |
| 159 | PeekableReadBuffer buf(istr); |
| 160 | buf.setCheckpoint(); |
| 161 | if (checkString(settings.bool_true_representation, buf) && check_end_of_value(buf)) |
| 162 | { |
| 163 | col->insert(true); |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | buf.rollbackToCheckpoint(); |
| 168 | if (checkString(settings.bool_false_representation, buf) && check_end_of_value(buf)) |
| 169 | { |
| 170 | col->insert(false); |
| 171 | buf.dropCheckpoint(); |
| 172 | if (buf.hasUnreadData()) |
| 173 | throw Exception( |
| 174 | ErrorCodes::CANNOT_PARSE_BOOL, |
| 175 | "Cannot continue parsing after parsed bool value because it will result in the loss of some data. It may happen if " |
| 176 | "bool_true_representation or bool_false_representation contains some delimiters of input format"); |
| 177 | return; |
| 178 | } |
| 179 | |
| 180 | buf.rollbackToCheckpoint(); |
| 181 | if (tryDeserializeAllVariants(col, buf) && check_end_of_value(buf)) |
| 182 | { |
| 183 | buf.dropCheckpoint(); |
| 184 | if (buf.hasUnreadData()) |
| 185 | throw Exception( |
| 186 | ErrorCodes::CANNOT_PARSE_BOOL, |
| 187 | "Cannot continue parsing after parsed bool value because it will result in the loss of some data. It may happen if " |
| 188 | "bool_true_representation or bool_false_representation contains some delimiters of input format"); |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | buf.makeContinuousMemoryFromCheckpointToPos(); |
| 193 | buf.rollbackToCheckpoint(); |
| 194 | throw Exception( |
| 195 | ErrorCodes::CANNOT_PARSE_BOOL, |
| 196 | "Cannot parse boolean value here: '{}', should be '{}' or '{}' controlled by setting bool_true_representation and " |
| 197 | "bool_false_representation or one of " |
| 198 | "True/False/T/F/Y/N/Yes/No/On/Off/Enable/Disable/Enabled/Disabled/1/0", |
| 199 | String(buf.position(), std::min(10lu, buf.available())), |
| 200 | settings.bool_true_representation, settings.bool_false_representation); |
| 201 | } |
| 202 | |
| 203 | } |
| 204 |
no test coverage detected