pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Martijn de Munnik <martijndemunnik@protonmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: ERROR: only immutable functions supported in continuous aggregate view
Date: Sat, 11 Mar 2023 10:47:52 -0500
Message-ID: <1171919.1678549672@sss.pgh.pa.us> (raw)
In-Reply-To: <0b21034b-3fa8-16b3-c65b-1ef6b67c4da2@protonmail.com>
References: <0b21034b-3fa8-16b3-c65b-1ef6b67c4da2@protonmail.com>

Martijn de Munnik <martijndemunnik@protonmail.com> writes:
> The error is caused by the jsonb_build_object function, is there any
> reason why this function is not IMMUTABLE?

It can invoke arbitrary datatype output functions, some of which are
not immutable.  We unfortunately lack any infrastructure that would
allow reasoning that "all the types used in this specific invocation
have immutable output functions, so it'd be OK to consider this
invocation immutable".  So we have to assume the worst when labeling
jsonb_build_object.  (Even if we had such infrastructure, I doubt
it would save you in this use-case, because it looks like some of
the values you're converting are timestamps, which respond to the
DateStyle and TimeZone settings.)

You could, on these grounds, argue that jsonb_build_object and other
functions with this problem actually need to be VOLATILE.  But we've
established a project convention that I/O functions should be at
worst STABLE, allowing calling functions to be STABLE as well.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <1171919.1678549672@sss.pgh.pa.us>
Permalink:  ../1171919.1678549672@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1171919.1678549672@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, martijndemunnik@protonmail.com
  Subject: Re: ERROR: only immutable functions supported in continuous aggregate view
  In-Reply-To: <1171919.1678549672@sss.pgh.pa.us>
  References: <0b21034b-3fa8-16b3-c65b-1ef6b67c4da2@protonmail.com> <1171919.1678549672@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox