Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single row mode streaming #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

fehrenbach
Copy link

This adds a version of foldWith that uses single row mode instead of a cursor under the hood.

The main benefit is that queries show up as themselves in logs and pg_stat_statements and the like (c.f., #100).

This PR doesn't yet define foldSingleRowMode and foldSingleRowMode_ (the versions using FromRow rather than an explicit parser). I'd be happy to add them or instead add a SingleRowMode constructor to FoldOptions. (Mild preference for the extra functions.)

@fehrenbach
Copy link
Author

It turns out that this is not really what I want. Ultimately I want to produce a servant stream, using its SourceT / StepT types. This means I need a right fold, not a left fold.

Right folds are awkward as an API because there is no guarantee that the combining function actually consumes all of the results. Not consuming all results means the connection is left in a bad state where the next query will complain that another command is already in progress. (This isn't that different from trying to execute another query in the combining function of a left fold, but it does seem worse somehow.)

If anyone has any clever ideas, please let me know.

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.

1 participant