rust-postgres: Error querying PgBouncer

PgBouncer seems to implement some, but not all, of the postgres protocol. Specifically, I was running into this error when trying to query it:

Db(DbError {
    severity: "ERROR",
    parsed_severity: None,
    code: ProtocolViolation,
    message: "unsupported pkt type: 80",
    detail: None,
    hint: None,
    position: None,
    where_: None,
    schema: None,
    table: None,
    column: None,
    datatype: None,
    constraint: None,
    file: None,
    line: None,
    routine: None
})

The error message is from PgBouncer internals (admin.c:1365). Basically, looks like the 'P' frame isn’t handled. This is generated from postgres_protocol::messages::frontend::parse.

Any suggestions on how to resolve?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (12 by maintainers)

Most upvoted comments

I have also encountered this issue, and have revised my code to use simple_query when used with pgbouncer. However, I notice that the documentation for simple_query states that it

should [not] be use[d] for any query which contains user-specified data, as they provided the functionality to safely embed that data in the request. Do not form statements via string concatenation and pass them to this method!

I’m a bit confused about how this interacts with the advice in this issue to use simple_query for all queries involving pgbouncer (since that will inevitably mean using simple_query with at least some user-provided data). Based on #575, it appears that rust-postgres does not currently provide a method for escaping user input when using simple_query; is that correct?

If so, what is the correct way to use pgbouncer for all Postgres queries (which, of course, includes queries with user-provided parameters)?

Thanks very much for any help and for rust-postgres as a whole!