| 215 | |
| 216 | |
| 217 | Block MySQLBlockInputStream::readImpl() |
| 218 | { |
| 219 | auto row = connection->result.fetch(); |
| 220 | if (!row) |
| 221 | { |
| 222 | if (settings->auto_close) |
| 223 | connection->entry.disconnect(); |
| 224 | |
| 225 | return {}; |
| 226 | } |
| 227 | |
| 228 | MutableColumns columns(description.sample_block.columns()); |
| 229 | for (const auto i : collections::range(0, columns.size())) |
| 230 | columns[i] = description.sample_block.getByPosition(i).column->cloneEmpty(); |
| 231 | |
| 232 | size_t num_rows = 0; |
| 233 | size_t read_bytes_size = 0; |
| 234 | |
| 235 | while (row) |
| 236 | { |
| 237 | for (size_t index = 0; index < position_mapping.size(); ++index) |
| 238 | { |
| 239 | const auto value = row[position_mapping[index]]; |
| 240 | const auto & sample = description.sample_block.getByPosition(index); |
| 241 | |
| 242 | bool is_type_nullable = description.types[index].second; |
| 243 | |
| 244 | if (!value.isNull()) |
| 245 | { |
| 246 | if (is_type_nullable) |
| 247 | { |
| 248 | ColumnNullable & column_nullable = assert_cast<ColumnNullable &>(*columns[index]); |
| 249 | const auto & data_type = assert_cast<const DataTypeNullable &>(*sample.type); |
| 250 | insertValue(*data_type.getNestedType(), column_nullable.getNestedColumn(), description.types[index].first, value, read_bytes_size); |
| 251 | column_nullable.getNullMapData().emplace_back(false); |
| 252 | } |
| 253 | else |
| 254 | { |
| 255 | insertValue(*sample.type, *columns[index], description.types[index].first, value, read_bytes_size); |
| 256 | } |
| 257 | } |
| 258 | else |
| 259 | { |
| 260 | insertDefaultValue(*columns[index], *sample.column); |
| 261 | |
| 262 | if (is_type_nullable) |
| 263 | { |
| 264 | ColumnNullable & column_nullable = assert_cast<ColumnNullable &>(*columns[index]); |
| 265 | column_nullable.getNullMapData().back() = true; |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | ++num_rows; |
| 271 | if (num_rows == settings->max_read_mysql_row_nums || (settings->max_read_mysql_bytes_size && read_bytes_size >= settings->max_read_mysql_bytes_size)) |
| 272 | break; |
| 273 | |
| 274 | row = connection->result.fetch(); |
nothing calls this directly
no test coverage detected