Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cast: set volatility of casts to/from TEXT and NAME to leak-proof
In Postgres 14, some casts which were previously immutable and not leak-proof are now leak-proof. This commit updates the volatility of casts to and from TEXT and NAME to leak-proof to match Postgres. This should aid the optimizer in decorrelating more subqueries. This is not backward incompatible because it is less restrictive and should not change the behavior of any users' existing queries. There are many other casts that can be changed to leak-proof, but our implementations of those casts need to be audited to ensure that they cannot err (one of the requirements for leak-proof). I leave this as future work. We must also take care with assignment casts, which currently use the same volatility as a normal cast. Some casts which cannot err and are leak-proof can err as an assignment cast, so the assignment cast cannot be leak-proof. For example, a cast like `'foo'::VARCHAR(1)` does not err, but an assignment cast with the same inputs will err because the value does not fit into the target type's width. To handle cases like this, we may need to label each cast with two volatilities, one for regular casts and one for assignment casts. Release note: None
- Loading branch information