Skip to content

Conversation

@fishcakez
Copy link
Member

  • Add declare(!)/3,4
  • Add fetch(!)/3,4
  • Add deallocate(!)/3,4

Explicitly defining handle_first/4 and handle_next/4 is deprecated
because callback implementations that are required to differentiate also
need to track cursors in their state. A single fetch/4 is cleaner to use
and these callbacks forward to handle_fetch/4 on use DBConnection.

For first/next/fetch the return value is {:cont | :halt, result, state}
where :cont is continue (same as :ok) and :haltmeans both that the cursor has finished enumerating results and the cursor is deallocated. Therefore:haltdoes not require adeallocatecall. This API is chosen to avoid an extra roundtrip that current adapters do. handle_first/4 and handle_next/4 still support:okand:deallocate`
tuples.

A callback implementation may need to deallocate if the transaction ends
without a cursor being deallocated (via fetch/4 or deallocate/4).

* Add declare(!)/3,4
* Add fetch(!)/3,4
* Add deallocate(!)/3,4

Explicitly defining handle_first/4 and handle_next/4 is deprecated
because callback implementations that are required to differentiate also
need to track cursors in their state. A single fetch/4 is cleaner to use
and these callbacks forward to handle_fetch/4 on `use DBConnection`.

For first/next/fetch the return value is `{:cont | :halt, result, state}`
where `:cont` is continue (same as :ok`) and `:halt` means both that the
cursor has finished enumerating results and the cursor is deallocated.
Therefore `:halt` does not require a `deallocate` call. This API is
chosen to avoid an extra roundtrip that current adapters do.
handle_first/4 and handle_next/4 still support `:ok` and `:deallocate`
tuples.

A callback implementation may need to deallocate if the transaction ends
without a cursor being deallocated (via `fetch/4` or `deallocate/4`).
@fishcakez fishcakez merged commit 664d962 into master Jul 11, 2017
@fishcakez fishcakez deleted the jf-public-cursor branch July 11, 2017 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants