As I understand it, the substring function should be immutable. However, when I try to generate a column from the expression substring(enumColumn::TEXT from '-(.+)') I get a generation expression is not immutable error.
enumColumn is constrained to not be NULL, and it is not a generated column. Its type is an enum whose values are strings that all match the pattern '-(.+)'.
Is the issue related to the possibility that the pattern won't match and return NULL? Or is PostgreSQL complaining about something else?
UPDATE: this works fine when the column type from which the substring is computed is already TEXT. I think the issue is that enumType::TEXT is only STABLE, not IMMUTABLE?
time_zone. So it's STABLE but not IMMUTABLE.enums. Using the example from here Enum type I could do :SELECT name, substring(current_mood::TEXT from '-(.+)') FROM people;without issue. Where are you running this query? Also can add a simple test case to the question? Also what version of Postgres and where did you get it from?