You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATEDOMAINmonth_idAS INT2 CHECK (1<= value AND value <=12);
CREATETYPEyear_monthAS (year INT4, month month_id);
CREATEDOMAINwinter_year_monthAS year_month CHECK ((value).month <=3);
CREATETABLEheating_bills (
month winter_year_month NOT NULLPRIMARY KEY,
cost INT4 NOT NULL
);
This is inspired from real use cases in my applications: a domain type (month_id) adds some constraints, it is then used in a composite type (year_month) which is itself behind a domain type (winter_year_month) to add more constraints.
I implemented the corresponding Rust types encode/decode impls manually:
let result = sqlx::query("INSERT INTO heating_bills(month, cost) VALUES($1::winter_year_month, 200)").bind(WinterYearMonth{year:2021,month:MonthId(2)}).execute(&mut conn).await;let result = result.unwrap();assert_eq!(result.rows_affected(),1);
This fails at the .unwrap step with the error Protocol("execute: unexpected message: PortalSuspended")
I believe this error is somehow related to oid cache for user types. The query fails only the first time its used. If I run it again, it succeeds:
// Warm-up the oid cache
sqlx::query("INSERT INTO heating_bills(month, cost) VALUES($1::winter_year_month, 100)").bind(WinterYearMonth{year:2021,month:MonthId(1)}).execute(&mut conn).await;// Now it succeedslet result = sqlx::query("INSERT INTO heating_bills(month, cost) VALUES($1::winter_year_month, 200)").bind(WinterYearMonth{year:2021,month:MonthId(2)}).execute(&mut conn).await;let result = result.unwrap();assert_eq!(result.rows_affected(),1);
I intend to look further into the issue and eventually submit a PR. I triggered this error with some complex types, but I believe that this is a more general issue with the communication with the database.
The text was updated successfully, but these errors were encountered:
I added support for PortalSuspended in the executor, only to figure out that the issue was elsewhere: domain types were not supported by postgres::connection::describe. Adding support for domain types fixed my issue, but I still think that there is an issue with how the executor handles suspended portals.
Hi!
I get the following error when running a request with composite types:
I wrote a minimal reproduction: demurgos@78cb672
Here is the setup code:
This is inspired from real use cases in my applications: a domain type (
month_id
) adds some constraints, it is then used in a composite type (year_month
) which is itself behind a domain type (winter_year_month
) to add more constraints.I implemented the corresponding Rust types encode/decode impls manually:
View encode/decode
And then tried to use them:
This fails at the
.unwrap
step with the errorProtocol("execute: unexpected message: PortalSuspended")
I believe this error is somehow related to oid cache for user types. The query fails only the first time its used. If I run it again, it succeeds:
I intend to look further into the issue and eventually submit a PR. I triggered this error with some complex types, but I believe that this is a more general issue with the communication with the database.
The text was updated successfully, but these errors were encountered: