Could Postgres warn about incorrect volatility class?

From: Philip Semanchuk <philip(at)americanefficient(dot)com>
To: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Could Postgres warn about incorrect volatility class?
Date: 2022-04-28 17:11:28
Message-ID: 5EB0EA00-DDFC-466C-88EE-F2230065EC24@americanefficient.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,
I recently discovered that a custom function that I thought was being inlined was not being inlined because I had declared it IMMUTABLE, but the function body cast an enum value to text which is a STABLE operator. Once I corrected my function's definition to declare it STABLE, Postgres inlined it.

Since Postgres can apparently determine during query parsing that my function has a volatility class mismatch, is there a reason that Postgres can't make the same determination and inform me about it when I define the function? In this case a helpful message would have been "I sure hope you know what you're doing..." :-)

Thanks
Philip

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2022-04-28 17:25:53 Re: Is this a reasonable use for advisory locks?
Previous Message KOPOSOV Sergey 2022-04-28 17:06:28 Re: int8range and index usage for <@ operator