Allow zero-sized buffers to be set to read queries
Although it is not useful to set a zero-sized buffer to a read query, from a correctness standpoint it should still be doable. Also in case the result is empty (e.g., in sparse arrays), the query must gracefully complete, rather than being marked as incomplete.
cc @prakhar0402
A related issue is that it would be nice to support passing a vector which is pre-allocated with std::vector::reserve. Passing such a vector to set_buffer currently fails in the same way as a true zero-element buffer, because we check buf.size() rather than buf.capacity(). (maybe that change is simple enough to do separately on its own, but I'm not sure if there would be any broader implications)
@ihnorton for the C++ API I don't think we can use buf.capacity() for the check, as there's no way for us to set the size of a std::vector after reading elements into its backing memory (without overwriting).