pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ilya Kosmodemiansky <ik@dataegret.com>
To: Wetmore, Matthew (CTR) <Matthew.Wetmore@express-scripts.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: GENERATE AS
Date: Thu, 22 Jun 2023 22:13:28 +0200
Message-ID: <D598E4B1-1B40-4B55-89A2-9296CDD2985D@dataegret.com> (raw)
In-Reply-To: <7c48174f8ce449af8f3e875bdeca7150@express-scripts.com>
References: <7c48174f8ce449af8f3e875bdeca7150@express-scripts.com>

Hi Matthew,

> On 22. Jun 2023, at 22:00, Wetmore, Matthew (CTR) <Matthew.Wetmore@express-scripts.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
>  
>  

view thread (9+ messages)  latest in thread

Message-ID: <D598E4B1-1B40-4B55-89A2-9296CDD2985D@dataegret.com>
Permalink:  ../D598E4B1-1B40-4B55-89A2-9296CDD2985D@dataegret.com/
Also on:    postgresql.org/message-id/D598E4B1-1B40-4B55-89A2-9296CDD2985D@dataegret.com

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: ik@dataegret.com, Matthew.Wetmore@express-scripts.com, pgsql-admin@lists.postgresql.org
  Subject: Re: GENERATE AS
  In-Reply-To: <D598E4B1-1B40-4B55-89A2-9296CDD2985D@dataegret.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