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

How to disable prepared statements #389

Closed
katcipis opened this issue Sep 3, 2015 · 5 comments
Closed

How to disable prepared statements #389

katcipis opened this issue Sep 3, 2015 · 5 comments

Comments

@katcipis
Copy link

katcipis commented Sep 3, 2015

I had some troubles integrating with a pgbouncer that did not had support for prepared statements, I researched a little and found this:

http://stackoverflow.com/questions/17614441/pq-driver-prepared-statement-does-not-exist

Is there a way to disable prepared statements on the driver ?

@johto
Copy link
Contributor

johto commented Sep 3, 2015

Is there a way to disable prepared statements on the driver ?

pgbouncer should be able to deal with what pq does if the (unfortunately undocumented) option binary_parameters added here is turned on. This has, however, some effects on your application; whenever it passes a byte slice as a parameter, it's assumed to be in the binary input format instead of textual.

@katcipis
Copy link
Author

katcipis commented Sep 3, 2015

Thanks @johto

@rskumar
Copy link

rskumar commented Aug 30, 2018

If you turn binary_parameters on, you cannot save JSONB data in PG.

@jonomacd
Copy link

@rskumar did you ever find a solution for this? We are hoping to use pgbouncer but we also use JSONB.

@tobischo
Copy link

If you turn binary_parameters on, you cannot save JSONB data in PG.

Maybe to add to this:
It seems to work if you typecast the []byte slice to string before passing it into Execute/Query/...

e.g.

jsonbData, err = json.Marshal(someStruct)

row := db.QueryRow(
  UpdateQuery,
  id,
  string(jsonbData),
)

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

No branches or pull requests

5 participants