interval_out() must be marked STABLE, not IMMUTABLE.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 19 Jan 2022 22:17:55 +0000 (17:17 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 19 Jan 2022 22:17:55 +0000 (17:17 -0500)
Its results vary depending on the IntervalStyle GUC, so it cannot
be considered immutable.

This is an extremely ancient bug.  AFAICT it was a sloppy mistake
in 6f58115dd, which marked it "cacheable" alongside marking several
other interval functions that way.  At the time, interval_out()
depended on DateStyle not IntervalStyle, but it was still wrong.

Back-patching this change doesn't look very practical, so I won't.
Aside from the usual difficulties of getting catalog changes
applied to existing databases, people might have indexes,
generated columns, etc that depend on interval-to-text casts
being considered immutable.  (This'd not really give them any
problem as long as they never change IntervalStyle.)  They
wouldn't appreciate us breaking such usage in minor releases.

Per bug #17371 from Marcus Gartner.

Discussion: https://postgr.es/m/17371-8f57e6e9ca5e35bf@postgresql.org

src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat

index 64b9aa36d8ba6af222ae66c6ec1fdd8957d9c4f7..1c2e38daf42bbbb74128559af3d0f3dd74c0613e 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 202201171
+#define CATALOG_VERSION_NO 202201191
 
 #endif
index b6f689e8d1e32d07f05da99b90d7845f4e023210..0859dc81cac843082536be666928c00e79cc54b3 100644 (file)
   proname => 'interval_in', provolatile => 's', prorettype => 'interval',
   proargtypes => 'cstring oid int4', prosrc => 'interval_in' },
 { oid => '1161', descr => 'I/O',
-  proname => 'interval_out', prorettype => 'cstring', proargtypes => 'interval',
-  prosrc => 'interval_out' },
+  proname => 'interval_out', provolatile => 's', prorettype => 'cstring',
+  proargtypes => 'interval', prosrc => 'interval_out' },
 { oid => '2903', descr => 'I/O typmod',
   proname => 'intervaltypmodin', prorettype => 'int4',
   proargtypes => '_cstring', prosrc => 'intervaltypmodin' },