Closed neeravbm closed 6 months ago
@neeravbm 。 No problem here. The callback may be called more than once. Your code should like this:
client.Select("SELECT * FROM tasks", [&taskId, &env, &error, &reset, &taskName, &detailsStr](const clickhouse::Block &block) {
if (block.GetRowCount() == 0) {
return;
}
taskName = block[1]->As<clickhouse::ColumnString>()->At(0);
detailsStr = block[2]->As<clickhouse::ColumnString>()->At(0);
});
@1261385937 It worked. Thanks! I think it'll be useful to update the example in README to reflect this.
I have the following code:
`
`
There are two rows in the task table. If I execute the same query via clickhouse client, I get the following result:
`
┌─────────id─┬─name──────────────────┬─details────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
The issue seems to be the following lines in the file client.cpp (line 617):
`
`
num_columns is set to 3 as expected but num_rows is set to 0.
I put a breakpoint and inspected the memory of input->arrayinput->data_.
The first line shows 03 at position 0x14c00c40a. This corresponds to num_columns. The next address has value 0 and based on the code, it should be equal to num_rows. But it's set to 0 instead of 2. As a result, num_rows is being set as 0 instead of 2. If you look at the values in memory, 2 is present in the next 4 bytes but I believe that corresponds to the length of the first column name and not num_rows.