Re: GENERATE AS

From: Ilya Kosmodemiansky <ik(at)dataegret(dot)com>
To: "Wetmore, Matthew (CTR)" <Matthew(dot)Wetmore(at)express-scripts(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: GENERATE AS
Date: 2023-06-22 20:13:28
Message-ID: D598E4B1-1B40-4B55-89A2-9296CDD2985D@dataegret.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Matthew,

> On 22. Jun 2023, at 22:00, Wetmore, Matthew (CTR) <Matthew(dot)Wetmore(at)express-scripts(dot)com> wrote:
> 4. ALTER TABLE auto_auth.matt
> ADD column matt_hour INT GENERATED ALWAYS AS (date_part('hour', current_timestamp)::INT - date_part('hour', matt_time)::INT) stored
>
> ERROR: generation expression is not immutable
> SQL state: 42P17

You can use only immutable functions to generate columns. Timestamp with time zone as an argument makes function not immutable because timezone could be set locally and results could differ depending on timezone

best regards,
Ilya
>
>

In response to

  • GENERATE AS at 2023-06-22 20:00:31 from Wetmore, Matthew (CTR)

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2023-06-22 20:25:34 Re: GENERATE AS
Previous Message David G. Johnston 2023-06-22 20:08:38 Re: GENERATE AS