Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"

From: Avi Weinberg <AviW(at)gilat(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"
Date: 2023-07-09 14:22:37
Message-ID: AS8PR07MB7175A518D1C22D3DB14E318CCB33A@AS8PR07MB7175.eurprd07.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

If you attempt to create an index based on function that is not IMMUTABLE you will get an exception "ERROR: functions in index predicate must be marked IMMUTABLE". However, if you created the index when the function was IMMUTABLE, but later on you updated the function and mistakenly removed the IMMUTABLE key, you will not get any error to alert you that there is an index based on this function and it should remain IMMUTABLE.

I suggest triggering error message also when updating a function that is used by index if it is no longer IMMUTABLE

Avi

IMPORTANT - This email and any attachments is intended for the above named addressee(s), and may contain information which is confidential or privileged. If you are not the intended recipient, please inform the sender immediately and delete this email: you should not copy or use this e-mail for any purpose nor disclose its contents to any person.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Zheng Li 2023-07-09 19:22:05 Re: Support logical replication of DDLs
Previous Message Tom Lane 2023-07-09 14:22:02 Re: now() literal in pg_input_is_valid