From: Martijn de Munnik <martijndemunnik@protonmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@postgresql.org
Subject: Re: ERROR: only immutable functions supported in continuous aggregate view
Date: Sun, 12 Mar 2023 08:49:45 +0000
Message-ID: <5a6b29d8-7223-5959-1e6e-c84468525f6f@protonmail.com> (raw)
In-Reply-To: <1171919.1678549672@sss.pgh.pa.us>
References: <0b21034b-3fa8-16b3-c65b-1ef6b67c4da2@protonmail.com>
<1171919.1678549672@sss.pgh.pa.us>
Ok, now I understand, thank you.
My solution is to create materialized view with intermediate values and
the create a normal view on top that uses the intermediate values and
the jsonb_build_object function to create the desired result.
Kind regards,
Martijn de Munnik
On 2023-03-11 16:47, Tom Lane wrote:
> 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
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: martijndemunnik@protonmail.com, tgl@sss.pgh.pa.us
Subject: Re: ERROR: only immutable functions supported in continuous aggregate view
In-Reply-To: <5a6b29d8-7223-5959-1e6e-c84468525f6f@protonmail.com>
References: <0b21034b-3fa8-16b3-c65b-1ef6b67c4da2@protonmail.com> <1171919.1678549672@sss.pgh.pa.us> <5a6b29d8-7223-5959-1e6e-c84468525f6f@protonmail.com>
* 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