clickhouse.rs icon indicating copy to clipboard operation
clickhouse.rs copied to clipboard

`Query::fetch_one()` and `Query::fetch_optional()` can still finish successfully even in the case of schema mismatch

Open slvrtrn opened this issue 1 year ago • 1 comments

From the https://github.com/ClickHouse/clickhouse-rs/pull/186#discussion_r1874799957:

Query::fetch_one() and Query::fetch_optional() can still finish successfully even in the case of schema mismatch, because they don't read the whole response. This is a trade-off made ages ago to avoid parsing unused bytes.

Should we also revise that behavior? By the way, if the server returns a lot of rows (or large ones), it's possible to get EPIPE errors on the server side (because not all bytes are delivered).

We have several options here:

  • Parse all rows (better to detect the schema mismatch) and discard all besides the first one.
  • Don't parse them, but read the whole stream (to avoid EPIPE on the CH side).
  • Wait for Native/RowBinaryWithNAT for reliable error-detection.

slvrtrn avatar Dec 10 '24 15:12 slvrtrn

The same question applies to cursors that are not fully drained.

loyd avatar Dec 16 '24 06:12 loyd