Reading up on this (
https://www.postgresql.org/docs/current/sql-prepare.html), it seems that there are a number of exceptions where the statement
will be re-planned:
- DDL modifications to the used objects
- updated planner statistics for the used objects
- modification to search path
I would expect a major Postgres version upgrade to hit these conditions, so the OP problem would still occur. Nevertheless, thanks for the pointer - I had mostly forgotten about this possibility.