Diesel Error: prepared statement "__diesel_stmt_0" already exists or unnamed prepared statement does not exist #3575
-
Hi all, I am using r2d2 postgres connection pool and diesel. I am running into a situation where one function that uses sql_query() randomly gives me an error like below
Okay just kidding, even ORM approach has "prepared statement "__diesel_stmt_3" already exists" issues. Now it seems like all my endpoints are having issue executing diesel sql code. Everything has this prepared statement already exists issue. Is this because I am using a r2d2 connection pool and the prepared statements are repeated/not repeated on the same connection or something? Any thoughts on what could the be the cause of this? I have no clue where to even begin investigating. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
This error message indicates that your database system does not support named prepared statements. That either means that you do not use postgres as backend, but something else that speaks postgres wire protocol. In that case that's an important missing feature in their implementation and should be fixed there. |
Beta Was this translation helpful? Give feedback.
This error message indicates that your database system does not support named prepared statements. That either means that you do not use postgres as backend, but something else that speaks postgres wire protocol. In that case that's an important missing feature in their implementation and should be fixed there.
The other variant is that you use an additional extern connection pooling layer like pgbouncer that also don't support prepared statements in some configurations. You cannot use that in combination with diesels build-in
PgConnection
as the usage of prepared statements is considered to be a fundamental security feature for diesel.